Andrew Mercer
on this page

What it is

iperf measures the maximum throughput between two hosts: one runs as a server, the other as a client. Two versions exist and they are not compatible with each other: classic iperf (2.x) and iperf3 (a rewrite). Use the same one on both ends. This page uses iperf3 syntax unless noted, since it is the one in most repositories today. Homepage: iperf.fr.

Install and open the port

sudo apt-get install iperf3         # or: sudo dnf install iperf3
sudo firewall-cmd --add-port=5201/tcp --add-port=5201/udp     # iperf3 default port is 5201

Classic iperf2 defaults to port 5001. Test the port with nc if the client hangs.

TCP test

On the server:

iperf3 -s

On the client:

iperf3 -c 192.168.1.10
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  18.4 GBytes  15.8 Gbits/sec    0    sender
[  5]   0.00-10.00  sec  18.4 GBytes  15.8 Gbits/sec         receiver

The Retr column counts TCP retransmissions. A healthy LAN shows 0 or very few. Many retransmits with low throughput point at loss, a duplex mismatch (see ethtool), or a bad cable.

Options worth knowing

iperf3 -c HOST -t 30            # run 30 seconds (default 10)
iperf3 -c HOST -P 4             # 4 parallel streams; one stream often cannot fill a fast link
iperf3 -c HOST -R               # reverse: server sends, client receives
iperf3 -c HOST --bidir          # both directions at once
iperf3 -c HOST -f m             # report in Mbits/sec
iperf3 -c HOST -p 65000         # custom port (server: iperf3 -s -p 65000)

UDP test

TCP takes as much as the path allows; UDP sends at the rate you choose and reports loss and jitter. Pick a target rate near what you expect the link to carry and step it up until loss appears.

iperf3 -s                                  # server
iperf3 -c HOST -u -b 100M                  # client: 100 Mbit/s UDP

Keep loss under about 1% when judging usable capacity.

Classic iperf2 equivalents

iperf -s                               # server
iperf -c HOST --format m               # TCP client, Mbits/sec
iperf -c HOST --dualtest               # simultaneous both ways
iperf -c HOST --tradeoff               # one way, then the other
iperf -s -u                            # UDP server
iperf -c HOST -u --bandwidth 1m        # UDP at 1 Mbit/s

For latency under load and bufferbloat, flent is a better tool than raw throughput numbers.