Search code examples
tcpstreamudpethernetdata-stream

UDP/TCP performance in an ideal Ethernet communication


Consider to have a point2point Ethernet connection on which you have to stream data as fast as possible. The connection is basically ideal, with low probability of losing data, but still some data can be lost and I would like not to lose data.

So what I want to achieve is an as fast as possible connection, without loss of data. Naturally this is not possible and I have to find a trade-off. On one side I could use TCP protocol, to avoid losing data, but I would lose on performance; On the other side I could use UDP, gaining on performance but with the risk of losing some data.

Do you know what is the difference in performance between the two protocol? In particular, if the connection is ideal, can I expect to have similar speed between TCP and UDP or UDP is supposed to be much faster?


Solution

  • In an ideal network you should have similar performance between TCP and UDP depending on a few factors.

    The TCP header quite a bit larger than the UDP header. If the data in your packets is small (< 100 bytes or so per packet) this might make TCP slower. Although on modern networks it shouldn't matter.

    If your packets are largeish (1000 bytes +) the difference in header size shouldn't matter.

    If the TCP window settings are sane (i.e. the defaults) you won't need much in the way of ACK messages so TCP rate and UDP rate will be generally the same.