In this article we shall see how to use iperf to very easily test the maximum throughput in network bandwidth between a server and a client. Iperf is a free and helpful tool, available on multiple platforms, to troubleshoot network performance.
It is not uncommon getting error reports similar to “the network is slow“, which is the assumed cause of various perceived problems. While it definitely sometimes is bandwidth congestion, my experience is that it most often is not the network being “slow”, but some other harder-to-spot factor being the bottleneck (disk, cpu, application logic or combinations). Being able to quickly test the physical bandwidth in such situation is often useful.
Iperf is an open source tool to test network bandwidth. A pre-compiled Windows version is available from Softpedia. The tool is a 110 kB single exe file with no installation. Place a copy at server and one copy on the other end, which could be an ordinary PC. One part will be representing a server which sends data to a client. The iperf tool could be used in virtual servers to test out the virtual network both internally between virtual machines and between VMs and the rest of the network.
Some confusion in the terminology exist, as the part sending the data (typically a server) is called the iperf “client“, and the computer receiving the data (typically a client computer) is called the “server“, which is reversed as how many client-server applications work.
On the PC side, download the iperf file and from the command line start with the following options: (Note that all options are case sensitive.)
-s (start the “server” which will receive the data)
-w 32768 (change the TCP window size to 32 KB, default is a bit low 8 KB)
iperf.exe -s -w 32768
The tool will listen on TCP port 5001 at default. Depending on your Windows firewall settings you might have to accept incoming connection to this port. If wanted you can change the listening port with -p (lowercase).
On the server (which could be physical or virtual) we will now start the iperf tool with different settings. Make sure the same executable file is available locally and use these settings:
-c IP-ADDRESS (the IP address to the other computer)
-w 32768 (to raise the TCP window size)
-t SECONDS (the number of seconds to send data)
-P 8 (the number of alternate streams to increase throughput, must be uppercase P)
iperf.exe -c IP -P 8 -t 30 -w 32768
When the test has been running for “t” seconds, perhaps 30-60 seconds at least, we will see the network result.
Observe the final line, the [SUM] and the rightmost column for the average throughput in Mbit per second. If wanted the -f option could be used to express the values in bits, kilobits or gigabits instead. When doing longer tests, like running the tool for several minutes you could use -i option to display results every X second.
You could experiment with the -w for TCP Window Size and the -P for parallel datastreams to find the optimal throughput in your situation.
If you want to test the full duplex network performance, that is, transmitting and receiving at the same time, just add the -d option at the client.
iperf.exe -c IP -P 8 -t 30 -w 32768 -d
This will monitor the bandwidth capacity in both directions simultaneous and also put a higher stress on the network interface card, CPUs and the network devices between the client and the server. In the test above we can see that the servers and the network are delivering great full duplex throughput with over 870 Mbit/s both incoming and outgoing.