TCP CONGESTION CONTROL

Probe, grow, lose, halve, repeat

L216 MINNETWORKING
PREDICT

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.

▶ SIMULATION
SENDER (Reno)
cwnd 1 · ssthresh 64
phase: slow start
fast retransmits 0 · timeouts 0
BOTTLENECK ROUTER
link: 0 / 12 segments per RTT
queue: 0 / 8
overflowing RTTs in a row: 0
TOTALS
RTT 0 · delivered 0
dropped 0
RTTs under 12 after first loss: 0
segments per RTT—
lastcwnd = 1 segment, ssthresh = 64
✓ after a loss, the next RTT sends no more than the bottleneck holds
SCHEDULE
01[SENDER]sender: TCP Reno
02[SENDER]RTT 1: send min(cwnd, rwnd) segments
03[SENDER]RTT 2: send min(cwnd, rwnd) segments
04[SENDER]RTT 3: send min(cwnd, rwnd) segments
05[SENDER]RTT 4: send min(cwnd, rwnd) segments
06[SENDER]RTT 5: send min(cwnd, rwnd) segments
07[SENDER]RTT 6: send min(cwnd, rwnd) segments
08[SENDER]RTT 7: send min(cwnd, rwnd) segments
09[SENDER]RTT 8: send min(cwnd, rwnd) segments
10[SENDER]RTT 9: send min(cwnd, rwnd) segments
11[SENDER]RTT 10: send min(cwnd, rwnd) segments
12[SENDER]RTT 11: send min(cwnd, rwnd) segments
13[SENDER]RTT 12: send min(cwnd, rwnd) segments
14[SENDER]RTT 13: send min(cwnd, rwnd) segments
15[SENDER]RTT 14: send min(cwnd, rwnd) segments
16[SENDER]RTT 15: send min(cwnd, rwnd) segments
17[SENDER]RTT 16: send min(cwnd, rwnd) segments
18[SENDER]RTT 17: send min(cwnd, rwnd) segments
19[SENDER]RTT 18: send min(cwnd, rwnd) segments
20[SENDER]RTT 19: send min(cwnd, rwnd) segments
21[SENDER]RTT 20: send min(cwnd, rwnd) segments
22[SENDER]RTT 21: send min(cwnd, rwnd) segments
23[SENDER]RTT 22: send min(cwnd, rwnd) segments
24[SENDER]RTT 23: send min(cwnd, rwnd) segments
25[SENDER]RTT 24: send min(cwnd, rwnd) segments
26[SENDER]RTT 25: send min(cwnd, rwnd) segments
27[SENDER]RTT 26: send min(cwnd, rwnd) segments
28[LINK]report
Start of reno: slow start + aimd scenario. 28 steps.
// a sender that retransmits but never slows down
onAck()    { cwnd += 1 }        // slow start forever
onDupAck() { retransmit() }     // loss? send it again, same rate
onTimeout(){ retransmit() }

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.

TUNE IT NOT YET

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)

FIX IT NOT YET

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.

Mental model:

the sender cannot see the network, so it treats loss as the signal. It adds slowly while things work and cuts sharply when they do not: additive increase, multiplicative decrease. That asymmetry is what makes many flows share a link instead of collapsing it. A timeout is the strongest signal and gets the strongest response: start again from one.

IN PRODUCTION

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.

IN INTERVIEWS

“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).

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.

USED IN

Chapters that build on this lesson.

NEXT: HEAD-OF-LINE BLOCKING →