TCP congestion theory
This is an optional deep dive. TCP congestion control explains the algorithms and tuning. Here are the arguments behind them: what congestion costs, what slow start and AIMD do window by window, how loss rate limits throughput, and why competing flows end up sharing evenly.
What congestion costs
Section titled “What congestion costs”Packet loss is a symptom. The cause is too many senders offering too much traffic. Retransmitting a lost packet treats the symptom. Three simplified scenarios show how the cost builds up. In each, link capacity is R.
1. Two senders, a router with unlimited buffers. Each sender gets at most R/2. As the combined load approaches R, the queue grows without bound and delay goes to infinity, even though no packet is lost and throughput is at its maximum.
For a simple queue with random arrivals, average delay scales like 1 / (1 - utilization). At 50% utilization a packet waits about twice its transmission time. At 90% it is ten times, and at 99% it is a hundred times. The edge of capacity is where delay explodes.
2. Two senders, finite buffers, retransmissions. Packets are dropped when the buffer is full, and the senders retransmit. Some of the link now carries retransmitted copies.
| Case | Offered load | Useful throughput | What is wasted |
|---|---|---|---|
| Retransmit only truly lost packets | R/2 | R/3 | R/6 goes to retransmissions |
| Premature timeouts: delayed packets are sent again | R/2 | R/4 | Router forwards each packet twice, receiver discards the extra |
3. Four senders, multi-hop paths. Flows cross several routers. A packet dropped at the second hop has already used capacity on the first. As offered load rises, fresh traffic at the second router crowds out packets arriving from upstream. Upstream links spend their capacity on packets that get dropped downstream. Useful throughput can fall toward zero while every link looks busy. This is congestion collapse, and it happened on the early internet in the 1980s before congestion control was added to TCP.
| Cost | Source |
|---|---|
| Delay without bound | Operating near capacity |
| Retransmission overhead | Buffer overflow |
| Duplicate copies | Timeouts shorter than the queuing delay |
| Wasted upstream work | Drops late in a multi-hop path |
Two broad remedies exist. End-to-end control infers congestion from loss or delay and has no network help, which is how classic TCP works. Network-assisted control has routers signal congestion directly, as ECN does.
Slow start, congestion avoidance, and recovery
Section titled “Slow start, congestion avoidance, and recovery”The sender limits itself to a congestion window (cwnd), measured here in segments (MSS). The sending rate is about cwnd / RTT. Three phases:
| Phase | cwnd growth | Ends when |
|---|---|---|
| Slow start | +1 MSS per ACK, which doubles cwnd every RTT | cwnd reaches ssthresh, or loss |
| Congestion avoidance | +1 MSS per RTT (linear) | Loss |
| Fast recovery (Reno) | Inflate by 1 for each extra duplicate ACK | The missing segment is acknowledged |
On loss, ssthresh is set to half of cwnd. What happens next depends on how the loss was noticed:
| Loss event | Tahoe | Reno |
|---|---|---|
| Timeout | cwnd = 1, slow start | cwnd = 1, slow start |
| Three duplicate ACKs | cwnd = 1, slow start | cwnd = ssthresh, congestion avoidance (via fast recovery) |
A timeout means the network may be badly congested, so both versions restart at 1. Three duplicate ACKs mean later segments are still getting through, so Reno keeps the window at half and carries on.
Worked trace
Section titled “Worked trace”Start at cwnd = 1 with ssthresh = 8. Counts are per RTT.
| RTT | cwnd | Phase | Event |
|---|---|---|---|
| 1 | 1 | Slow start | |
| 2 | 2 | Slow start | |
| 3 | 4 | Slow start | |
| 4 | 8 | Slow start | Reaches ssthresh |
| 5 | 9 | Congestion avoidance | |
| 6 | 10 | Congestion avoidance | |
| 7 | 11 | Congestion avoidance | |
| 8 | 12 | Congestion avoidance | Three duplicate ACKs |
| 9 | 6 (Reno) | Congestion avoidance | ssthresh = 6. Reno resumes at 6 |
| 10 | 7 | Congestion avoidance | |
| 11 | 8 | Congestion avoidance | Timeout |
| 12 | 1 | Slow start | ssthresh = 4 |
| 13 | 2 | Slow start | |
| 14 | 4 | Slow start | Reaches ssthresh |
| 15 | 5 | Congestion avoidance |
Tahoe would have gone to 1 at round 9, and grown 1, 2, 4, 6 before turning linear. Reno recovered in one step. The sawtooth this pattern draws on a graph (linear climb, sharp halving) is the signature of AIMD: additive increase, multiplicative decrease.
Average throughput of AIMD
Section titled “Average throughput of AIMD”In congestion avoidance the window climbs from W/2 to W, where W is the window at the moment of loss. The average is the midpoint:
average window = (W/2 + W) / 2 = 0.75 Waverage throughput ~ 0.75 x W / RTTThis ties throughput to the window at which loss occurs. A more useful result relates throughput to the loss rate L (the fraction of packets lost). A well-known approximation, from research on TCP steady-state behavior, is:
throughput ~ 1.22 x MSS / (RTT x sqrt(L))Two consequences matter in practice:
- Throughput falls with RTT and with the square root of loss. Halving the RTT doubles the rate. Reducing loss by 100 times raises the rate 10 times.
- A single flow needs astonishingly low loss to fill a fast, long path. With a 1,460-byte MSS and a 50 ms RTT:
| Loss rate | Approximate throughput of one flow |
|---|---|
| 0.01% (1 in 10,000) | 28 Mbit/s |
| 0.0001% (1 in 1,000,000) | 285 Mbit/s |
| 0.000000081% (about 1 in 1.2 billion) | 10 Gbit/s |
That is why transfers over high-latency links use parallel streams, tuned buffers, or a different algorithm such as BBR or CUBIC (see TCP congestion control), which do not treat every loss as a congestion signal in the same way. It is also a reason to cure loss at the source (a bad cable or an overloaded queue) before tuning anything else.
Why AIMD is fair
Section titled “Why AIMD is fair”If K flows share a bottleneck of rate R, a fair outcome gives each R/K. TCP flows do not coordinate, yet they converge there. Work it through with two flows, with R = 100 Mbit/s. Both have the same RTT, so each adds 10 Mbit/s per round while there is no loss. Loss happens when the total passes 100, and both halve.
| Round | Flow 1 | Flow 2 | Total | Difference | What happens |
|---|---|---|---|---|---|
| Start | 20 | 60 | 80 | 40 | |
| +10 each | 30 | 70 | 100 | 40 | At capacity |
| +10 each | 40 | 80 | 120 | 40 | Loss, both halve |
| After halving | 20 | 40 | 60 | 20 | |
| +10 each, three rounds | 50 | 70 | 120 | 20 | Loss, both halve |
| After halving | 25 | 35 | 60 | 10 | |
| +10 each, three rounds | 55 | 65 | 120 | 10 | Loss, both halve |
| After halving | 27.5 | 32.5 | 60 | 5 |
Additive increase adds the same amount to both, so it leaves the difference unchanged. Multiplicative decrease halves each rate, and so halves the difference. Each cycle halves the gap, and the flows approach 50/50. On a graph of flow 1 against flow 2, additive increase moves the point up along a 45 degree line, and each halving moves it straight toward the origin. Repeated, the path spirals in toward the equal-share line.
Three things break the neat result:
| Factor | Effect |
|---|---|
| Different RTTs | Flows with a short RTT grow faster per second. In the simple model, throughput scales as 1/RTT, so a 10 ms flow gets roughly ten times the share of a 100 ms flow |
| Unresponsive UDP | Senders that never back off take what they want, and the TCP flows give way |
| Many connections per application | Fairness is per connection. An application using 11 connections against 9 single-connection users takes 11 of 20 shares, or 55% |
The last point matters for design. Opening more parallel connections is an unfair gain, and it also strains NAT tables, load balancers, and server limits. HTTP/2 and HTTP/3 reduce the need by multiplexing many requests on one connection.