TCP vs. UDP: Key differences and which one is better
TCP and UDP are the two most common protocols used to transmit information across the internet, from servers to devices and vice versa. Learn about the key differences between TCP and UDP, and how both are useful in different scenarios. Then, help boost your privacy and security on the web with a VPN that you can trust.
Key differences between TCP and UDP
TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are both protocols used by devices and servers to communicate data across the Internet. The main difference between them is that TCP prioritizes reliability, ensuring that information ends up where it’s supposed to with no mistakes, while UDP is built for speed, sending information without checking whether it’s actually being received.
For example, when you load a webpage, TCP is used to ensure you receive all the information it contains and to help your browser display it in the correct order. But, when you play an online game or use an application like Zoom to make a video call, UDP might be used instead. This protocol is better-suited to real-time communication, prioritizing lower latency over perfect reliability.
Here’s a table outlining all of the main differences between TCP and UDP:
Feature |
TCP |
UDP |
|---|---|---|
Connection |
Requires a connection before communication begins. |
Sends data without establishing a connection. |
Resending |
If data isn’t acknowledged as received within a certain timeframe, it’s resent. |
Doesn’t check if data is received, meaning lost or corrupted data isn’t resent. |
Speed |
Higher (slower) max latency due to more computation required. |
Capable of lower latency (faster) data transfers. |
Ordering |
Keeps track of packets and, if they arrive out of order, reassembles them in the right order. |
Doesn’t track packets sent, meaning they may arrive and be processed in the wrong order. |
How does TCP work?
TCP is a connection-oriented protocol that helps make up part of the TCP/IP network model. When a TCP connection is made, information is exchanged between devices, and data integrity is upheld through features like the retransmission of lost packets and the reordering of any packets that arrive out of sequence.
Here are a few key elements that contribute to how TCP works:
- Connection orientation: Unlike UDP, TCP establishes a connection between the sending and receiving devices before transmitting any data. This involves the sender requesting to connect, the receiver accepting, and the sender acknowledging the successful connection. This “three-way handshake” allows TCP to send data more reliably.
- Error recovery: When an error occurs in the data transfer process, like a lost or corrupted packet, the receiver won’t acknowledge it as received. The sender will notice the missing acknowledgement and retransmit the same packet until it’s received correctly.
- Correct packet ordering: When a TCP connection is made, a sequence number is known to both sides communicating. Each packet sent will include this sequence number that increments based on the size of the packet. This information ensures the receiver knows if it is missing packets, and how to put them in the correct order once they’re received.
- Network congestion controls: If lots of packets go unacknowledged from the receiver, it can signal network congestion is causing packet loss. TCP can respond to this by slowing its sending rate to maximize packet delivery, and steadily increasing the rate of transfer to boost speed.
How does UDP work?
UDP is a connectionless protocol that minimizes overhead costs and prioritizes speed, making it the prime choice for applications that require lower latency. Although UDP is generally faster than TCP, the speed comes with a trade off. UDP doesn’t monitor the delivery of packets, meaning they can arrive out of order or get lost/corrupted on their way, and they won’t be resent.
Here are some key features of UDP that will help you understand how it works:
- Network broadcasts: Unlike TCP, which requires a one-to-one connection, UDP is connectionless. This allows data to be broadcast across UDP to entire networks at once. This is useful for service discovery and other fundamental underlying protocols like DHCP and ARP.
- No fixed order of data: UDP makes no guarantees about the arrival of the information it carries, or the order that it will arrive in. This means applications that use UDP must be fault tolerant. If you’ve ever been in a Zoom call, you may have experienced glitches with a user’s streaming of sound or video that may be caused by packets arriving in the wrong order.
- Smaller header size: Due to the connectionless nature of UDP, not much information is required when it’s being used to send information. There are just four fields in a UDP header, compared to a TCP header which has 11 fields, meaning UDP is much “lighter.”
- Real-time data focus: One of the major reasons to use UDP is lower overhead costs, resulting in lower latency. This makes it perfect for applications that require information as soon as possible, like online gaming or voice over internet protocol (VoIP) apps, such as Discord or Zoom.
Examples of TCP and UDP in use
The speed offered by UDP is valuable in lots of cases, like playing online games or making voice or video calls, but there are times when you need TCP’s reliability guarantees. Low latency isn’t particularly important for online banking or secure messaging applications, for example, but you definitely want to avoid errors.
To give you a clearer idea of when each of these protocols is used, here are some examples of situations that call for TCP vs UDP:
TCP |
UDP |
|---|---|
Web browsing: Pages load using TCP, helping data arrive safely and in the right order. |
Voice/video calls: UDP tolerates occasional lost packets, keeping internet calls smooth. |
Email: Email clients use TCP to ensure messages are delivered exactly how they were sent. |
Network operations: Internet services like DHCP, NTP, and DNS use UDP for its transfer speed. |
File downloads: TCP prevents file corruption by checking that all data is delivered correctly. |
Online gaming: UDP helps keep latency low, and occasional dropped packets don’t typically break gameplay. |
Remote device access: Remote inputs must arrive intact, which TCP allows with reliable transfers. |
Some VPNs: Certain VPNs use UDP for faster performance, falling back on TCP when necessary. |
Both protocols have their pros and cons — whether TCP or UDP is used depends on the task and whether speed or reliability is more important.
Pros and cons of TCP
Reliability is TCP’s most significant advantage. It’s designed to prioritize complete delivery of packets, and ensure they arrive in the correct order. But this reliability comes at a cost, most notably in the form of computational expense, which makes it slower and poorly suited to real-time applications.
Here’s an overview of some of the pros and cons of TCP:
Pros |
Cons |
|---|---|
Reliability: Information is delivered intact and in order, guaranteed. |
Higher computational cost: The features that make TCP reliable add processing overheads, which make it slower. |
Error recovery: corrupted or missing packets are detected and resent. |
No broadcast capabilities: TCP can’t send data to multiple recipients at once; it’s strictly one-to-one. |
Congestion control: TCP automatically slows down data transfers on congested networks to prevent packet loss. |
Head-of-line blocking: Since TCP delivers information in the right order, a single delayed packet can hold up all the subsequent packets. |
Security: Many web protocols use TCP for a safe and secure web experience. |
Inefficient for smaller messages: TCP’s connection setup and overhead make it an inefficient choice for short, lightweight data transfers. |
TCP is useful for many kinds of applications, largely because of its reliability and session-based nature. Your web browser, email client, file transfer or remote access software, cloud database, and other applications will typically employ TCP to prioritize reliability.
However, for applications that need information as soon as possible and cannot wait for missing information to be retransmitted, or for applications that send small amounts of data that isn’t vital, TCP would not be the superior choice.
Pros and cons of UDP
UDP’s key advantages include its ability to broadcast to a network and its low computational cost, which boosts speed. Of course, there are also disadvantages to take into account, like its inability to detect and resend dropped packets.
Let’s take a closer look at some of the pros and cons of UDP:
Pros |
Cons |
|---|---|
Network broadcast capabilities: UDP can send packets to multiple devices, enabling functions like group video calls or multiplayer games. |
No guarantees about delivery: UDP has no mechanism to check whether data arrives in the right order, or at all. |
Low computational cost: UDP has minimal protocol overhead and doesn’t require a connection, reducing cost and increasing speed. |
No congestion control mechanisms: UDP doesn’t slow down on congested networks, which can lead to high packet loss. |
Smaller header size: The small header used by UDP saves bandwidth and improves efficiency. |
No recovery from errors: If a packet is corrupted or lost in transit, UDP won’t retransmit it. |
Connectionless: UDP transfers don’t involve handshakes or acknowledgements, keeping latency low. |
Security concerns: UDP is connectionless and stateless, making it easier to spoof — which means it’s used in DDoS attacks like Smurf attacks. |
There are clear benefits to UDP, like being able to broadcast to a network with lower overhead and faster transmission. These make it ideal for certain use cases, like a VPN using IPSec in transport mode, or an online gaming application where speed matters more than reliability.
However, due to its low reliability, UDP is not suited to applications that require dependable, trustworthy data. If you need reliability but must use UDP, then that reliability has to be built on top of the protocol — as with the QUIC protocol that powers streaming on platforms like YouTube, Facebook, and Instagram.
TCP vs. UDP: Which is the better protocol?
Framing these protocols as competitors and thinking that it’s a case of TCP vs. UDP isn’t strictly accurate. One protocol isn’t better than the other — they both have their use cases, and which one is the right fit depends entirely on the task.
TCP’s strength is its reliability, while UDP’s strength is its low latency. It’s all about finding which protocol is best suited to a use case. In most situations, you don’t even get the chance to pick between the two — instead, it’s the developer who chooses which protocol to build the app on.
The protocols in use can also change over time. For example, DNS messages have historically been sent using UDP, but with the advent of secure DNS, a lot of these now require TCP.
Keep your connection secure
TCP and UDP are there to optimize how data is transferred to and from your devices, but it’s important to ensure your connection is secure. A virtual private network can help you protect your privacy online, encrypting your in-transit data to keep snoops and hackers away. Get Norton VPN for a more private browsing experience that can also offer seamless streaming and access to content across borders.
FAQs
How do UDP, TCP, and HTTP differ?
UDP and TCP are transport layer protocols, which help move data between devices. HTTP, and the more advanced HTTPS, are application layer protocols that define how web browsers and servers exchange information.
How do I know if I’m using TCP or UDP?
You can make an educated guess based on what kind of application you’re using, but if you’re unsure, you can use a protocol analyzer tool such as Wireshark to see which protocol is in use.
Which layer does TCP and UDP work on?
TCP and UDP work on the transport layer of the TCP/IP network model, which is considered Layer 4 in the OSI model.
When to use UDP vs. TCP?
In general, applications that are fault tolerant and require real-time communication should use UDP, while applications that need guarantees about data delivery and reliable packet ordering should use TCP.
Editorial note: Our articles provide educational information for you. Our offerings may not cover or protect against every type of crime, fraud, or threat we write about. Our goal is to increase awareness about Cyber Safety. Please review complete Terms during enrollment or setup. Remember that no one can prevent all identity theft or cybercrime, and that LifeLock does not monitor all transactions at all businesses. The Norton and LifeLock brands are part of Gen Digital Inc.
Want more?
Follow us for all the latest news, tips, and updates.