Bandwidth and Link Quality Testing with “IPerf”

Linux Networking Random Uncategorized

IPerf is a tool that can be used to measure the bandwidth and quality of a network link. Its a useful little tool, so I’ll introduce some of the basics of how you can use it to perform some tests. Bear in mind this is not an exhaustive guide, there are many tweaks that can be used to get the most out of the tool and test all parts of the link(s) you are testing.

Installation

First install the tool with

sudo apt install iperf

Simple Test

IPerf can be run in one of two modes, “Server” or “Client”, in this example, i’ve got two machines, one running on 192.168.1.8/24 which will be the “Server” and the other is running on 192.168.1.4/24 which will be the client. First start the server with:

iperf -s

It listens by default on port 5001/TCP, assuming there are no firewalls in the way, now you can start the client and therefore start a simple test.

iperf -c 192.168.1.8

The tests will start to be performed, and after a short while you’ll get some results listed on both the server and the client (the below is the client output).

ubuntu@development4:~$ iperf -c 192.168.1.8
------------------------------------------------------------
Client connecting to 192.168.1.8, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  1] local 192.168.1.4 port 46714 connected with 192.168.1.8 port 5001
[ ID] Interval       Transfer     Bandwidth
[  1] 0.0000-10.0600 sec   113 MBytes  94.0 Mbits/sec

The test is only one-way, i.e. from the client to the server. You can run it bidirectionally to test the send and receive at the same time.

Simple Test – Bidirectional

To run a bi-directional test use the following on the “client”, you can leave the “server” running as it was before.

iperf -c 192.168.1.8 -r

Let’s examine the results….

ubuntu@development4:~$ iperf -c 192.168.1.8 -r
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size:  128 KByte (default)
------------------------------------------------------------
------------------------------------------------------------
Client connecting to 192.168.1.8, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  1] local 192.168.1.4 port 46204 connected with 192.168.1.8 port 5001
[ ID] Interval       Transfer     Bandwidth
[  1] 0.0000-10.0615 sec   113 MBytes  94.0 Mbits/sec
[  2] local 192.168.1.4 port 5001 connected with 192.168.1.8 port 59442
[ ID] Interval       Transfer     Bandwidth
[  2] 0.0000-10.0690 sec   113 MBytes  94.1 Mbits/sec

The test was bi-directional and sequential, if you want to test both ways (send and receive) at the same time, you can use:

iperf -c 192.168.1.8 -d

Test Time Duration

You can run a test for a period of time, for example 60 seconds with:

iperf -c 192.168.1.8 -t 60

Additional Statistics

If you want to see some more details, for example packet loss, you can switch to UDP mode, for this you’ll need to start the Server with a different set of arguments:

iperf -s -u -i 1

Then start the Client with the “-u” added, and you’ll see something like this:

iperf -c 192.168.1.8 -u
------------------------------------------------------------
Client connecting to 192.168.1.8, UDP port 5001
Sending 1470 byte datagrams, IPG target: 11215.21 us (kalman adjust)
UDP buffer size:  208 KByte (default)
------------------------------------------------------------
[  1] local 192.168.1.4 port 48756 connected with 192.168.1.8 port 5001
[ ID] Interval       Transfer     Bandwidth
[  1] 0.0000-10.0155 sec  1.25 MBytes  1.05 Mbits/sec
[  1] Sent 896 datagrams
[  1] Server Report:
[ ID] Interval       Transfer     Bandwidth        Jitter   Lost/Total Datagrams
[  1] 0.0000-10.0154 sec  1.25 MBytes  1.05 Mbits/sec   0.042 ms 0/895 (0%)

As you can see there are now values for Jitter and also packet loss, which might be helpful if you are trying to isolate a network error or issues affecting IP telephony which is sensitive to Jitter.

Conclusion

As you can see, this is a simple and useful tool, there’s so many more options I’ve not explored here, but you can find out more at https://openmaniak.com/iperf.php if you are interested.

In the case of my testing, the results were as expected, the two machines (Raspberry Pi 3s) were connected up with 100Mbit links via a 100Mbit switch, so getting about 94 Mbit/s bandwidth is roughly what would be expected.

Leave a Reply

Your email address will not be published. Required fields are marked *