How to perform network throughput tests with iperf

Network throughput got you down? Start your troubleshooting with the iperf command.

How to perform network throughput tests with iperf

As a network administrator, one of your jobs is to always make sure your network and the connected servers are working as efficiently and reliably as possible. When things go wrong, such as a network slow-down, you have to have the tools at the ready for troubleshooting. With so many tools available, where do you turn? One tool you can use on your Linux servers is iperf. 

Iperf is a command line-only tool that is used to diagnose network speed issues. Iperf measures the maximum network throughput a server can handle and reports the results back to you. If you find a server's maximum throughput is lower than it should be, it might well be possible that particular server is the cause of your network slowdown.

SEE: Choosing your Windows 7 exit strategy: Four options (TechRepublic Premium)

What you'll need

Iperf can be installed on nearly any Linux distribution. In order to make use of it, you need two Linux machines. The machines used can be either server or desktop, but chances are at least one of them will be a server--unless you have a desktop machine causing the network slowdown. 

I'll be demonstrating with a Ubuntu Server and Ubuntu Desktop instance.

How to install iperf

The first thing you must do is install iperf on both Linux machines. As iperf can be found in the standard repositories of most distributions, you can install using the package manager shipped with your version of Linux. For instance, on Ubuntu (or other Debian derivatives), the installation command is:

sudo apt-get install iperf -y

And that's it. You're ready to make use of the tool.

How to use iperf

The first thing you need to do is run iperf in listening mode on the offending server. To do that, log in to the server and issue the command:

iperf -s

You should see that iperf is now listening on TCP port 5001 (Figure A).

Figure A


Iperf is listening.

Now go to the other Linux machine and test the iperf-listening server. This is done with the command:

iperf -c SERVER_IP

Where SERVER_IP is the IP address of the iperf-listening server.

You should see two things. The first is on the iperf-listening server, where you'll see the connection has been received, the interval in which it was received, the total amount of transfer, and the bandwidth used (Figure B).

Figure B


The results of the iperf test from the iperf-listening server.

The second thing you should see is on the testing machine, where you'll see the same results, only you'll get your prompt returned to you (Figure C).

Figure C


The same results are reported.

If the throughput is considerably less than it should be, you might start your troubleshooting with that machine. 

If that basic test doesn't give you enough data, you can always customize the command. Say, for instance, you want:

  • Test on port 80
  • The test to run for thirty seconds
  • To display transfer data every two seconds

Such a command would look like: 

iperf -c SERVER_IP -p 80 -t 30 -i 2

This command should give you significantly more information (Figure D).

Figure D


Testing the web server port.

You can customize that command to test any port you might suspect is causing problems on your server/network.

For more information on how iperf can help you troubleshoot your network throughput issues, make sure to read the man page with the command man iperf. 

Also see

Bearded IT specialist setting servers in data center

Image: iStockphoto/EvgeniyShkolenko