Reputation: 1990
I referred to different threads about reliable UDP vs TCP for large file transfers. However, before making the decision of choosing UDP over TCP ( and add reliability mechanism to UDP ) I want to benchmark performance of UDP & TCP. Is there any utility in linux or windows that can give me this performance benchmark ?
I found Iperf is one such utility. But when I used Iperf on two linux machines to send data using both udp and tcp, I found that TCP performs better than UDP for 10MB of data. This was surprising for me as it is well known fact that UDP performs better than TCP.
My Questions are :
Does UDP always perform better than TCP ? or is there any specific scenario where UDP is better than TCP.
Is there any published benchmarks for validating this fact ?
Is there any standard utilty to measure tcp and udp performance on a particular network ?
Thanks in Advance
Upvotes: 4
Views: 9705
Reputation: 956
UDP is NOT always faster than TCP. There are many TCP performance turning including RSS/vRSS. For example, TCP on Linux-on-HyperV can get 30Gbps and on Linux-on-Azure can get 20G+. //I think for Windows VM, it is similar; also on other virt platform such XEN, KVM, TCP did even better.
There are lot of tools to measure: iPerf, ntttcp (Windows), ntttcp-for-Linux, netperf, etc:
iPerf3: https://github.com/esnet/iperf
Windows NTTTCP: https://gallery.technet.microsoft.com/NTttcp-Version-528-Now-f8b12769
ntttcp-for-Linux: https://github.com/Microsoft/ntttcp-for-linux
Netperf: http://www.netperf.org/netperf/
Upvotes: 3
Reputation: 12866
The differences have two sides, conceptually and practically. Many documentation regarding performance is from the '90s when CPU power was significantly faster than network speed and network adapters were quite basic.
Consider, UDP can technically be faster due to less overheads but modern hardware is not fast enough to saturate even 1 GigE channels with smallest packet size. TCP is pretty much accelerated by any card from checksumming to segmentation through to full offload.
Use UDP when you need multicast, i.e. distributing to say more than say a few recipients. Use UDP when TCP windowing and congestion control is not optimised, such as high latency, high bandwidth WAN links: see UDT and WAN accelerators for example.
Find any performance documentation for 10 GigE NICs. The basic problem is that hardware is not fast enough to saturate the NIC, so many vendors provide total TCP/IP stack offload. Also consider file servers, such as NetApp et al, if software is used you may see tweaking the MTU to larger sizes to reduce the CPU overheads. This is popular with low end equipment such as SOHO NAS devices from ReadyNAS, Synology, etc. With high end equipment if you offload the entire stack then, if the hardware is capable, better latency can be achieved with normal Ethernet MTU sizes and Jumbograms become obsolete.
iperf
is pretty much the one goto tool for network testing, but it will not always be the best on Windows platforms. You need to look at Microsoft's own tool NTttcp:
http://msdn.microsoft.com/en-us/windows/hardware/gg463264.aspx
Note these tools are more about testing the network and not application performance. Microsoft's tool goes to extremes with basically a large memory locked buffer queued up waiting for the NIC to send as fast as possible with no interactivity. The tool also includes a warm up session to make sure no mallocs are necessary during the test period.
Upvotes: 2