Testing Network Throughput with an Iperf Server

/, tips/Testing Network Throughput with an Iperf Server

Testing Network Throughput with an Iperf Server

Every now and again I need to test throughput on a local segment of our LAN. Other times I want to test the throughput of an offsite VPN connection. I am able to accomplish this with Iperf, Iperf2 specifically.  This post will focus on setting up iperf2 in server mode on an Ubuntu 14.04 machine and then using iperf2 from a Macbook.

Note: Iperf3 is available with a few added features. However, I occasionally want to use jperf so that I can pass along graphs to the management team. 

Building the Server

We are going to assume that you already have Ubuntu 14.04 up and running on a VM somewhere. If you need help doing that, check out this article from Frank Hinek.

Launch a SSH session or open terminal and type:

sudo apt-get install iperf

Once installed, you can run:

sudo iperf -s

The -s switch starts iperf in server mode. However, I was interested in automating this a bit more. I wanted to be able to have iperf startup when the server did, with no interaction necessary. This allows for any of our engineers to use iperf without worrying if it has been started up. To do this, run the following commands:

sudo touch /etc/init.d/iperf
sudo chmod +x /etc/init.d/iperf

These two commands create a script called iperf and make it executable. Next, we’ll load the script in nano:

sudo nano /etc/init.d/iperf

and add the following lines:

#!/bin/bash
/usr/bin/iperf -s &

then save the file. You can add any switch you would like. Run iperf –help to see a full list of switches. Finally, we need to tell Ubuntu when we want iperf to run during the boot sequence:

sudo update-rc.d iperf defaults

Ok, our server should be setup. To recap, we installed iperf from the default Ubuntu repos and automated its startup. The service should be running after a reboot, so lets move on to the client setup.

Client Setup – Mac OS X

Setting up a Mac with iperf2 is a simple task thanks to rudix. You can grab the package from this link and install it like any other application. Depending on how your security settings are configured, you may see the following message:

Security Setting on Mac

Go ahead and open the Security settings for your Mac and click ‘Open Anyway.’ Go through the standard install process and things should be ready to go in just a few minutes. Once installed, launch terminal and type:

iperf -c *serverIpAddress*

Where *serverIpAddress* is your iperf server. This will launch a single 10 second test, the results should be similar to this screenshot.

Output of iperf -cGreat! So now we have setup our iperf server and verified that we can test. From this point on, you should be able to connect to any LAN segment that has access back to your iperf server and run a throughput test. Please remember this is just a basic overview of what iperf is capable of, and with a little tuning you can hit even better speeds. Have a look at the manual for iperf here or by using the –help switch in terminal.

Note: Windows users can grab a client .exe from iperf.fr as well.

Wrap-Up

There you have it, a quick guide to setting up an Ubuntu 14.04 server with iperf2 and a Mac (or Windows) client setup guide. Overall this is quick and easy setup, and iperf is a great tool to have in your arsenal. It is a nice utility that helps troubleshoot LAN to datacenter connections and with an add-on like jperf you can even report you findings with a visual graph.

In the next week or so I will have another post detailing some of the more advanced features of iperf. If you use iperf and have any good tips or tricks, leave a comment below!

By | 2017-02-16T22:08:01+00:00 April 7th, 2015|Mac OS X, tips|2 Comments

About the Author:

I am a Network Engineer with about five years of experience. Currently I'm working towards my CCNP Data Center and training for a marathon!

2 Comments

  1. xbmcnut May 4, 2016 at 7:41 pm - Reply

    Thanks heaps. Was looking for a way to start iPerf on my Pi so I could deploy in the field without needing to RDP into it and your instructions worked a treat.

  2. Fredrik February 16, 2017 at 5:26 am - Reply

    Thanks for this. I had some real problems getting this working until I noticed it should be: #!/bin/bash instead of !#/bin/bash

Leave A Comment