TCP CONGESTION CONTROL
Probe, grow, lose, halve, repeat
TCP caps the segments in flight at a congestion window, cwnd. Three duplicate ACKs tell the sender that one segment was lost while later ones still arrived. A Reno sender at cwnd = 21 gets three duplicate ACKs. What does it send in the next RTT?
TCP limits unacknowledged data to a congestion window, cwnd. It starts at a small initial window (10 segments on Linux; the sim uses 1 so the doubling is easy to follow) and adds one per ACK, which doubles it every RTT: slow start. Above the threshold ssthresh it adds one segment per RTT: congestion avoidance.
When the bottleneck queue overflows, a segment is lost. Three duplicate ACKs mean later segments still arrive, so Reno retransmits at once and halves: ssthresh = cwnd/2, cwnd = ssthresh. A retransmission timeout means nothing came back, so cwnd drops to 1. Additive increase, multiplicative decrease: the window saws up and down around what the path can carry.
// a sender that retransmits but never slows down
onAck() { cwnd += 1 } // slow start forever
onDupAck() { retransmit() } // loss? send it again, same rate
onTimeout(){ retransmit() }// TCP Reno, RFC 5681 (in segments)
onAck() {
dups = 0
if (cwnd < ssthresh) cwnd += 1 // slow start: x2 per RTT
else if (++acked >= cwnd) { cwnd += 1; acked = 0 } // +1 per RTT
}
onDupAck() {
if (++dups == 3) { // fast retransmit
retransmit(); ssthresh = max(cwnd / 2, 2); cwnd = ssthresh
}
}
onTimeout() { retransmit(); ssthresh = max(cwnd / 2, 2); cwnd = 1 } The link carries 12 segments per RTT and the queue holds LOSS AT − 12 more. Watch the segments-per-RTT row and the invariant strip. RENO overshoots in slow start, halves, and saws between 10 and 21. NO BACKOFF retransmits but keeps sending 32, so the queue overflows every RTT and the invariant fails at RTT 7. RENO: TIMEOUT loses a whole RTT of ACKs, drops to 1 and slow-starts back to ssthresh.
The link carries 12 segments per RTT. LOSS AT is 12 plus the router queue. After every loss Reno halves its window; if half the window is below 12 the link sits partly idle until the window grows back. Find the smallest LOSS AT at which no RTT after the first loss delivers fewer than 12 segments.
GOAL: after the first loss, every RTT keeps the link full (12 segments)
Implement Reno in segments. onAck: +1 per ACK below ssthresh (slow start), +1 per full window of ACKs at or above it. onDupAck: on the third duplicate in a row, ssthresh = max(floor(cwnd/2), 2) and cwnd = ssthresh; a new ACK resets the count. onTimeout: same ssthresh, cwnd = 1. The grader also runs 30 RTTs against a bottleneck that drops above 20.
Linux tcp_congestion_control (CUBIC by default, BBR as an option), QUIC's congestion controllers, ss -ti showing cwnd and ssthresh per socket, bufferbloat in home routers, and a single big transfer that never reaches link speed on a long, lossy path.
“Explain TCP congestion control” or “why does my transfer not use the whole link?” Name slow start, congestion avoidance, fast retransmit and the timeout, give the cwnd and ssthresh updates, explain AIMD, and say why loss-based control struggles on high bandwidth-delay paths (CUBIC and BBR exist for that).
USED IN
Chapters that build on this lesson.
- Satellite, direct-to-device and coverage for the unservedHow Mobile Networks Work
- Troubleshooting a live faultNetwork Engineer