Congestion Control
How TCP avoids collapsing the network — slow start, congestion avoidance (AIMD), fast recovery, CUBIC and BBR, bufferbloat, and what it means for your applications.
If every sender transmitted as fast as it could, router queues would overflow, packets would be dropped, senders would retransmit, and the network would spend its capacity carrying retransmissions. This happened in 1986 — congestion collapse — when Internet throughput fell by a factor of 1000. Van Jacobson's congestion control algorithms fixed it and are a big reason the Internet works at all.
The congestion window
Besides the receiver's window (flow control), the sender keeps a congestion window (cwnd): its own estimate of how much the network can absorb.
There's no explicit signal from the network about capacity, so TCP probes: it increases cwnd until it sees signs of congestion (packet loss, or rising delay), then backs off.
Classic TCP (Reno)
- Slow start — begin with cwnd ≈ 10 segments (~14 KB) and double it every RTT (+1 segment per ACK). Despite the name, it grows exponentially.
- When cwnd reaches the slow-start threshold (ssthresh), switch to congestion avoidance: add about 1 segment per RTT (linear).
- On 3 duplicate ACKs (one packet lost, the rest arriving): halve cwnd and set ssthresh to it — fast recovery — then continue linearly.
- On a timeout (severe loss): set ssthresh = cwnd / 2, reset cwnd to 1 segment, and slow-start again.
This is AIMD — additive increase, multiplicative decrease. AIMD is provably fair: competing flows on a shared link converge to equal shares.
Why slow start matters to web performance
A new connection starts at ~14 KB per RTT and needs several round trips to reach full speed. A 500 KB page over a fresh connection with 100 ms RTT needs about 5–6 round trips just from slow start, regardless of your bandwidth.
- Reuse connections (keep-alive, HTTP/2, connection pools) to keep a warm cwnd.
- Keep the critical first response small (critical CSS inline, around the first 14 KB).
- Put servers close to users (CDNs) to cut RTT, since every round trip counts.
Modern algorithms
| Algorithm | Signal | Idea | Used by |
|---|---|---|---|
| Reno / NewReno | Loss | AIMD | Historical baseline |
| CUBIC | Loss | Window grows as a cubic function of the time since the last loss: fast recovery to the previous level, careful probing near it, aggressive beyond | Default in Linux, Windows, macOS |
| BBR (v1–v3) | Bandwidth + RTT model | Measure the bottleneck bandwidth and minimum RTT; pace sending at that rate rather than filling buffers | Google, YouTube, many CDNs |
| Vegas, Copa | Delay | Back off when RTT rises, before loss | Research, some products |
| DCTCP | ECN marks | Fine-grained reaction to congestion marks | Data centres |
Bufferbloat
Routers and modems with huge buffers let loss-based TCP fill them, adding hundreds of milliseconds (sometimes seconds) of queuing delay. That's why a video call stutters when someone else in the house starts a large upload.
Fixes:
- Active queue management (AQM) in routers: CoDel, fq_codel, CAKE drop or mark packets early when queuing delay grows, and isolate flows from each other.
- ECN (explicit congestion notification): routers mark packets instead of dropping them, and the sender slows down without losing data. L4S extends this for very low latency.
- Delay-aware algorithms like BBR.
Fairness and the real world
- AIMD flows share a bottleneck roughly equally per flow, so an application opening 6 parallel connections gets 6 shares. Browsers historically did exactly that with HTTP/1.1.
- Flows with shorter RTTs grow faster and get more bandwidth (RTT unfairness).
- UDP applications have no built-in congestion control; well-behaved ones (QUIC, WebRTC) implement it themselves, and network operators worry about those that don't.
Checking your connections
sysctl net.ipv4.tcp_congestion_control # e.g. cubic
sysctl -w net.ipv4.tcp_congestion_control=bbr # switch (needs the module)
ss -ti # per-connection cwnd, rtt, retransmits- Congestion control protects the network; cwnd limits data in flight; throughput ≈ cwnd / RTT.
- Slow start doubles cwnd each RTT; congestion avoidance adds 1 segment per RTT.
- On loss, cut cwnd (halve on dup ACKs, reset on timeout): AIMD is stable and fair.
- CUBIC is the common default; BBR models bandwidth and RTT to avoid filling queues.
- Bufferbloat adds latency; AQM (fq_codel) and ECN fix it.
- Reuse connections and reduce RTT — slow start penalises fresh connections.
QWhy is it called slow start if the window grows exponentially?easy
Compared with what came before — sending a full receiver window immediately — starting from a small window is slow. It then doubles each RTT until it hits ssthresh or sees loss.
QWhy might adding more bandwidth not make a website load faster?medium
Page loads are often dominated by round trips: DNS, the TCP and TLS handshakes, slow start's ramp-up, and dependent requests. These depend on latency (RTT), not bandwidth. Reducing round trips (connection reuse, HTTP/2–3, CDNs, preconnect) helps more.