Preface
iPerf measures the maximum network throughput a server can handle. It is particularly useful when experiencing network speed issues, as you can use iPerf to determine which server is unable to reach maximum throughput.
Install iPerf
The installation section assumes that you are the root user. If you are not using the super user, you will need to use sudo before each command. To enter into root mode, type sudo -i
from the terminal.
On Ubuntu
You can use apt-get
to install iPerf on Debian and Ubuntu:
apt-get update
apt-get install iperf
On CentOS
CentOS repositories do not have iPerf by default. Use the EPEL
repository, which is a repository used to install third-party software packages on RedHat
systems such as RHEL
and CentOS
:
yum install epel-release
For Both
yum update
yum install iperf
How to Use iPerf
iPerf must be installed on both computers between which you are testing the connection. If you are using a Unix or Linux-based operating system on your personal computer, you may be able to install iPerf on your local machine. If you are testing the throughput of your VM, however, it’s better to use another server as the end point, as your local ISP may impose network restrictions that can affect the results of your test.
TCP Clients & Servers:
iPerf requires two systems because one system must act as a server, while the other acts as a client. The client connects to the server you’re testing the speed of. On the VM you wish to test, launch iPerf in server mode:
iperf -s
You should see output similar to:
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
On your second VM, connect to the first. Replace ip_address with the first VM IP address.
iperf -c ip_address
The output should be similar to:
Cient connecting to ip_address , TCP port 5001
TCP window size: 45.0 KByte (default)
[ 4] local ip_address port 5001 connected with ip_address port 50616
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.1 sec 1.27 GBytes 1.08 Gbits/sec
To stop the iPerf server process, press CTRL + c.
UDP Clients and Servers:
Using iPerf, you can also test the maximum throughput achieved via UDP connections.
Start a UDP iPerf server:
iperf -s -us
The output will be similiar to:
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size: 208 KByte (default)
Connect your client to your iPerf UDP server. Replace ip_address with your IP address:
iperf -c ip_address -u
The -u option we’ve passed tells iPerf that we are connecting via UDP. This is important, because we want to see the maximum throughput achieved via UDP. The output should be similar to:
Client connecting to ip_address, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 208 KByte (default)
[ 3] local ip_address port 58070 connected with ip_address 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.084 ms 0/ 893 (0%)
Looking at the output we have received, 1.05 Mbits/sec is considerably less than what we received on the TCP tests. It is also considerably less than the maximum outbound bandwidth cap provided by the VM. This is because iPerf limits the bandwidth for UDP clients to 1 Mbit per second by default.
You can change this with the -b flag, replacing the number after with the maximum bandwidth rate you wish to test against. If you are testing for network speed, we recommend setting this number above the maximum bandwidth cap provided by VM.
iperf -c ip_address -u -b 1000m
This tells the client that we want to achieve a maximum of 1000 Mbits per second if possible. The -b flag only works when using UDP connections, since iPerf does not set a bandwidth limit on the TCP clients.
The output should be similar to:
Client connecting to ip-address, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 208 KByte (default)
[ 3] local ip-address port 52308 connected with 198.51.100.5 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 966 MBytes 810 Mbits/sec
[ 3] Sent 688897 datagrams
[ 3] Server Report:
[ 3] 0.0-10.0 sec 966 MBytes 810 Mbits/sec 0.001 ms 0/688896 (0%)
[ 3] 0.0-10.0 sec 1 datagrams received out-of-order
Now that is considerably better than the 1.05 Mbits/sec we were seeing earlier!
Bidirectional Tests:
In some cases, you may want to test both servers for the maximum amount of throughput. This can easily be done using the built-in bidirectional testing feature iPerf offers.
First, switch to TCP mode:
iperf -s
Now, run the following command to test both connections:
iperf -c ip_address -d
The result is that iPerf will start a server and a client connection on the original client server (ip_address). Once this has been done, iPerf will connect the original iPerf server to the client connection, which is now acting as both a server connection and a client connection. This will look similar.
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
Client connecting to ip-address, TCP port 5001
TCP window size: 351 KByte (default)
[ 3] local ip-address port 50618 connected with ip-address port 5001
[ 5] local ip-address port 5001 connected with ip-address port 58650
[ ID] Interval Transfer Bandwidth
[ 5] 0.0-10.1 sec 1.27 GBytes 1.08 Gbits/sec
[ 3] 0.0-10.2 sec 1.28 GBytes 1.08 Gbits/sec
On the original iPerf server, you will see:
Client connecting to ip_address, TCP port 5001
TCP window size: 153 KByte (default)
[ 6] local ip-address port 58650 connected with ip-address port 5001
[ 6] 0.0-10.1 sec 1.27 GBytes 1.08 Gbits/sec
[ 5] 0.0-10.2 sec 1.28 GBytes 1.08 Gbits/sec
Options
Option Description:
-f
Change the format in which the tests are run. For example, you can use -f k to get results in Kbits per second instead of Mbits per second. Valid options include m (Mbits, default), k (Kbits), K (KBytes), and M (MBytes).
-V
Forces iPerf to use IPv6 rather than IPv4.
-i
Changes the interval between periodic bandwidth tests. For example, -i 60 will make a new bandwidth report every 60 seconds. The default is zero, which performs one bandwidth test.
-p
Changes the port. When not specified, the default port is 5001. You must use this flag on both the client and server.
-B
Binds iPerf to a specific interface or address. If passed through the server command, the incoming interface will be set. If passed through the client command, the outgoing interface will be set.
More Information You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.