netcat throughput low but iperf high

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.


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?