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 iperf3

On RHEL, Rocky Linux, or Fedora:

sudo dnf install iperf3

On Arch Linux:

sudo pacman -S iperf3

Step 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 -s

Ensure 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 --reload

Step 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:

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 1G

This 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 4

This 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> -R

Custom 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 60

Factors Influencing Linux Benchmark Accuracy