How To: Test Connection Speed Between Two Machines

Purpose: as a quick diagnostic tool, sometimes it’s nice to know exactly how fast two machines can (theoretically) be connected.  I was having some slow downs on my NAS and using these command line tools, was able to determine that it was my NIC (and not my hard drives) that was causing the slow down.  I learned this from a thread at slashdot.

install nc and pv

If you are on a mac, you can use MacPorts to install this easily enough:

  • $ sudo port install netcat pv

If you are on Ubuntu, you just need to get pv installed (nc is already there):

  • $ sudo aptitude install pv

Once you have nc and pv installed, it’s really simple.  On one machine, run the following command:

  • $ nc -ulp 5000 > /dev/null

On the second machine run the following command (you need the IP address of the first machine):

  • $ pv < /dev/zero | nc -u ip.addy.of.other.machine 5000

And you should get some output with a little <=> sign moving across the screen that resembles this (static):

1.15GB 0:00:19 [ 218MB/s] [             <=>                  ]

This will show you the number of MB/s the connection is averaging; if you watch if for a bit, you can get an idea of where things stand. Here are some of the results I got between my PowerMac, PowerBook, and EEE PC:

localhost:                      218MB/s
gigabit Ethernet:               143MB/s
100MB ethernet:                 11.5MB/s
wireless (poor connection):     141kB/s

If you read the original post on slashdot, it seems you can us pv to measure a lot of other stuff as well — I haven’t played with it yet but should, one day.

One Comment (newest first)

  1. Dennis Roberts says:

    There is a utility called iperf designed to do this. It allows you to test both TCP and UDP.