TCP vs. UDP- What’s the difference?

If you’re not a network engineer, then the concept of TCP vs. UDP might be hard to wrap your head around. While researching the differences, you may realize that most available information about TCP vs. UDP protocols is pretty advanced. That’s why this article will explain what each protocol is in simple terms and discuss the differences between the two. 

TCP vs. UDP in short

The main difference between TCP vs. UDP is that TCP, or Transfer Control Protocol, checks for errors and resends missing data; it’s often used for emails and websites. On the other hand, UDP, or User Datagram Protocol, sends data even if nobody is getting it; it’s often used in streaming and broadcasting. 

What’s the difference between TCP vs. UDP?

TCP and UDP both use the internet protocol (IP). The protocol divides data into datagrams or packets, which are then sent from IP address to IP address. Apps are built to use either TCP or UDP based on their needs.

It might be easier to understand the main differences by comparing the two to the postal system. TCP is like sending something through the post office that requires tracking and insurance. UDP is more like sending something in an envelope with no tracking or insurance and just assuming it will arrive at its destination. 

Each protocol comes with advantages and challenges, and determining the best protocol to use depends on the situation.

TCP vs. UDP: The main differences

So, now you have a basic understanding of TCP vs. UDP, but you want to know more. Well, let’s dive into some details. Here is a brief explanation of the differences:

TCP (Transfer Control Protocol)
UDP (User Datagram Protocol)
Requires an established connection (handshake) to transfer data. When complete, the connection must be closed.
Since it’s a connectionless protocol, no handshake is required.
Best Use Cases
Best suited for situations where transfer speed doesn’t really matter, but reliability does.
Best suited for situations where transfer speed is the prime consideration.
Supports acknowledgment of received data, so the server will confirm if the data is received.
No acknowledgment of received data, so the client has no way of knowing if the data was received.
Arrangement of Data Packs
Supports arrangement, so data packets are sent and received in order.
No guarantee that data packets will arrive in order.
Error Checking
Error checking is supported with checksum. Data packets with errors are thrown out and resent from the source.
Error checking with checksum is supported, but resending them is not attempted when data packets are thrown out.
Speed of Data Transfer
Has more overhead for additional data like acknowledgment packets and error checking, so speeds are slower than UDP.
Not as many details are transmitted, so the stream of data transferred is continuous and faster than TCP.
Reliability of Delivery
Because of the arrangement of packets and error checking, TCP is reliable. You can guarantee that all data will be sent and received in order.
It’s possible that data packets won’t be sent in order or sent at all.

What is TCP? An in-depth explanation

Still a little blurry on the details? No worries, here’s a fun example: 

Imagine you walk into a sandwich shop. You have been here many times and know Jake, the sandwich guy behind the counter. You walk in, make eye contact with Jake, and say, “Hey Jake, how’s it going?” 

He responds, “Hey there, good to see you again.” You might even shake hands. You then tell Jake you want a BLT and a side of fries. He says, “Got it.” He makes the BLT. You confirm it’s the right sandwich but realize you are missing your side. He fixes the issue by giving you your fries. When the order is complete, you tell each other to have a nice day, and you leave. 

How it applies:

TCP works very similarly. TCP is connection-based, so the first thing that will happen is the client will talk to the server, and the server will respond. This interaction is known as a handshake, and it basically means a connection has been formed between the server and the client.

The data transfer will then happen, and the data packets will be sent and received in order. The recipient will acknowledge when the data packets are received. By using checksum (sort of like a digital fingerprint used to verify whether a file is identical to the original (TCP can throw out data with errors before sending them on their way. If not successfully received, they won’t get acknowledged, so the data packets will be sent again. At the end of the data transfer, the connection will be closed.

The constant communication between client and server makes TCP very reliable and successfully protects exchanged data.

Simply said, TCP ensures the data arrives intact, with no changes or errors. As a result, it is the most widely used protocol on the internet because of its reliability. It is probably used whenever you download a file, visit a website or send an email.

However, the constant communication between the client and server is also responsible for TCP data exchanges being a lot slower. Imagine how long your trip to the sandwich shop took with all that extra talking between you and Jake!

What is UDP? An in-depth explanation

Let’s revisit the sandwich shop for an example. 

This time you walk in and immediately say, “Hey, get me a BLT and some fries.” You don’t say hello to Jake or make sure that he got your order. You just assume that he heard you and will get your order right. No handshake, no greetings; you just order your food and go with it. 

Unfortunately, Jake thought you asked for a side of pie instead of a side of fries. He has no way of knowing about this error because you leave as soon as he gives you your bag of food.

How it applies: 

This is the case with UDP. UDP is a connectionless protocol, so no handshake is made. Data is transferred, and UDP doesn’t check to see if the server was ready to receive any data or if the data was even received at all.

UDP is considered a “best-effort” protocol. Packets with errors are thrown out using checksum, but any data that isn’t successfully received isn’t sent again. This is because by the time UDP can correct the error, it would be useless. For example, imagine you are playing a video game and a frame from a couple of seconds ago finally comes through; that would probably just hurt your gaming experience.

Just like your interaction with Jake at the sandwich shop this time, UDP data transfers are quick. But, unfortunately, because data packets sent through UDP do not have arrangement abilities, they can be sent and received out of order.

UDP is best used in situations where reliability isn’t as important as speed. Some of these situations include streaming music, videos, or video games. Basically, UDP is best for any situation where the data is time-sensitive, and the occasional loss of button clicks or frames isn’t a big deal. 

Ever wonder why net streaming services like Netflix and YouTube usually have a bit of buffering before the video starts? It’s because instead of UDP, which is preferred by voice and video calling (VoIP), live broadcasts, and online gaming apps, they use TCP.

The right protocol for the right purpose

As mentioned earlier, the stark differences in TCP vs. UDP make them very different from one another. They are better suited for different situations, so there is no easy way to say if one or the other is better. In fact, you can test the difference if you have Surfshark VPN as you can switch between TCP and UDP configurations of the OpenVPN protocol!

Test out Netflix’s buffered TCP implementation no matter where you are!

Get Surfshark