Upgrading to Gigabit and Testing it with netcat

4 minute read

When I setup the network connection to the room in my apartment I bought a 100 Mbps switch, choosing not to spend the extra $20 for gigabit. Today I’m upgrading to a gigabit switch, having realized that the 100 Mbps switch is what’s limiting local traffic between my desktop and server.

The other part of my motivation comes from setting up a new ZFS mirror on my desktop and wanting to transfer data off my sever to the mirror over the network. I then plan on streaming media from the desktop to the server, which is being repurposed to a HTPC (with a much smaller SSD instead of the failing 2TB drive in it now).

Before I swapped in the new switch I wanted to test the network transfer speeds, something I have never really done before, just so I can see the speed increase associated with the new switch.

I found this guide helpful, and we’re basically following along here.

Netcat

To test the 100 Mbps connection we’ll use netcat. I am testing from my desktop to my server. We’ll need netcat on both computers we want to test. On the server (which runs Ubuntu 12.04) we’ll need to install the netcat-traditional package:

$ sudo apt-get install netcat-traditional

We’ll also need netcat on the desktop (running Arch linux). The package is called gnu-netcat:

$ sudo pacman -S gnu-netcat

100 Mbps Test

To start we’ll need to setup the listening part of the connection on the server:

$ nc.traditional -v -v -l -n -p 2222 > /dev/null 
listening on [any] 2222 ...

The flags here get us a very verbose output (the two -v options), -l sets up listen mode, -n tells us we want to user numeric-only IP addresses, not DNS, and -p 2222 tells netcat to listen on port 2222. > /dev/null redirects all the traffic we send to /dev/null.

Then, on the desktop, we can send some traffic to the server:

$ time yes|nc -v -v -n 192.168.1.7 2222 > /dev/null
192.168.1.7 2222 (EtherNet-IP-1) open
^CExiting.
Total received bytes: 0
Total sent bytes: 111M (110594432)


real    0m9.398s
user    0m1.960s
sys 0m0.623s

This uses time to track how long we send traffic for. You’ll want to stop this after about 10 seconds by hitting ctrl+c. (If you don’t it’s no big deal, you might just actually wrap the integer count on received traffic, making it more difficult to calculate speeds.) On the server we’ll see a message like this:

connect to [192.168.1.7] from (UNKNOWN) [192.168.1.112] 43341
 sent 0, rcvd 110498864 : Connection reset by peer

Now we just need to calculate our resulting speeds. You’ll notice in the sent traffic the units are bytes. So we’ll take our 110498864 bytes and multiply by 8 bits/byte and divide by the 9.398s to get 94061599.5 bytes/s, or 94 Mbps.

This is in line with the 100 Mbps switch that I have right now. Let’s swap in the Gpbs switch.

1000 Mbps Test

The switch I got was this Netgear 5 Port Gigabit switch from Newegg. They were running a deal for $19.99 with mail in rebate, so I jumped on it.

The switch indicates that both lights surrounding the ports will illuminate with gigabit traffic, and upon plugging everything in, they are both blinking, so I expect to see gigabit speeds.

Running a test we get the following results:

$ nc.traditional -v -v -l -n -p 2222 > /dev/null 
listening on [any] 2222 ...
connect to [192.168.1.7] from (UNKNOWN) [192.168.1.112] 47939
 sent 0, rcvd 840984576
$ time yes|nc -v -v -n 192.168.1.7 2222 >/dev/null
192.168.1.7 2222 (EtherNet-IP-1) open
^CExiting.
Total received bytes: 0
Total sent bytes: 870M (869988352)

real    0m10.207s
user    0m9.040s
sys 0m5.110s
>>> 840984576*8/9.780/1000000.
687.9219435582822

A solid 687.9 Mbps, much better than our previous 94 Mbps. Not exactly 1000 Mbps that the switch can do, but I’m much happier with it. Perhaps something else is limiting me now, though I’m not sure what it is, as the router is also gigabit wired.

Repeatability

Just to check repeatability I tried the 100 Mbps switch connection a day after this first test, below are the results:

$ nc.traditional -v -v -l -n -p 2222 > /dev/null 
listening on [any] 2222 ...
connect to [192.168.1.7] from (UNKNOWN) [192.168.1.112] 47495
 sent 0, rcvd 251576544 : Connection reset by peer
$ time yes|nc -v -v -n 192.168.1.7 2222 >/dev/null
192.168.1.7 2222 (EtherNet-IP-1) open
^CExiting.
Total received bytes: 0
Total sent bytes: 252M (251669216)

real    0m21.381s
user    0m5.053s
sys 0m1.310s
>>> 251576544*8/21.381/1000000.
94.13088031429774

So a pretty repeatable 94 Mbps.

On the gigabit switch I get some more variability, repeating the test a week or so after installing it I got as much as 728 Mbps, which makes me suspect other network traffic on the router is limiting what I can get, though I don’t know enough about a router handles traffic to all it’s ports to know if that’s a true statement.

Conclusions

I have put a lot of traffic over the new switch in the past week since I installed it. I’m definitely appreciating the upgrade in speed. If you know your switch is limiting your speeds and want a cheap upgrade to boost your local network speeds I can’t recommend a gigabit switch enough, and Netgear products have always done well for me.

Updated: