How to Use iperf3 on Linux: Measuring Bandwidth, Jitter, and Troubleshooting Real-World Networks

Network tutorial - IT technology blog
Network tutorial - IT technology blog

The other day, someone from the ops team came over and asked me: “Why does the link say 1Gbps, yet our online meetings keep breaking up and copying files between two internal servers crawls?” Explaining that to a non-specialist using endless log files is tough to visualize. Familiar speed-test websites only check your route out to the Internet and are completely useless for connections between two internal servers.

iperf3 solves that exact problem. Instead of guessing whether it’s the ISP or a bad cable, this tool blasts a simulated data stream directly from machine A to machine B. The numbers returned directly reflect the health of the link between the two endpoints.

Quick start: Measure network speed with iperf3 in 5 minutes

No bloated config files needed. As long as two Linux machines can reach each other over the network (via LAN, VPN, or public IP), follow these 3 steps to get numbers right away.

Step 1: Install iperf3 on both machines

On Ubuntu or Debian:

sudo apt update && sudo apt install -y iperf3

On Rocky Linux, AlmaLinux, or CentOS 8+:

sudo dnf install -y iperf3

Step 2: Start Server mode on the receiving machine (Machine A)

Pick one machine as the destination to receive data and run:

iperf3 -s

When the screen shows Server listening on 5201, Machine A is ready and waiting for connections.

Step 3: Run the test from the sending machine (Machine B)

Switch to Machine B, replace 192.168.1.10 with Machine A’s IP, and type:

iperf3 -c 192.168.1.10

Wait exactly 10 seconds. The last two lines will display the speed for the sender (Machine B pushing data) and the receiver (Machine A receiving it). On a 1Gbps link, 930–945 Mbits/sec is right on target because the rest goes to TCP/IP and Ethernet headers.

Understanding Bandwidth, Jitter, and Packet Loss

When explaining this to colleagues outside networking, I like to compare a network link to a highway:

  • Bandwidth (Bitrate): The number of lanes. A 10-lane highway moves more cargo at once than a 2-lane road.
  • Latency: How long it takes one vehicle to travel from station A to station B.
  • Jitter: How consistently vehicles arrive. You dispatch 10 trucks exactly 1 minute apart, but some arrive on time while others show up 5 minutes late. File downloads won’t notice a thing, but video calls or VoIP will immediately stutter and distort.
  • Packet Loss: Cargo falling off the truck mid-trip. The system either has to turn around to resend it or accept losing that data altogether.

Decoding iperf3’s default output table

A basic TCP test prints metrics second by second as shown below:

[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   112 MBytes   941 Mbits/sec    0    421 KBytes
...
- - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  1.09 GBytes   938 Mbits/sec    2             sender
[  5]   0.00-10.00  sec  1.09 GBytes   936 Mbits/sec                  receiver

Alongside Transfer (total data moved) and Bitrate (average speed), pay close attention to the Retr (Retransmissions) column. This is the number of times packets had to be resent due to loss. A few packets over 10 seconds is normal, but if it jumps into the hundreds or thousands, the network is congested or a cable is degrading.

Advanced techniques: In-depth network performance testing

By default, iperf3 -c only measures upload speed using a single TCP stream. To pinpoint infrastructure bottlenecks, you’ll need to combine it with the advanced flags below.

1. Measure Jitter and Packet Loss with UDP for real-time services

VoIP, livestreams, and security cameras prioritize UDP because they need speed over retransmitting dropped packets. TCP doesn’t measure Jitter by default, so you have to enable the -u flag:

iperf3 -c 192.168.1.10 -u -b 100M -t 30
  • -u: Switches the test to UDP.
  • -b 100M: Forces the target send rate to 100 Mbps. If you omit this flag, iperf3 tests UDP at just 1 Mbps, which can easily mislead you.
  • -t 30: Extends the test duration to 30 seconds to observe stability.

The output table will now include Jitter (ms) and Lost/Total Datagrams columns. A healthy LAN typically has Jitter under 1 ms and 0% packet loss. If Jitter exceeds 20–30 ms or packet loss goes above 1%, voice and video quality will definitely suffer.

2. Run Parallel Streams to saturate 10Gbps bandwidth

On servers with 10Gbps NICs or high-latency cross-country links (for example, 30–50 ms RTT), a single TCP stream often hits a ceiling due to TCP Window size limits. In that case, open multiple parallel streams using the -P flag:

iperf3 -c 192.168.1.10 -P 8 -t 20

The command above spawns 8 simultaneous streams for 20 seconds, letting you measure the true bandwidth ceiling (usually 9.4–9.8 Gbps on healthy 10G infrastructure).

3. Test the opposite direction with Reverse Mode (-R) and Bidirectional (–bidir)

By default, the Client pushes data to the Server (Upload). If you want to measure Download from the Server back to the Client without SSHing into the other machine to swap roles, just add -R:

iperf3 -c 192.168.1.10 -R

Need to check Full-Duplex capacity when both directions blast at full throttle simultaneously? Use the --bidir flag (available in iperf3 3.7 and later):

iperf3 -c 192.168.1.10 --bidir

4. Export results to JSON

When you need to send proof to your ISP or feed metrics into a monitoring system, the -J flag exports all stats cleanly to a JSON file:

iperf3 -c 192.168.1.10 -u -b 50M -J > network_report.json

Field notes from real-world network debugging

The most frustrating case I ever ran into was intermittent packet loss that only showed up during peak hours. Every day between 2 PM and 4 PM, internal APIs would sporadically time out. Yet whenever the network team ran ping or iperf3 in the morning or evening, every metric looked spotless. Staring at the screen all afternoon was pointless because the glitch only flashed for a few seconds and vanished.

To catch it red-handed, I left iperf3 -s running in the background on the target server. Then I wrote a bash loop on the client machine to automatically fire a 15-second UDP test every 5 minutes and log the output with timestamps:

while true; do
  echo "=== $(date '+%Y-%m-%d %H:%M:%S') ===" >> udp_monitor.log
  iperf3 -c 192.168.1.10 -u -b 50M -t 15 | tail -n 5 >> udp_monitor.log
  sleep 300
done

Checking the log the next day, I immediately saw a burst of 12% packet loss over 15 seconds at exactly 14:35. Cross-referencing with the system schedule revealed an exact match with an automated backup job on another switch branch saturating the link and causing localized congestion.

Before adding iperf3 to your daily toolkit, keep these 3 quick tips in mind to avoid wasting time:

  1. Open the firewall for both TCP and UDP port 5201: Many people open TCP 5201 and see smooth tests, then add -u for Jitter and get nothing. The simple reason is forgetting to allow UDP port 5201 in ufw or firewalld.
  2. iperf3 isn’t bottlenecked by disk speed: Test data is generated directly in RAM rather than read from or written to disk. That said, if CPU usage on either machine hits 100%, measured network throughput will drop accordingly.
  3. Keep Server processes tidy: Use iperf3 -s -D to run as a background daemon, or iperf3 -s -1 so the server exits after a single test. When you’re done, remember to run pkill iperf3 so you don’t leave ports open and burn bandwidth unintentionally.
Share: