Raspberry Pi and Iperf

The Raspberry Pi (RPi) has been a smash hit in so many different areas. Hobbyists love them and professionals have found a reliable, low-cost, and small-footprint platform to build commercial products.

In this series of blog posts we’ll cover several different ways on how to use the $35 Linux platform to perform network tests that can help you troubleshoot network issues. What we’ll cover applies to any Linux platform, but with a focus on RPi’s idiosyncrasies. Their main benefit is their price point that allows the deployment of dozens or hundreds of independent Linux platforms at each network locations readily available for your troubleshooting needs.

Raspberry Pi Set Up

To set up an RPi with its operating system you can follow the instructions here. Alternatively, you can order a kit that includes the RPi, the power supply, and the SD card with the OS installed. The preferred distributors or the RPi Foundation are www.element14.com and egoman.com.cn.

Iperf

Iperf is an open source Linux tool that can be used for bandwidth testing. We wrote a good introduction on iperf and all of its command-line options.

To run an iperf test you need two RPis: one to act as a client and one to act as a server. The client pushes traffic through the network while the server receives the data and measures statistics. Note that Iperf pushes actual traffic through your network, and you need to take this into consideration to avoid clogging your pipes.

Iperf installation

To install Iperf log into the RPi, open a console and type:

sudo apt-get install iperf

Now you can start playing with Iperf.  Here is a list of the most useful types of tests your can perform:

Running iperf in TCP mode

The TCP test pushes as much traffic as possible between the two RPis. All current RPi models have a 10/100 interface, so the maximum theoretical bandwidth they can push is 100Mbps. Note that Iperf is CPU intensive and the maximum achievable bandwidth is also limited by the RPi’s CPU capabilities. If you are not running any other heavy applications on the RPi, you might be able to achieve up to 75Mbps. If you overclock the CPU, you might get close to the theoretical maximum of 100MBps. Since TCP Iperf is CPU intensive it can skew any other tests you might be running on the RPi.

Commands (start the server command first):
(Note: command line outputs have been shortened for clarity)

Client agent:
pi@172.30.0.20 :~:$ iperf -s
[ 4] 0.0-10.0 sec 87.2 MBytes 73.0 Mbits/sec
 
Server agent:
pi@172.30.0.11 :~:$ iperf -c 172.30.0.20
[ 3] 0.0-10.0 sec 87.2 MBytes 73.0 Mbits/sec

Running iperf in UDP mode

With UDP you can control the amount of traffic to be pushed from the client to the server. E.g. you can test your pipes with a 10Mbps test. UDP also measures the jitter and the packet loss between the two ends. These two metrics are used by many network engineers as an early indication of network problems (e.g. run a 1Mbps UPD Iperf every 1 hour and raise an alarm when jitter goes beyond 15 milliseconds).

Commands (if you start the server after the client, some packets will get lost. It is advised to start the server before the client):

Server agent:
pi@172.30.0.20 :~:$ iperf -s -u
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 3] 0.0-10.0 sec 11.9 MBytes 10.0 Mbits/sec 0.059 ms 0/ 8504 (0%)
[ 3] 0.0-10.0 sec 1 datagrams received out-of-order
Client agent:
pi@172.30.0.11 :~:$ iperf -c 172.30.0.20 -u -b 10M
[ 3] 0.0-10.0 sec 11.9 MBytes 10.0 Mbits/sec 0.058 ms 0/ 8504 (0%)
[ 3] 0.0-10.0 sec 1 datagrams received out-of-order

Running multicast iperf

If you have multicast enabled in your network, you can test if your forwarding works as expected. You can start more than one multicast servers and bind them to a specific group address, and then broadcast from a client to all servers. Also, you can set the maximum Time-To-Live (ttl) value to make sure your multicast packets reach each server within the desired hop limit.

Commands (if you start the server after the client, some packets will get lost. It is advised to start the servers before the client):
Server agent 1:
pi@172.30.0.20 :~:$ iperf -s -u -B 224.0.67.67
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 3] 0.0-10.0 sec 1.25 MBytes 1.05 Mbits/sec 0.061 ms 0/ 893 (0%)
 
Server agent 2:
pi@172.30.0.13 :~:$ iperf -s -u -B 224.0.67.67
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 3] 0.0-10.0 sec 801 KBytes 655 Kbits/sec 0.068 ms 335/ 893 (38%)
 
Client agent:
pi@172.30.0.11 :~:$iperf -c 224.0.67.67 -u –ttl 5
[ 3] 0.0-10.0 sec 1.25 MBytes 1.05 Mbits/sec
[ 3] Sent 893 datagrams

Setting the TOS field in iperf

If you want to test how your routers forward packets based on their type-of-service (TOS) marking you can use the option –tos.

Commands (start the server command first):
Server agent:
pi@172.30.0.20 :~:$ iperf -s
[ 4] 0.0-10.0 sec 89.9 MBytes 75.2 Mbits/sec
 
Client agent:
pi@172.30.0.11 :~:$ iperf -c 172.30.0.20 –tos 96
[ 3] 0.0-10.0 sec 89.9 MBytes 75.2 Mbits/sec

Use Case of Running iperf on Raspberry Pi

When a user complains about an application being slow, the network is blamed first. Until proven otherwise, the networking group jumps onto the problem. A quick way to check if a connection can pass a certain amount of traffic is to run, for example, a 10Mbps Iperf test between the RPi deployed at the location that opened the ticket (Iperf client) and the RPi sitting at the datacenter that runs the application (Iperf server). If the results show that the bandwidth is in good standing, then you can pass the ticket to the next level of support.

Ipef is only one of many open source tools that can be used for network and application troubleshooting. In following blog posts I will cover how to test DNS resolution time, TCP ports, HTTP applications, and others.

NetBeez and Raspberry Pi

NetBeez is a distributed network monitoring solution that can be installed on Raspberry Pi’s to detect network performance issues via different tests, including iperf. The NetBeez agent can be easily installed on a Raspbyan or Debian like distribution with “apt install netbeez-agent”. To learn more about it, read the article on synthetic network monitoring or consult the documentation page about installing NetBeez agents.

decoration image

Get your free trial now

Monitor your network from the user perspective

You can share

Twitter Linkedin Facebook

Let's keep in touch

decoration image