How To Enable TCP BBR on Ubuntu 22.04 | Easy Guide

Posted on

How To Enable TCP BBR on Ubuntu 22.04 | Easy Guide

This guide on the Orcacore website intends to teach you How To Enable TCP BBR on Ubuntu 22.04. During March and April 2019, CloudFront deployed a new TCP congestion control algorithm to help improve latency and throughput: the TCP bottleneck bandwidth and round trip (BBR) congestion control algorithm.

BBR is an algorithm developed by Google that aims to improve performance for internet traffic. BBR works by observing how fast a network is already delivering traffic and the latency of current roundtrips. It then uses that data as input to packet-pacing heuristics that can improve performance.

The BBR algorithm provides several advantages over other congestion control methods. All TCP congestion control algorithms—such as CUBIC, Reno, and Vegas—attempt to balance packet transmission fairness with how they detect or respond to congestion or packet loss. Older algorithms can result in latency and throughput oscillation because they more aggressively back off packet transmission or recover more cautiously in response to packet loss detection. In contrast, BBR evaluates congestion by measuring round-trip times, which provides higher, more stable throughput, while also improving latency. BBR responds more agilely to changing conditions but continues to aggressively attempt to transmit as much data as possible even when there are transient issues.

To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on the Initial Server Setup with Ubuntu 22.04.

Enable BBR Congestion Control Algorithm on Ubuntu 22.04

First, you need to update and upgrade your local package index with the following command:

sudo apt update && sudo apt upgrade -y

Then, you need to check your existing congestion controls on your server.

Check Existing Congestion Control Algorithms

Typically, Linux uses reno and cubic algorithms.

At this point, you need to run the following command to check what existing TCP congestion controls are in place:

sudo sysctl net.ipv4.tcp_congestion_control
Check Existing Congestion Control Algorithms

In the above output, cubic is employed in our system, but your output may show different results.

Next, list available TCP congestion control algorithms on your server by using the following command:

sudo sysctl net.ipv4.tcp_available_congestion_control

From the output, reno and cubic are available, and once BBR has been added/enabled, this should feature BBR.

Add TCP BBR on Ubuntu 22.04

Now that you have checked the basics to confirm the available algorithms, you need to open the sysctl.conf file. Here we use the vi editor to open the file:

sudo vi /etc/sysctl.conf

Add the following content to the file:

net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr

When you are done, save and close the file.

Then, reload the configuration file with the command below:

sudo sysctl -p
**Output**
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr

At this point, you need to verify that BBR is enabled and active as the new TCP congestion control by using the following command on Ubuntu 22.04:

sudo sysctl net.ipv4.tcp_congestion_control
**Output**
net.ipv4.tcp_congestion_control = bbr

Also, you can use the command below to verify it:

lsmod | grep bbr
**Output**
tcp_bbr                20480  1

Finally, list available TCP congestion controls on your server again:

sudo sysctl net.ipv4.tcp_available_congestion_control

You should see BBR in your list:

**Output**
net.ipv4.tcp_available_congestion_control = reno cubic bbr

That’s it. You have successfully added BBR to your server.

Conclusion

At this point, you have learned How To Enable TCP BBR on Ubuntu 22.04. TCP BBR improves network speed, reduces latency, and increases throughput for better internet performance.

Hope you enjoy it. Please subscribe to us on Facebook, Instagram, and YouTube.

You may also be interested in these articles:

How To Install WineHQ on Ubuntu 22.04

Install and Configure LibreNMS on Ubuntu 22.04

Set up TCP BBR on AlmaLinux 9

Alternative Solutions for Enabling TCP BBR on Ubuntu 22.04

While the method described above is a standard and effective way to Enable TCP BBR on Ubuntu 22.04, there are a couple of alternative approaches. These alternatives might be useful in specific situations or for users who prefer different methods of configuration. Let’s explore two such alternatives.

Alternative 1: Using echo and tee to Modify sysctl.conf

Instead of using a text editor like vi, we can leverage the echo and tee commands to append the necessary configurations to the sysctl.conf file. This method can be faster for those comfortable with command-line redirection and avoids the need to open and manually edit the file. This is another method to Enable TCP BBR on Ubuntu 22.04.

Explanation:

  • echo "net.core.default_qdisc=fq": This command simply prints the string "net.core.default_qdisc=fq" to the standard output.
  • sudo tee -a /etc/sysctl.conf: This command takes the standard input and appends it (-a option) to the file /etc/sysctl.conf. The sudo command ensures that we have the necessary permissions to modify the file.
  • The second echo and tee command does the same for the net.ipv4.tcp_congestion_control=bbr setting.
  • sudo sysctl -p remains the same, reloading the settings from the modified file.

Code Example:

echo "net.core.default_qdisc=fq" | sudo tee -a /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Advantages:

  • Faster than using a text editor for simple modifications.
  • Can be easily scripted or automated.
  • Avoids potential errors from manual editing, such as typos.

Disadvantages:

  • Potentially less readable and maintainable if the sysctl.conf file contains a large number of custom configurations.
  • Less suitable for complex configurations that require more than simple appending.

Alternative 2: Creating a Separate Configuration File in /etc/sysctl.d/

Instead of directly modifying the main sysctl.conf file, we can create a separate configuration file within the /etc/sysctl.d/ directory. This directory is designed to hold individual configuration files that are read by sysctl during startup and when reloading configurations. This approach promotes better organization and simplifies the process of managing custom system settings. It’s another valid route to Enable TCP BBR on Ubuntu 22.04.

Explanation:

  • sudo vi /etc/sysctl.d/99-tcp-bbr.conf: This command opens a new file named 99-tcp-bbr.conf (the 99- prefix is used to ensure it’s loaded after the default configurations, but any number can be used, as long as the file ends with .conf) in the /etc/sysctl.d/ directory using the vi editor. You can use any other editor you prefer like nano.
  • The content of the file is the same configuration directives: net.core.default_qdisc=fq and net.ipv4.tcp_congestion_control=bbr.
  • sudo sysctl -p reloads the configurations, including those from the new file in /etc/sysctl.d/.

Code Example:

First, create the configuration file:

sudo vi /etc/sysctl.d/99-tcp-bbr.conf

Then, add the following content to the file:

net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr

Save the file and close the editor. Finally, reload the sysctl configuration:

sudo sysctl -p

Advantages:

  • Better organization: Keeps custom configurations separate from the main system configuration file.
  • Easier to manage: Enables you to quickly enable or disable specific configurations by simply removing or renaming the corresponding file.
  • Prevents conflicts: Reduces the risk of overwriting or corrupting the main sysctl.conf file.

Disadvantages:

  • Requires creating and managing an additional file.
  • Slightly more steps compared to directly editing sysctl.conf.

In summary, while directly modifying sysctl.conf works, using echo and tee offers a quicker, scriptable alternative, and creating a separate configuration file in /etc/sysctl.d/ provides a more organized and manageable approach to Enable TCP BBR on Ubuntu 22.04. Choose the method that best suits your needs and preferences.