Iperf Performance Tool
Measuring Network Performance
Iperf is a network performance monitoring tool that can be used to measure throughput between two servers on a network. Iperf is a simple command line tool that allows you to test bandwidth between two servers. These servers are identified by the terms "Client" and "Server". Below are instructions for installing "iperf" on your Linux system. In most cases, iperf can be found within your repositories, however, if you need to download the packages to match your architecture, then you can visit the iperf website: iperf.
Installing iperf on a Red Hat Linux System (RHEL/CentOS/Fedora/Rocky Linux)
To install iperf on a Red Hat Linux based system, you can issue the following command:
dnf install iperf3
# dnf install iperf3
Last metadata expiration check: 0:06:47 ago on Thu 22 Jul 2021 19:57:20 BST.
Dependencies resolved.
===========================================================================================================================================
Package Architecture Version Repository Size
===========================================================================================================================================
Installing:
iperf3 x86_64 3.5-6.el8 appstream 99 k
Installing dependencies:
lksctp-tools x86_64 1.0.18-3.el8 baseos 98 k
Transaction Summary
===========================================================================================================================================
Install 2 Packages
Total download size: 198 k
Installed size: 475 k
Is this ok [y/N]: y
In the above example, we have installed iperf. Notice, the name on newer Linux systems is "iperf3".
Installing iperf on a Debian based system (Debian/Ubuntu/Mint)
To install iperf on a Debian based system, you can issue the following command:
sudo apt install iperf3
$ sudo apt install iperf3
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libiperf0 libsctp1
Suggested packages:
lksctp-tools
The following NEW packages will be installed:
iperf3 libiperf0 libsctp1
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 94.1 kB of archives.
After this operation, 331 kB of additional disk space will be used.
How to use iperf
Iperf must be installed on both servers/computers that you wish to test the link performance between. Each server will be known by the terms "Server" and "Client". In the following example, I will run a test between two CentOS 8 servers.
CentOS 8 Server - Server IP Address: 192.168.0.73
CentOS 8 Client - Client IP Address: 192.168.0.51
Start iperf on Server
To start the iperf server process, we run the following command:
iperf3 -s
The "-s" flag specifies that this is the server connection. By default, the connection will listen on port 5201, as this is the default port used by iperf. It is important that if you have a firewall that you open a port between your server and client connection, otherwise you will receive an error indicating connection refused or a timeout.
Start iperf on the Client
To start the iperf process, we run the following command:
iperf3 -c 192.168.0.73.
The IP address is that of the Server. You can check the IP address on your system quickly by issuing the command "ip a s ".
Output from Server side
Below is the output from the server side:
# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.0.51, port 57576
[ 5] local 192.168.0.73 port 5201 connected to 192.168.0.51 port 57578
[ ID] Interval Transfer Bitrate
[ 5] 0.00-1.00 sec 312 MBytes 2.62 Gbits/sec
[ 5] 1.00-2.00 sec 343 MBytes 2.88 Gbits/sec
[ 5] 2.00-3.00 sec 349 MBytes 2.93 Gbits/sec
[ 5] 3.00-4.00 sec 315 MBytes 2.64 Gbits/sec
[ 5] 4.00-5.00 sec 332 MBytes 2.79 Gbits/sec
[ 5] 5.00-6.00 sec 311 MBytes 2.61 Gbits/sec
[ 5] 6.00-7.00 sec 297 MBytes 2.50 Gbits/sec
[ 5] 7.00-8.00 sec 306 MBytes 2.57 Gbits/sec
[ 5] 8.00-9.00 sec 313 MBytes 2.62 Gbits/sec
[ 5] 9.00-10.00 sec 330 MBytes 2.77 Gbits/sec
[ 5] 10.00-10.04 sec 12.5 MBytes 2.73 Gbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate
[ 5] 0.00-10.04 sec 3.15 GBytes 2.69 Gbits/sec receiver
Output from Client side
Below is the output from the client side:
# iperf3 -c 192.168.0.73
Connecting to host 192.168.0.73, port 5201
[ 5] local 192.168.0.51 port 57578 connected to 192.168.0.73 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 328 MBytes 2.75 Gbits/sec 404 226 KBytes
[ 5] 1.00-2.00 sec 342 MBytes 2.87 Gbits/sec 493 226 KBytes
[ 5] 2.00-3.00 sec 349 MBytes 2.93 Gbits/sec 420 184 KBytes
[ 5] 3.00-4.00 sec 314 MBytes 2.64 Gbits/sec 484 214 KBytes
[ 5] 4.00-5.00 sec 332 MBytes 2.78 Gbits/sec 487 171 KBytes
[ 5] 5.00-6.00 sec 312 MBytes 2.62 Gbits/sec 374 211 KBytes
[ 5] 6.00-7.00 sec 295 MBytes 2.48 Gbits/sec 366 229 KBytes
[ 5] 7.00-8.00 sec 307 MBytes 2.58 Gbits/sec 362 182 KBytes
[ 5] 8.00-9.00 sec 312 MBytes 2.62 Gbits/sec 374 198 KBytes
[ 5] 9.00-10.00 sec 330 MBytes 2.76 Gbits/sec 524 185 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 3.15 GBytes 2.70 Gbits/sec 4288 sender
[ 5] 0.00-10.04 sec 3.15 GBytes 2.69 Gbits/sec receiver
iperf Done.
Specify a Port
To specify a specific port to use for your tests, you can override the default port of "5201" and specify a port of your own with the "-p" parameter. Remember, you will need to specify the same port on both the "Server" side and also the "Client" side.
Output from Server:
# iperf3 -s -p 5678
-----------------------------------------------------------
Server listening on 5678
-----------------------------------------------------------
Accepted connection from 192.168.0.51, port 56416
[ 5] local 192.168.0.73 port 5678 connected to 192.168.0.51 port 56418
[ ID] Interval Transfer Bitrate
[ 5] 0.00-1.00 sec 305 MBytes 2.56 Gbits/sec
[ 5] 1.00-2.00 sec 311 MBytes 2.61 Gbits/sec
[ 5] 2.00-3.00 sec 300 MBytes 2.52 Gbits/sec
[ 5] 3.00-4.00 sec 318 MBytes 2.66 Gbits/sec
[ 5] 4.00-5.00 sec 310 MBytes 2.60 Gbits/sec
[ 5] 5.00-6.00 sec 351 MBytes 2.95 Gbits/sec
[ 5] 6.00-7.00 sec 319 MBytes 2.67 Gbits/sec
[ 5] 7.00-8.00 sec 316 MBytes 2.65 Gbits/sec
[ 5] 8.00-9.00 sec 339 MBytes 2.84 Gbits/sec
[ 5] 9.00-10.00 sec 336 MBytes 2.82 Gbits/sec
[ 5] 10.00-10.04 sec 14.0 MBytes 3.05 Gbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate
[ 5] 0.00-10.04 sec 3.14 GBytes 2.69 Gbits/sec receiver
Output from Client:
# iperf3 -c 192.168.0.73 -p 5678
Connecting to host 192.168.0.73, port 5678
[ 5] local 192.168.0.51 port 56418 connected to 192.168.0.73 port 5678
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 319 MBytes 2.68 Gbits/sec 648 168 KBytes
[ 5] 1.00-2.00 sec 310 MBytes 2.60 Gbits/sec 438 214 KBytes
[ 5] 2.00-3.00 sec 302 MBytes 2.53 Gbits/sec 552 225 KBytes
[ 5] 3.00-4.00 sec 316 MBytes 2.65 Gbits/sec 551 198 KBytes
[ 5] 4.00-5.00 sec 311 MBytes 2.61 Gbits/sec 288 201 KBytes
[ 5] 5.00-6.00 sec 352 MBytes 2.95 Gbits/sec 599 185 KBytes
[ 5] 6.00-7.00 sec 318 MBytes 2.66 Gbits/sec 462 188 KBytes
[ 5] 7.00-8.00 sec 316 MBytes 2.65 Gbits/sec 483 170 KBytes
[ 5] 8.00-9.00 sec 340 MBytes 2.85 Gbits/sec 681 204 KBytes
[ 5] 9.00-10.00 sec 338 MBytes 2.83 Gbits/sec 334 195 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 3.15 GBytes 2.70 Gbits/sec 5036 sender
[ 5] 0.00-10.04 sec 3.14 GBytes 2.69 Gbits/sec receiver
iperf Done.
Understanding the results
The results of the transfer tests are displayed on both the Server and the Client. By default there are 10 transfers, this value can be changed by specifying the "-t" parameter. The interval by default is 1 second. This value can be changed by specifying the flag "-i" followed by a new interval period in seconds.
The "Transfer" column indicates how much data was transferred and the "Bitrate" column displays the transfer rate.
Measuring the Download Speed
Normally test data is sent from the Client side to the Server giving an indication of the upload speed of the client. Measuring the download speed from the server can be done by specifying the "-R" parameter on the client. This will cause data to be sent from the Server side to the Client.
Example command: iperf3 -c 192.168.0.73 -p 5678 -R
# iperf3 -c 192.168.0.73 -p 5678 -R
Connecting to host 192.168.0.73, port 5678
Reverse mode, remote host 192.168.0.73 is sending
[ 5] local 192.168.0.51 port 56430 connected to 192.168.0.73 port 5678
[ ID] Interval Transfer Bitrate
[ 5] 0.00-1.00 sec 350 MBytes 2.94 Gbits/sec
[ 5] 1.00-2.00 sec 323 MBytes 2.71 Gbits/sec
[ 5] 2.00-3.00 sec 315 MBytes 2.64 Gbits/sec
[ 5] 3.00-4.00 sec 323 MBytes 2.71 Gbits/sec
[ 5] 4.00-5.00 sec 324 MBytes 2.72 Gbits/sec
[ 5] 5.00-6.00 sec 337 MBytes 2.83 Gbits/sec
[ 5] 6.00-7.00 sec 337 MBytes 2.83 Gbits/sec
[ 5] 7.00-8.00 sec 315 MBytes 2.64 Gbits/sec
[ 5] 8.00-9.00 sec 337 MBytes 2.82 Gbits/sec
[ 5] 9.00-10.00 sec 317 MBytes 2.66 Gbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.04 sec 3.20 GBytes 2.74 Gbits/sec 4848 sender
[ 5] 0.00-10.00 sec 3.20 GBytes 2.75 Gbits/sec receiver
iperf Done.
Parameters and Options available to iperf
Below are some of the options that are available to be used for performance testing and tuning.
Server or Client:
-p, --port # server port to listen on/connect to
-f, --format [kmgtKMGT] format to report: Kbits, Mbits, Gbits, Tbits
-i, --interval # seconds between periodic throughput reports
-F, --file name xmit/recv the specified file
-A, --affinity n/n,m set CPU affinity
-B, --bind <host> bind to the interface associated with the address <host>
-V, --verbose more detailed output
-J, --json output in JSON format
--logfile f send output to a log file
--forceflush force flushing output at every interval
-d, --debug emit debugging output
-v, --version show version information and quit
-h, --help show this message and quit
Server specific:
-s, --server run in server mode
-D, --daemon run the server as a daemon
-I, --pidfile file write PID file
-1, --one-off handle one client connection then exit
--rsa-private-key-path path to the RSA private key used to decrypt
authentication credentials
--authorized-users-path path to the configuration file containing user
credentials
Client specific:
-c, --client <host> run in client mode, connecting to <host>
--sctp use SCTP rather than TCP
-X, --xbind <name> bind SCTP association to links
--nstreams # number of SCTP streams
-u, --udp use UDP rather than TCP
--connect-timeout # timeout for control connection setup (ms)
-b, --bitrate #[KMG][/#] target bitrate in bits/sec (0 for unlimited)
(default 1 Mbit/sec for UDP, unlimited for TCP)
(optional slash and packet count for burst mode)
--pacing-timer #[KMG] set the timing for pacing, in microseconds (default 1000)
--fq-rate #[KMG] enable fair-queuing based socket pacing in
bits/sec (Linux only)
-t, --time # time in seconds to transmit for (default 10 secs)
-n, --bytes #[KMG] number of bytes to transmit (instead of -t)
-k, --blockcount #[KMG] number of blocks (packets) to transmit (instead of -t or -n)
-l, --length #[KMG] length of buffer to read or write
(default 128 KB for TCP, dynamic or 1460 for UDP)
--cport <port> bind to a specific client port (TCP and UDP, default: ephemeral port)
-P, --parallel # number of parallel client streams to run
-R, --reverse run in reverse mode (server sends, client receives)
-w, --window #[KMG] set window size / socket buffer size
-C, --congestion <algo> set TCP congestion control algorithm (Linux and FreeBSD only)
-M, --set-mss # set TCP/SCTP maximum segment size (MTU - 40 bytes)
-N, --no-delay set TCP/SCTP no delay, disabling Nagle's Algorithm
-4, --version4 only use IPv4
-6, --version6 only use IPv6
-S, --tos N set the IP type of service, 0-255.
The usual prefixes for octal and hex can be used,
i.e. 52, 064 and 0x34 all specify the same value.
--dscp N or --dscp val set the IP dscp value, either 0-63 or symbolic.
Numeric values can be specified in decimal,
octal and hex (see --tos above).
-L, --flowlabel N set the IPv6 flow label (only supported on Linux)
-Z, --zerocopy use a 'zero copy' method of sending data
-O, --omit N omit the first n seconds
-T, --title str prefix every output line with this string
--get-server-output get results from server
--udp-counters-64bit use 64-bit counters in UDP test packets
--username username for authentication
--rsa-public-key-path path to the RSA public key used to encrypt
authentication credentials
[KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga-