TCP vs UDP: What’s the difference?

Last updated: June 17, 2021

Everything you do online depends on data transfers — sending emails to a friend, streaming videos on Netflix, checking your bank accounts, etc.

How that data is sent depends on the network protocol you use. If you’re setting up a Virtual Private Network (VPN) to protect your online privacy, you can choose between two protocols:

  • Transmission Control Protocol (TCP)
  • User Datagram Protocol (UDP)

Both transmit data over the network, but in different ways. But what are these two protocols, and how do they work? And should you use TCP or UDP when using a VPN?

In this article, we’ll provide a comprehensive overview of TCP and UDP, including how they differ, when to use them, and much more.

Click the links below to head to the section you want to learn more about:

What is TCP?

Transmission Control Protocol (TCP) is a connection-oriented protocol for sending data or packets of information over the internet. This means once a connection is established, data can flow in both directions.

This method of delivery is extremely reliable, as it guarantees data delivery to the destination server. There are also built-in systems that check for errors and ensure that data gets sent in the correct order.

TCP is well-suited for transferring most data types (e.g., webpages, emails, documents, etc.) over the internet, where reliability is imperative.

How does TCP work?

TCP is the most commonly used protocol for sending and receiving data over the internet. It’s not exactly the fastest, but it’s more reliable than its UDP counterpart (more on that later).

Here’s how the TCP protocol works:

  1. Connections start with what’s called a “three-way handshake” — a three-step process that involves exchanging synchronization and acknowledgment packets before data gets transmitted.
  2. Once the TCP handshake is complete, you can get to work on your email (or another task). Your data gets divided into smaller units called “packets” or diagrams. These are part of a larger message.
  3. A unique identifier and a sequence number are assigned to each TCP packet. These numbers guarantee that the data packets are sent and received in the correct order.
  4. When you send data over TCP, the receiver sends an acknowledgment back to the sender (if it’s in the correct order). The sequence and acknowledgment numbers are used to keep track of individual data packets.
  5. Data packets can get lost or arrive in the wrong order when traveling across a computer network. If the sender doesn’t receive an acknowledgment, the data packet gets sent again. If the data is sent in the wrong order, the recipient can use the sequence numbers to reassemble the data.
  6. Finally, either side can send a FIN packet to close the TCP connection.

Let’s look at an example.

Imagine that you want to communicate with your neighbor. But your homes are far apart, so that rules out shouting from your windows.

The TCP protocol is akin to building a “road” between your homes. Once that connection is established, you and your neighbor can freely send messages back and forth.

All communications are also sent in the right order. If your neighbor is telling a joke, you won’t hear the punchline before they finish. And you can always close the connection whenever you need personal time to yourself (or when your neighbor gets overly nosy).

TCP is a reliable data transmission protocol, as there are mechanisms in place to prevent packet loss. But there are also downsides to consider before making it the default option.

What are the disadvantages of TCP?

The first major disadvantage of TCP is that connections are slower because of the constant back-and-forth to synchronize and acknowledge data packets. Communications won’t feel as “real-time” as you might want them to be.

Transferring a 10GB file across the U.S. on a typical 100 Mbps line would take 10 to 20 hours. It would actually be faster to load the data on a hard drive and take a plane (flights are about five hours from Los Angeles to New York).

The second is that TCP is “heavier” compared to UDP. This means that sending data over TCP connections requires more system resources.

If there’s a problem with the connection, such as packets sending in the wrong order or getting lost, the data has to be transmitted again. You may end up using more bandwidth than necessary to send or receive a file.

Finally, the TCP protocol is limited to unicast transmissions — data transfers that occur from one device on the network to another.

In other words, you can’t send multicasts over TCP from one device to multiple recipients. If you want to send data to multiple devices, you’ll need to make those transfers individually and use more bandwidth in the process.

What is UDP?

User Datagram Protocol (UDP) is a connectionless protocol. It doesn’t require a “handshake,” and data packets are sent in a continuous stream. This makes data transfers much faster than TCP.

UDP is also “lighter” than TCP. It has practically no overhead, and there’s no additional processing aside from sending the actual data.

This makes UDP ideal for online activities like video streaming, online gaming, and live broadcasts. Speed is more important than accuracy for these types of communications.

While UDP is faster than TCP, it’s not as reliable. Some data packets may be lost during transfers, and there are no mechanisms in place for retransmissions. If you’re sending something important, then you’ll want to think twice about using this protocol.

How does UDP work?

Data transfers are more straightforward with UDP.

TCP connections always start with a three-way handshake to synchronize and acknowledge data packets. This guarantees data transfers.

UDP communications don’t need to go through this process. Data packets are sent directly to a target device without having to establish a connection or check the order of said packets.

UDP has what’s called a “checksum” — a mechanism that checks for corrupted data packets. Here’s how it works:

  1. The sender sends a checksum value (the number of bits in a message).
  2. The receiver also calculates the checksum. If the values match, the data is uncorrupted.
  3. If the checksum values don’t match, the receiver knows the data is corrupted. Lost or corrupted data packets are simply discarded.

Let’s go back to our example of communicating with your neighbor.

The UDP protocol is akin to using drones to communicate. The advantage here is that conversations are significantly faster, as there’s no need to build a road. Instead of sending messages individually, you can send them all at once.

But communicating in this manner isn’t always reliable — a drone might veer off course or take a longer route to its destination. This means that messages may get lost or arrive in the wrong order.

Let’s take a closer look at the downsides of UDP.

What are the disadvantages of UDP?

The first is that UDP doesn’t guarantee data delivery. It’s not a reliable way to send important information as there’s no data recovery or retransmissions for lost packets.

TCP has extensive error checking through synchronization and acknowledgment packets. If any packet loss occurs, the data is transmitted again.

UDP only does basic error checking by matching checksum values. And if it does detect corrupted data packets, it discards instead of retransmitting them. The plus side is this saves you a lot of bandwidth.

The second is unstable connections. UDP is a connectionless protocol that allows for faster data transfers. But this can make your streaming or gaming appear choppy if data packets drop.

Finally, another concern with UDP is accessibility. Some VPN providers use the UDP protocol by default, as it provides faster browsing experiences.

However, many internet-restrictive countries block UDP traffic to prevent users from circumventing its firewall. The good news is you can bypass these restrictions with TCP VPN tunnels. These operate on common ports like 443 (the port for HTTPS web traffic).

Despite these disadvantages, UDP is still an excellent protocol — it’s faster and more efficient than its TCP counterpart.

Let’s take a closer look at how these two protocols differ.

What are the main differences between TCP and UDP?

Whether you’re browsing the web or streaming your favorite shows, you’ll use either the TCP or UDP protocol to send and receive data. The following table sums up the key differences between these two transfer protocols.

TCPUDP
ConnectionRequires a connectionDoesn’t require a connection
SpeedSlower than UDPFaster than TCP
Data sequencingData packets are sent in the right orderData packets can arrive at different times
DeliveryDelivery is guaranteedDelivery isn’t guaranteed
Data retransmission Lost or corrupted packets are retransmittedLost or corrupted packets are discarded
Header sizeData packets have a larger header size (more overhead)Data packets have a smaller header size (less overhead)
Error controlExtensive error checking through synchronization and acknowledgment checksOnly matches the checksum value of packets to check for corrupted data
Flow controlControls the flow of data packetsDoesn’t control the flow of data packets
BroadcastingDoesn’t support broadcastingSupports broadcasting

Let’s look at each of these in more detail.

TCP vs UDP: Connection

TCP requires a connection before data gets sent. The process of setting up this connection is called a three-way handshake.

UDP is a connectionless protocol. As such, data is simply sent to the receiving device in a continuous stream.

TCP vs UDP: Speed

TCP is slower because it has more to do. It has to establish a connection, check for errors, assign sequence numbers, and put data packets in the right order.

UDP is faster than TCP. It doesn’t need to establish a connection to transmit data, and it’s more efficient in terms of bandwidth. These factors make UDP ideal for real-time activities like streaming and gaming.

TCP vs UDP: Data sequencing

Data sequencing refers to arranging data packets in the correct order.

TCP adds sequence numbers to each data packet. These numbers allow the receiving device to arrange the packets in the right order and even determine which packets are missing.

UDP doesn’t have this mechanism, as data packets are sent without sequence numbers. This means two things:

  • Data packets can arrive at their destination in the wrong order
  • Receiving devices can’t determine if all packets have been received

TCP vs UDP: Delivery

TCP guarantees delivery. It has built-in mechanisms that track and sequence data packets to ensure the data arrives intact.

UDP doesn’t guarantee delivery. If you’re sending important or sensitive information, then you’ll want to use the TCP protocol instead.

TCP vs UDP: Data retransmission

If any packets get lost or corrupted, the TCP protocol will send those packets again. Note that this will use more bandwidth.

If UDP detects corrupted data packets, it simply drops them, and they won’t be retransmitted.

TCP vs UDP: Header size

TCP packets have a larger header size because it contains more information. The size varies from 20 to 60 bytes.

UDP packets have a smaller header size, which is just eight bytes. This lower overhead is what makes UDP much faster than TCP.

TCP vs UDP: Error control

Network congestion is the most common cause of packet loss. This occurs when a network is carrying more data than it can handle, which can result in errors.

TCP has extensive error checking and correction mechanisms. These include synchronization and acknowledgment checks, which keep track of received and lost data.

UDP only checks for corrupted data by matching the checksum value of data packets. It doesn’t keep track of which data packets have been received.

TCP vs UDP: Flow control

Traffic signals on freeway on-ramps manage the flow of traffic and decrease congestion.

Similarly, TCP has a flow control mechanism that tells the sender how much data to send to avoid overloading the receiver. This is useful because receiving devices have limited speed and memory.

UDP doesn’t have a flow control mechanism. Data packets arrive in a continuous stream or are simply dropped. Think of it as a freeway on-ramp without traffic signals. Data continues to transmit even if the network is congested.

TCP vs UDP: Broadcasting

TCP doesn’t support broadcasting. Transmissions can only occur from one point in a network to another point.

UDP supports broadcasting. This means you can transmit data from one device in a network to many.

Simply put, the main differences between TCP and UDP ultimately come down to reliability and speed. There are situations where one is more important than the other, and vice versa.

When should you use TCP and UDP?

It depends.

If you need guaranteed delivery of your data, then you’ll want to use TCP. You may experience slower transmissions, but you can at least be sure that the recipient will receive the data.

If speed is more of a priority, then stick with UDP. You may experience some data loss, but this likely won’t have a huge impact on what you’re doing.

TCP is ideal for:

  • Browsing the web
  • Sending emails
  • Exchanging files

UDP is ideal for:

  • Live streaming
  • Video conferencing
  • Online gaming

OpenVPN: TCP or UDP?

OpenVPN is a highly secure protocol that you can use to establish and encrypt point-to-point connections. Data transmitted through this connection is kept hidden from prying eyes.

In other words, OpenVPN allows you to securely and anonymously browse the web. It also ensures that anyone snooping on your connection can’t view or access your online activities.

VPN providers like ExpressVPN and NordVPN offer OpenVPN, which supports both TCP and UDP.

So whether you’re working with sensitive information or streaming your favorite show, you can encrypt your connection and protect your privacy online.

Which transfer protocol you use with OpenVPN will depend on your use case. TCP is more reliable as delivery is guaranteed, but UDP is much faster.

ExpressVPN will choose the best settings based on factors like your network and location. This means that data may be transmitted through TCP or UDP. But you can always change these settings depending on your requirements.

Find out more about this in our ExpressVPN review.

Conclusion

To summarize: TCP and UDP are protocols that let you send and receive data over the internet.

TCP is much more reliable, as it guarantees the delivery of your data. This makes it ideal for things like web browsing and file transfers.

On the other hand, UDP is significantly faster as data is sent in streams, but data loss may occur. UDP is better suited for things like live streaming and online gaming.

Regardless of which you choose, it’s important that you take steps to protect your online privacy. Check out our VPN reviews, where we provide in-depth reviews of some of the best VPNs on the market.

Published on: June 14, 2021