I have a gigabit network set up in my house and a few Ubuntu based boxes. Out of complete curiosity I would like to check the speed between the two boxes. I am not having any problems with speed or anything, it really is just the geek in me that is curious. Plus maybe the results will let me know if there is room for improvement, or that I have something configured wrongly.
So how do you properly test the network speed between Ubuntu boxes?
I use
iperf
. It's a client server arrangement in that you run it in server mode at one end and connect to its from another computer on the other side of the network.One both machines run:
We'll start an
iperf
server on one of the machines:And then on the other computer, tell
iperf
to connect as a client:On the client machine, you'll see something like this:
Of course, if you're running a firewall on the server machine, you'll need to allow connections on port 5001 or change the port with the
-p
flag.You can do pretty much the same thing with plain old
nc
(netcat) if you're that way inclined. On the server machine:And the client can pipe a gigabyte of zeros through
dd
over thenc
tunnel.As demod:
The timing there is given by
dd
but it should be accurate enough as it can only output as fast the pipe will take it. If you're unhappy with that you could wrap the whole thing up in atime
call.Remember that the result is in megabytes so multiply it by 8 to get a megabits-per-second speed. The demo above is running at 944mbps.
Same as Oli's recommendation for iperf. Just want to add several points:
-t <seconds>
changes the test length.-P <n>
changes the number of simultaneous connections. For example,iperf -c [target IP] -P 10 -t 30
tests 10 connections together for 30 seconds and gives aggregated results along with 10 separate connection speeds.wget
, make it executable withchmod
, and you can directly run the binary. It works perfectly.I found that, using default settings, the single connection speed fluctuates quite a bit. However, with 3+ parallel connections, the results are more consistent on my gigabyte switch. (consistently @ 910-920Mbps)
The command below does not require additional packages but SSH access:
Example output:
The command prints a 3GB (1000^3 bytes) dummy file full of zeros to stdout on the remote server, which is printed (transferred) via SSH to stdout of the local server and then locally piped to
/dev/null
(i.e. ignored). You can even see the progress of the test while executing it.Certainly not as precise as other tools but my use case was to debug a backup process where I wanted to test if network speed was the issue without installing additional packages.
Using this script you can easily test connection speed between your machine and some remote host. Example of using:
user@remote_host
is your destination host (you must have ssh-access to this host)80000
is the approximate size of test file (in kbs), which will be received to the remote host. It is not mandatory argument.If you want to test your Ethernet LAN at a lower level you can use Etherate which is a free Linux CLI Ethernet testing tool:
https://github.com/jwbensley/Etherate
Throwing it in the mix as tools like iPerf (which are very good!) operate over IP and TCP or UDP. Etherate tests directly over Ethernet / OSI layer 2.
There are also some other nice command-line tools for bandwidth benchmarking between two hosts:
nuttcp
nepim
goben
as I pointed out in my comment at best answer, that solution is not good enough be cause client/server is not optimized to ... squeeze every bit of speed
my solution:
make a ramdisk on both sides (therefore, you aren't limited by storage speed and I suggest you made them with ramfs not tmpfs, so they won't go in swap ... just be careful not to leave at least 512M free memory for system, this is REQUIRED if you have giga ethernet, at that speed even SSDs may slow things down) install apache on server, then create a link to ramdisk, create few large files on ramdisk (100M-1G, you can create them with dd from /dev/random or copy if you have some at hand) then go client side and download them (also on that side's ramdisk) with an advanced download program, I used
lftp
oh well, difference was major, from 75mbps reported by iperf and 9.5M/s netcat
to 11.18M/s with my solution:
It's easy plug your computer on the first box, plug the other box to the first box. Then from your computer ping the first box save the result, ping the other box and do the substraction.