Computer Networking › Section C · The transport layer › Topic C.7

TCP congestion control

TCP has no router telling it how fast to go, yet millions of connections share the internet without collapsing it. Each sender probes for spare capacity, backs off when it sees loss, and the result is the famous sawtooth of additive increase and multiplicative decrease.

The congestion window

Besides the receive window, rwnd, from flow control, every TCP sender keeps a congestion window, cwnd, measured in bytes but usually described in MSS-sized segments. The sender keeps its unacknowledged data within the smaller of the two: last byte sent minus last byte acknowledged must not exceed min(cwnd, rwnd). Assuming rwnd is large, cwnd sets the pace: about cwnd bytes leave per round trip, so

\text{rate} \approx \frac{\mathrm{cwnd}}{\mathrm{RTT}}

For example, cwnd = 30 segments of 1,460 bytes with a 60 ms RTT gives \(30 \times 1{,}460 \times 8 / 0.06 \approx\) 5.84 Mbps. TCP changes this rate by changing cwnd.

Three guiding rules

Classic TCP uses end-to-end control, as the topic Principles of congestion control describes, guided by three rules. A lost segment, signalled by a timeout or three duplicate ACKs, means the path is congested, so the sender must slow down. An arriving ACK means a segment got through, so the sender may speed up. And because nobody tells it the right rate, it must keep probing: increase until loss appears, back off, and increase again. ACKs also pace the sender, so TCP is called self-clocking: on a slow path ACKs return slowly and cwnd grows slowly.

Slow start

A new connection begins with a small cwnd: 1 MSS in classic descriptions, and up to 10 MSS in most systems today, following RFC 6928. In slow start, cwnd grows by 1 MSS for every ACK received. Each segment sent in a round trip returns an ACK, so cwnd doubles every RTT: 1, 2, 4, 8 and so on. The name is ironic; growth is exponential. Slow start ends in one of three ways. If cwnd reaches the slow-start threshold, ssthresh, TCP switches to congestion avoidance. If a timeout occurs, ssthresh is set to half the current cwnd and cwnd restarts at 1 MSS. If three duplicate ACKs arrive, TCP halves and enters fast recovery.

Congestion avoidance and fast recovery

In congestion avoidance TCP grows cautiously: about 1 MSS per RTT, achieved by adding MSS × MSS / cwnd bytes for each ACK. Two loss signals are treated differently. A timeout suggests serious congestion: ssthresh becomes half of cwnd, cwnd falls to 1 MSS, and slow start begins again. Three duplicate ACKs are milder, because later segments are still getting through. TCP Reno then sets ssthresh to half of cwnd and enters fast recovery, briefly setting cwnd to ssthresh plus 3 MSS for the segments that have left the network, and adding 1 MSS per further duplicate ACK; when a new ACK arrives, cwnd drops to ssthresh and congestion avoidance resumes. The older TCP Tahoe had no fast recovery and fell to 1 MSS on every loss.

Worked example: a Reno trace

Count in RTT rounds, starting with cwnd = 1 MSS and ssthresh = 16. Three duplicate ACKs arrive during round 9. 1. Slow start doubles cwnd: 1, 2, 4, 8, 16 in rounds 1 to 5. 2. cwnd has reached ssthresh, so congestion avoidance adds 1 per round: 17, 18, 19, 20 in rounds 6 to 9. 3. The loss at cwnd = 20 sets ssthresh to 10. 4. After fast recovery, cwnd = 10 in round 10, then 11, 12, 13 and so on. Check: Tahoe would instead restart at 1 in round 10 and slow-start to 2, 4, 8 and then 10, capped at ssthresh in this simplified count, reaching 12 only by round 16, against 16 for Reno.

AIMD and the sawtooth

Ignoring slow start and timeouts, Reno adds 1 MSS per RTT and halves cwnd at each loss: additive increase, multiplicative decrease (AIMD). Plotted against time, cwnd forms a sawtooth, climbing steadily and then dropping by half. If losses occur when cwnd reaches W segments, it swings between W/2 and W, averaging about 3W/4, so the average throughput is roughly

\frac{0.75\,W \times \mathrm{MSS}}{\mathrm{RTT}}

The design was more than a guess: analysis shows that AIMD drives competing flows towards an efficient, fair share of a bottleneck. Its weakness is slow additive growth on very fast, long paths, which motivated newer algorithms.

Worked example: sawtooth throughput

A Reno flow with an MSS of 1,460 bytes sees a loss each time cwnd reaches 40 segments, and its RTT is 50 ms. 1. Peak rate: \(40 \times 1{,}460 \times 8 = 467{,}200\) bits per RTT, and dividing by 0.05 s gives about 9.34 Mbps. 2. After each loss cwnd falls to 20, so the rate swings between about 4.67 and 9.34 Mbps. 3. Average: \(0.75 \times 9.344 \approx 7.01\) Mbps. 4. Each sawtooth tooth takes about 20 RTTs to climb from 20 back to 40, or 1 second. Check: the average lies midway between the low and high points, as a straight-line climb should give.

ECN and delay signals

Loss is a late signal: by the time packets drop, queues are already full. With Explicit Congestion Notification, a router sets the congestion bits in the IP header of a passing packet; the receiving TCP sets the ECE flag in its ACKs, and the sender reduces cwnd as it would for a loss, then sets the CWR flag to confirm. Both ends must agree to use ECN during the handshake. Another approach watches delay. If the RTT rises above the smallest RTT seen, queues are building, so a delay-based sender eases off before loss. TCP Vegas, from the 1990s, worked this way; the next topic, Evolution of the transport layer: QUIC, describes today's main algorithms, CUBIC and BBR.

Fairness

If K flows share a bottleneck of rate R, a fair outcome gives each R/K. Two AIMD flows with equal RTTs converge on this: each additive step adds the same amount to both, while each halving takes more from the larger flow, so the gap shrinks. In practice fairness is imperfect. Flows with shorter RTTs grow faster and take more. UDP applications without congestion control do not back off at all. And fairness is per connection: if four flows share a link and a new application opens six parallel connections, it gets about 6/10 of the capacity, not 1/5.

Common mistakes to avoid

First, thinking slow start is slow; it doubles cwnd every RTT. Second, treating every loss alike: Reno halves on three duplicate ACKs but drops to 1 MSS on a timeout. Third, forgetting that the sending limit is min(cwnd, rwnd). Fourth, assuming cwnd keeps doubling after it reaches ssthresh; growth becomes linear. Fifth, assuming fairness is per application rather than per connection.

Key takeaways

TCP limits unacknowledged data to min(cwnd, rwnd), sending at about cwnd/RTT. Slow start doubles cwnd each RTT from 1 MSS (10 MSS today) up to ssthresh; congestion avoidance adds 1 MSS per RTT. Three duplicate ACKs halve cwnd via fast recovery in Reno; a timeout sets ssthresh to half and cwnd to 1 MSS. The AIMD sawtooth averages about 0.75 W per RTT. ECN marks warn before loss, and delay-based methods watch the RTT. AIMD tends towards fairness, though short RTTs, UDP and parallel connections distort it.

Flashcards

Flashcard

cwnd

Congestion window: the sender's network-based limit

Unacknowledged data ≤ min(cwnd, rwnd).

Test your understanding

Question 1 of 5

A TCP sender has cwnd = 20 segments of 1,000 bytes and the RTT is 40 ms. About what is its sending rate?

Question 2 of 5

A Reno sender in congestion avoidance has cwnd = 24 MSS when three duplicate ACKs arrive. After fast recovery, what is cwnd?

Question 3 of 5

In slow start with no losses, cwnd is 4 MSS. What is it one RTT later?

Question 4 of 5

A flow's cwnd peaks at 60 segments of 1,000 bytes before each loss, and its RTT is 100 ms. Roughly what is its average throughput?

Question 5 of 5

Five TCP flows share a link. A new application opens five more connections. What share does the new application get?

← Previous topicNext topic →