In this lesson, you will learn how to select and tune Linux congestion control algorithms like CUBIC and BBR to optimize throughput for your specific network environment.
The Role of Congestion Control
When a network link becomes saturated, packets are dropped or delayed, leading to retransmissions. The Linux kernel manages this via Congestion Control Algorithms (CCAs), which determine how fast the sender pushes data based on feedback from the network.
- CUBIC: The default in most Linux distributions. It uses a cubic function to grow the congestion window, making it excellent for high-bandwidth, high-latency networks. However, it can be "overly aggressive" in some scenarios, leading to bufferbloat.
- BBR (Bottleneck Bandwidth and Round-trip propagation time): Developed by Google, BBR focuses on the actual physical bottleneck capacity rather than packet loss. It is significantly more resilient to jitter and packet loss, making it ideal for modern, global-scale traffic.
Viewing and Switching Algorithms
You can inspect which algorithms are currently available on your kernel and which one is currently active using sysctl:
# See available algorithms
sysctl net.ipv4.tcp_available_congestion_control
# Check current active algorithm
sysctl net.ipv4.tcp_congestion_control
To switch to BBR for a specific workload, you must ensure it is loaded (it is usually a kernel module) and then update the configuration:
# Load the BBR module
sudo modprobe tcp_bbr
# Apply BBR globally
sudo sysctl -w net.ipv4.tcp_congestion_control=bbr
Tuning for Performance
While CUBIC handles traditional "steady" internet traffic well, BBR often provides lower latency and higher throughput on unstable links (like wireless or cross-continental routes). When tuning these, remember that the algorithm acts as the "controller" for your network stack; changing it can drastically alter how your system handles packet reordering and queue buildup. Always monitor your throughput using tools like iperf3 after switching algorithms to ensure the change benefits your specific traffic pattern.
Key Takeaway: Use CUBIC for standard reliable links, and transition to BBR to maximize throughput and reduce latency on high-loss or high-latency long-haul connections.