Benchmark Network Throughput with iperf on Linux
This guide provides an overview of how the Linux operating system
utilizes the iperf (and modern iperf3) utility
to accurately benchmark network throughput. You will learn the core
architecture behind the tool, the standard commands required to measure
transmission speeds between two endpoints, and how to test under both
TCP and UDP protocols to identify bandwidth limitations and network
bottlenecks.
How iperf Works on Linux
iperf functions on a client-server model. To benchmark
network performance, one Linux machine acts as the server listening for
incoming traffic, while a second Linux machine acts as the client
generating and sending network packets.
During the test, the client generates synthetic traffic—either TCP or UDP—and transmits it across the local network or the internet to the server. The tool then calculates the total amount of data transferred, the elapsed time, and the resulting throughput (typically displayed in Megabits or Gigabits per second).
Installing iperf3
Most modern Linux distributions include iperf3 in their
default software repositories.
On Ubuntu or Debian systems:
sudo apt update
sudo apt install iperf3On RHEL, Rocky Linux, or Fedora:
sudo dnf install iperf3On Arch Linux:
sudo pacman -S iperf3Step 1: Start the iperf3 Server
Before sending traffic, initialize the target machine in server mode.
By default, iperf3 listens on TCP/UDP port 5201.
Run the following command on the server machine:
iperf3 -sEnsure that your Linux firewall allows traffic through port 5201:
# For UFW (Ubuntu/Debian)
sudo ufw allow 5201/tcp
sudo ufw allow 5201/udp
# For firewalld (RHEL/CentOS/Fedora)
sudo firewall-cmd --add-port=5201/tcp --permanent
sudo firewall-cmd --add-port=5201/udp --permanent
sudo firewall-cmd --reloadStep 2: Run a Standard TCP Benchmark
On the client machine, run iperf3 directed at the
server's IP address to initiate a default 10-second TCP benchmark:
iperf3 -c <SERVER_IP>Understanding the Output
The output provides interval metrics followed by a summary:
- Interval: The timeframe for the specific report
slice (e.g.,
0.00-1.00 sec). - Transfer: The volume of data transmitted during
that interval (e.g.,
112 MBytes). - Bandwidth: The calculated transfer rate (e.g.,
941 Mbits/sec). - Retr: The number of TCP segments retransmitted due to network congestion or packet loss.
Step 3: Advanced Benchmarking Scenarios
Testing UDP Throughput and Jitter
TCP uses flow control and window sizing, which may mask underlying network capacity. UDP bypasses connection overhead, making it ideal for measuring raw packet loss and jitter.
Because UDP does not self-regulate speed, specify a target bandwidth
using the -b flag:
iperf3 -c <SERVER_IP> -u -b 1GThis tests for 1 Gigabit per second of UDP throughput and reports latency jitter and lost packet percentages.
Multi-Stream (Parallel) Testing
Saturating high-bandwidth connections (such as 10GbE or 40GbE) often
requires multiple simultaneous connections. Use the -P flag
to open parallel streams:
iperf3 -c <SERVER_IP> -P 4This command establishes four parallel TCP connections to ensure full hardware and interface utilization.
Reverse Direction Testing
By default, the client sends data and the server receives it. To test
download speeds from the server to the client without reconfiguring the
server, add the -R flag:
iperf3 -c <SERVER_IP> -RCustom Test Duration
To run a longer burn-in test to detect thermal throttling or link
degradation over time, use the -t flag with the desired
duration in seconds:
iperf3 -c <SERVER_IP> -t 60Factors Influencing Linux Benchmark Accuracy
- CPU Utilization: Running high-throughput benchmarks
(10Gbps+) requires significant CPU resources. Monitor CPU usage with
toporhtopduring tests; a saturated CPU core can artificially cap measured throughput. - MTU (Maximum Transmission Unit): Mismatches in MTU size along the path can cause packet fragmentation, reducing measured speeds.
- TCP Congestion Control: Linux uses algorithms like
CUBIC or BBR. You can test specific algorithms using the
--cportand Linux kernelsysctlconfigurations to see how different congestion engines perform on your link.