Privacy Canada is community-supported. We may earn a commission when make a purchase through one of our links. Learn more.
TCP vs UDP
If you’ve been knocking around the internet for a while and have started looking into computer networking, you’ve probably heard of both the terms TCP and UDP. These are the two networking protocols that basically run everything on the internet and even allow you to see this page.
What is the difference though, and which one should you be using? What protocol you need to use (and is used) depends a lot on what it’s being used for. To that end, we’ll take a deeper look into the more, whether it’s deciding what to use for a DCE environment or what to use for file transfers.
What is TCP?
Otherwise known as Transmission Control Protocol, it is the backbone of the internet and the go-to networking protocol. It’s used for everything from sending emails, accessing websites, and transferring files between two different servers or locations.
So why is it so the default? The answer is pretty straightforward: TCP is a connect-oriented protocol, which means that it established a connection between nodes and maintains it throughout the connection time, in a similar way to how a VPN creates a secure tunnel. By doing this, it makes sure that all the data is being transferred before presenting or loading it, thereby making sure nothing is lost in the process.
The reason that’s important is that a lot of things will simply refuse to load if there’s a missing bit of data. Take for example all the images on this webpage; if any one of them misses a single bit of information, they will refuse to load, and the page will look like a disaster.
Advantages of TCP 📈
Generally speaking, the main advantage of TCP is that its operating system agnostic, and therefore people can use it regardless of the OS that they have. This allows an Android user and a Mac user to access the same website hosted on a Linux server for example.
The other big advantage, as mentioned above, is that it can ensure that files are fully transferred without error. This is important in a lot of applications, especially in environments where it’s high-value data and any loss can cause a large number of issues. For example, without TCP, blogging platforms would not be able to load any of their pages.
Besides that, TCP supports different types of routing protocols, and is very scalable, being viable for both company intranet and the internet at large.
Disadvantages of TCP 📉
The biggest issue with TCP is that it comes with a variety of features packaged into it that you might not necessarily want. This might not be an issue at face value, but when you consider that each additional feature can slow down the connection speed, it starts to be a problem. Essentially, your speed is forced to slow down due to features you don’t need, which can be very frustrating.
It also has several other issues, such as not being ideal for broadcasting, replacing TCP/IP protocols is not easy, there are no packaged block boundaries, so you need to create your own.
What is UDP?
User Datagram protocol is the other major, but slightly less reliable, cousin to TCP. It’s used when data loss isn’t as big of a factor compared to having a faster speed, for example with live streaming or online gaming.
This lack of reliability is both its weakness and its strength. Because it’s a much simpler protocol overall and not weighed down by the additional features of TCP, it’s much, much faster. Unfortunately, a lack of these other features means that it’s prone to data loss, which is why you might not see it with things like secure browsers.
Also, unlike TCP, UDP is a connection-less protocol, which means that it doesn’t establish a connection beforehand. It functions as if it’s an antenna that only sends signals, without actually caring who or what listens in and if the data even gets received. This is why it’s known as the “fire and forget” protocol since it doesn’t wait for confirmation of receipt like TCP does.
Advantages of UDP 👍
The main advantage of UDP is that it has a very low latency due to it being a connectionless protocol. This means it’s great for broadcasting, live gaming, and pretty much anything that heavily relies on having a fast connection and low latency connection.
It also has block boundaries, since packets are received unmanaged.
Disadvantages of UDP 👎
The biggest issue with UDP is the packet loss and unmanaged packets, which can be problematic in certain circumstances. You might get a packet that is not sent, sent twice, or packets sent out of order with no indication of which order they should be in. This is why the majority of secure email hosts use TCP instead of UDP; imagine losing parts of an important email
Also, since it’s unmanaged, there’s no congestion or flow control, so all of that has to be programmed into the application that is using it. An example is routers that allow us to connect to the internet, and in fact, they don’t often do a good job of managing UDP, especially when it comes to colliding packets.
TCP vs UDP
As we can see, both protocols have their specific niches.
When it comes to TCP, it’s best used in places where speed isn’t a factor, but data retention is. It also has a variety of different additional features, such as supporting different types of routing protocols, but that comes at the cost of speed and needing to create block boundaries, which is a bit of extra work.
As for UDP, it’s generally recommended for scenarios where speed and low latency is the most important factor. That does come at the cost of data loss and the need to create congestion and flow management in some shape or form.
Conclusion
Ultimately, the truth is that the majority of times where networking protocols come into play, you’re going to be running TCP. The main use-case for UDP is things like live broadcasting and multiplayer games, where the need for low latency outweighs the slight packet loss here and there.