Reading — step 1 of 5
Read
Retransmission and RTO
IP makes no promises — packets vanish in congested routers and flaky links. TCP builds reliability on top with a brutally simple contract: keep a copy of every segment until it is acknowledged, and if the ACK does not come in time, send it again. "In time" is the retransmission timeout, RTO, and choosing it well is the whole art.
The RTO must adapt
Set the RTO too low and you flood the network with needless duplicates; too high and you stall for seconds after a single loss. The right value tracks the connection's actual round-trip time, which Jacobson's algorithm (RFC 6298) estimates with two running averages:
SRTT = (1 - 1/8) * SRTT + 1/8 * RTT_sample
RTTVAR = (1 - 1/4) * RTTVAR + 1/4 * abs(SRTT - RTT_sample)
RTO = SRTT + 4 * RTTVAR
SRTT is the smoothed round-trip time; RTTVAR tracks how variable it is. Adding four times the variance means a jittery path gets a generous timeout while a steady one gets a tight one. The RTO is clamped to a floor (commonly 1 s) so a brief lull cannot make it fire instantly.
When the timer fires
On timeout you retransmit the oldest unacknowledged segment, then double the RTO — exponential backoff. Backoff is what keeps a genuinely congested network from being hammered: each successive loss makes TCP wait longer before trying again. (Congestion control, next chapter, also collapses the sending rate at this moment.)
Fast retransmit: do not wait for the timer
Waiting a full RTO after every loss is slow. If a segment is lost but later ones arrive, the receiver keeps ACKing the same number — the last in-order byte it holds — producing duplicate ACKs. Three of them is TCP's signal that a segment was lost while data still flows, so the sender resends immediately instead of waiting:
Why three and not one? A single duplicate ACK is normal packet reordering; requiring three avoids retransmitting over harmless jitter.
Two rules that keep the estimate honest
- Karn's rule — never measure RTT from a segment that was retransmitted. When an ACK arrives you cannot tell whether it answers the original or the retransmit, so the sample is ambiguous; discard it and trust only clean measurements.
- SACK (selective ACK, RFC 2018) — the receiver reports the non-contiguous blocks it already holds, so the sender resends only the real gaps. Without SACK, one lost segment early in a window can force resending everything after it.
The trap
The retransmission queue holds byte ranges, not "segment 5." When an ACK partially covers the oldest segment, trim its front — do not drop it whole. And always resend the oldest outstanding bytes first: the peer is telling you exactly where its stream stalled.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…