Linux for Network Engineers: How to Use iPerf

By July 24, 2019Linux

iPerf is an open source, free, network performance measurement tool. It works by simply sending traffic from one host to another and measuring the bandwidth that can be achieved. In addition to the throughput measurement it can give metrics such as packet loss, jitter, and traffic distribution. iPerf works for both TCP and UDP traffic with certain nuances that pertain to the specifics of each protocol.

Versions

There are two versions of iPerf which are being developed in parallel: version 2 and version 3. They are incompatible to each other, and maintained by different teams. However, both have the same set of functionalities, more or less.

iPerf version 2 was released in 2003 and it’s currently in version 2.0.13. iPerf version 3 was released in 2014 and it’s current version is 3.7. iPerf3 is a rewrite of the tool in order to produce a simpler and smaller code base.

The team that has taken the lead in iPerf2 development is mainly focused on WiFi testing, while iPerf3 is focused on research networks. However, most of their functionality overlaps, and they can be both used for general network performance and testing.

Both versions support a wide variety of platforms, including Linux, Windows, and MAC OS. And there is also a GUI version of iPerf2 based in Java, called JPerf.

Usage

In iPerf “lingo”, the host that sends the traffic is called client and the receiver is called server. Here is how the command line output looks for the two versions and for UDP and TCP tests, at their basic forms without any advanced options.

TCP

iPerf2 server

netbeez.net$ iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 172.31.0.25 port 5001 connected with 172.31.0.17 port 55082
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-10.0 sec  1.09 GBytes   939 Mbits/sec

iPerf2 client

netbeez.net$ iperf -c 172.31.0.25
------------------------------------------------------------
Client connecting to 172.31.0.25, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  3] local 172.31.0.17 port 55082 connected with 172.31.0.25 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.09 GBytes   940 Mbits/sec

iPerf3 server

netbeez.net$ iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 172.31.0.17, port 56342
[  5] local 172.31.0.25 port 5201 connected to 172.31.0.17 port 56344
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-1.00   sec   108 MBytes   907 Mbits/sec
[  5]   1.00-2.00   sec   112 MBytes   941 Mbits/sec
...
[  5]   9.00-10.00  sec   112 MBytes   941 Mbits/sec
[  5]  10.00-10.04  sec  4.21 MBytes   934 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  5]   0.00-10.04  sec  1.10 GBytes   938 Mbits/sec    0             sender
[  5]   0.00-10.04  sec  1.10 GBytes   938 Mbits/sec                  receiver

iPerf3 client

netbeez.net$ iperf3 -c 172.31.0.25
Connecting to host 172.31.0.25, port 5201
[  4] local 172.31.0.17 port 56344 connected to 172.31.0.25 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   112 MBytes   943 Mbits/sec    0    139 KBytes
[  4]   1.00-2.00   sec   112 MBytes   941 Mbits/sec    0    139 KBytes
...
[  4]   8.00-9.00   sec   112 MBytes   941 Mbits/sec    0    223 KBytes
[  4]   9.00-10.00  sec   112 MBytes   941 Mbits/sec    0    223 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  1.10 GBytes   941 Mbits/sec    0             sender
[  4]   0.00-10.00  sec  1.10 GBytes   941 Mbits/sec                  receiver

iperf Done.

 UDP

iPerf2 server

netbeez.net$ iperf -s -u
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size:  208 KByte (default)
------------------------------------------------------------
[  3] local 172.31.0.25 port 5001 connected with 172.31.0.17 port 54581
[ ID] Interval       Transfer     Bandwidth        Jitter   Lost/Total Datagrams
[  3]  0.0-10.0 sec  1.25 MBytes  1.05 Mbits/sec   0.022 ms    0/  893 (0%)

iPerf2 client

netbeez.net$ iperf -c 172.31.0.25 -u
------------------------------------------------------------
Client connecting to 172.31.0.25, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:  208 KByte (default)
------------------------------------------------------------
[  3] local 172.31.0.17 port 54581 connected with 172.31.0.25 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.25 MBytes  1.05 Mbits/sec
[  3] Sent 893 datagrams
[  3] Server Report:
[  3]  0.0-10.0 sec  1.25 MBytes  1.05 Mbits/sec   0.022 ms    0/  893 (0%)

iPerf3 server

netbeez.net$ iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 172.31.0.17, port 56346
[  5] local 172.31.0.25 port 5201 connected to 172.31.0.17 port 51171
[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
[  5]   0.00-1.00   sec   120 KBytes   983 Kbits/sec  1882.559 ms  0/15 (0%)
[  5]   1.00-2.00   sec   128 KBytes  1.05 Mbits/sec  670.381 ms  0/16 (0%)
...
[  5]   9.00-10.00  sec   128 KBytes  1.05 Mbits/sec  0.258 ms  0/16 (0%)
[  5]  10.00-10.04  sec  0.00 Bytes  0.00 bits/sec  0.258 ms  0/0 (-nan%)
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
[  5]   0.00-10.04  sec  1.25 MBytes  1.04 Mbits/sec  0.258 ms  0/159 (0%)

iPerf3 client

netbeez.net$ nbiperf3 -c 172.31.0.25 -u
Connecting to host 172.31.0.25, port 5201
[  4] local 172.31.0.17 port 51171 connected to 172.31.0.25 port 5201
[ ID] Interval           Transfer     Bandwidth       Total Datagrams
[  4]   0.00-1.00   sec   128 KBytes  1.05 Mbits/sec  16
[  4]   1.00-2.00   sec   128 KBytes  1.05 Mbits/sec  16
...
[  4]   8.00-9.00   sec   128 KBytes  1.05 Mbits/sec  16
[  4]   9.00-10.00  sec   128 KBytes  1.05 Mbits/sec  16
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
[  4]   0.00-10.00  sec  1.25 MBytes  1.05 Mbits/sec  0.258 ms  0/159 (0%)
[  4] Sent 159 datagrams

iperf Done.

As you can see, the output format is very similar and both versions gave the same measurements in this example. More specifically, in TCP mode iPerf tries to achieve the maximum possible bandwidth. In the previous example, it almost saturated the gigabit link that connects the two hosts. In UDP mode, you can specify the target throughput, and if you don’t give any bandwidth input value iPerf targets 1Mbps.

This is just an introduction on the basics of iPerf. If you have questions don’t hesitate to ask them in the comments. To explore further by yourself, here is a list of resources that you may find useful:

iPerf2 home page

iPerf3 home page

iPerf2 vs iPerf3

iPerf Performance Testing on Single Board Computers

Speedtest Comparison: Ookla, NDT, NetFlix, HTML, iPerf

Iperf WiFi: Raspberry Pi 3, ASUS, Hawking, LinkSys & TP-LINK

iPerf Series of Videos