I’m not going to list ALL the differences between TCP and UDP but just the fundamental ones. This article will list them along with the pros and cons of each.

Main Characterises of TCP

  • TCP is reliable  – This means it guarantees the delivery packets uncorrupted. This is all done by controlling the session with flow control, error detection, congestion control and re-transmission of lost packets.
  • TCP is a connection orientated protocol – This means a connection or socket must first be established before data can flow. Data travels both ways.
  • TCP  is ordered – TCP uses sequence numbers to ensure that packets are re-constructed in the correct order.
  • TCP is slower than UDP – Because TCP does all the above there is additional overhead needed and processing time which makes TCP slower than UDP.

Main Characteristics of UDP

  • UDP is unreliable – UDP does not guarantee delivery of packets. There is no error detection, flow control or re-transmission of lost packets. It just sends them and doesn’t care whether they arrive or not.
  • UDP is a connection-less protocol –  Data is just sent and no socket needs to be established first. Data can flow one way (as in a radio broadcast) or both ways (a 2 way phone call). It also allows you to traverse some NAT devices without using port forwarding using a technique called UDP hole punching.
  • UDP is  not ordered – UDP does not use sequence numbers therefore it cannot guarantee that they will reconstructed in the right order.
  • UDP is fast – Because UDP doesn’t have the additional overhead as TCP it is a faster protocol ideal for streaming.

When to Use TCP or UDP and Why

So now knowing the main differences between TCP and UDP you may have already worked out yourself that sometimes it is better to use UDP over TCP. TCP should be used when no packet loss is a requirement and the data must be correct free from errors. This is obviously useful when viewing web pages, Emails and most forms of networking communication we are used to. But what about video and music streaming? What about Live TV, Radio and VoIP?

Does it really matter if when you are on a VoIP call that part of that sentence you heard was lost? Do you need the VoIP system to re-transmit that one word that was lost or can you work out what it probably was? Or better still ask the person to repeat himself…If it was resent then it wouldn’t even make sense anyway. Imagine this phrase “Hi Adam my name is DARYL”. What if the packets that made up the word Adam was lost so they only heard “Hi [crackle or pause] my name is DARYL”. If the lost packets were then resent you would hear the missing word at the end and it would sound like “Hi [crackle or pause] my name is DARYL Adam”. See….there is no need to confirm packet delivery in this case therefore UDP is perfect for VoIP. The same applies for live TV or a radio broadcast. Do you really care if you missed one word in that entire song you were listening to? Would you rather listen to the rest of the song sounding as it should or be interrupted at certain intervals playing those lost words? No, it would be frustrating… With these types of data streams it doesn’t really matter if a packet or two is lost or even corrupted. By using UDP it makes the data streams faster because the overhead is less than TCP.

Print Friendly, PDF & Email