4.3.20Computer Networks

TCP reliability — seq - ack numbers, retransmission, cumulative ACK

2,565 words12 min readdifficulty · medium

WHY does TCP need this at all?

WHAT is "reliability" here precisely? Two guarantees:

  • No loss: every byte the app writes eventually reaches the other app (or the connection breaks).
  • In order: bytes are delivered to the receiving app in the exact order they were sent.

Sequence numbers — numbering the bytes


ACK numbers — cumulative acknowledgement

Figure — TCP reliability — seq - ack numbers, retransmission, cumulative ACK

Retransmission — how loss gets repaired

There are two complementary mechanisms.

1. Timeout-based retransmission (RTO)

2. Fast retransmit (duplicate-ACK based)


Putting it together: WHY cumulative ACK is both great and limited

Recall Feynman: explain it to a 12-year-old

Imagine mailing a long letter one numbered page at a time. Your friend doesn't email back "got page 5, got page 7." Instead they say "I have everything up to page 4, send page 5 next." If a page gets lost in the mail, they keep saying "still need page 5!" After hearing that a few times, you just re-mail page 5 — and once it lands, your friend suddenly has pages 5, 6, AND 7 (they were keeping the extra pages on their desk), so they say "now I have up to page 7!" That "everything up to page X" message is the cumulative ACK, and re-mailing the lost page is retransmission.


Common mistakes (steel-manned)


Active recall

What does the TCP sequence number of a segment represent?
The stream position of the segment's first data byte; it covers [SEQ,SEQ+L)[\text{SEQ}, \text{SEQ}+L).
How is the cumulative ACK number computed?
ACK = (highest contiguous byte received) + 1 = the next byte expected.
Why does TCP number bytes instead of packets?
So every byte has a permanent identity; resends/splits/merges stay unambiguous even if segment sizes change.
Why is the Initial Sequence Number random, not 0?
To avoid confusing old delayed segments from a previous connection, and to resist sequence-injection attacks.
What does a duplicate ACK indicate?
A later segment arrived out of order while an earlier one is still missing — i.e. there is a gap; the named segment was buffered, not lost.
After how many duplicate ACKs does fast retransmit trigger, and what is resent?
After 3 duplicate ACKs; the sender resends the segment starting at the ACK number (the missing one).
Give the RTO formula and its terms.
RTO = SRTT + 4·RTTVAR, where SRTT is smoothed RTT and RTTVAR is RTT variation (mean deviation).
Why does cumulative ACK make a lost ACK self-healing?
A later ACK carries a larger number that already covers everything the lost ACK would have, so the lost ACK is irrelevant.
Why does one ACK sometimes jump forward by many bytes?
Filling a single hole connects all the out-of-order data already buffered, so the contiguous prefix (and thus the ACK) leaps ahead.
What limitation of cumulative ACK does SACK fix?
Cumulative ACK can't report received-but-non-contiguous ranges; SACK lets the receiver report exactly which extra blocks it has.
What happens to RTO on repeated timeouts?
It is doubled each time (exponential backoff) to avoid overloading a congested network.
Do SYN and FIN flags consume sequence numbers?
Yes, each consumes one sequence number, so an ACK to a SYN with ISN x is x+1.

Connections

  • TCP three-way handshake — where ISNs are exchanged and SYN consumes a seq number.
  • Sliding window flow control — the window bounds how many unacked bytes may be outstanding.
  • TCP congestion control — fast retransmit pairs with fast recovery; dup ACKs drive cwnd logic.
  • Selective ACK (SACK) — fixes cumulative ACK's inability to report gaps precisely.
  • Go-Back-N vs Selective Repeat — TCP is a hybrid leaning toward selective repeat with SACK.
  • IP unreliable datagram service — the lossy substrate TCP compensates for.
  • RTT estimation / Jacobson's algorithm — the math behind the RTO timer.

Concept Map

drops reorders dups

TCP must fix

number every byte

starts

prevents

consume 1 seq

next byte expected

receiver computes

equals highest contiguous plus 1

resends unacked

repairs loss

missing triggers

IP lossy postman

Unreliable delivery

Reliable in-order byte stream

Sequence numbers

Random ISN

Stale segment confusion

SYN and FIN flags

Cumulative ACK

Confirms whole prefix

Retransmission timer

Retransmission

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, internet ka IP layer ek lapervah postman jaisa hai — packets kho sakte hain, aage-peeche (out of order) aa sakte hain, ya duplicate ban sakte hain. App ko chahiye ek reliable, in-order byte stream. TCP yahi gap bharta hai teen ideas se: har byte ko number do (sequence number), jo mila uska acknowledgement bhejo (ACK number), aur jo time pe acknowledge nahi hua use dobara bhejo (retransmission).

Sabse important cheez hai cumulative ACK. Receiver yeh nahi batata ki "ye-ye segment mile"; balki bolta hai "mere paas byte X tak sab kuch contiguous mil gaya, ab X agla byte bhejo". Yaani ACK = sabse last contiguous byte + 1. Isका faayda — agar ek ACT kho bhi jaaye, koi baat nahi, agla ACK bada number lekar aata hai jo purane ko bhi cover kar leta hai. Self-healing!

Ab maan lo beech ka ek segment (SEQ=1100) kho gaya, par uske aage wale aa gaye. Receiver gap dekh ke baar-baar wahi purana ACK=1100 bhejta hai — inhe duplicate ACK kehte hain. Yeh galti nahi hai; iska matlab data out-of-order aaya hai aur ek hole hai. Jab sender ko 3 duplicate ACK mil jaate hain, woh timer ka wait kiye bina turant woh missing segment dobara bhej deta hai — isko fast retransmit kehte hain. Hole bharte hi receiver ka ACK ek dum se aage chhalang maar deta hai (1100 se seedha 1500), kyunki buffer me pade saare segments ab connect ho gaye.

Yeh kyun matter karta hai? Kyunki har reliable cheez jo tum online karte ho — file download, web page, video buffering — TCP ke isi seq/ack + retransmission machinery pe chalti hai. Bina iske internet bharosemand hi nahi ban paata. Yaad rakho: SEQ = main kahan se start kar raha hoon, ACK = mujhe ab kaunsa byte chahiye.

Go deeper — visual, from zero

Test yourself — Computer Networks

Connections