DEV Community

Cover image for Enable BBR, a Better Network Congestion Control Algorithm From Google on Linux
Archer Allstars
Archer Allstars

Posted on

Enable BBR, a Better Network Congestion Control Algorithm From Google on Linux

TCP BBR (Bottleneck Bandwidth and Round-trip propagation time) is a congestion control algorithm developed by Google to improve internet performance by focusing on actual network conditions rather than relying solely on packet loss as a signal to reduce transmission speed.

It can significantly improve throughput compared to traditional algorithms like CUBIC, with improvements ranging from 2 to 25 times.

BBR is also used on Google Search and YouTube servers, resulting in a 4% average global increase in YouTube network throughput and over 14% improvement in some countries. Meaning, it has been used (not only tested/experimented) on a global scale!

Therefore, it would be wised to enable BBR in your system, especially if you're on a wireless network with a lot of packet loss.

Note that you need Linux kernel version 4.9+ for BBR v1, or 5.18+ for BBR v2.


1. Enable the Module

Check whether the module is already enabled:

lsmod | grep bbr
Enter fullscreen mode Exit fullscreen mode

If the module is loaded, it should return something like this:

tcp_bbr                20480  26
Enter fullscreen mode Exit fullscreen mode

You can skip to the next step.

If it doesn't return anything, you must enable tcp_bbr module first:

echo "tcp_bbr" | sudo tee /etc/modules-load.d/bbr.conf
Enter fullscreen mode Exit fullscreen mode

Reboot. Then, check if bbr is listed as one of the congestion control algorithms:

cat /proc/sys/net/ipv4/tcp_available_congestion_control
Enter fullscreen mode Exit fullscreen mode

This should return something like:

reno cubic bbr
Enter fullscreen mode Exit fullscreen mode

2. Change the Congestion Control Algorithm to BBR

You can use nano or your preferred text editor to edit the /etc/sysctl.conf file:

sudo nano /etc/sysctl.conf
Enter fullscreen mode Exit fullscreen mode

Then, add these lines:

net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
Enter fullscreen mode Exit fullscreen mode

Reboot the system. Then, check the current congestion control algorithm:

sysctl net.ipv4.tcp_congestion_control
Enter fullscreen mode Exit fullscreen mode

This should return:

net.ipv4.tcp_congestion_control = bbr
Enter fullscreen mode Exit fullscreen mode

Note that even though it has ipv4 in the name, it applies to IPv6 as well.


Explanation

You can notice that I also enabled the fair queueing packet scheduler (qdisc) as well with net.core.default_qdisc = fq.

Why?

It's a match made in heaven for BBR. For example:

Without the fair queueing (traditional qdiscs like pfifo_fast):

BBR wants to send at 950 Mbps
↓
Kernel qdisc can't pace → bursts 1 Gbps for 100ms → queue builds → 200ms latency
Enter fullscreen mode Exit fullscreen mode

With the fair queueing:

BBR wants to send at 950 Mbps
↓
FQ paces exactly 950 Mbps → no bursts → queue stays <1ms
Enter fullscreen mode Exit fullscreen mode

Thanks for reading 🙏 God bless ✝️


Cover Photo by Shiwa ID on Unsplash

Top comments (0)