
Table of contents
Hello!
In this article, we take a closer look at iPerf, a powerful tool for measuring network performance.
An affordable and versatile single-board computer, the Raspberry Pi offers endless possibilities for technology enthusiasts and IT professionals. Combining iPerf with Raspberry Pi opens up new possibilities for exploring and optimizing networks in a home or small business.
What is iPerf?
iPerf is a network throughput testing tool that measures TCP and UDP performance. It is an open-source program, available on Linux, Windows and macOS. iPerf works by creating data that is transmitted between a server and a client (also iPerf), allowing analysis of various network parameters such as data rates, packet loss and latency. Its simplicity and flexibility make it an ideal tool for testing networks in a variety of environments, including on the Raspberry Pi.
Users can easily install and run iPerf on a Raspberry Pi, using its capabilities to monitor and diagnose network health, which is particularly useful for education, hobbyist projects and small businesses.
iPerf or iPerf3?
There are two versions of the network throughput testing tool: iPerf and its newer version, iPerf3. Here are the key differences between the two:
- Development and Support: iPerf (sometimes called iPerf2) is the original version of the tool. iPerf3 was written from the ground up and is supported by ESnet. iPerf3 is not a continuation of iPerf2, but a separate project.
- Compatibility: iPerf3 is not backward compatible with iPerf2. This means that the server and client using iPerf3 will not be able to communicate with counterparts using iPerf2.
- Functionality: iPerf3 offers some new features and fixes that are missing from iPerf2. For example, iPerf3 has better support for reporting results, allows testing of multiple data streams simultaneously and offers more detailed analysis.
- User interface and output: iPerf3 has a slightly different user interface and output format compared to iPerf2. The changes are intended to make it easier to interpret test results.
- Protocol support: Both tools support TCP and UDP protocols, but iPerf3 introduces better management and diagnostics for these protocols.
In practice, the choice between iPerf and iPerf3 depends on the specific needs of the user and the requirements of the test environment. iPerf3 is often preferred because of its newer features and better support. For more information, click here.
Preparation
Before we start checking bandwidth, it is a good idea to properly prepare our device – I will use Raspberry Pi version 4B for the tutorial. We will issue commands to our device via SSH.
- Currently, you can already use the commercially available Raspberry Pi 5, however, its availability is very low. I recommend using rpilocator.com to see where you can currently get a reasonably priced device;
- For Microsoft Windows operating system I recommend PuTTY, while for Apple macOS operating systems I recommend Termius.
Step 1 – Update package list and upload updates
- Launch PuTTY (Windows OS) or Termius (macOS), then connect to your device,
- Enter the following command to update the package list and install available updates:
sudo apt-get update && sudo apt-get upgrade -y
Step 2 – Install the iPerf3 package
- Enter the following command to install the bandwidth measurement package:
- The package must be installed on a device that acts as a server as well as a client during the measurement.
sudo apt-get install iperf3 -y
- Wait a short while until the package installation process is complete. Once successfully installed, you can move on to the next command you will execute on the command line.
sudo apt-get install iperf3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
iperf3
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/28.4 kB of archives.
After this operation, 56.3 kB of additional disk space will be used.
Selecting previously unselected package iperf3.
(Reading database ... 76055 files and directories currently installed.)
Preparing to unpack .../iperf3_3.9-1+deb11u1_arm64.deb ...
Unpacking iperf3 (3.9-1+deb11u1) ...
Setting up iperf3 (3.9-1+deb11u1) ...
Processing triggers for man-db (2.9.4-2) ...
- To check the package version, call the command:
iperf3 --version
- In my example, it looks as follows:
iperf 3.9 (cJSON 1.7.13)
Linux rec-rsp01 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64
Optional features available: CPU affinity setting, IPv6 flow label, SCTP, TCP congestion algorithm setting, sendfile / zerocopy, socket pacing, authentication
How to measure throughput with iPerf3 on Raspberry Pi
Server
- To check the bandwidth between the two devices, on the first Raspberry Pi that will act as a server, use the following command to run the application:
iperf3 -s -p 11111
- When you call listen on the server, you will receive a message:
iperf3 -s -p 11111
-----------------------------------------------------------
Server listening on 11111
-----------------------------------------------------------
Client
- Now on the second Raspberry Pi, which will act as the client, use the following command to run the measurement:
iperf3 -c IP_DRUGIEGO_RASPBERRY_PI -p 11111
- After successfully establishing a connection between the server and the client – the measurement will begin. The result should look similar to the one below:
Connecting to host XXX.XXX.XXX.XXX, port 11111
[ 5] local XXX.XXX.XXX.XXX port 38668 connected to XXX.XXX.XXX.XXX port 11111
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 101 MBytes 851 Mbits/sec 0 573 KBytes
[ 5] 1.00-2.00 sec 93.3 MBytes 783 Mbits/sec 0 601 KBytes
[ 5] 2.00-3.00 sec 83.8 MBytes 703 Mbits/sec 0 826 KBytes
[ 5] 3.00-4.00 sec 97.5 MBytes 818 Mbits/sec 0 826 KBytes
[ 5] 4.00-5.00 sec 93.8 MBytes 786 Mbits/sec 0 872 KBytes
[ 5] 5.00-6.00 sec 97.5 MBytes 818 Mbits/sec 0 1004 KBytes
[ 5] 6.00-7.00 sec 95.0 MBytes 797 Mbits/sec 0 1.03 MBytes
[ 5] 7.00-8.00 sec 98.8 MBytes 827 Mbits/sec 29 812 KBytes
[ 5] 8.00-9.00 sec 85.0 MBytes 714 Mbits/sec 0 812 KBytes
[ 5] 9.00-10.00 sec 100 MBytes 839 Mbits/sec 0 812 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 946 MBytes 794 Mbits/sec 29 sender
[ 5] 0.00-10.04 sec 943 MBytes 788 Mbits/sec receiver
iperf Done.
Change the condition for displaying throughput
- We can change how the results are displayed in the Bitrate column using the -f switch – available options: K (Kbps), M(Mbps), G (Gbps) and T (Tbps). For example, for a measurement result in Kbps – the measurement report will come out as follows:
iperf3 -c XXX.XXX.XXX.XXX -p 11111 -f k
Connecting to host XXX.XXX.XXX.XXX, port 11111
[ 5] local XXX.XXX.XXX.XXX port 38668 connected to XXX.XXX.XXX.XXX port 11111
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 89.2 MBytes 747852 Kbits/sec 0 503 KBytes
[ 5] 1.00-2.00 sec 91.7 MBytes 768921 Kbits/sec 0 559 KBytes
[ 5] 2.00-3.00 sec 99.6 MBytes 835087 Kbits/sec 0 745 KBytes
[ 5] 3.00-4.00 sec 93.8 MBytes 786487 Kbits/sec 0 783 KBytes
[ 5] 4.00-5.00 sec 95.0 MBytes 796908 Kbits/sec 0 1.08 MBytes
[ 5] 5.00-6.00 sec 92.5 MBytes 775914 Kbits/sec 0 1.08 MBytes
[ 5] 6.00-7.00 sec 92.5 MBytes 775956 Kbits/sec 0 1.13 MBytes
[ 5] 7.00-8.00 sec 91.2 MBytes 765473 Kbits/sec 0 1.13 MBytes
[ 5] 8.00-9.00 sec 102 MBytes 859814 Kbits/sec 0 1.13 MBytes
[ 5] 9.00-10.00 sec 91.2 MBytes 765477 Kbits/sec 0 1.13 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 939 MBytes 787789 Kbits/sec 0 sender
[ 5] 0.00-10.04 sec 936 MBytes 782272 Kbits/sec receiver
iperf Done.
Additional sources and information
- iPerf3 User Documentation – Command line options: https://iperf.fr/iperf-doc.php#3doc
Read also
- UniFi Controller in Docker: Migrating to UniFi Network Application
- Home Assistant: Installing mirror lighting on ESPHome
- How to make an internet speed test on a Raspberry Pi
- ADS-B: Receiver installation and configuration on Raspberry Pi
- Traccar: Docker installation guide on Synology
- Traccar: Configuring GPS communication in Docker
Leave a Reply