10

I was testing the throughput between two pcs, connected on the same router, one with 100mbps lan, the other with 54mbps wifi.

Here is the interesting part:

  • using nc, I get 2.63MB/s when sending from A to B (measured with pv -r|nc ipB)
  • using iperf, I get 23MB/s which is pretty much ok.

What could be wrong with nc?

The OS is ubuntu 11.04 for both.

Caleb
  • 11,583
  • 4
  • 35
  • 49
george
  • 101
  • 1
  • 3
  • I have a very similar question that you might find useful: [Measuring network throughput with netcat vs. CIFS/SMB transfer rates](http://serverfault.com/questions/211410/measuring-network-throughput-with-netcat-vs-cifs-smb-transfer-rates) –  Aug 02 '11 at 16:23
  • See also https://unix.stackexchange.com/questions/48399/fast-way-to-copy-a-large-file-on-a-lan – rogerdpack Sep 24 '18 at 18:59

4 Answers4

6

The scale sound about right for NetCat not supporting TCP Windowing. If you do a tcpdump on the interface while the two benchmarks are running I'm guessing you'll see this pattern for NC:

  1. Packet ->
  2. <- Ack
  3. Packet ->
  4. <- Ack
  5. Packet ->
  6. <- Ack
  7. Packet ->
  8. <- Ack

And this pattern for IPerf:

  1. Packet ->
  2. Packet ->
  3. Packet ->
  4. Packet ->
  5. Packet ->
  6. Packet ->
  7. <- Ack
  8. Packet ->
  9. Packet ->
  10. Packet ->
  11. Packet ->
  12. Packet ->
  13. Packet ->
  14. <- Ack
  15. Packet ->
  16. Packet ->
  17. Packet ->
  18. Packet ->
  19. Packet ->
  20. Packet ->
  21. <- Ack

By Windowing TCP segments you can get much higher throughputs since you don't have to wait for the Ack after every packet, only after every segment.

sysadmin1138
  • 131,083
  • 18
  • 173
  • 296
  • 1
    I can confirm I see the same issue on my 10g setup. `dd/netcat` is reports lower bandwidth as compared to `iperf`. `dd/netcat` report about 3Gb/s whereas `iperf` reports 9Gb/s. – Vince Sep 14 '15 at 17:08
  • Care to check if your guess is correct here? :) – rogerdpack Sep 24 '18 at 18:57
  • My Windows 10 box using netcat was just sending 8KB packets with a TCP window size of only 8KB, resulting in awful performance over gigabit. Happens in both nc and ncat, but SSH gives 90+ MB/sec between the same machines. There is an old bug in windows sockets that causes this: https://support.microsoft.com/en-us/help/823764/slow-performance-occurs-when-you-copy-data-to-a-tcp-server-by-using-a – Orion Lawlor Mar 02 '19 at 00:33
1

It isn't netcat. With iperf I get

[  3] local 192.168.1.201 port 55610 connected with 192.168.1.200 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   394 MBytes  39.4 MBytes/sec

With nc -l -p 1852 > /dev/null and cat /dev/zero | pv -r | nc 192.168.1.200 1852 I get

[  34MB/s]

(Fluctuates between 30 and 60.)

What data are you feeding netcat?

Mark Wagner
  • 17,764
  • 2
  • 30
  • 47
0

Just because your wireless card is capable of 54mbs connections doesn't mean you are going to get that throughput. In particularly, it sounds like you have 802.11g which has an Achilies heel. As long as **every* wireless device it is talking to is also g it will go fast, but as soon as even one device that is only b speed capable, it has to use the lowest common denominator to talk to all devices.

You might try opening a terminal on the machine with wireless and running iwconfig. Look for the Bit Rate= field and see what speed you are actually connected at.

Caleb
  • 11,583
  • 4
  • 35
  • 49
0

Beware about iperf units. This is a common pitfall: iperf often display in Mbit/s instead of Mbyte/s.

Gregory MOUSSAT
  • 1,737
  • 2
  • 25
  • 48