Hack 36. Estimate Network Performance
Just how quickly can you squeeze data through your access point?
Many people use online tools such as DSL Reports' Speed test (http://speedtest.dslreports.com) to estimate the performance of their Internet connection. When run from a machine directly connected to the Internet, this can give you a fairly good indication of your upload and download capacity.
This tool becomes less useful when trying to estimate the available bandwidth on other networks. For example, on a large wireless network, it is useful to measure the actual capacity of a network link regardless of the speed of the Internet connection. One useful utility for measuring performance is iperf, a simple, freely available tool that will run on Linux, BSD, Mac OS X, and even Windows. You can download it online at http://dast.nlanr.net/Projects/Iperf.
In order to measure performance, it needs to be used in pairs, with one instance at either end of a link. On one end of the link to be measured, start up iperf in server mode:
server:$ iperf -s
Note that it doesn't matter which end is used as the server, as both upload and download speeds will be tested. On the other end of the link, run iperf in client mode, specifying the server to be tested:
testmachine:$ iperf -c testmachine -r ----------------------------------------------------------------------- Server listening on TCP port 5001 TCP window size: 32.0 KByte (default) ----------------------------------------------------------------------- ----------------------------------------------------------------------- Client connecting to testmachine, TCP port 5001 TCP window size: 32.5 KByte (default) ----------------------------------------------------------------------- [ 4] local 10.15.6.33 port 50421 connected with 10.15.6.4 port 5001 [ ID] Interval Transfer Bandwidth [ 4] 0.0-10.2 sec 2.95 MBytes 2.43 Mbits/sec [ 4] local 10.15.6.33 port 5001 connected with 10.15.6.4 port 60977 [ ID] Interval Transfer Bandwidth [ 4] 0.0-10.0 sec 3.09 MBytes 2.60 Mbits/sec
By default, iperf uses port 5001 for its communications. If this port is in use, you can specify a different one with the -p switch on both sides:
server:$ iperf -s -p 30000 testmachine:$ iperf -c livia -r -p 30000 -------------------------------------------------------- Server listening on TCP port 30000 TCP window size: 32.0 KByte (default) …
If you don't want just anyone connecting to your iperf server, don't forget to kill the server side with a Ctrl-C when you are finished making your measurements.
In addition to simple TCP testing, it can also manipulate various TCP parameters, test UDP streams, use multicast or IPv6, and even use a custom defined data stream for testing. Running with the defaults should give you a good basic idea of how much data you can cram through your connection, particularly if it is not being used by any other clients. For more complete details on some of the testing this flexible tool can do, see the online documentation at http://dast.nlanr.net/Projects/Iperf/iperfdocs_1.7.0.html.