When troubleshooting network related issues and suspect the network at fault it can be challenging at times to finding supporting evidence. One great tool for on-the-spot testing of network bandwidth is Iperf. It’s a simple, yet powerful tool that can provide visibility on network performance metrics such as bandwidth, latency (delay), jitter, and packet loss. While I prefer using the program via the command prompt be aware there is a GUI version called Jperf too.
Today we’ll be using Iperf to measure network performance in terms of bandwidth, but before we get started its worth noting the unit of measurement for file size and transfer rate are different. Files are typically stated in bytes, while transfer speeds are expressed in bits!
When testing bandwidth performance with Iperf, what we’re actually testing is maximum TCP bandwidth at the transport layer (L4). Lots of applications use TCP as the transport protocol, include HTTP, SMTP, FTP, etc. Unlike UDP (another commonly used L4 protocol) TCP is a reliable, connection-oriented protocol with built-in mechanisms for connection established, acknowledgement, and termination. This connection management is why TCP is used (and not UDP) to test bandwidth. If UDP was being used, any lost packet(s) would go missing from the traffic flow and not be resent. Simply put, TCP has a means to detect and retransmit any lost segments.
The following examples use a combination of Microsoft Windows 7 (64-bit) and XP (32-bit). Also, the default TCP window size is used but keep in mind you can adjust window size and effect bandwidth results. To use the program, open the command prompt and navigate to the directory where Iperf.exe is located (Start>Run and type cmd, then press enter). Once in the command prompt you can change directories via the cd command. As you can see I am using Iperf version 1.7.0.
Before we get started I want to quickly discuss Iperf’s architecture. It uses a client/server model, where traffic is initiated from the client and traverses the network (LAN and/or WAN) to the server. So when testing bandwidth in both directions we’ll need to run the test twice, once in each direction. Also, by default the server will listen for the client on TCP port 5001 but like most options this can be changed. Note the ability to change TCP ports in Iperf opens avenues to use it for testing open TCP ports. Thus if a firewall or filtering device is blocking port(s) on a segment of your network you can use Iperf to verify this.
To get started we’ll setup the server side first, entering iperf -s -i 1. The -s command designates this workstation as the “server” and the -i 1 command sets the console output interval to one second.
Now to start a test, go onto the client and enter iperf -c
Now if we look back at the server you’ll also see similar output as the client. The test output shows Iperf was able to transfer 110MBytes of data at a rate of 92.3Mbits, from client to server.
Now to run the test in the opposite direction simply reverse the commands on the client and server. To stop Iperf on the server or client side enter Ctrl+C.
A key point to remender when testing bandwith with Iperf is that it consumes all bandwidth available between clinet/server via TCP, regardless of LAN, WAN, or VPN connection. Thus if traversing a WAN link you can quickly saturate the link, potentially effecting user/application experience!
Below is another Iperf test in the same environment as above but this time the client is wirelessly connected to the LAN. As you can see below, the wireless media has a big impact on bandwidth performace.
One last example is of a test performed over a VPN connection. As you might imagine, the bandwidth performace is considerably slower which is attributable to factors such as encryption and Internet speed.
Also, you can use a protocol analyzer such as WireShark on the client/server to verify various aspects of the test, such as L4 protocol, Src/Dst ports, packet size, etc.
As you can see, Iperf is a simple to use tool that can quickly provide bandwidth performance metrics over a given link. Instead of guessing or suspecting network performance is the issue, with Iperf you can now know!
Lastly, the examples above use the basic options but keep in mind you can change or add numerous options to your testing. Below is the output of the help command to show you the various things you can change.