A Guide to Using iperf3 on Linux: Measure Bandwidth, Jitter, and Network Performance Between Servers

Linux tutorial - IT technology blog
Linux tutorial - IT technology blog

Context: When ping Doesn’t Tell the Whole Story

Chances are you’ve heard users complain: “Hey, why is pulling the backup file from the branch office to HQ taking over an hour?”

Out of habit, many sysadmins immediately run ping 192.168.1.100. The output looks pristine: 0% packet loss, RTT hovering at a mere 2ms. Yet pushing a multi-gigabyte data file over SCP or rsync still crawls along at 80–100 KB/s. Why does this happen?

The ping command only sends tiny ICMP packets, typically around 56 or 64 bytes. Its primary job is simply to check whether the destination host responds. It is like calling someone up to ask: “Are you home?” and hearing: “Yes.” But when you ask them to help carry a 400-liter refrigerator through a narrow hallway, it’s a completely different story. Real-world transfer speeds depend on pipe capacity (bandwidth), delay variation (jitter), and packet drop behavior under heavy load.

To accurately gauge the true capacity of a network link, you need a tool that actively saturates the pipe with data. That is exactly what iperf3 does. Operating on a client-server architecture, it allows you to benchmark both TCP and UDP throughput to their absolute limits, complementing packet analyzers like tcpdump by exposing switch bottlenecks, duplex mismatches, and faulty cable terminations.

Installing iperf3 on Popular Linux Distributions

The iperf3 package is lightweight and available in the official repositories of most major operating systems. You should install it on both machines: one serving as the Server (receiver) and the other as the Client (sender).

1. On Ubuntu / Debian

sudo apt update
sudo apt install -y iperf3

2. On RHEL, Rocky Linux, AlmaLinux

sudo dnf install -y epel-release
sudo dnf install -y iperf3

3. Opening Firewall Ports

iperf3 listens by default on port 5201 for both TCP and UDP. Ensure this port is open on the server (for example, with firewalld or UFW) before initiating your tests:

# For Firewalld (RHEL/Rocky/AlmaLinux)
sudo firewall-cmd --add-port=5201/tcp --permanent
sudo firewall-cmd --add-port=5201/udp --permanent
sudo firewall-cmd --reload

# For UFW (Ubuntu/Debian)
sudo ufw allow 5201/tcp
sudo ufw allow 5201/udp
sudo ufw reload

Real-World Testing Scenarios

The benchmarking workflow always involves two steps: start the receiving host first, then have the transmitting host generate load against the receiver’s IP.

Step 1: Starting the iperf3 Server

Log in to the receiving server (e.g., IP: 192.168.1.100) and run:

iperf3 -s

The server will wait for incoming connections on port 5201. If you don’t want to tie up your terminal session, you can run it in the background as a daemon using the -D flag:

iperf3 -s -D

Step 2: Basic TCP Bandwidth Measurement

From the client machine, run the test against the server:

iperf3 -c 192.168.1.100

By default, the benchmark runs for 10 seconds. The tool logs per-second metrics displaying the data transferred (Transfer) and average speed (Bitrate). The summary lines at the end (Sender and Receiver) reveal the actual throughput achieved in Mbits/sec or Gbits/sec.

Step 3: Maxing Out the NIC with Parallel Streams

A single TCP stream often struggles to saturate high-speed links like 10Gbps, especially over bonded interfaces or fiber infrastructure. This is largely due to TCP window size limits and RTT latency. To closely simulate concurrent multi-user workloads, add the -P (Parallel) flag:

iperf3 -c 192.168.1.100 -P 4 -t 20

This command opens 4 simultaneous streams for a duration of 20 seconds (-t 20). For example, on a cluster with 10GbE NICs, a single stream might top out around 3.2 Gbps. Scaling to 4 or 8 parallel streams—paired with sysctl tuning (boosting net.ipv4.tcp_rmem and net.ipv4.tcp_wmem to 16MB)—can push throughput right up to the 9.4 Gbps ceiling.

Step 4: Testing in Reverse Mode

By default, the client sends data to the server (upload). To test download speed without swapping host roles or logging back into the server, simply append the -R flag:

iperf3 -c 192.168.1.100 -R

Measuring Jitter and Packet Loss with UDP

VoIP, Zoom calls, and RTSP video surveillance streams rely heavily on UDP. For these applications, real-time delivery matters far more than guaranteed packet retransmission. In UDP testing, the two key quality-of-service metrics are Jitter (delay variation) and Packet Loss.

1. Configuring Target UDP Bandwidth

Note: By default, iperf3 caps UDP bandwidth at only 1 Mbps unless specified otherwise. To thoroughly stress the link, use the -b flag to set a higher target rate:

# Push 100 Mbps of UDP traffic to the server for 15 seconds
iperf3 -c 192.168.1.100 -u -b 100M -t 15

2. Reading and Analyzing the Output

Once the test completes, you will see a summary table:

[ ID] Interval           Transfer     Bitrate         Jitter    Lost/Total Datagrams
[  5]   0.00-15.00  sec   179 MBytes  100 Mbits/sec  0.038 ms  0/132314 (0%)
[  5] Sent 132314 datagrams
  • Jitter: The variance in arrival time between consecutive packets. On a local LAN, the ideal figure is under 1ms. Across VPNs or the public Internet, under 20ms is acceptable. If jitter spikes to 50–100ms, voice calls will start to stutter or distort.
  • Lost/Total Datagrams: The packet drop rate. If packet loss exceeds 1%, investigate the physical infrastructure immediately: you could be dealing with switch buffer contention, poorly crimped CAT6 cables, or ISP link instability.

3. Automating Monitoring with JSON Output

Need to run a scheduled cron job at 2 AM and ingest the metrics into your monitoring stack? Just use the -J flag to export all test metrics formatted as JSON:

iperf3 -c 192.168.1.100 -J --logfile /var/log/iperf3_report.json

This raw JSON output can easily be parsed by a Python script or exported directly into Prometheus / Grafana using the Node Exporter textfile collector, giving you an intuitive dashboard to track network health 24/7.

Share: