TCP and UDP are the protocols used to determine how data is to be exchanged across the internet. Both of them are built on the Internet Protocol (IP), with many similarities in common.
However, they each have some unique differences, rendering them appropriate for several different purposes.
You will find these two protocols are the two protocols most commonly used by all internet users in everyday life to send data packets from their machines to the destination.
To fully understand the differences between TCP/ UDP protocol, you need to have a good understanding of the IP protocol on which they are both based.
In this guide, you can learn everything you need to know about the protocols. In the end, you will understand the difference between TCP and UDP protocols, and where it is most often used.
What is the IP Protocol?
Every device which connects to the internet will have an assignment of a unique IP address made up of numbers and decimals.
In the same ways as a street address, an IP address enables a computer to know where to send or return information across the internet. (Read How to Change Your IP Address)
The function that enables them to do this is termed routing, and it is the routing of data that allows us to have internet.
The IP protocol splits data into small pieces, and these are called either datagrams or packets. Continual streams of data are comprised of these data packets. So, every time you click on a webpage, a signal or packet leaves your machine to the web page you are currently on. It is the IP address that makes sure these packets know where to go.
Along with the data contained in the packets, the segments include a header, and it is the header, where all the routing information is stored, such as the IP address.
Packets leave your computer and make their way to a ‘Gateway.’ The gateway being another computer which can see portions of IP addresses as they travel around the internet.
If a packet has a destination IP the gateway doesn’t recognize, it continues up to the next until it reaches a gateway that acknowledges it. This works in the same way as the postal service. Portions of the post may know the city, while others know the area of the city, and the remaining ones know the streets.
Once the gateway sees the destination IP is on its domain, the gateway will forward the packet to the computer whose IP is listed in the packet header.
One thing many users don’t know is that all data may not go via the same path to reach the destination; furthermore, many packets may not even travel or arrive in order.
Each time you are on the internet, you will use the IP protocol. As an aside, the IP protocol doesn’t care the type of data it is exchanging, so it will be used for to pass data ranging from text, images, video, music, email or when you are gaming and much more.
What you may see is that most applications use IPv4, which is the fourth incarnation of the IP protocol. However, as the number of devices on the internet increases, the pool of IPv4 addresses decreases.
IPv6 is the next and already runs in parallel in specific scenarios. It will replace IPv4 and is very different in looks and operation, which is way beyond the scope of this guide.
What is UDP and TCP
TCP/IP came before UDP and stands for Transmission Control Protocol. TCP is a connection-oriented protocol, which computers use for communication across the internet.
TCP provides error-checking and guarantees data delivery along with the packets being delivered in the order they are sent. (Read How To Stop DNS Hijacking)
Once IP breaks up the data into packets, it is the function of TCP to organize these packets as they arrive. Upon arrival, the files will be reassembled by computer or device at the destination into their original form.
- TCP expects both ends to communicate to establish a connection and send data.
- TCP guarantees the recipient receives packets in order using the sequence numbers embedded in the header.
- The recipient then sends an acknowledgement to the sender for each packet, confirming receipt.
- Any packets not acknowledged by the recipient will be resent.
- The packets will be checked for errors using a checksum, also included in the header.
- TCP will assure data integrity that is sent across the internet with no missing parts or modifications.
- TCP is beneficial for a vast number of applications and is the most common protocol in use.
- One downside of the transmission control protocol (TCP/IP) connection-oriented protocol is all the forwarding and acknowledging of connection-oriented communication slows TCP down.
- Should a packet go missing, then the full process has to wait until the missing packet is resent from the sender.
You may think this can take a while yet you may be surprised how fast things happen, although a millisecond here or there can make a difference if they keep mounting up.
What is UDP
User Datagram Protocol (UDP) is a connectionless protocol, and thus assumes error-checking and flow control and confirmation of UDP packets are not required.
Instead, UDP (User Datagram Protocol) continuously sends datagrams to a recipient and has no concern if they receive them or they don’t.
A datagram and a packet are much the same things, albeit with different control functions. UDP is also built on the IP protocol and works like TCP, yet with less going on in terms of flow control, UDP packets are much smaller and faster to reach their destination.
UDP doesn’t need any confirmation from the receiver that it has received each packet, and any loss on the way is lost, and the sender won’t know to resend them. One scenario you may see this is a skipped frame on Netflix.
UDP does not possess sequence numbers like TCP and can arrive out of order. However, they do come with a checksum to make sure they are protected against corruption or modification
UDP is used for speed more than for integrity and error correction.
Difference Between UDP and TCP
Here are some uses where TCP and UDP are advantageous in daily use:
UDP is suited where you need speed and efficiency.
- Video Streaming
- Online Gaming
- Live TV broadcasts
- Domain Name System (DNS)
- VoIP – Skype etc.
- TFTP file transfers
TCP is used where you need reliability
- FTP – File transfer protocol
- SSH data communications
- Using the Internet (HTTP and HTTPS)
One other place you may see TCP and UDP mentioned and in use is with a VPN. In many VPN clients, users can choose between Open VPN over TCP or OpenVPN over UDP. While you may not notice too much difference in use, you may see a slightly better increase in speed using UDP. (Read Best VPN Services Guide)
Besides this, UDP and TCP operate with different ports so that one may get around a Firewall easier than another. For instance, OpenVPN over UDP may be blacklisted, so OpenVPN over TCP packets may get around the restrictions.