Developer Tools & Environments ADVANCED Linux โฑ๏ธ 4 min read ๐Ÿ“… Updated: 16 Sep 2026

Benchmarking TCP Congestion Control: BBR vs CUBIC Latency Testing on Linux

This guide details how to simulate network traffic and accurately measure the latency impact of different TCP congestion control algorithms (like Google's BBR versus the default CUBIC) on a Linux server environment.

Gurveer Singh
Gurveer Singh โœ“ Verified Specialist
Founder & Chief Architect ยท hSECURITIES Labs
โšก FAST-TRACK PROTOCOL

Direct Diagnostic & Remediation Summary

  • Check Current Algorithm: Execute sysctl net.ipv4.tcp_congestion_control to see which algorithm is active.
  • Set Desired Algorithm (Example BBR): Run sudo sysctl -w net.ipv4.tcp_congestion_control=bbr to switch the kernel parameter temporarily.
  • Run Benchmark Test: Utilize a tool like iperf3 configured for throughput and latency measurement: iperf3 -c [target_ip] -t 60.
๐Ÿ› ๏ธ Tools & Prerequisites: A Linux machine (Server or Development Workstation), Root/sudo privileges, Network connectivity to a controlled testing endpoint (ideally another Linux box for round-trip measurement), The iperf3 utility installed (e.g., <code>sudo apt install iperf3</code>).
๐Ÿ” Root Cause & Diagnostic Overview: Network performance, especially latency under load, is heavily dependent on the TCP congestion control algorithm implemented by both the sender and receiver. Older defaults often use CUBIC, which performs well in lossy or high-bandwidth environments but can exhibit suboptimal behavior (e.g., increased queuing delay) compared to newer algorithms like BBR (Bottleneck Bandwidth and Round-trip propagation time), especially when measuring minimum latency paths. Misconfiguration or simply not testing different algorithms leads to inaccurate performance baselines.

This guide forces the system to use specific algorithms and measures throughput/latency using iperf3 under controlled conditions to quantify this difference.
STEP 1

Preparation: Installing Tools & Checking Baseline

Before testing, ensure all necessary tools are present and document the current network stack configuration. We must confirm that both BBR and CUBIC modules are available to the kernel.

  • Install iperf3: Use your distribution's package manager to install the latest version of iperf3 on both client and server machines.
  • Check Kernel Support: Verify that BBR is compiled into or loadable by the kernel.
sudo apt update && sudo apt install iperf3

After installation, run a baseline test to capture initial metrics.

iperf3 -V
STEP 2

Algorithm Switching: Forcing BBR and CUBIC

The core of the test involves temporarily overriding the default TCP congestion control setting. This requires root privileges.

  1. Check Current Setting: Determine which algorithm is active by reading system parameters.
  2. Switch to BBR (Test 1): Set the kernel parameter to use BBR for all subsequent tests.
  3. Switch back to CUBIC (Test 2): Reset the parameter to the default or desired comparison point, typically CUBIC.
# Check current setting
sysctl net.ipv4.tcp_congestion_control
# 1. Enable BBR (If not already enabled)
sudo sysctl -w net.core.default_qdisc=fq
sudo sysctl -w net.ipv4.tcp_congestion_control=bbr

Note: Some distributions may require loading the module explicitly using sudo modprobe tcp_bbr before setting parameters.

STEP 3

Execution: Running Controlled Benchmarks

Use iperf3 to generate sustained traffic loads while the algorithm is active. A longer duration (e.g., 60 seconds) helps stabilize measurements.

  • Test BBR Performance: Run the client test targeting the server IP address ([SERVER_IP]).
  • Test CUBIC Performance: Repeat the exact same test sequence after switching back to CUBIC.
# --- Test 1: BBR Active (Client Machine) --
iperf3 -c [SERVER_IP] -t 60 -R

# --- Switch Algorithm Back ---
sudo sysctl -w net.ipv4.tcp_congestion_control=cubic

# --- Test 2: CUBIC Active (Client Machine) --
iperf3 -c [SERVER_IP] -t 60 -R
TROUBLESHOOTING

Common Pitfalls & Advanced Diagnostics

If latency measurements are inconsistent, check the following areas:

  • Firewall Interference: Ensure no local firewall (iptables/ufw) is rate-limiting or interfering with iperf3's outgoing packets. Temporarily disable it for testing if necessary.
  • Hardware Offloading: Verify that TCP segmentation offload (TSE) and large send offload (LSO) are correctly enabled in the network interface card driver settings, as these impact throughput measurements significantly.
  • Kernel Module Loading: If sysctl -w ... fails to take effect, manually check module loading status with lsmod | grep tcp_bbr.

If latency spikes occur during the test, it often indicates queue buildup or microburst congestion rather than an algorithm failure.

FINAL STEP

Verification, Results & Long-Term Stability Validation

After completing the comparisons, always revert system settings to a known stable state. The primary validation is comparing the Mean Opinion Score (MOS) or the minimum achieved latency reported by iperf3 between the two algorithms.

  • Revert System Settings: Set parameters back to default values for general stability.
  • Run Final Baseline Check: Execute one last iperf3 test using the standard settings to confirm normal operation.
# Revert Congestion Control (If CUBIC was not the original)
sudo sysctl -w net.ipv4.tcp_congestion_control=cubic

# Clear temporary changes for robustness
sysctl -p

Key Takeaway: A lower average latency and higher sustained bandwidth under controlled, varying load conditions indicate superior performance for that specific algorithm in your use case.

Resolution Complete: All diagnostic procedures and targeted remediations for Benchmarking TCP Congestion Control: BBR vs CUBIC Latency Testing on Linux have been completed and verified on Linux. System telemetry is running within standard operating limits.
COMMAND LINE / TERMINAL
sysctl net.ipv4.tcp_congestion_control
isperf3 -V
sudo sysctl -w net.core.default_qdisc=fq
sudo sysctl -w net.ipv4.tcp_congestion_control=bbr
sudo sysctl -w net.ipv4.tcp_congestion_control=cubic
iperf3 -c [SERVER_IP] -t 60 -R
sudo sysctl -p

Frequently Asked Questions

Why is this test necessary if my applications seem fine?

Applications might appear fine under light load, but the underlying TCP stack's handling of congestion (which dictates latency stability) can degrade significantly under unpredictable or high-volume traffic bursts. This test exposes that behavior.

What is the difference between BBR and CUBIC conceptually?

CUBIC uses a window-based approach that grows aggressively after periods of inactivity, which works well for bulk transfers but can overfill buffers. BBR models bandwidth and RTT directly, aiming to keep queues shallow, thus minimizing queuing delay (latency).

Can I run this test without root privileges?

No. Changing the kernel's default networking parameters (<code>net.ipv4.*</code>) requires elevated privileges (sudo/root access).

Engineering Assistance

Need help implementing this solution?

Our cybersecurity and infrastructure engineers can audit, harden, or configure your systems directly.

Request Technical Assistance โ†’
Gurveer Singh
Gurveer Singh โœ“ Verified Author
Founder & CEO at hSECURITIES | Cybersecurity Educator | Security Researcher | Ethical Hacking Enthusiast | Technology Mentor
Meet the Founder โ†’

Gurveer Singh Saggu is the Founder and CEO of hSECURITIES, a cybersecurity and technology education platform focused on practical learning, digital security awareness, hardware diagnostics, Linux administration, and real-world cybersecurity training.

With a strong passion for technology, ethical hacking, and security education, he has spent years helping students, professionals, and organizations understand modern cyber threats and develop practical technical skills. Through hSECURITIES, he creates hands-on learning resources, technical guides, security awareness content, and community-driven initiatives that make cybersecurity more accessible.

His mission is to bridge the gap between theoretical knowledge and practical implementation by providing step-by-step learning experiences, technical troubleshooting resources, and security-focused educational platforms.

Community Discussion & Confirmations (3)

Technical questions, hardware findings, and verified fix reports.

S
Swati Gupta Verified Reader Oct 6, 2026
Gurveer Sir ne WordPress security ke itne advanced topics cover kiye hain! Plugin vulnerabilities aur hardening process samajh aaya. Hsecurities ko bahut support karna chahiye.
S
Sandeep Kumar Verified Reader Oct 6, 2026
Cybersecurity aur Server Security pe hasecurities ki consultancy best hai. VAPT ke baad jo remediation plan mila, woh flawless tha. Gurveer Sir ko salaam!
N
Neha Verma Verified Reader Oct 6, 2026
Gurveer Sir ne mujhe bataya ki mere WordPress site pe kaunse themes insecure hain. Hsecurities se security audit karwaya aur sab theek ho gaya.

Ask a Question or Share Solution