Both for my work and private tinkering I often have the need to do bandwith tests over a network connection. Sometimes it’s troubleshooting ethernet connections up to 10Gbit, sometimes it’s testing an internet line, a WiFi link or actual real-world VPN throughput potential. Whatever the case I often need a good mutli-platform bandwith testing tool.
For this I use a program called “iperf” and while it can be a bit daunting at first with a little know-how it’s actually pretty easy! Read on to find out how to use it in a variety of situations:
Iperf consists of one executable which can run in both “client” or “server” mode. Both allow options to be specified to direct what you wish to have tested.
Downloading Iperf
Ubuntu/Debian based Linux
Red Hat based Linux
Windows based OS
Android
Single connection bandwith test
Server side
iperf -s -w 1MB
- -s enable the server side
- -w TCP Window size, most often the default is 64KB which is a bit small to test actual bandwith, especially on high bandwith connections. I have found 1MB to be a good size to try and saturate links.
Client side
iperf -c 10.10.128.254 -w 1MB -r -t 20
- -c 10.10.128.254 specifies that you wish to run in client mode and want to connect to IP/DNS name of said server
- -w 1MB Again the TCP Window size the client should use
- -r Do a sequential bi-directional test. This instructs iperf to test traffic both ways, in 2 tests not running at the same time
- -t 20 Instructs each test to last 20 seconds
Multiple connection bandwith test
Server side
iperf -s -w 1MB
- -s enable the server side
- -w TCP Window size, most often the default is 64KB which is a bit small to test actual bandwith, especially on high bandwith connections. I have found 1MB to be a good size to try and saturate links.
Client side
iperf -c 10.10.128.254 -w 1MB -r -t 20 -P 10
- Using the same options as above we add
- -P 10 Creates 10 parallel streams
Simultaneous upload&download
Server side
iperf -s -w 1MB
- -s enable the server side
- -w TCP Window size, most often the default is 64KB which is a bit small to test actual bandwith, especially on high bandwith connections. I have found 1MB to be a good size to try and saturate links.
Client side
iperf -c 10.10.128.254 -w 1MB -d -t 20 -P 10
- Using the same options as above we add
- -d Tells the test you wish to run it in simultaneous upload & download test mode
Results you ‘should’ achieve
The above should give you most options you would use under normal circumstances. There are several more, like switching between TCP or UDP, but you can find those by checking the help of the application itself.
Results you should achieve, a hard subject. A lot of things can influence the results you are going to see. From network chip, to cabling, chip, drivers, switches, etc. So always try and interpret where your ‘lower’ speed is coming from. In IT, whenever something doesn’t do what you could/should expect for it, it has to have a logical reason
First we need to talk about Mbps, MB, Mbit and such. Very often I see this done wrong and to be frank, this irritates me. 😉
Mbit and Mbps mean the same. Mega (Capital M) bits per second. 1 byte is 8 bits. So let’s say we have an internet connection of 1Mbit that would mean you could achieve 1024Kbit or 1Mbit, 128KB/sec or 0,125MB/sec.
Captical M means mega, small m means micro. Be correct! “bps” stands for bits per second. So 100Mbps stands for 100 Megabit and 100MBps stands for 100 MegaBytes per second. A big difference! Most often Mbps is used for bits and to describe Bytes you use MB/sec.
Now a connection will never give you 100% of the line or wire speed. There is always overhead because of TCP and other protocols. But at all times around 92,5% should be achievable.
If we take a Gigabit Ethernet line as an example this is 1000Mbit/1000Mbps, 125MB/sec.
Okay, so what do we achieve on common connections:
1Gigabit or 1000Mbit will give you a max net result of around 945Mbit at maximum, but it should always deliver around 900Mbit. 900Mbit translates into 112,5MB/sec.
100Mbit will deliver you around 11,25MB/sec and 10Mbit around 1,125MB/sec. This is all calculates quite easily.
Hopefully that will help you figuring out what you should be achieving. If your internet provider says they will give you 60Mbit for instance, this should translate into download speeds of around 7MB/sec in real world throughput while downloading something. If you don’t, try and figure out where the bottleneck may lie (Your WiFi?) and if there is none on your side, harass them about it! 😉
With Fedora 20 at least, it's just a matter of doing 'yum install iperf' without any special repository actions otherwise. It's in the default repo.