TCP vs. UDP – which protocol to use for VPN Applications
James Patterson | Last Updated:
Online Gaming & Internet Privacy Expert
Online connections use a variety of ports and protocols when devices try to communicate with each other. It might seem like an effortless matter when your browser connects to Facebook, or when your media server sends video to your TV, or when your phone jumps on the Wifi at the coffee shop, but there are actually dozens of ways that these connections can take place, and smarter people than us have figured out the best method for each scenario. This article will focus on the two backbone protocols that make up the vast majority of internet connections, TCP and UDP, with guidance at the end for using a VPN service like OpenVPN on these protocols.
TCP: Secure and Reliable for Most Applications
Transmission Control Protocol (TCP) is the standard type of connection when two devices need to send important files and information between each other. Other protocols and applications which rely on TCP include FTP, HTTP(S), SSH, Telnet, SMTP, IMAP, and POP3 for email. TCP is used for important data communication because it ensures that every piece of data is correctly transmitted. It does this via “Synchronize” and “Acknowledge” functions in the connection, wherein the destination device verifies with the sender that it has correctly received all of the information. Here is a quick breakdown of the TCP connection process, which is called a “handshake”:
- Device A sends a “Synchronize” packet (referred to as a SYN) to Device B
- Device B receives the SYN
- Device B sends a “Synchronize Acknowledgement” (referred to as a SYN-ACK) to Device A
- Device A receives the SYN-ACK
- Device A sends an “Acknowledge” (ACK) that it has received the SYN-ACK
- Device B receives the ACK
Or in other words…
- A: “Hey, I want to talk to you.”
- B: “Okay.”
- B: “I got your request to talk.”
- A: “Okay.”
- A: “I got your confirmation that you got my request to talk.”
- B: “Okay, let’s start talking.”
This conversation might seem like overkill if it were between two humans, but when machines are talking to each other, this verification is necessary. This process of checking and re-checking is great when you’re receiving a file that needs to be 100% complete, or sending an email where you need all of the contents to be correctly delivered to your recipient. However, the validation built into TCP can cause this connection to be slower compared to its counterpart, UDP, since it needs to check every individual piece of data as it goes back and forth.
To summarize, TCP is the best choice when accurate transmission of data is required.
UDP: Fast and Loose
User Datagram Protocol (UDP) is the counterpart to TCP and emphasizes the speed of data transfer over accuracy. In a UDP connection, the sending device simply throws its data at the receiving device, and there is no validation or verification process that the transfer was accurate, or that the receiving device even got anything at all. There are no “handshakes” between the two machines or any acknowledgements. Now, you might question why anyone would be OK with their data not being 100% accurate, but UDP actually has many useful applications where it is the clear winner over TCP.
UDP is used in real-time data communication where the information has to be sent now, and can’t wait to have each individual piece verified. For example, the cable box attached to your TV uses UDP when receiving signals from the cable company. Imagine you’re watching a live TV program – You want to see what’s happening right this instant, and you don’t care if one pixel was the wrong color in one frame of the program. This is sometimes the reason that live broadcasts have brief glitches, or the color is wrong for a split-second: A small part of the data transfer from the cable company wasn’t accurately received by your cable box. The great thing about UDP is that it won’t back up and try the transmission again (which would cause a delay in seeing the rest of the program) – it’ll just keep going with the rest of the information.
Other UDP applications include VOIP and online gaming. Again, complete accuracy isn’t needed because you want to hear what the other person is saying right now, or you need to be able to see what your opponent is doing right now, and you don’t mind a brief hiccup which usually isn’t noticeable anyway. If you were using TCP, these real-time communications would be slowed down significantly while the validation process happens, resulting in a connection that would be totally unusable.
Which Protocol to Use for VPN Applications?
OpenVPN and other VPN solutions are flexible and can be operated either on TCP or UDP according to what you set. Which protocol is best depends on what you’ll be using the VPN for. As a general rule of thumb, most providers recommend using UDP for the speed increase, with some exceptions.
If you’ll be using a VPN to bypass geo-restrictions and stream content which is locked in your country, UDP is the clear choice for the reasons we’ve already described. Or if you’ll be using it to boost your gaming performance, UDP is the winner again. Even if you’re just browsing the internet without real-time communications, UDP is a good choice since your connections will usually be accurate and sufficient for most tasks.
On the other hand, if the VPN will be frequently used for transferring files or sending important communications, you should use TCP instead to ensure accuracy. The speed will still be good enough, and you’ll have peace of mind with the handshake verification process to know that the data is being sent accurately. Whether you opt for the accuracy of TCP or the speed of UDP, remember that you can change your mind at any time and reconfigure the VPN for what you’re currently doing.
In summary, TCP and UDP are the backbone of the majority of online connections, and each has its own advantages and disadvantages.