CCNA / CCENT / Network+ Tutorial: TCP Sequence Numbers
In the first installment of this CCNA tutorial on TCP and UDP, we took a look at the fundamentals of each along with the TCP three-way handshake. Here, we’ll see how TCP detects lost segments and recovers from said loss.
These TCP tutorials are excellent study material for the Network+ exam as well, so please share this page with anyone you know working on that certification. Thank you!
The TCP header contains separate fields for the sequence number and the acknowledgment number, and it’s these two values that allow TCP to detect lost segments and in turn recover from that loss. (I’ll refer to “acknowledgment” as “ack” from here on out.)
The TCP header fields:
Coming September 2018 in hard and soft copy!
Watch this site (and our mailing list) for pre-order info!
Here, a host is sending four 2000-byte segments after the three-way handshake is complete. The sequence numbers are used by the recipient to determine the order of the segments and to anticipate the number on the next segment.
The recipient will send an ack back to the transmitting host, and that ack serves two purposes, one obvious and one not so much:
- Obvious: The ack lets the sender know the recipient received the segments. After all, it is an ack.
- Not-so-obvious: The acknowledgment number in that ack allows the sender to determine if any segments were lost during transmission. If segments were indeed lost, the sender would re-transmit them.
The ack number is not set to the number of the last segment received. Instead, it is set to the number of the next segment the recipient expects to see. With this pattern, that would be 10000. This cumulative acknowledgment scheme allows the sender to identify segment loss.
Let’s see what happens when one of those segments gets lost along the way.
Server A didn’t see Seq 6000, so that’s the number it sends back in its ack, telling the host “Hey, I expect to see this one next.”
The host sees that and knows something’s up, since it sent a segment with that sequence number, along with the next one in sequence (8000). The host resends that missing segment. The server will then send an ack of 10,000, reflecting the next sequence number it expects, having received 8000 earlier.
In both life and networking, one answer can lead to two more questions, and that’s certainly true of this process.
- How does the sender know how many segments to send before waiting for an ACK?
- Wouldn’t problems be detected faster if the recipient sent an ACK for every segment?
We’ll answer those questions and many more (okay, maybe a few more) regarding TCP flow control and windowing in the next segment of this CCNA TCP and UDP tutorial.
When you’re done here, tackle my free CCNA Practice Exams and join me on Twitter and Facebook!