The serial number (sequence number) in a TCP packet is not numbered by the packet segment. Instead, all the data transmitted during the connection life cycle is treated as a byte stream, the serial number is the number of each byte in the entire byte stream. A tcp data packet contains data of multiple byte streams (that is, data segments), and the data size of each TCP data packet is not necessarily the same. During the three-way handshake of a TCP connection, both parties have determined the initial serial numbers x and y, the serial number field value in each TCP packet segment indicates the serial number of the first byte in the message to be transmitted.
The TCP packet arrival confirmation (ACK) is the confirmation of the highest serial number of the received data, and returns the serial number (ACK number) of the TCP packet to the sending end for the next receiving period ). For example, if the number of the data sent by host a is 400 and the data length is 100, the receiving end returns a confirmation number of 501 to host.
The validation mechanism provided by TCP can be used to issue a separate validation packet (delayed ack mechanism) for each TCP packet during the communication process. Instead, the validation information is transmitted when data is transmitted, this greatly improves the Network Utilization and transmission efficiency. At the same time, the TCP validation mechanism can also confirm multiple data packets at a time. For example, if the receiver receives a 201,301,401 data packet, you only need to confirm the 401 data packet, the validation of 401 of data packets also means that all data packets before 401 have been confirmed, which can also improve the system efficiency.
If the sender does not receive confirmation from the recipient within the specified time, it will re-Send the unconfirmed data packet. If the recipient receives an error message, it discards the message and does not send confirmation information to the sender. Therefore, the retransmission mechanism of TCP packets is determined by the set timeout timer. If no confirmation information is received within the scheduled time, the request is re-transmitted. The setting of this scheduled time value is very important. If it is too large, the packet retransmission delay will be relatively large. If it is too small, the sender of the confirmation packet may re-transmit the packet before receiving the confirmation packet from the other party, this will cause the network to enter an endless re-transmission process. If the recipient receives a duplicate message, the recipient discards the duplicate message, but must send the confirmation message back. Otherwise, the recipient will send the message again.
The TCP protocol should ensure that the data packets arrive at the receiver in order. If the data packet received by the receiver is correct, but the serial number is not followed, how can this problem be solved? The TCP protocol itself has no provisions, but is determined by the real-time users of the TCP protocol. There are two methods to deal with it: one is to directly discard messages that do not arrive by serial number, and the other is to put packets that do not arrive by serial number in the buffer first, wait until the serial number package arrives before it is handed over to the application process. The latter method will improve the system efficiency. For example, the sender continuously sends a TCP datagram of 100 bytes in each packet, whose serial numbers are 1,101,201 ,..., 701. If the other seven datagram packets are received, but the 201 datagram is not received, the receiving end should confirm the two datagram packets 1 and 101 and submit the data to the relevant application process, the five datagram data packets 301 to 701 should be stored in the buffer zone. After the datagram 201 arrives, the data packets 201 to 701 will be submitted to the relevant application process in order, the 701 datagram is confirmed to ensure the arrival of TCP data at the application process level in order.
Thanks http://blog.csdn.net/wjtxt/article/details/6606022
Wireshark TCP packet arrival confirmation (ACK) Mechanism