The Sys admin's daily grind: Nttcp

Under the Weather


Some weather forecasts give you the temperature and a windchill adjustment, and a similar forecast for bandwidth would be helpful. If you feel the bandwidth is too low - and it always is - you need some kind of measuring instrument to reveal the truth.

By Charly Kühnast

If you are a DSL customer and want to find out whether you really are getting what you pay for, it makes sense to measure the actual bandwidth between two machines. If I set up an encrypted VPN tunnel, I'm obviously interested in the effect that encryption has on the transmission speed.

Is the new antivirus proxy spoiling my customers' surfing experience? Does the firewall appliance really provide the "wirespeed" the vendor promised? How fast is my wireless LAN with a massive concrete wall separating two access points? Is the PowerLAN connection between my laptop and my Linux video recorder fast enough for streaming? Nttcp [1] answers all of these questions.

Nttcp

To measure the bandwidth between two machines, you need to install the program on each machine. Thankfully, most distributions include a package. One partner sends data and the other receives. Both Nttcps transfer 2048 TCP packets of 4KB each by default, which is a total of 8MB. The transfer speed is calculated by investigating the packet run time.

Forecasting

Start by typing nttcp -i on the receiving machine. It would be possible to use Inetd or Xinetd, too, but the program's author, Elmar Bartel, advises against this for security reasons. The danger of a denial-of-service attack is far too great. Next, it's time to launch Nttcp on the local (transmitting) machine:

nttcp -T targethost

The -T parameter adds column headers to the output to format the output as shown in Figure 1. In this example, the two machines are connected by a 34Mb line with a firewall at each endpoint. Because I'm not the only user, the measured speed of approximately 28Mb/s is fine.

Figure 1: The 28Mb/s speed I measured on a 34Mb line using Nttcp is fine because two firewalls are in the transmission path.

Nttcp accepts a couple of other parameters. The most important parameter is probably -r, which reverses the data transmission direction, sending the data from the remote machine to the local machine. If you have ADSL, this approach has no alternative because the upstream and downstream bandwidth will be different.

If you prefer to use UDP instead of TCP, just set the -u flag. You can also manipulate the volume of data you send. If you prefer to transmit 1024, 8KB blocks, instead of 2048, 4KB blocks, try the following:

nttcp -n 1024 -l 8192 targethost

Bandwidth is like the weather. Knowing the temperature doesn't necessarily make you feel more comfortable.

INFO
[1] Nttcp: http://freeware.sgi.com/source/nttcp/
THE AUTHOR

Charly Kühnast is a Unix System Manager at the data center in Moers, near Germany's famous River Rhine. His tasks include ensuring firewall security and availability and taking care of the DMZ (demilitarized zone).