Detailed TCP and UDP

A, TCP features

  • Connection-oriented, reliable transport layer protocol based on the byte stream.
  • The application layer is divided into segments, and the target node transmits the TCP layer send.
  • It has a number of data packets, the other received the acknowledgment ACK is transmitted, retransmission is not received.
  • Use efficacy and efficiency if the experimental data to error during transmission.

Two, TCP packet information

  Packet header contains information include:

  • Source port, destination port
  • Marking process (socket): IP address + protocol + port number

  The TCP flags mark:

  1. URC: urgent, urgent pointer is effective when 1;
  2. ACK: acknowledgment sequence number flag;
  3. PSH: push sign, do not enter the data cache, directly to the application;
  4. RST: Reset the connection flag;
  5. SYN: synchronization sequence number, the process for establishing a connection;
  6. FIN: finish flags to release the connection.

Three, TCP three-way handshake

Flow chart below (painted by Yo - Recommended tools: online at ProcessOn):

 

TCP three-way handshake flow chart Details:

  1. When connection is established, the client sends a SYN packet (seq = x) to the server, and enter SYN-SEND state, the server waits for acknowledgment.
  2. Server receives a SYN packet, the client must confirm SYN (ack = x + 1), at the same time, they would send a SYN packet (seq = y), i.e., SYN + ACK packet and the SYN-RECV state into the server.
  3. Client receives the SYN + ACK packet to the server, the server sends an acknowledgment packet ACK (ack = y + 1), this packet is sent, the client and the server into ESTABKISHED state. Start data transmission.

Four, TCP's four wave

 

TCP flow chart four times and waved Details:

  1. After the client sends a FIN, for closing the data transfer service to the client, client enters FIN-WAIT-1 state.
  2. After receiving the FIN service, transmits an ACK to the Client, the acknowledgment number of the received seq + 1 (the same SYN, FIN a occupy a sequence number), service into the CLOSED-WAIT.
  3. sending a service FIN, for closing the data transfer service to the client, service into the LAST-ACK state.
  4. After the client receives the FIN, client enters TIME-WAIT state, then sends an ACK to-Service, the acknowledgment number of the received sequence number +1. service enter CLOSED state, completed four times and waved.

Five, TCP sliding window

Role: ① to ensure the reliability of TCP;

   ② ensure that the flow control characteristics of TCP (transmission data sequence).

Six, UDP characteristics

  • For non-connection
  • Does not maintain a connection state, supports simultaneous transmission of multiple clients want the same message
  • Only the packet header 8 bytes, an additional small opening
  • Restricted to only certain data generation rate, the transmission rate and performance of the machine
  • Do our best to interact, does not guarantee reliable delivery, does not maintain a connection status table
  • Oriented message, the message does the application submitted by the split and merge

Seven difference, TCP and UDP

  • For connection / connectionless
  • Reliable / Unreliable
  • Packet order / disorder
  • speed
  • Middleweight

 

Guess you like

Origin www.cnblogs.com/yonghome/p/tcpAndUdp.html