Get CactusVPN for $3.5/mo!
When using OpenVPN, you probably noticed an option that lets you choose between TCP and UDP. Ever wondered what those settings are, and how they affect your VPN connection?
If yes, this is the place to be. We’ll discuss what they are, offer a quick look at TCP vs. UDP, talk about the difference between TCP and UDP more in-depth, and see which option works best for VPN users.
TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are network protocols whose purpose is to send data packets. If you’re not sure what those are, they’re any type of data you send over the web – emails, messages, connection requests, etc.
TCP and UDP work on top of the Internet Protocol (IP), and they use different ports on your device to forward data packets to the right routers. Besides that, they will also send the packets to the IP address of the recipient (like the person you’re sending a Facebook message to).
Some people might tell you that TCP and UDP are the only network protocols, but that’s not true. There’s also ICMP (Internet Control Message Protocol), for example. But TCP and UDP are used the most.
Moving on, let’s analyze each protocol separately.
Out of the two, TCP is used more often. The protocol runs on two-way communications – it sends data packets back and forth between your browser and the website’s web server.
Here’s exactly how it works – when you connect to a website, your device sends TCP request packets to the appropriate web server. The server replies with its own TCP data packets which your browser puts together to display the website on your screen.
Every time you go to a new website or interact with a link on a website, that process repeats.
Note the difference – the browser sends request packets which “request” data from the web server. In turn, the server replies to the requests with data packets. Don’t get the two terms confused cause they’re not the same.
Here are other things you should know about TCP:
The main difference between TCP and UDP is that UDP is much more lightweight. Why? Because reliability isn’t so important.
Unlike TCP, UDP only has one-way communications. It sends packets to a recipient, but it doesn’t check if they were delivered successfully. So, UDP doesn’t:
All in all, if the recipient misses some UDP packets, they can’t get them back. Because of that, the protocol is mostly used for gaming, video conferencing, and broadcasts.
For example, if you miss a few UDP packets in an online match, you might experience things like randomly teleporting across the map when walking or shooting multiple bullets instead of one when hitting Mouse 1 just once.
It’s not ideal, sure, but it’s better than what would happen with TCP in this scenario – your game freezing.
Here’s a quick look at the main differences between TCP and UDP:
|Doesn’t establish connection
|Stream of packets
|Requires acknowledgements from recipient
|None – doesn’t number packets
|Yes – ensures proper flow control
|Gaming, broadcasts, video conferences
|Email, web browsing, file transfers, streaming
So what is the difference between TCP and UDP, exactly? We took a quick look at their differences before, but let’s see what they all mean.
We’re not going to discuss UDP vs. TCP applications, though, since they’re pretty straightforward. What we mentioned in the table at “Used For” pretty much sums it all up.
There’s not much to be said about transfer methods either. What you see is what you get, essentially – TCP uses streams of data packets, and UDP sends packets individually.
With that out of the way, let’s get started:
UDP doesn’t do any error checking, ask for acknowledgements, have congestion control, and bother numbering packets. Because of that, the header will be much more lightweight and no time will be spent waiting for responses from recipients or double-checking connections.
Obviously, UDP will deliver much faster speeds than TCP.
Those high speeds come at a cost, though – unreliable data transfers. When you use UDP, there’s no guarantee you will get all the packets you need. Or that you will get them error-free.
That’s not a huge problem in online games or when you’re binging content. But if you use UDP for file transfers, you’ll be likely to receive corrupted files or files that don’t work because they’re missing data.
TCP might be slower, but it has a good system in place to make sure the data transfer is reliable (error detection & correction, packet sequencing, TCP handshake, acknowledgements, etc.).
One difference between TCP and UDP that’s not very obvious is the way they handle connections.
TCP is very connection-focused, so it establishes one before transferring any data. That process is called a “TCP handshake.” Once TCP sets up the connection, it begins the transfer of request packets and data packets.
UDP, on the other hand, doesn’t bother with that all the time. Usually, the protocol can start sending packets without even establishing a connection to the recipient.
TCP has clearly defined error detection and correction methods. If a single packet is found to be corrupted, TCP won’t send an acknowledgement for it. So it forces the sender to resend the packet again.
The process is repeated until there are no errors.
UDP only has error detection in place. It uses checksum to find faulty packets. When it does, it discards them. The detection isn’t perfect, though. It’s relatively weak, and it’s actually optional, meaning an intermediate hop router could remove it.
UDP headers are very lightweight, which also contributes to the protocol’s high speeds. An UDP header has a fixed size of 8 bytes, and looks like this:
|Payload Data (If Any Is Present)
Here’s a quick breakdown of all those terms:
TCP headers are heavier – anywhere between 20 and 60 bytes. They contain more data, and look like this:
|Payload Data (If Any Is Present)
All those terms can get overwhelming, so we’ll describe them – except for source port, destination port, header length, and checksum since they’re the same as the ones in UDP headers. So here’s what they mean:
TCP sends an acknowledgement to the sender whenever the recipient successfully receives a packet. If an acknowledgement isn’t sent, TCP automatically assumes the packet didn’t reach the destination. So it sends it again.
With UDP, the sender has no idea if the recipient got all the packets because the protocol doesn’t use acknowledgements.
As TCP sends a stream of packets, it adds a sequence number to all of them. Doing that makes it simple for the recipient to arrange and put together the message once they get the data.
Because UDP doesn’t use sequencing, the recipient has no way of knowing if they received all the packets they needed. Also, they won’t know if the ones they did get are in the right order or not.
Because TCP focuses on connections so much, it uses congestion control to make sure the data channel it uses is clear. That makes sure packets aren’t lost due to congestion.
UDP doesn’t care about lost packets, so it doesn’t offer any congestion control.
In certain situations, yes. Just like TCP is better than UDP in other scenarios.
It really depends what you are doing. If you’re gaming online or on a Skype call with your friends, UDP is much, much better than TCP. You might get some lag, but it’s much better than the game freezing or the connection dropping.
Overall, if you do anything online that requires speed and isn’t extremely important (like sending an email or online banking), UDP is a good choice.
TCP vs. UDP – which one goes best with OpenVPN?
Again, it depends. A lot of factors affect VPN speeds, and the protocol you use has a big influence on that. OpenVPN is pretty notorious for slowing down original ISP speeds, so many VPN users prefer to use it over UDP to get a smoother experience.
Our advice is to use OpenVPN over TCP for important stuff – online browsing, emailing, chatting with friends, Internet banking, downloads, and other stuff like that. Stick with UDP for streaming, gaming, and video calls.
If you get very bad speeds with TCP, though, try UDP.
How big is the difference?
Well, we ran a test with Speedtest.net. For reference, we are from Romania, and our original ISP speeds are around 100 Mbps. So we used the CactusVPN Romanian VPN server to make sure the distance between us and the server doesn’t affect the results too much.
Here are our results with OpenVPN over TCP:
And OpenVPN over UDP:
Pretty noticeable difference.
Not all of you are going to get the same results, though. There’s a chance some of you might get better speeds with TCP instead of UDP. So you should do some tests before settling on a protocol to use.
In general, our tests show that you’ll get decent speeds with OpenVPN over any protocol on our servers. They offer high speeds and unlimited bandwidth, which helps. We also optimized them for speed.
Which protocol offers you the best experience? Is stability the most important to you, or do you value speeds more?
Go ahead and let us know in the comments. And please share any other relevant information about the difference between TCP and UDP too.