Menu

iperf2 / iperf3

October 17, 2024

iperf is a simple tool to let you measure memory-to-memory performance access a network. iperf3 is a newer implementation from scratch, with the goal of a smaller, simpler code base, and a library version of the functionality that can be used in other programs. iperf3 is not backwards compatible with iperf2.

The most recent version of iperf3 can be found on github, and fairly recent versions are available for both Debian and RHEL-based systems from the perfSONAR repository. iperf3 is also in the standard linux repositories, but is usually a bit out of date.

A comparison of throughput measurement tools is available here.

The basic commands are the same for iperf2 and iperf3:

Sample iperf / iperf3 commands
Server:

iperf -s

iperf3 -s

Start server on the default port

iperf -s -w 32M -D

iperf3 -s -D

Start server with larger TCP window, and in daemon mode

iperf -i1 -u -s -p 5003

iperf3 -s -p 5003

Start UDP server on port 5003, and give 1 sec interval reports. Note that for iperf3 the -u option is passed to the server from the client.
Client
iperf/iperf3 -c remotehost -i 1 -t 30 Run a 30 second tests, giving results every 1 second
iperf/iperf3 -c remotehost -i 1 -t 20 -r Run a test from remotehost to localhost
iperf/iperf3 -c remotehost -i 1 -t 20 -w 32M -P 4 Run a test with 4 parallel streams, and with a 32M TCP buffer
iperf/iperf3 -c remotehost -u -i 1 -b 200M Run a 200 Mbps UDP test

iperf3 adds a number of additional features. For example, the -i mode reports TCP retransmit info (and is on by default), and the verbose mode now gives a lot of useful information on CPU usage, etc. Other new options include:

New iperf3 commands
Client:
iperf3 -c remotehost -i.5 -0 2 Run the test for 2 seconds before collecting results, to allow for TCP slowstart to finish. (Omit mode)
iperf3 -Z -c remotehost Use the sendfile() system call for "Zero Copy" mode. This uses much less CPU on older hardware.
iperf3 -c 192.168.12.12 -T s1 & iperf3 -c 192.168.12.13 -T s2 Run tests to multiple interfaces at once, and label the lines to indicate which test is which
iperf3 -c remotehost -J Output the results in JSON format for easy parsing.
iperf3 -A 4,4 -c remotehost Set the CPU affinity for the sender,receiver (cores are numbered from 0). This has the same affect as doing 'numactl -C 4 iperf3' on both client and server.

iperf3 -c 10.20.1.20 -A2,2 -T "1" & ; iperf3 -c 10.20.1.20 -p 5400 -A3,3 -T "2" &

Run 2 streams on 2 different cores, and label each using the "-T" flag.

iperf3 is normally used to measure memory to memory performance, but you can also use iperf3 for determine if the network or the disk is the bottleneck.

iperf3 thread model

In order to keep the code as simple and maintainable as possible, iperf3 was originally  single threaded. This meant that multi-stream iperf3 would often be CPU-bound. To run parallel stream iperf3 on multiple cores, you needed to use the method shown in the table above, or use iperf2, which is multi-treaded.

Starting with iperf3 v3.16, multiple threads are supported, eliminating this constraint.

For more information, see the iperf3 FAQ.

iperf2

Note that older versions of iperf were buggy. Most of the important bugs were fixed iperf2.0.8, and even newer versions have a number of nice features, so be sure to use a newer release of iperf2.