If you usually fiddle with your router or mess about with firewalls, you’ve probably noticed these two protocols: TCP and UDP. If you’ve ever wondered what do they mean and what are the differences between the two, then you’ve come to the right place.
TCP/IP is named after the two protocols which originated this protocol suite: the Transmission Control Protocol and the Internet Protocol. These protocols handle communications over the internet and over local networks between devices by allowing them to deliver and receive ordered, error-checked streams of information packets.
UDP stands for User Datagram Protocol and allows programs to deliver information quicker. UDP lets programs deliver packets faster because it does away with error-checking.
What do These Protocols Have in Common?
These two protocols, TCP and UDP, are used for sending and receiving packets over the internet and local networks. Packets are essentially small pieces of data.
Both TCP and UDP work atop the IP protocol. This means that regardless of whether you’re using TCP or UDP, the packet is being sent to an IP address. Both types of packets are treated similarly.
Even though there are a few more protocols that work atop the Internet Protocol, TCP and UDP are the standard and the most commonly used.
How Does TCP Work?
Whenever you try to open a web page with your web browser, your computer sends a TCP packet to that web page server’s address, asking for the server to send you the web page back.
If the server accepts this request — i.e. if everything is working properly —, it then sends you a stream of TCP packets. Your browser then puts these TCP packets together and presents them nicely to you in the form of the web page you were trying to access.
This is how almost everything works on the internet. Whether you’re trying to access a link, or posting a comment online, you’re sending TCP packets to the server and receiving them back.
TCP is very reliable. Every packet is tracked, so no data is lost or ends up corrupted during transit. When using TCP, your downloads won’t become corrupted, regardless of any hiccup in the connection.
In order to work this way, TCP assigns a number to each packet, ordering them. Then, TCP error-checks the packet by asking the receiver to send a message confirming the packet’s reception. If the message sent by the receiver is not the correct one, the packets are resent until they’re received properly.
TCP is the most used protocol on the entire internet.
How Does UDP Work?
Almost everything that applies to TCP also applies to UDP. The main difference is the error-checking part. UDP does not error-check. Why? Because error-checking introduces latency to the equation.
With UDP, packets are only sent to the receiver. There’s no confirmation message being sent back. Instead of waiting for a confirmation, UDP just keeps sending packets away.
Of course this means that packet loss is a real possibility with UDP, but it makes the process much quicker.
UDP is mainly used whenever speed is the main desirable factor and it doesn’t matter if you end up losing a packet or two. It is the go-to protocol when it comes to online gaming and live streams.
This is why when you’re watching a live stream and you lose your connection, the video will skip to what’s current being streamed when you get your connection back, instead of trying to recoup the lost part of the stream. The negative side is that if you do suffer from packet-loss, video or audio might be distorted for a couple of seconds or more.
The same applies to online gaming. High packet loss causes other players to apparently teleport across the map. Asking for the lost packets serves no purpose — the game isn’t waiting for you, what matters is what’s happening at the moment and not what happened a while ago.
Which one you should use? Deciding on TCP or UDP is up to the program’s developer. If the program he’s developing needs speed above everything else, then UDP is the way to go. Otherwise, or if you need error-checking, TCP is the standard.
Luckily, these kinds of doubt do not affect most users. Even if you’re setting your router or your firewall up and you’re unsure whether to allow TCP or UDP packets, most network software has an option to allow both types.
Do you have any other doubts about TCP or UDP? If so, let us know!