Understanding TCP and UDP
If you’ve ever configured a firewall or set up port-forwarding for a wireless router, you may have encountered TCP and UDP references, and wondered, “What are these, and what is the difference?” Before discussing the impact on VPN, let’s do a quick primer on the overall “big picture…”
There are lots of similarities, and both TCP and UDP work in a similar manner. But, depending on the network hardware or software you may have to configure, it can be beneficial to know the difference.
- BOTH TCP and UDP are protocols.
- BOTH are used to send ‘packets’ of data over the internet to an IP address.
- BOTH have their packets of data forwarded from an intermediary router to their ultimate destination.
- BOTH are protocols working “on top of” IP—though not the only ones, just the most common.
TCP stands for “Transmission Control Protocol,” and is the most widely used today. It tracks packets being sent to ensure receipt, and error checks the transmission all the way. This makes it slower, but more reliable.
UDP stands for “User Datagram Protocol,” with ‘Datagram,’ meaning simply, ‘packet.’ It doesn’t error check or validate the back and forth of the packets, which makes it considerably faster, but with no guaranteed delivery of all packets accurately.
So which is better? Like most things in life, it depends.
When TCP is Better
When you’re on the web, your browser is sending the packets via TCP back and forth between the server and your computer. It’s a two-way street: the packets are sent in order, and numbered. If any packets are ‘missed,’ TCP will resend them again until everything is received and verified. It’s all about being completely accurate—so all packets are checked for errors, too. No corruption in transport, no lost data. Even if there’s a disruption in the network, TCP will pick up again from anything sort of a complete failure—meaning completely offline. And even then you’ll get an error message… Very thorough! If data needs to be 100% reliable when received, like with online banking or similar financial transactions, you’d want to trust TCP.
Why UDP is Better
UDP basically does no error checking. The packets are just sent. Receipt is not verified. UDP defaults to moving on, and on, and on—and forget about anything in the past. The benefit? Everything speeds up without all the error checking and back and forth for verification. And if you’re thinking the error checking is awfully important—think about a streaming video of an event happening live. The goal is to get everything to you as close the actual moment it is happening as possible. If there’s a quick ‘glitch,” on the screen, it’s not an earth-shattering event. UDP helps minimize latency, and what you want in this case is speedy delivery of the data.
Now that you know the difference, you should also know that with most situations, with the exception for VPN detailed below, it doesn’t usually matter that much. If you’re developing an application, then yes, you have to decide whether to use TCP or UDP. But as a typical user, be aware in establishing your router or firewall setup that you an almost always select either TCP or UDP—or be safe by selecting ‘Both.” Then your router or firewall will apply the same rules to both types of packet delivery.
However, when it comes to your VPN connection, there are some valid questions you should ask about TCP or UDP. The easiest thing to remember is that UDP will almost always provide higher speeds, and is suitable for all users in most cases.
TCP may be a better choice in a couple of cases.
- If you are having connection issues, TCP can detect any problems, and initiate new connections more quickly.
- If you are having blocks on your network, the TCP protocol and ports may be combined to mimic other traffic—thereby getting around the block. An example is using port 443 and TCP to mimic HTTPS traffic, which is seldom blocked if ever.
In all cases, keeping your client software up to date is important. New versions will have updates to help improve the stability and speed of your connection. Changes to the software on the server side are made over time as well, meaning your updates will help improve your overall experience.