Sequence numbers
A key part of TCP’s reliability service is the use of sequence numbers and acknowledgments, allowing the sender and receiver to constantly inform each other of the data that has been sent and received. These two mechanisms work hand-in-glove to ensure that data arrives at the destination system.
RFC 793 states that “each [byte] of data is assigned a sequence number.” The sequence number for the first byte of data within a particular segment is then published in the Sequence Identifier field of the TCP header. Thus, when a segment is sent, the Sequence Identifier field shows the starting byte number for the data within that particular segment. Note that sequence numbers do not refer to segments, but instead refer to the starting byte of a segment’s data block.
Once a segment is received, the data is verified by the recipient (using the checksum), and if it’s okay, then the recipient will send an acknowledgment back to the sender. The acknowledgment is also contained within a TCP segment, with the Acknowledgment Identifier field in the TCP header pointing to the next sequence number that the recipient is willing to accept. The acknowledgment effectively says “I received all of the data up to this point and am ready for the next byte of data, starting at sequence number n.”
When the acknowledgment arrives, the sender knows that the receiver has successfully received all of the data contained within the segment, and the sender is then able to transmit more data (up to ...
Get Internet Core Protocols: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.