Wait! We Have a Special Deal!

Get CactusVPN for $3.5/mo!

Save 64% Now
30-Day Money-Back Guarantee

What’s the Difference Between TCP and UDP?

TCP vs UDP

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.

What Is TCP and UDP & How Do They Work?

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.

TCP

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:

  • It numbers all its packets, sending them in order. 
  • When TCP successfully delivers a data packet, the recipient sends an acknowledgement to the sender. If an acknowledgement isn’t received, TCP will assume the data packet was lost. So it will send it again.
  • TCP carefully checks all data packets for errors and corruption. Also, it tracks them to make sure no data is lost in transfer. Thanks to that, pretty much any file you download will be in good shape even if you have connectivity issues.
  • If TCP can’t establish a connection with a web server because it’s offline, it will give up after a few tries. That’s why you get the “This site can’t be reached” error.

UDP

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:

  • Require any acknowledgements.
  • Do any error-checking.
  • Number packets.
  • Request any resends.

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.

TCP vs. UDP at a Glance

Here’s a quick look at the main differences between TCP and UDP:

UDPTCP
SpeedFastSlow
ReliabilityLowHigh
ConnectionDoesn’t establish connectionEstablishes connection
Transfer MethodIndividual packetsStream of packets
Error DetectionPresentPresent
Error CorrectionNonePresent
Header SizeSmallLarge
AcknowledgementsNoneRequires acknowledgements from recipient
SequencingNone – doesn’t number packetsNumbers packets
Congestion ControlNoneYes – ensures proper flow control
Used ForGaming, broadcasts, video conferencesEmail, web browsing, file transfers, streaming

TCP vs. UDP (In-depth Look)

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:

Speeds

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.

Reliability

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.).

Connections

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.

Error Detection & Error Correction

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.

Header Size

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:

Source Port Destination Port
Length Checksum
Payload Data (If Any Is Present)

Here’s a quick breakdown of all those terms:

  • Source port – The port UDP uses on your device to send data.
  • Destination port – The port UDP uses to send data to the recipient.
  • Length – The total number of bytes comprising both the header and payload data.
  • Checksum – A sequence of numbers and letters used to detect errors.

TCP headers are heavier – anywhere between 20 and 60 bytes. They contain more data, and look like this:

Source Port Destination Port
Sequence Number
Acknowledgement Number
Header
Lenght
Reserved U
R
G
A
C
K
P
S
H
R
S
T
S
Y
N
F
I
N
Window Size
Checksum Urgent Pointer
Options Padding
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:

  • Sequence number – The number TCP assigns to the packet. It segments data into TCP segments, and then helps reassemble them on the recipient’s side. This number also helps TCP keep track of how much data was exchanged.
  • Acknowledgement number – The number TCP uses to acknowledge a packet was sent successfully.
  • Reserved – Set aside for future use. Normally set to zero.
  • Control flags – 1-bit control bits that handle connections.
    • URG – Shows if the Urgent Pointer field is important.
    • ACK – Shows that the Acknowledgement Number field is important. 
    • PSH – A request to push the buffered data to the recipient.
    • RST – Resets the TCP connection.
    • SYN – Synchronizes sequence numbers. Used during 3-way handshakes.
    • FIN – The last packet from the sender, indicating the TCP session is over.
  • Window size – Specifies the number of window size units the sender of the TCP stream can receive.
  • Urgent pointer – Points to the data that is the most urgent and needs to be received ASAP.
  • Options – Varies significantly depending on the Payload Data field.
  • Padding – Makes sure the TCP header ends and the data begins on a 32-bit boundary.

Acknowledgements

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.

Sequencing

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.

Congestion Control

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.

Is UDP Better Than TCP?

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.

So Which Protocol Should You Use with OpenVPN?

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.

TCP vs. UDP Speeds with OpenVPN

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.

If you want to learn more about CactusVPN, check out our features. And feel free to sign up for a free trial to test your OpenVPN connections before buying a subscription.

TCP vs. UDP – Which One Do You Prefer?

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.

Posted on

Leave a Reply

Your email address will not be published. Required fields are marked *