TCP numbering system

      Although TCP software needs to keep track of every segment being transmitted or received, there is no segment number field in the segment header. In fact, there are two fields in this header called sequence number and acknowledgement number. Both of these fields refer to byte numbers rather than segment numbers.

 

byte number

      TCP numbers all data bytes (octets) to be sent in a connection. The numbers for the two directions are independent of each other. When TCP receives data bytes from a process, it stores them in the send buffer and numbers them. Numbering does not have to start from 0. TCP chooses a random number between 0 and (2^32 - 1) as the number of the first byte. For example, if the number happens to be 1057, and the data to be sent has a total of 6000 bytes, then these bytes are numbered from 1057 to 7056. We will see that bytes are used in both flow control and error control. serial number. The data bytes sent on each connection are numbered by TCP. Numbering starts with a randomly generated number.

 

 

serial number

       After the bytes are numbered, TCP assigns a sequence number to each segment to be sent. The sequence number of each segment is the sequence number of the first data byte in this segment.

        Suppose a TCP connection wants to transfer a 5000-byte file. The number of the first byte is 10001. If the data is sent in 5 packets, and each segment carries 1000 bytes of data, what is the sequence number of each segment? The sequence number of each segment is given below.

     

         The sequence number field of a segment defines the number assigned to the first data byte contained in this segment.

       When a segment carries both data and control information (piggybacking), it uses a sequence number. But if the segment does not carry user data, logically, it does not define the sequence number. The sequence number field always exists, but its value is meaningless, but some segments that only carry control information still need a sequence number to facilitate the receiver's confirmation. These messages are used for connection establishment, connection termination, and connection abnormal termination. Each of these segments consumes a sequence number, as if it carried a byte of data, but in reality there is no data.

 

 

Confirmation Number

      TCP communication is full duplex. When a connection is established, both parties can send and receive data at the same time. Usually both sides start numbering bytes from different start numbers. The sequence number in each direction indicates the number of the first byte carried by the segment in that direction. Both parties also use an acknowledgment number to acknowledge the bytes they have received, but this acknowledgment number defines the number of the next byte it expects to receive. In addition, the acknowledgment number is cumulative, that is, he declares the acknowledgment number by adding 1 to the number of the last (completely intact) byte received. The term cumulative here means that if a party uses 5643 as the acknowledgment number, it means that it has received all bytes from the beginning up to number 5642. Note that it does not mean that this party has received 5642 bytes, because the first byte numbering does not necessarily start from 0.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326405977&siteId=291194637