TCP CUBIC vs BBR on Linux: Testing Congestion Control Under Loss and Latency with netem and iperf3
Debian ships with CUBIC as the default TCP congestion control and BBR available as a kernel module. Most write-ups of the difference are either theory or a screenshot from somebody’s production link. I wanted numbers I could reproduce, so I built a controlled path with netem and ran the same iperf3 test with each algorithm.
The lab
Two namespaces joined by a veth pair, with netem on the sender’s interface to act as the “WAN”:
sudo apt install iperf3 iproute2
sudo modprobe tcp_bbr
sudo ip netns add tx
sudo ip netns add rx
sudo ip link add t0 type veth peer name r0
sudo ip link set t0 netns tx
sudo ip link set r0 netns rx
sudo ip -n tx addr add 10.50.0.1/24 dev t0
sudo ip -n rx addr add 10.50.0.2/24 dev r0
for l in "tx t0" "rx r0" "tx lo" "rx lo"; do set -- $l; sudo ip -n $1 link set $2 up; done
sudo ip netns exec rx iperf3 -s -D
What the kernel offers:
$ sysctl net.ipv4.tcp_available_congestion_control net.ipv4.tcp_congestion_control
net.ipv4.tcp_available_congestion_control = reno cubic bbr
net.ipv4.tcp_congestion_control = cubic
sudo modprobe tcp_bbr is what puts bbr on that list. iperf3 can pick an algorithm per test with -C, so there is no need to change the system default to compare them.
The path is a 100 Mbit/s link with 20 ms of one-way delay on the data direction and a 1000 packet queue:
sudo ip netns exec tx tc qdisc replace dev t0 root netem delay 20ms loss 0.5% rate 100mbit limit 1000
Each result is a 6 second run: sudo ip netns exec tx iperf3 -c 10.50.0.2 -t 6 -C cubic (then -C bbr).
Result 1: throughput under random loss
| Path | CUBIC | BBR |
|---|---|---|
| 20 ms, 100 Mbit, 0% loss | 98.7 Mbit/s | 98.7 Mbit/s |
| 20 ms, 100 Mbit, 0.5% loss | 35.5 Mbit/s | 98.2 Mbit/s |
| 20 ms, 100 Mbit, 2% loss | 5.94 Mbit/s | 97.7 Mbit/s |
On a clean path they are identical. Add a little random loss and CUBIC falls apart, because it treats every loss as a signal of congestion and halves its window. At 2% loss it delivers 6% of the link. BBR builds a model from measured bandwidth and round trip time and does not back off because of loss alone, so it keeps the pipe full.
The price is retransmissions. The same runs counted retransmitted segments:
| Path | CUBIC retransmits | BBR retransmits |
|---|---|---|
| 0.5% loss | 76 | 237 |
| 2% loss | 64 | 989 |
BBR sends through the loss, so it retransmits more. CUBIC retransmits less because it sends almost nothing. High throughput with high retransmits is not free if you pay per byte on the path.
Result 2: latency under load
This was the result that surprised me more. With no loss at all, I measured ping while iperf3 saturated the link.
idle ping: rtt min/avg/max/mdev = 20.097/20.152/20.207/0.039 ms
cubic under load: rtt min/avg/max/mdev = 169.014/206.037/243.082/27.509 ms
bbr under load: rtt min/avg/max/mdev = 22.076/22.169/22.331/0.100 ms
CUBIC fills the 1000 packet queue before it backs off, so anything sharing that link, including your SSH session or a video call, waits behind it. 20 ms became 206 ms. That is bufferbloat, reproduced on a lab bench. BBR keeps the queue nearly empty and the ping barely moves, 22 ms against 20 ms idle.
While BBR runs, ss shows what it believes about the path:
$ sudo ip netns exec tx ss -tin dst 10.50.0.2
bbr:(bw:96190768bps,mrtt:20.187,pacing_gain:1,cwnd_gain:2)
pacing_rate 95228864bps
It estimated 96 Mbit/s of bandwidth and a minimum RTT of 20.187 ms, which are the two numbers I configured. That is the model behind the behaviour.
Switching the default
To make BBR the system default on Debian 13:
sudo tee /etc/sysctl.d/90-bbr.conf <<'EOF'
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
EOF
echo tcp_bbr | sudo tee /etc/modules-load.d/bbr.conf
sudo sysctl --system
fq is the classic qdisc pairing for BBR. I did not test the combination without it, so treat that as the documented recommendation and not something I measured. The modules-load.d file makes sure the module is there at boot, so the sysctl does not fail.
What I did not test
The honest limits of this lab:
- It only affects the sending side. Congestion control runs on whoever sends the data. Changing your server to BBR speeds up downloads from it, not uploads to it.
- One flow at a time. I did not run BBR and CUBIC against each other on a shared link. Reports of BBR taking more than its fair share against CUBIC flows are common enough that I would test that before changing a shared production link.
- Random loss only. netem’s loss is uniform and independent. Real loss comes in bursts, and shallow buffers behave differently from my 1000 packet queue.
- One kernel, 6 second runs. Treat the figures as a demonstration of the shape, not as a benchmark.
When I would use it
BBR makes the most difference on long, lossy or buffered paths: a server delivering to mobile users, a long-haul link, or a connection through a bloated consumer router. On a clean datacenter LAN you will not see a difference, as the first row of the table shows.
The takeaway is the method as much as the result. With two namespaces, one tc qdisc line and iperf3 -C, you can answer “would BBR help here?” in a few minutes, on the same Debian box, before changing anything that matters.