How to setup an Iperf3 Server on Ubuntu

Introduction

In April of 2024, we released version 14.1 and with it came a massive improvement to our schedule testing feature. Previously, if you wanted to configure many Iperf tests you typically had to make a test for each agent/destination. You could spin up an Iperf server and run multiple tests at the same time, but you would risk running out of resources. This is because Iperf requires quite a bit of processing power and will saturate all of the available bandwidth (unless you cap the maximum throughput) especially when multiple tests are run against the same server in parallel. With version 14.1 we added the ability to run tests in serial (one starts after one completes) or random (all must complete in a given time window spread out uniformly). This extends to both Iperf and speedtest. On top of that we added alerting to deliver a complete monitoring solution for these tests. Today, we will show you how to set up an Iperf server, how to configure an Iperf test and set metrics on how to verify performance to maintain SLA’s

Step 1: Prerequisites to Setting up the Server

We are using Ubuntu here but there are other distros that may work. In our example we will be using Ubuntu 20.04.6 (Server). If you already have a Ubuntu server that is used for other applications, you can use it assuming you have some resources and bandwidth available. It is IMPORTANT that the agents are able to reach the server in order to run the tests.

Step 2: Configuring the Server

You can use this link to download the latest 20.04.6 server and you should be fine with 2v CPU and 4GB of ram. Storage can be minimal because the testing data is going to be stored on the NetBeez Server. We simply just need a destination to run against. You can follow this guide regarding setting up the Ubuntu Server (Procedure steps 1 & 2). Once the server reboots, SSH to the server and login as root (sudo). Then input these commands:

apt update
apt install iperf3

From there you can run this command iperf3 -v to verify it installed, you may get output like this:

Iperf 3.7 (cJSON 1.5.2)
Linux nb2 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64
Optional features available: CPU affinity setting, IPv6 flow label, SCTP, TCP congestion algorithm setting, sendfile / zerocopy, socket pacing, authentication

From there execute this command iperf3 -s to start the server to listen for Iperf3 requests on the default TCP port 5201.

Step 3: Run the Test

Go over to your BeezKepper, login and navigate to the “AD-HOC TESTING” Tab. Select any of the agents that can reach the new server, and for the destination put the IP Address of the Ubuntu Server. Make sure you select Version 3 for the “Iperf Version”. You should see an output after 10-15 seconds like the one below:

Step 4: Permanent Test

Now we need to make sure that the server will still listen for Iperf requests even after a server reboot as these can happen for patching, updates, maintenance or power loss. Go and SSH to the Iperf server, login as root (sudo) and using your favorite text editor (mine is VIM), go into this file /etc/systemd/system/iperf3.service and add the following:

[Unit]
Description=iperf3 server
After=syslog.target network.target auditd.service

[Service]
ExecStart=/usr/bin/iperf3 -s

[Install]
WantedBy=multi-user.target

Save and quit then run this command: sudo systemctl enable iperf3 and reboot the server. Rerun the AD-HOC Test again to make sure that it is still running. If so, we are good to move on to configuring the next steps.

Step 5 (Recommended): Setting up SLA/Metrics

We talked a bit about SLA Metrics in this blog here back in June. If you navigate to the Settings>Anomaly Detection tab, there are some brand new options introduced in version 14.1. When you click “+ Add Alert” under “Alert Type” there are 3 new options: Schedule Test Error, Schedule Test Baseline and Schedule Test Watermark.

Schedule Test Error: Alert in the system if the test fails to start

Schedule Test Baseline: Alert if the aggregate averages over a set amount of runs deviates too far front he average

Schedule Test Watermark: Set the exact Metric needed to be met and alert if any test or an average of test fails to meet these metrics

Step 6: Configuring the Test

Login to your NetBeez Dashboard and navigate to the “Test” Tab. Then select Iperf and “+ Add Scheduled Iperf Test”. Select Multiple Agents to Server, then select as many source agents as you wish and input the IP/FQDN of the new Iperf Server. Make sure you select Version 3 for Iperf Version. You can modify other attributes of the test such as setting a specific port or capping the bandwidth.

Under the schedule, we caution you to remember that Iperf is measuring real bandwidth to the network and will be saturated for a few seconds for each test. So space these out where it makes sense or cap it if necessary. As for the run mode, Below is a brief explanation of each.

Parallel: All tests run at the same time

Serial: Tests will begin once the previous one ends

Random: Tests will complete in a given time period with as little overlap as possible.

Random is great if you have tons of agents and need to complete the test in a time window to prevent overlap with other tests such as speedtest. Serial is good for smaller deployments or in situations where there is no real conflict for overlap.

Schedule Test Error and Watermark are used the most frequently and these can be added to the test itself on the far right section called “Alerts”.

Step 7 (Recommended): Getting notified for Alerts

Navigate to Settings>Notifications and add schedule test alerts to your existing external alerting system (Slack, Teams, SMTP, etc) that you use for NetBeez.

Additional Notes

If you’re using an existing server that has other applications running, the test results may not be accurate due to additional resource load (CPU/NIC). So while you can run iperf on an existing server we caution you on this and recommend a smaller dedicated server for this type of testing. Also, DO NOT run iperf on your BeezKeeper, it can impact performance and metrics not just on the iperf test but the dashboard performance as well.

Conclusion

Iperf is a great tool and with our recent improvements you can seamlessly measure network performance easier than ever. This guide was designed for anyone who has even the basic knowledge of Linux to follow, so if you have any recommendations on how to improve this process, please comment down below!