Should we use TCP or UDP? This is one of the questions that professional application developers might have to ponder. Most commonly, when they begin development on a future computer application that will rely on communication over the internet to operate properly. Both of these data transport protocols have their advantages, but they do come with disadvantages that turn certain developers away.
Before I begin explaining both protocols in technical detail, let me provide some insight to those who might not be familiar to this subject.
Data sent over computer networks is transferred through packets, which are of a specified size (typically 1500 bytes), which is known as the network’s Maximum Transmittable Unit (MTU). These packets are delivered to the next network and/or destination in an order defined by the respective transport layer protocol (e.g. TCP or UDP). These protocols are designed with a different goal in mind. Every networked computer application uses one or more protocols that will deliver data pursuant to the applications needs.
Transmission Control Protocol (TCP)
The Transmission Control Protocol (TCP) is designed to deliver packets and data across local networks and the internet, while doing so reliably. TCP would establish linked connections across the data path all the way to the destination, to ensure data arrives at the intended destination reliably. If the connection is interrupted the host computers at both ends would be alerted and would work to re-establish the connection. Even in the case of missing packets, TCP would keep track. Any communications sent over TCP are “handshaked”. This is both the origin and destination host computer confirming every transmission made.
So, TCP already sounds like the best protocol! Why bother using anything else? Well, you won’t feel that way after reading about the one disadvantage of TCP.
While consisting of a reliable method for data packet transmission, this causes TCP to transmit packets at a slower speed than other protocols that weren’t designed with reliability in mind, such as UDP. Let’s head over and see what UDP has in store…
User Datagram Protocol (UDP)
User Datagram Protocol (UDP) is designed to allow rapid packet transmission over local network as well as the internet. Because of this, UDP does not establish reliable connection to the destination, and does not verify if a packet was ever received by the end host or if it was received in the right order. Think about someone telling you a phone number as you are dialing it, but they are not confirming that you dialed the number as you have said. It is a simple protocol designed with speed in mind.
Thank you for reading! Please leave a question or comment below, and share this article with others.