Commands / Speed and link quality

Speed and link quality

iperf3

Also iperf, throughput, bandwidth test

Measures how fast data moves between two devices over TCP or UDP, second by second.

Run iperf3 -s on one device and iperf3 -c ADDRESS on the other. It sends as fast as it can for a few seconds and reports the bitrate, the retransmissions (Retr) and TCP's congestion window (Cwnd). -R measures the other direction, -u -b 5M sends UDP at a fixed rate and reports loss and jitter instead. Ping while it runs to see bufferbloat: the delay grows as the queue fills.

iperf3 command usage

iperf3 -s [-p PORT] [-1] [-D]
iperf3 -c ADDRESS [-p PORT] [-t SECONDS] [-i SECONDS] [-f m] [-T TITLE] [-R] [-P STREAMS] [-u -b RATE] [-w WINDOW]

Options

-s
be the server
-c 10.0.2.10
be the client, testing to that server
-t 5
run for 5 seconds
-i 0.1
a report line every tenth of a second (default: every second)
-f m
every rate in Mbit/s, so lines compare
-T first
start every line with a title: tells two runs' lines apart
-p 5202
another port: a second server, since one serves a single test at a time
-1
server: serve one test, then exit
-R
reverse: the server sends, you receive
-P 2
two connections side by side
-u -b 5M
UDP at 5 Mbit/s: reports loss and jitter
-w 16K
limit the TCP window to 16 KB

iperf3 examples

iperf3 -s -D
Starts an iperf3 server in the background, on port 5201.
iperf3 -c 10.0.2.10 -t 5
Measures TCP throughput to 10.0.2.10 for five seconds.
iperf3 -c 10.0.2.10 -R
Measures the other direction: the server sends to you.
iperf3 -c 10.0.2.10 -u -b 5M -t 5
Sends UDP at 5 Mbit/s and reports how much was lost and the jitter.
iperf3 -c 10.0.2.10 -t 4 -w 16K
Measures throughput with the TCP window capped at 16 KB.
iperf3 -c 10.0.2.10 -t 3 -i 0.1
Prints a line every tenth of a second: the congestion window growing in slow start.
iperf3 -s -p 5202 -1 -D
Starts a second server, on port 5202, for one test, in the background.
iperf3 -c 10.0.2.10 -P 4
Runs four streams at once: one stream may not fill a fast or long link.
iperf3 -c 10.0.2.10 --bidir
Measures both directions at the same time (iperf3 3.7 and later).
iperf3 -c 10.0.2.10 -t 10 -O 2
Leaves the first two seconds out of the result, so slow start does not pull the average down.
iperf3 -c 10.0.2.10 -n 100M
Sends 100 MB and stops, instead of running for a time.
iperf3 -c 10.0.2.10 -C bbr
Uses the BBR congestion control for this test, to compare it with the default cubic (Linux).
iperf3 -c 10.0.2.10 -u -b 1M -l 200
Sends small 200-byte UDP packets at 1 Mbit/s, close to a voice call.
iperf3 -c 10.0.2.10 -J > result.json
Writes the result as JSON, for a script or a graph.
iperf3 -c 10.0.2.10 -B 10.0.1.50
Sends from that local address, to test one uplink.

Reading the output

$ iperf3 -c 10.0.2.10 -t 2
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  7.63 GBytes  65.4 Gbits/sec    0   1.53 MBytes
[  5]   1.00-2.01   sec  7.24 GBytes  61.9 Gbits/sec    0   1.79 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   0.00-2.01   sec  14.9 GBytes  63.7 Gbits/sec    0             sender
[  5]   0.00-2.01   sec  14.9 GBytes  63.7 Gbits/sec                  receiver
  • Bitrate: the throughput each second, and in the sender/receiver summary.
  • Retr: segments sent again. Many retransmissions: loss on the path.
  • Cwnd: how much TCP dared to have in flight. Small and stuck: a small window, or loss keeps cutting it.
  • An unshaped lab link is this fast: numbers in Mbit/s mean a tc limit is doing its job.

Pitfalls

  • iperf3: error - unable to connect to server: no iperf3 -s on the other side, or port 5201 is blocked.

Run it on real machines

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Start this lab, free