14. Congestion Control: Protecting the Network

How a TCP sender that can only see ACKs, losses and delays works out how fast to send, from the 1986 collapses through slow start, AIMD and fast recovery to CUBIC, BBR, bufferbloat and ECN

Picture pouring water into a funnel with your eyes shut. Below the funnel is a pipe whose width you don't know, and a friend at the far end tells you, every so often, how much water has come out. Pour too slowly and the pipe runs half empty. Pour faster than the pipe drains and the funnel fills up, and every extra drop just waits longer in the funnel before it gets through. Keep going and it overflows onto the floor. Your friend won't mention the spill. You'll only notice that less water arrives than you poured.

How do you pour at exactly the right rate? You can't measure the pipe. All you can do is pour, listen, and adjust: speed up while everything arrives, slow down sharply when some of it doesn't. And if several people are pouring into the same funnel, each with their eyes shut, you'd like them all to end up with a fair share without ever talking to each other.

That's congestion control. A TCP sender can't see the routers between it and the receiver. It doesn't know how fast the slowest link is, how big the queue in front of it is, or how many other connections share it. All it gets back is a stream of ACKs, and from their timing and their gaps it has to decide, many times every round trip, how much data to have in flight. Get it wrong in one direction and a fast link sits idle. Get it wrong in the other and queues overflow, packets are lost and retransmitted, and the retransmissions make the congestion worse. In 1986 that second failure took down the Internet.

This page follows the laptop's upload from the TCP article, but bigger, and through a path with a real bottleneck. We'll build the classic algorithms from first principles, see why the simplest rule turns out to be fair, and then look at what Linux actually runs today: CUBIC, BBR, and the queue managers that keep them honest.

The Day the Internet Slowed to 40 bit/s

In October 1986 Van Jacobson, at Lawrence Berkeley Laboratory, noticed that file transfers to UC Berkeley, a few hundred metres away, had become absurdly slow. In his words:

Jacobson and Karels, "Congestion Avoidance and Control", 1988

"In October of '86, the Internet had the first of what became a series of 'congestion collapses'. During this period, the data throughput from LBL to UC Berkeley (sites separated by 400 yards and two IMP hops) dropped from 32 Kbps to 40 bps."

That's a factor of 800. The links were working. The routers were working. The network was busy from end to end, and almost none of the traffic was useful: it was copies of segments that had already been sent, many of them several times.

The mechanism is a feedback loop. When a router's queue fills, it drops packets. TCP of the day retransmitted on a timer and, apart from respecting the receiver's window, had no notion of how much the network could carry. So every lost segment was sent again, and every connection kept sending a full window. The extra copies filled the queues further, more packets were lost, more were retransmitted, and the round trip time grew until timers fired for segments that weren't even lost, adding duplicates on top. John Nagle had predicted exactly this two years earlier in RFC 896 (1984) and given it a name: congestion collapse.

Jacobson and Michael Karels of UC Berkeley worked out why, and how to fix it, in a paper presented at SIGCOMM in August 1988. Their starting point was a principle from physics: a connection running in equilibrium should be conservative. "A new packet isn't put into the network until an old packet leaves." Collapse happens when that rule breaks: when a sender starts by dumping a whole window into the network at once, when it injects new packets before old ones have left, or when it can't reach equilibrium because the path's capacity has changed.

Their fix shipped in the 1988 4.3BSD-Tahoe release, and every TCP since descends from it: a better retransmission timer (the RTT estimator from the TCP article), exponential timer backoff, slow start, congestion avoidance that cuts the window sharply on loss and grows it gently otherwise, and fast retransmit. None of it needed any change to routers or to the TCP header. It was all in how the sender decides when to send.

Where the Queue Builds

Let's set up the path. The laptop at 192.168.10.10 is uploading a large file to the server at 203.0.113.80, port 80, over the same connection as before, with source port 47130. Its own link to R1 is gigabit Wi-Fi or Ethernet. But R1's WAN interface, 198.51.100.23, connects to the ISP's edge router R2 over a home uplink, and home uplinks are slow. Ours runs at 10 Mb/s. Past R2 the ISP's core and the data centre are far faster. So the uplink is the bottleneck: the slowest link on the path, the one that sets the pace for everything.

Laptop 192.168.10.10 1 Gb/s R1 · home router WAN 198.51.100.23 uplink queue 10 Mb/s bottleneck R2 · ISP edge 198.51.100.1 Server 203.0.113.80:80 ACKs come back, small and unqueued Whenever the laptop sends faster than 10 Mb/s, the excess waits in R1's queue. Round trip with an empty queue: 40 ms. Segments: 1,000 bytes, as in the TCP simulator.

Two numbers describe this path. The first is the bandwidth-delay product, or BDP: how much data fits "in the pipe", in flight between the laptop and the server, when the bottleneck is busy and the queue is empty.

BDP=10 Mb/s×40 ms=400,000 bits=50,000 bytes=50 segments\begin{aligned} \text{BDP} &= 10\text{ Mb/s} \times 40\text{ ms} \\ &= 400{,}000\text{ bits} \\ &= 50{,}000\text{ bytes} \\ &= 50\text{ segments} \end{aligned}

The second is R1's buffer: how many packets its uplink queue can hold before it starts dropping. We'll give it 50 packets, which at 10 Mb/s is 40 ms of waiting. So:

  • With fewer than 50 segments in flight, the uplink is sometimes idle. The laptop is wasting capacity.
  • With exactly 50, the uplink is always busy and nothing waits. This is the sweet spot.
  • With 50 to 100, the uplink is still busy, so throughput is no higher, but the extra segments sit in R1's queue. Every packet waits longer, and the round trip grows from 40 ms towards 80 ms.
  • With more than 100, the queue is full and R1 drops whatever doesn't fit. This is the overflowing funnel.

The sender's job is to find that range without being told any of these numbers. Worse, the numbers change: when someone else in the house starts a video call, the laptop's share of the uplink halves.

The Sender's Limit: Two Windows

The TCP article ended with the receive window, rwnd: how much the receiver can buffer, carried in every ACK. Congestion control adds a second window that the sender keeps to itself, the congestion window, cwnd: its current guess at how much the network can take. Unlike rwnd, cwnd is never sent on the wire. The rule is simply:

How much may be in flight

allowed = min(cwnd, rwnd)
in flight = SND.NXT − SND.UNA
send another segment while  in flight + MSS ≤ allowed

On a long, fast path it's usually cwnd that binds; rwnd matters when the receiving application is slow. Our server has a 1 MB receive window (1,000 segments), far more than the path holds, so from here on the limit is cwnd.

Once cwnd is right, something elegant happens. The bottleneck spaces packets out: two segments that arrive at R1 back to back leave it 0.8 ms apart, the time 1,000 bytes take at 10 Mb/s. The server ACKs each one as it arrives, so the ACKs come back 0.8 ms apart too, and each ACK lets the laptop send one new segment. The sender is now transmitting at exactly the rate the bottleneck drains, without ever measuring it. Jacobson called this self-clocking, and the returning ACKs the ACK clock. It's what "conservation of packets" looks like in practice: a new packet enters only when an old one leaves.

What's left is to find the right window, and to keep finding it as conditions change. That takes two separate tools: one for starting up, and one for running.

Slow Start

A connection starts knowing nothing. Starting with a full receive window, as pre-1988 TCPs did, dumps a burst into the network that the bottleneck can't possibly absorb. Starting at one segment per round trip and adding one each time is safe, but it would take 50 round trips, two whole seconds, just to fill our modest pipe.

Slow start is the compromise, and despite the name it's fast: the window doubles every round trip. The rule is per ACK:

on each ACK that acknowledges new data, while cwnd < ssthresh:
    cwnd = cwnd + 1 MSS

Every segment sent produces one ACK, and every ACK adds one segment to the window and lets the sender send two: one to replace the segment that left, one for the increase. So a window of 10 becomes 20 one round trip later, then 40, then 80. It's "slow" only compared with what came before it, which was sending everything at once.

The initial window

How big is the first flight? It used to be one segment, then RFC 3390 (2002) allowed up to four. Today it's ten. RFC 6928 (2013), based on measurements Google ran across its own traffic, set the initial window to:

IW=min⁡(10⋅MSS, M)M=max⁡(2⋅MSS, 14,600)\begin{aligned} \text{IW} &= \min(10 \cdot \text{MSS},\ M) \\ M &= \max(2 \cdot \text{MSS},\ 14{,}600) \end{aligned}

For a 1,460-byte MSS that's 14,600 bytes, ten full segments; Linux has used 10 since 2011. Many small responses fit in those ten segments, so one round trip after the handshake, they're already on their way.

Slow start on our path

With IW = 10 and a 40 ms round trip:

Round trip cwnd at start What happens at R1
1 10 Uplink mostly idle
2 20 Still under the BDP of 50
3 40 Nearly full
4 80 Busy; a queue starts to build
5 160 Queue overflows: far more than 100 in flight

The doubling overshoots, and it always will, because the sender learns about a loss only when the duplicate ACKs come back, a full round trip after the damage. In the simulator below, with the classic algorithms, the first loss is discovered at 261.6 ms, by which time cwnd has reached 201 segments, twice what the pipe and the buffer can hold. About a hundred segments were dropped in that one round trip. Remember that number; it'll matter.

ssthresh

The variable in the rule, ssthresh (the slow-start threshold), is where slow start hands over to the gentler regime. It starts "arbitrarily high", so the first slow start runs until something is lost. After a loss, ssthresh is set to half the data that was in flight, the last window that's known to have worked. From then on, slow start only runs below that threshold, to get quickly back to a known-safe window, before handing over.

Congestion Avoidance: AIMD

Above ssthresh, the sender is in congestion avoidance. Now it's near the limit, so it creeps up, and when it sees a loss it backs off hard. The two rules are:

  1. Additive increase

    Add one segment per round trip. Per ACK, that's cwnd += MSS × MSS / cwnd: a window of 50 segments gets 50 ACKs per round trip, each adding 1/50 of a segment.

  2. Multiplicative decrease

    On a loss, cut the window in half: ssthresh = max(FlightSize / 2, 2 × MSS), and cwnd follows (exactly how depends on the algorithm, as we'll see).

This is AIMD, additive increase, multiplicative decrease, and on one flow it produces TCP's signature sawtooth: a slow climb, a sudden halving, a slow climb again. Here's NewReno running for 13 seconds through R1, from the reference simulator:

050100 7 s10 s13 s16 s19 s fast retransmit cwnd (segments) R1's queue (packets) BDP, 50 (also the buffer size) BDP + buffer, 100: beyond it, drops Seconds 6.5 to 19.5 of the simulator's NewReno preset. Goodput over this stretch: 10.00 Mb/s.

The window climbs from 51 to 103 segments, a few segments past the limit of 100, because the loss is only noticed a round trip later, then halves. Each climb of 52 segments takes 52 round trips, and since the round trip grows from 41 ms to 81 ms as the queue fills, the teeth are about 3.3 seconds apart. And notice what the halving does: cwnd drops to 51, which is the BDP, and the queue drains to empty just as the link would run dry. So the uplink never idles, and the sender gets the full 10.00 Mb/s.

That's the reason for an old rule of thumb: a bottleneck should buffer one BDP. With less, the queue empties after a halving and the link idles until the window regrows; with more, the link is no busier, and the extra buffer only adds delay. We'll come back to that.

Why halve rather than back off a little? Jacobson's argument was a hand-wave he was happy to admit to. If you're in steady state and lose a packet, it's probably because a new connection has arrived and is taking its share, and if there are now two of you, half is about right. If you just finished slow start, half the window is the last size you know worked, because slow start doubled it from there. The deeper reason, that halving makes competing flows fair, came a year later, and gets its own section.

Tahoe, Reno and NewReno

AIMD says how much to cut. The three classic algorithms differ in how they notice a loss and what they do while repairing it. All three share two loss signals from the TCP article: a retransmission timeout, and three duplicate ACKs.

On a timeout: back to one segment

An RTO means the ACK clock has stopped completely: nothing has come back for a whole timeout. The sender can't trust anything about the path any more, so RFC 5681 restarts from scratch:

on RTO:
    ssthresh = max(FlightSize / 2, 2 × MSS)
    cwnd     = 1 × MSS        # the "loss window"
    retransmit the oldest unacknowledged segment, then slow start again

Note the difference from the start of the connection: the initial window is 10, but the loss window after a timeout is one segment. Slow start then doubles back up to the new ssthresh in a few round trips, and AIMD takes over.

Tahoe: three duplicates mean a loss, start over anyway

Tahoe added fast retransmit: after three duplicate ACKs, resend the missing segment without waiting for the timer. But then it treated the loss exactly like a timeout: ssthresh to half the flight, cwnd to one, slow start again. That's safe, but wasteful. Three duplicate ACKs mean three segments got through. The pipe isn't empty; it's still carrying data, and the ACK clock is still ticking.

Reno: fast recovery

Jacobson's 1990 refinement, shipped in 4.3BSD-Reno, keeps the clock running. It's called fast recovery, and its odd-looking trick is window inflation:

  1. Third duplicate ACK

    Set ssthresh = max(FlightSize / 2, 2 × MSS). Retransmit the missing segment. Set cwnd = ssthresh + 3 × MSS: the three duplicates mean three segments have left the network, so count them as gone.

  2. Each further duplicate ACK

    cwnd += 1 × MSS. Another segment has reached the receiver. Once cwnd climbs past the amount in flight, each duplicate ACK releases one new segment.

  3. The ACK for new data

    The retransmission has arrived. Deflate: cwnd = ssthresh, and carry on in congestion avoidance.

Inflation looks like cheating, a window that grows during a loss, but it isn't. The flight size TCP counts (SND.NXT − SND.UNA) can't shrink while the hole is outstanding, because SND.UNA is stuck at the hole. Each duplicate ACK is evidence that one more segment has left the network, and inflating cwnd by one is how the sender takes that segment out of its count. Here it is with numbers.

Worked example: one loss in a window of 10

in flight: segments 21–30; segment 21 is lost
ACKs from 22, 23, 24   3 duplicates for 21
                       ssthresh = 10/2 = 5, resend 21, cwnd = 5 + 3 = 8
ACKs from 25, 26       cwnd 9, 10   (flight is 10: nothing to send yet)
ACK from 27            cwnd 11  →  send 31
ACK from 28            cwnd 12  →  send 32
ACK from 29            cwnd 13  →  send 33
ACK from 30            cwnd 14  →  send 34
resent 21 arrives      ACK 31 covers 21–30: cwnd = ssthresh = 5
                       in flight 31–34 = 4  →  send 35

The sender went from 10 segments in flight to 5, exactly the halving AIMD asks for, and the ACK clock never stopped: new segments went out on the duplicates for 27 to 30. Tahoe would have dropped to one segment and needed three round trips of slow start to get back to five.

Reno's weak spot: two losses

Reno's recovery ends on the first ACK for new data. If two segments in the same window were lost, that ACK is a partial ACK: it covers the first hole and stops at the second. Reno has already deflated and left recovery, and it needs three fresh duplicate ACKs to resend the second hole. After a halving, there may not be enough segments in flight to produce them, so it often ends up waiting for the timer, and back at a window of one. (Some Reno stacks instead fast-retransmit again and halve a second time for the same congestion event.)

NewReno: stay in recovery until it's all repaired

NewReno (Janey Hoe, 1996; RFC 6582 today) fixes this without any help from the receiver. On entering recovery, it records recover, the highest sequence number sent so far. It stays in fast recovery until an ACK covers recover. A partial ACK below that means "there's another hole right here", so:

on a partial ACK (new data acknowledged, but not up to recover):
    retransmit the first unacknowledged segment
    cwnd = cwnd − (newly acknowledged) + 1 MSS     # partial deflation
    stay in fast recovery; duplicate ACKs keep inflating
on a full ACK (covers recover):
    cwnd = ssthresh; leave fast recovery

You've already watched this happen. In the TCP simulator, with seed 196, the laptop lost seq 1001 and seq 4001 from the same window, fast-retransmitted 1001, and resent 4001 the moment the partial ACK 4001 arrived. That simulator held cwnd fixed at five segments. Here's the same transfer, the same seed and the same lost segments, with a real NewReno window starting at IW = 10:

  1. 110–232 ms: slow start

    Ten segments go out, 10 ms apart; seq 1001 and seq 4001 are lost. The first ACK, at 221.9 ms, grows cwnd to 11,000 bytes, and segments 11 and 12 follow. Segment 12, seq 11001, is lost too: the tail segment that needed an RTO last time.

  2. 265.2 ms: fast retransmit

    The third duplicate ACK for 1001. 11,000 bytes are in flight, so ssthresh = 5,500, cwnd = 8,500, and seq 1001 is resent, 62 ms sooner than with the fixed window. Five more duplicates inflate cwnd to 13,500.

  3. 376.1 ms and 490.9 ms: two partial ACKs

    ACK 4001 covers the first hole: resend seq 4001, cwnd 11,500. Then ACK 11001: resend seq 11001, cwnd 5,500. Because the tail segment was sent before recovery began, it's inside recover, and a partial ACK finds it. No timer needed.

  4. 543.5 ms: all 12,000 bytes are in

    ACK 12001 reaches the laptop at 603.3 ms; recovery is over and cwnd deflates to ssthresh, 5,500 bytes. With the fixed window, the last byte arrived at 920.6 ms, after an RTO.

Where NewReno still hurts

NewReno repairs one hole per round trip. That's fine for two or three losses. It's painful after slow start's overshoot, which drops about a hundred segments in one window. Without SACK, the sender can only discover those holes one at a time: each retransmission brings back a partial ACK that reveals the next hole. In the simulator's NewReno preset the first recovery lasts from 261.6 ms until 4,420 ms, and in that time 100 partial ACKs arrive, 40.8 ms apart, one per round trip.

Meanwhile every duplicate ACK inflates cwnd and releases a new segment, until at 2,080 ms the data in flight reaches the server's 1,000-segment receive window and sending stops. The duplicate ACKs from the segments already on their way keep inflating cwnd anyway, which is how it peaks at 1,097.5. From then until recovery ends, the uplink carries little more than one retransmission per round trip and sits idle for 2.2 seconds.

One detail of the simulator makes this as stark as it can be: its retransmission timer. RFC 6582's NewReno resets the timer only on the first partial ACK of a recovery. The older NewReno specification, RFC 3782, calls that the "Impatient" variant, and also describes a "Slow-but-Steady" alternative that resets the timer on every partial ACK. The simulator uses Slow-but-Steady, so that you can watch the one-hole-per-round-trip limit play out in full. With the standard Impatient timer, the RTO fires partway through, the sender slow-starts and resends the rest, and the same upload averages 8.95 Mb/s, with 5 timeouts.

So NewReno trailing Tahoe in this run isn't typical. With a loss or two per window, NewReno is clearly better. The run shows that cumulative ACKs can't describe a hundred holes, and that's exactly the problem SACK-based loss detection (which the CUBIC and BBR runs below use) solves. (Reno, in the same situation, gives up at the first partial ACK, times out at 540 ms and slow-starts back, which here turns out to be quicker.)

The real fix is the receiver's help: SACK tells the sender exactly which segments arrived, so it can resend every hole at once (RFC 6675). Modern Linux combines SACK with RACK (RFC 8985), which declares a segment lost once a segment sent sufficiently later (by more than a small reordering window) has been delivered, and PRR (RFC 6937), which spreads the window reduction smoothly over the recovery round trip instead of halting and then bursting. That's the machinery the CUBIC and BBR simulations below use. The congestion control, how big the window should be, is a separate question from the loss recovery, which segments to resend, and from here on we'll mostly talk about the former.

Why AIMD Is Fair

Suppose the laptop's upload is running and a second device in the house starts its own. Both connections now share R1's uplink. Neither knows the other exists. Both see the same signal: when the queue overflows, packets get dropped, and roughly speaking, both see a loss. Will they end up with half each?

In 1989, Dah-Ming Chiu and Raj Jain answered that with a picture. Plot the two flows' rates as a point: flow 1 on the horizontal axis, flow 2 on the vertical. The line where they add up to the link's capacity is the efficiency line; below it the link is under-used, above it the queue overflows. The diagonal where they're equal is the fairness line. The goal is where the two cross.

Now play the rules. When the link is under-used, both flows add the same amount: the point moves at 45°, parallel to the fairness line, so their difference stays the same. When it's overloaded, both multiply by one half: the point moves straight towards the origin, which halves their difference. Each cycle keeps the difference on the way up and halves it on the way down, so the point zigzags towards the fair share.

flow 1's rate flow 2's rate 05010050100 start (70, 10) start (20, 60) fairness line (equal rates) efficiency line (rates add up to the link) optimum

In the plot, the teal AIMD path (+5 each, then × 0.5 each) starts at (70, 10). Each climb at 45° keeps the gap between the flows the same, and each halving towards the origin halves it; after 39 steps it's at (50.6, 49.6). The amber AIAD path (+5 each, then −5 each) starts at (20, 60) and just bounces between (30, 70) and (35, 75): its gap of 40 never shrinks.

The other combinations fail. Additive decrease (the amber path) moves back along the same line it went up, so an unfair split stays unfair forever. Multiplicative increase, as in slow start, moves away from the origin, which preserves the ratio between the flows: if one has seven times the other's rate, it keeps seven times. Chiu and Jain showed that among linear increase and decrease rules, additive increase with multiplicative decrease is the only one that converges to both efficiency and fairness. That's the real reason TCP halves.

The simulator agrees. Two NewReno uploads through R1, the second starting 5 seconds after the first, settle at 4.95 and 5.03 Mb/s over the last 15 seconds of a 30-second run.

Two flows share a link of capacity 100. After every step both get the same one-bit signal, "overloaded" when x1 + x2 > 100, and both apply the same rule. Click the plot to choose where they start.

Every step

How Fast Can a Window Go?

Two formulas tell you most of what you need to know about a loss-based TCP's speed.

Filling the pipe

A sender can't have more than one window in flight per round trip, so to keep a link busy, the window must hold at least the bandwidth-delay product. We worked it out for R1's uplink: 50,000 bytes. For a fast path the numbers get large quickly. A 1 Gb/s path with a 100 ms round trip has a BDP of 12.5 MB, which is why window scaling exists (the TCP article did that sum). Neither cwnd nor rwnd can be smaller than that if the link is to be filled.

The Mathis formula

How fast does AIMD go when the path loses packets at some steady rate p? In 1997 Matt Mathis, Jeffrey Semke, Jamshid Mahdavi and Teunis Ott worked it out from the sawtooth. If the window climbs from W/2 to W and then loses one packet, each tooth lasts W/2 round trips and carries about (3/8)W² packets, one of which is lost:

p≈138W2⇒ W≈83p\begin{aligned} p &\approx \frac{1}{\tfrac{3}{8} W^2} \\ \Rightarrow\ W &\approx \sqrt{\frac{8}{3p}} \end{aligned}

The average window is 34W\tfrac{3}{4} W, one window per RTT:

rate≈34W⋅MSSRTT=MSSRTT⋅Cp\begin{aligned} \text{rate} &\approx \frac{\tfrac{3}{4} W \cdot \text{MSS}}{\text{RTT}} \\ &= \frac{\text{MSS}}{\text{RTT}} \cdot \frac{C}{\sqrt{p}} \end{aligned}

with C=3/2≈1.22\text{with } C = \sqrt{3/2} \approx 1.22

That 1/√p is the important part. A loss-based TCP's speed falls with the square root of the loss rate, and with the round trip time. Plug in our path, 1,000-byte segments and 40 ms, with 1% random loss on top of congestion:

8,000 bits0.04 s×1.220.01≈ 2.45 Mb/s\begin{aligned} & \frac{8{,}000\text{ bits}}{0.04\text{ s}} \times \frac{1.22}{\sqrt{0.01}} \\ \approx\ & 2.45\text{ Mb/s} \end{aligned}

A quarter of the link, lost to a loss rate that has nothing to do with congestion. The reference simulator agrees: with 1% random loss after R1, NewReno manages 2.06 Mb/s and CUBIC 2.56 Mb/s. That's why loss on Wi-Fi or a flaky line hurts TCP far more than the bare percentage suggests, and it's one of the reasons BBR was built.

Run the formula the other way and it shows the problem with fast paths. To fill 10 Gb/s over 100 ms with 1,500-byte packets, the average window must be about 83,333 segments, and the loss rate must be below about 2.2 × 10−10: one loss in 4.6 billion packets, about one every 93 minutes. That's the sawtooth again: the window peaks at about 111,111, halves to 55,556, and Reno's +1 per round trip needs 55,556 round trips, the same 93 minutes, to climb back. No real path is that clean. That's what CUBIC was designed to fix.

Watch the Window

The simulator below runs one long upload from the laptop through R1's uplink, packet by packet. Every segment waits its turn in R1's queue, crosses the bottleneck, may be lost on the way at random (seeded, so a run is repeatable), and is ACKed by the server. You choose the algorithm and the path, and watch cwnd, ssthresh, the queue and the throughput. With the defaults, 10 Mb/s, 40 ms, a 50-packet buffer, no random loss and seed 196, over 20 seconds:

  • Tahoe sets ssthresh to half the flight and drops to one segment at each of 7 fast retransmits: a sawtooth of slow starts, averaging 9.20 Mb/s.
  • Reno halves instead; after the overshoot it times out once at 540 ms and then settles into the sawtooth: 9.66 Mb/s overall, a full 10 Mb/s in the second half.
  • NewReno spends four seconds repairing the overshoot one hole at a time (the Slow-but-Steady timer of RFC 3782, above), then runs the sawtooth: 7.77 Mb/s overall, 10 in the second half.
  • CUBIC, with SACK-based recovery as in Linux, repairs the overshoot within a few round trips (two cuts, done by about 0.5 s): 9.96 Mb/s, but it keeps R1's queue fuller: 30.6 ms of queueing delay on average over the second half.
  • BBR overshoots in startup (172 drops), then holds the queue nearly empty: 9.84 Mb/s, with an average queueing delay of 2.1 ms over the second half.

Then try a 1% random loss rate (Mathis in action), a 400-packet buffer (the next section), or a long fat path: 20 Mb/s, 100 ms and a 250-packet buffer, where CUBIC's shape shows clearly.

The laptop uploads through R1's uplink in 1,000-byte segments, for the whole run. The server ACKs every segment, and ACKs are never lost or queued. A preset sets the path; the algorithm stays as you chose it.

Algorithm

The path

Congestion events (times in ms)

Bufferbloat

Back to the rule of thumb: buffer one BDP. Memory is cheap, and a router vendor that drops packets looks bad in benchmarks, so for years devices shipped with far more. Cable modems, DSL routers and Wi-Fi drivers with hundreds of milliseconds of buffering at their uplink rate were common. In 2010 Jim Gettys traced the terrible latency on his home network to exactly this, and named it bufferbloat.

The trouble is that a loss-based TCP fills whatever buffer it's given. It only backs off when packets are dropped, and they're only dropped when the buffer is full. Give R1 a 400-packet queue instead of 50 and run CUBIC:

50-packet buffer (40 ms)

Throughput 9.96 Mb/s over the 20-second run. Average time waiting in R1's queue, over the last 10 seconds: 30.6 ms.

400-packet buffer (320 ms)

Throughput 9.96 Mb/s: no better. Average queueing delay over the last 10 seconds: 264.4 ms.

The upload doesn't care. Everything else does. A DNS lookup, a video call, a game, or the ACKs for someone else's download all queue behind the upload, and the whole house's round trip time goes from 40 ms to 300. It's the funnel again: the water level stays at the brim, and every new drop waits behind all of it.

Active queue management

The cure is for the router to signal congestion before the buffer is full: active queue management, or AQM: the router drops (or, as we'll see, marks) a few packets early, based on how its queue is behaving, rather than only when it's full.

  • RED, Random Early Detection (Sally Floyd and Van Jacobson, 1993), drops arriving packets with a probability that rises with the average queue length. It works, but it has several parameters that must be tuned to the link, and badly tuned RED is worse than none, so it was rarely switched on.
  • CoDel, Controlled Delay (Kathleen Nichols and Van Jacobson, 2012; RFC 8289, 2018), watches something simpler: how long each packet spent in the queue, its sojourn time. A short burst that drains quickly is fine; that's what buffers are for. But if the sojourn time has stayed above a target of 5 ms for a whole interval of 100 ms, the queue isn't absorbing a burst, it's standing. CoDel drops one packet, and if the queue still doesn't drain, drops the next one sooner, at intervals of 100 ms/√2, 100 ms/√3, and so on, until it does. There are no link-specific knobs.
  • fq_codel (RFC 8290, 2018) adds flow queueing: it hashes packets into separate queues by their five-tuple, serves the queues in turn, and runs CoDel on each. A sparse flow, such as a DNS query or a keystroke over SSH, barely waits behind a bulk upload. Many Linux distributions use fq_codel as their default queueing discipline, and its successor CAKE (Common Applications Kept Enhanced), which adds a traffic shaper, is popular on home routers.

Switch R1's queue to CoDel, still 400 packets deep, and the same CUBIC upload averages 9.39 Mb/s over the 20-second run, with a queueing delay of 1.5 ms over the last 10 seconds. The buffer is still there for bursts; it just isn't allowed to stand full.

There's a practical catch for a home network. The queue that bloats is the one in front of the bottleneck, and that's often inside the ISP's modem, where you can't change it. The usual trick is to make R1 the bottleneck on purpose, by shaping its WAN interface to slightly below the uplink rate, so the queue forms in R1, where fq_codel or CAKE can manage it.

ECN: Marking Instead of Dropping

An AQM that drops a packet to say "slow down" still costs a retransmission. Explicit Congestion Notification (RFC 3168, 2001) lets it say so without losing anything. It uses two places you've already met: the two low bits of the IP header's old Type of Service byte, and the ECE and CWR flags in the TCP header.

IP ECN bits Name Meaning
00 Not-ECT This sender doesn't understand ECN
10 or 01 ECT(0), ECT(1) ECN-capable transport
11 CE Congestion Experienced: set by a router
  1. Negotiate

    The laptop's SYN carries ECE and CWR; the server's SYN-ACK answers with ECE. From then on, both mark their data packets ECT(0).

  2. Mark

    When R1's AQM would have dropped an ECT packet, it sets the bits to CE instead and forwards it.

  3. Echo

    The server sees CE and sets ECE on its ACKs, and keeps setting it until the laptop confirms.

  4. React

    The laptop treats ECE like a loss, at most once per round trip: it cuts cwnd and ssthresh as for a loss, retransmits nothing, and sets CWR on its next segment: "I've slowed down."

Run the CoDel queue with ECN, and CUBIC gets 9.37 Mb/s over the run, with no drops and no retransmissions at all: CoDel marks 20 packets, the laptop cuts its window 16 times, and the queueing delay averages 1.7 ms over the last 10 seconds.

ECN's one bit per round trip is coarse. It says "there was congestion", not how much. Accurate ECN (AccECN, RFC 9768, April 2026) repurposes a reserved header bit alongside ECE and CWR as a counter, so the receiver can report how many packets were marked; recent Linux kernels support it (net.ipv4.tcp_ecn values 3 to 5). That precision is what L4S needs (RFCs 9330–9332, 2023). L4S senders mark their packets ECT(1), and an L4S queue marks them very early, at a millisecond or so of queueing, much more often. The sender reduces its window in proportion to the fraction marked, in the style of data-centre TCP (DCTCP), rather than halving. The result is a queue that hovers around a millisecond at full throughput. A "dual queue" keeps L4S traffic apart from classic traffic so the two can share a link.

Linux's default, net.ipv4.tcp_ecn = 2, accepts ECN when the other side asks for it but doesn't ask on its own connections.

CUBIC

Reno's +1 segment per round trip has two problems on modern paths. On a long fat path it's far too slow to regrow, as the Mathis numbers showed. And because it grows per round trip, a flow with a short RTT grows faster than one with a long RTT, which matters when they share a link (we'll measure that shortly).

CUBIC, by Injong Rhee, Lisong Xu and Sangtae Ha (2005), replaced its predecessor BIC as Linux's default in kernel 2.6.19 in 2006 and has been the default ever since. Windows and Apple's stacks use it too. It's specified in RFC 9438 (2023). Its key idea is to grow the window as a function of time since the last loss, not of ACKs, along a cubic curve:

W(t)=C (t−K)3+Wmax⁡W(t) = C\,(t - K)^3 + W_{\max}

K=Wmax⁡ (1−β)C3\begin{aligned} & K = \sqrt[3]{\frac{W_{\max}\,(1 - \beta)}{C}} \end{aligned}

C=0.4,β=0.7C = 0.4,\quad \beta = 0.7

Here Wmax is the window just before the last loss, t is in seconds, and W is in segments. On a loss, CUBIC cuts to β = 0.7 of the window, not half. Then it climbs back along the curve: fast at first, flattening out as it approaches Wmax, the size that last caused trouble, lingering there, and then, if no loss comes, accelerating away to probe for more. K is the time it takes to get back to Wmax.

Worked example: Wmax = 100 segments

after the loss   W = 0.7 × 100 = 70
K = ∛(100 × 0.3 / 0.4) = ∛75 ≈ 4.22 s
W(1 s) ≈  86.7     concave: catching up quickly
W(3 s) ≈  99.3
W(K)   = 100.0     the plateau
W(6 s) ≈ 102.3     convex: probing, slowly at first
W(8 s) ≈ 121.7     then faster and faster
70100120 0 s2 s4 s6 s8 s 0.7 × Wmax = 70 Wmax K ≈ 4.22 s concave race back towards Wmax convex probe for a new maximum Window in segments, against seconds since the loss. C = 0.4, β = 0.7.

The plateau is the clever part. CUBIC spends most of its time near the window that last worked, which keeps the link busy, and creeps carefully past it, which keeps losses rare. The curve's shape is fixed in seconds, so two CUBIC flows with different round trip times grow at the same rate: CUBIC is much less RTT-unfair than Reno.

A few more pieces make it practical:

  • The Reno-friendly region. At small BDPs, the cubic curve can be slower than Reno would be. So CUBIC also tracks West, an estimate of what Reno's window would be by now (growing by about 0.53 segment per round trip until it reaches the old window, then by 1), and uses whichever is bigger. On our 50-segment path, CUBIC mostly runs in this region.
  • Fast convergence. If a loss comes before the window reaches the old Wmax, a new flow is probably taking a share, so CUBIC lowers Wmax a further 15%, to (1 + β)/2 of the window, to make room.
  • HyStart. Linux's CUBIC also watches the RTT during slow start and leaves it early once the RTT has risen by a few milliseconds, the sign that a queue is building, instead of waiting for the overshoot's mass loss. (RFC 9406's HyStart++ is the standardised version.) It isn't always in time: on our 10 Mb/s path it fires at 220.8 ms with cwnd already at 152, so the overshoot still costs losses, but SACK-based recovery repairs them within a few round trips (two cuts, done by about 0.5 s).

On the long fat preset, 20 Mb/s and 100 ms with a 250-packet buffer, HyStart ends slow start at 430 ms with a window of 152, long before the pipe and buffer's 500. CUBIC then climbs through its convex region and reaches the first loss at 10.2 seconds, at a window of 524. After that it cycles: down to 367, concave back up to the plateau, convex past it, about every 4 to 12 seconds. NewReno, on the same path, never gets going: its slow start runs into the receive window at 1,000 segments, loses hundreds of them in one round trip, and spends the rest of the minute repairing them one hole at a time, at 0.44 Mb/s. (That's the Slow-but-Steady timer again. With RFC 6582's standard Impatient timer, NewReno would time out, slow-start and reach 19.08 Mb/s; CUBIC gets 19.33 Mb/s without a single timeout.)

BBR: Model the Pipe

Every algorithm so far uses loss as its signal of congestion. That has two built-in problems, both of which we've measured: in a deep buffer, a loss-based sender keeps the buffer full, and the queueing delay is enormous (bufferbloat); and on a path with random loss, it backs off when there's no congestion at all (Mathis).

In 2016, Neal Cardwell, Yuchung Cheng, C. Stephen Gunn, Soheil Hassas Yeganeh and Van Jacobson at Google published BBR, Bottleneck Bandwidth and Round-trip propagation time. It starts from an observation Leonard Kleinrock made in 1979: a path performs best, at full throughput with no queue, when exactly one BDP is in flight.

10 Mb/s 40 ms 80 ms delivery rate round trip time 050 (BDP)100 Segments in flight BBR aims here loss-based CC fills to here loss

Loss-based algorithms operate at the right-hand edge, where the buffer overflows. BBR tries to operate at the left-hand knee. To do that, it builds a model of the path from two measurements:

  • BtlBw, the bottleneck bandwidth: the maximum delivery rate seen over the last ten round trips. Every ACK yields a sample: how much data was delivered between when the ACKed packet was sent and now, divided by the time.
  • RTprop, the round-trip propagation time: the minimum RTT seen over the last ten seconds. Any queueing only adds to the RTT, so the minimum is the best estimate of the bare path.

Their product is BBR's estimate of the BDP. Then it sets two controls:

  • the pacing rate, pacing_gain × BtlBw: BBR doesn't send in ACK-clocked bursts but spaces packets out at a chosen rate;
  • cwnd, cwnd_gain × BtlBw × RTprop, with a gain of 2 in steady state: a cap on data in flight, as a safety net in case the model is wrong.

The catch is that you can't measure both at once. To see the full bandwidth, you have to fill the pipe, which builds a queue. To see the bare RTT, you have to empty the queue, which leaves the pipe short. So BBR alternates between phases:

  1. Startup

    Pace at 2/ln 2 ≈ 2.89 times the bandwidth estimate, doubling the delivery rate every round trip, like slow start. When three round trips in a row raise BtlBw by less than 25%, the pipe is full.

  2. Drain

    Startup has built a queue. Pace at the inverse gain, 1/2.89, until the data in flight is down to one estimated BDP.

  3. ProbeBW

    The steady state, nearly all the time. Cycle through eight phases of one RTprop each, with pacing gains 1.25, 0.75, 1, 1, 1, 1, 1, 1: briefly push a quarter more to see whether BtlBw has grown, then drain the queue that made, then cruise.

  4. ProbeRTT

    If RTprop hasn't been refreshed in ten seconds, drop cwnd to four packets for at least 200 ms, so the queue empties and a fresh minimum RTT can be measured.

In the simulator, through R1's 50-packet buffer, BBR's startup decides the pipe is full at 457.5 ms, drains, and enters ProbeBW at 531.1 ms. Startup's 2.89× pacing overshoots, and costs 172 drops, all in the first second. Over the second half of the run the queue averages 2.1 ms, against CUBIC's 30.6 ms, and throughput is 9.84 Mb/s. At 10,000.4 ms it enters ProbeRTT and returns to ProbeBW 242 ms later. With the bloated 400-packet buffer, CUBIC's queueing delay was 264 ms; BBR's is 1.7 ms, with no drops at all. And with 1% random loss, where NewReno fell to 2 Mb/s, BBR keeps 9.73 Mb/s, because loss isn't part of its model.

v1, v2 and v3

That last result is also BBR's biggest problem. BBRv1, the version in mainline Linux since 4.9 (2016), and still the one you get with bbr there, ignores loss almost entirely. In a shallow buffer that's too small for its probing, it keeps on sending while other flows back off, and its retransmission rate can be high. BBRv2 (2019) and BBRv3 (2023) add the lessons of the deployment: they treat loss above about 2% per round trip, and ECN marks, as a sign that probing has gone too far, remember that amount of data in flight as an upper bound, back off by a factor of 0.7, and probe for bandwidth on a slower, Reno-friendly time scale. BBRv3 is being specified in the IETF's congestion control working group (draft-ietf-ccwg-bbr) and runs Google's own traffic, but it isn't in mainline Linux.

BBR and CUBIC on one link

What happens when BBRv1 and CUBIC share R1's uplink? It depends on the buffer, and in opposite directions:

50-packet buffer (1 BDP)

CUBIC backs off at every loss; BBR doesn't. Over the last 15 seconds, BBR gets 7.81 Mb/s and CUBIC 2.02 Mb/s.

400-packet buffer (8 BDP)

CUBIC fills the buffer, and BBR's cwnd cap of 2 × its BDP estimate keeps it to a small part of the queue. CUBIC gets 7.75 Mb/s and BBR 2.02 Mb/s.

Neither is fair. That's typical of what published measurements of BBRv1 found, and much of what v2 and v3 were built to fix.

Sharing the Bottleneck

So far, fairness has meant "two identical flows get the same rate". Real links are messier.

RTT unfairness

Reno and NewReno add one segment per round trip, so a flow with a short RTT grows its window faster, and its window is worth more bandwidth too, since rate is window ÷ RTT. Run a NewReno flow with a 20 ms round trip against one with 80 ms through R1, with a little random loss (0.1%) to keep the flows from locking into step, and over the last 15 seconds the short flow gets 7.61 Mb/s and the long one 2.22 Mb/s, a ratio of about 3.4. At equal loss rates, Reno's rate goes as 1/RTT, which with R1's average 20 ms of queueing added to both round trips predicts about 2.5. But a drop-tail queue tends to synchronise losses: when it overflows, both flows lose packets in the same event, so they see the same loss events rather than the same loss rate. Then the ratio moves from RTT₂/RTT₁ towards its square, here from 2.5 towards 6.25, and our 3.4 sits in between. CUBIC's time-based growth narrows the gap but doesn't close it, and BBR's model has its own RTT biases.

The limits of per-flow fairness

Even perfect per-flow fairness isn't fairness between people. A program that opens ten connections to the same server gets ten shares of the bottleneck, against one for the person next door. Download managers and some browsers' parallel connections do exactly that. Bob Briscoe's 2007 paper "Flow rate fairness: dismantling a religion" argued that per-flow rate fairness was never a sound goal in the first place, and that what matters is the cost each user's traffic imposes on others. Routers can enforce some fairness themselves (fq_codel shares a link per flow, CAKE can share it per host), but TCP's congestion control on its own can't.

Nobody enforces it

Congestion control runs entirely in the sender. Nothing in TCP or IP checks that a sender follows it. A sender that ignored losses, or grew its window faster than AIMD, would take more than its share and push everyone else back, and the network itself would never know. The Internet works because almost every stack plays by the same rules, and because the rules are written down: RFC 8085 asks applications that run over UDP to do congestion control too, and new algorithms are expected to coexist reasonably with the existing ones.

QUIC: congestion control in user space

QUIC changes where that code lives. TCP's congestion control is in the operating system kernel, shared by every program and updated with the OS. QUIC runs over UDP, and its loss detection and congestion control, specified in RFC 9002 (2021) with a NewReno-like default, are part of the application's QUIC library. A browser or a video service can ship a new algorithm with its next release. That's made experimentation with new algorithms much faster. It also means the network's well-being now depends on a lot more independently written congestion controllers.

Two or three uploads share R1's uplink for 30 seconds. Each has its own algorithm, round trip time and start time. ECN only takes effect for Reno, NewReno and CUBIC flows, and only when R1 runs CoDel with marking on.

The flows

The link

Congestion events (times in ms)

Things to try in the simulator: two CUBIC flows, the second starting at 5 s, end up at 5.42 and 4.58 Mb/s. The 20 ms and 80 ms pair shows RTT unfairness. CUBIC against BBR shows the buffer effect above. And two CUBIC flows through a 400-packet drop-tail buffer suffer an average queueing delay of 199.3 ms over the last 15 seconds; switch R1 to CoDel and it's 4.1 ms, with throughput still 10 Mb/s between them. Add ECN, and there are no drops at all.

Pacing

One idea runs through BBR and has spread to everything else: pacing. A window-based sender sends in bursts: an ACK covering several segments, or the start of a round trip, releases a burst of back-to-back packets that hits the bottleneck queue all at once, and bursts are what overflow small buffers. A paced sender spreads the same window over the round trip at a steady rate. The average rate is the same, but the queue sees a smooth stream instead of spikes.

Linux computes a pacing rate for every TCP connection. For loss-based algorithms it's 2 × cwnd/RTT in slow start and 1.2 × cwnd/RTT in congestion avoidance, enough to smooth bursts without capping the window. The rate is enforced by the fq queueing discipline when that's in use, and since kernel 4.13 (2017) the TCP stack can pace by itself for algorithms like BBR that depend on it.

Congestion Control on Linux

The algorithm is a per-socket choice, with a system-wide default:

$ sysctl net.ipv4.tcp_congestion_control
net.ipv4.tcp_congestion_control = cubic
$ sysctl net.ipv4.tcp_available_congestion_control
net.ipv4.tcp_available_congestion_control = reno cubic
$ sudo modprobe tcp_bbr
$ sudo sysctl -w net.ipv4.tcp_congestion_control=bbr
net.ipv4.tcp_congestion_control = bbr

A program can also choose for one socket, with the TCP_CONGESTION socket option. And ss -ti shows the congestion state of every connection. Here's the laptop's upload, in CUBIC's congestion avoidance, with real-world 1,448-byte segments (1,460 minus 12 bytes of timestamps option):

$ ss -tin dst 203.0.113.80
State  Recv-Q  Send-Q   Local Address:Port    Peer Address:Port
ESTAB  0       1436416  192.168.10.10:47130   203.0.113.80:80
     cubic wscale:7,7 rto:260 rtt:59.2/3.6 mss:1448
     pmtu:1500 cwnd:48 ssthresh:41
     bytes_sent:31508480 bytes_retrans:28960
     send 9.39Mbps pacing_rate 11.3Mbps
     delivery_rate 9.4Mbps unacked:48
     retrans:0/20 minrtt:40.3

(Trimmed, and wrapped to fit; the real output is one long line per connection.) Reading it:

  • cubic: the algorithm. With BBR you'd also see its model, bbr:(bw:…,mrtt:…).
  • rtt:59.2/3.6: smoothed RTT and its variation, in ms. minrtt:40.3 is the bare path; the other 19 ms is R1's queue. rto:260 is the smoothed RTT plus Linux's 200 ms floor.
  • cwnd:48 ssthresh:41: the window in segments. ssthresh is 41, about 0.7 of 59, the window at the last loss; cwnd has grown past it since.
  • send 9.39Mbps: cwnd × MSS ÷ RTT, what the window allows. pacing_rate is 1.2 times that, as in congestion avoidance. delivery_rate is what's actually getting through: just under the 10 Mb/s uplink, as it should be.
  • retrans:0/20: nothing being retransmitted right now; 20 segments resent in total, the 28,960 bytes of bytes_retrans.

Where to Go Next

  • TCP: the reliability machinery underneath: sequence numbers, the RTO, fast retransmit, SACK and the receive window.
  • UDP: no congestion control at all, which is why applications built on it must bring their own.
  • DHCP: the next article, and the first of the network services: how the laptop got its address in the first place.
  • NAT: R1 rewrites every one of these segments on its way to the uplink.
  • HTTP: HTTP/3 over QUIC, where congestion control moved into the application.

Key Takeaways

  • In October 1986 congestion collapse cut LBL–UC Berkeley throughput from 32 kbit/s to 40 bit/s: retransmissions filled the queues that were dropping them. Jacobson and Karels (SIGCOMM 1988, 4.3BSD-Tahoe) fixed it in the sender alone, by conserving packets.
  • The sender keeps min(cwnd, rwnd) in flight: rwnd protects the receiver, cwnd the network. Once cwnd is right, the ACK clock paces the sender at the bottleneck's rate.
  • Slow start doubles cwnd every round trip from an initial window of 10 (RFC 6928) until a loss or ssthresh. It always overshoots by up to a window.
  • Congestion avoidance is AIMD: +1 MSS per RTT, halve on loss, giving the sawtooth. A buffer of one BDP keeps the link busy through the halvings.
  • An RTO sets cwnd to a loss window of 1 MSS. Tahoe also does that on three duplicate ACKs; Reno's fast recovery halves and inflates the window instead; NewReno stays in recovery through partial ACKs, repairing one hole per round trip. SACK, RACK and PRR do better.
  • Chiu and Jain (1989): among linear rules, only additive increase with multiplicative decrease converges to both efficiency and fairness.
  • Throughput needs a window of at least one BDP. Mathis: rate ≈ (MSS/RTT) · 1.22/√p, so random loss and long RTTs hurt loss-based TCP badly.
  • Bufferbloat: loss-based TCP fills any buffer, adding hundreds of ms of delay. AQM fixes it: CoDel drops when sojourn time stays above 5 ms for 100 ms; fq_codel adds per-flow queues.
  • ECN marks CE instead of dropping; the receiver echoes ECE and the sender answers with CWR. AccECN (RFC 9768, 2026) gives counts; L4S (RFCs 9330–9332) uses ECT(1) and shallow, frequent marking.
  • CUBIC (RFC 9438; Linux, Windows and Apple default): W(t) = C(t−K)³ + Wmax, C = 0.4, β = 0.7, concave up to the old maximum and convex beyond it, with a Reno-friendly floor.
  • BBR models the pipe: BtlBw (max delivery rate over 10 RTTs) and RTprop (min RTT over 10 s), pacing at gain × BtlBw with cwnd = 2 BDP, through Startup, Drain, ProbeBW and ProbeRTT. BBRv1 ignores loss and can be unfair to CUBIC; v2/v3 react to loss and ECN.
  • Per-flow fairness has limits: RTT unfairness, multiple connections, and no enforcement. QUIC moves congestion control into user space. Linux: net.ipv4.tcp_congestion_control, and ss -ti to watch it.

That's the transport layer: UDP's ports and checksum, TCP's reliable stream, and the congestion control that keeps millions of independent senders from drowning the links they share. Every one of those connections started with the laptop knowing its own address, its router and its resolver. Where did those come from? Nobody typed them in. The next section, the network services, starts with DHCP.