What Is UDP (User Datagram Protocol)?
The transport layer of the OSI model is responsible for the end-to-end delivery of data, using either TCP (Transmission Control Protocol) or UDP (User Datagram Protocol). Though UDP isn't as reliable as TCP, it's ideal for time-sensitive communication like computer gaming, video playback, and DNS lookup. In this article, learn what UDP is, how it works, and its applications.
What is UDP (User Datagram Protocol)?
User Datagram Protocol (UDP) is a core network communication protocol that transmits data without establishing any connection between the sender and receiver. It’s primarily used for fast, connectionless data transmission over networks.

UDP is sometimes referred to as a fire-and-forget protocol because its goal is to send data quickly. User Datagram Protocol speeds up transmissions because it doesn’t establish a session during data delivery.
Therefore, User Datagram Protocol is ideal for time-sensitive applications where speed is more critical than absolute reliability. Applications such as gaming, video or voice communications, and DNS lookup use the protocol because they tolerate packet loss, which is what User Datagram Protocol is known for.
UDP also sets low-latency connections between the different applications. Its low overhead feature results in lower latency compared to TCP.
Like TCP, UDP runs on top of Internet Protocol (IP). UDP is a transport layer protocol and part of the UDP/IP suite. User Datagram Protocol sends messages to other hosts on an IP network, which are transported as datagrams in packets.
However, because UDP lacks error handling, reliability, or sequencing, it isn’t a good option for most common tasks like file transfer, where we care about security. Some packets are lost in transit, thus making it easier for attackers to flood a target with DDoS attacks.
How does UDP work?
Like other widely used protocols, User Datagram Protocol provides a set of rules that govern how data is transferred over the Internet. This transport layer protocol works straightforwardly, so it is favored for some applications.
The entire process begins at the application layer. When an application wants to send data, it creates a message and hands it over to the protocol. User Datagram Protocol then encapsulates the message in a datagram. The datagram includes the UDP header with the source and destination ports, the length of the message, and the checksum.
The datagram then passes to the IP layer, which adds its own header and delivers the packet to the destination based on the IP address. Since UDP is connectionless, there is no handshake or connection establishment phase. It sends the data immediately without waiting for an acknowledgment from the receiver.
The IP layer processes the packet at the destination, strips off its header, and passes the UDP datagram to the User Datagram Protocol layer. User Datagram Protocol checks the destination port number and forwards the datagram to the corresponding application.
If the process uses a checksum, User Datagram Protocol performs a checksum computation to verify the integrity of the data. If the checksum fails, it silently discards the packet.
UDP does not send back any acknowledgment to the sender, so the sender will not know if the datagram reached the destination. Error processing is minimal, too. If a datagram arrives with an error, it's simply discarded, and UDP does not attempt to resend it.
Applications using User Datagram Protocol are typically responsible for handling any errors if needed. This might involve implementing custom error-checking and recovery procedures within the application itself.
Brief history of UDP
David P. Reed designed the User Datagram Protocol in 1980 and formally defined it in RFC 768. It was initially developed for the ARPANET, the precursor to the modern Internet.
Engineers designed it as a more efficient alternative to Transmission Control Protocol. At that time, many considered TCP too complex for certain applications. The primary objective of UDP was to provide a lightweight and fast way to transmit datagrams over the network.
This made it worthwhile when real-time connections are of great concern, such as when a user streams media. Over the years, various applications and Internet protocols adopted UDP.
Despite its simplicity, User Datagram Protocol complements TCP’s reliability with a lightweight alternative for numerous networking user cases.
Features of UDP
User Datagram Protocol has many attributes that make it useful in scenarios where the overhead of establishing a reliable connection would not suffice.
Some of the protocol's key characteristics include:
- It's connectionless. It doesn’t require a connection or virtual path to transfer the data.
- It's a transport layer protocol. User Datagram Protocol is defined as a transport layer communication protocol. Application layer protocols encapsulate their headers and send them to the transport layer, where UDP works.
- It has no acknowledgment mechanism. UDP does not provide acknowledgment of receipt. While it reduces the time required for data transmission, it doesn’t care if packets arrive in the correct order or even at all.
- It doesn't guarantee an ordered delivery of data. In User Datagram Protocol, if senders send the data to the recipient, then there’s no guarantee the receiver successfully receives the data. It only operates on a best-effort delivery basis. You can’t rely on it for order or duplicate protection of datagrams.
- Faster transmission. UDP's connectionless nature means it is fast. Its low latency benefits real-time applications like video conferencing, gaming, and live streaming.
- It's simple and lightweight. It uses a simple transmission model with minimal protocol mechanisms, and small User Datagram Protocol headers result in faster transmission.
- It's stateless. It doesn't keep track of a connection's state. This makes UDP simple to implement, and the protocol has lower processing requirements compared to more complex protocols like TCP.
- It's a contactless protocol. The User Datagram Protocol does not require a virtual circuit to transfer data.
- Broadcast and multicast support. User Datagram Protocol supports broadcasting (sending data to all devices in a subnet) and multicasting (sending data to a group of devices), which is useful for applications like online gaming.
UDP header composition
UDP uses headers to package and send metadata over network connections. The header comprises a fixed 8-byte structure divided into four fields, each being 2 bytes (16 bits) long. The fields help identify the data and then direct it to the correct destination.
Here's a breakdown of the User Datagram Protocol header composition.
- Source port. The source port is a 16-bit field that identifies the port number of the sending process. The field helps the receiver know which application on the sending device sent the data.
- Destination port. This is also a 16-bit field specifying the port number of the destination address to which the datagram is being sent. It could be between 0 and 65,535.
- Length. This field indicates the total length of the UDP header and the encapsulated data. The minimum length is 8 bytes since that’s the header's length.
- Checksum. Checksum is an optional field used for error detection. It calculates a value based on the header and data, and the receiver can verify this checksum to check for any data corruption during transmission.
In IPv4, using the source port and checksum field is optional. In IPv6, however, only the source field is optional. Unlike in TCP, checksum calculation is not mandatory in UDP. Each of these fields plays a vital role in the delivery and integrity of the UDP datagram.
Applications of UDP
User Datagram Protocol has a multitude of user cases. It works well for the following instances.
DNS lookups
UDP is unreliable but a lot faster than TCP. The DNS generally depends on UDP for transport. DNS queries and responses are transmitted over User Datagram Protocol because they are very tiny.
This means the small amounts of data in DNS requests can travel quickly without the need for more complex segmentation. DNS protocol uses UDP to load users' web pages.
Streaming media
With video and audio streaming on the rise, leading companies want to improve the user experience for these entertainment activities. Services like Netflix, YouTube, and Twitch use UDP for live streaming video, because in these cases, some packet loss doesn’t adversely affect perceived quality.
However, these services also implement error correction strategies in addition to UDP to bolster video quality despite some losses.
Online gaming
UDP's low latency is crucial for fast-paced online gaming. Games like first-person shooters, real-time strategy games, and battle royale games use User Datagram Protocol to provide low-latency communication between the game server and players.
In this case, timely delivery of game state updates is more important than reliability. User Datagram Protocol saves plenty of time.
Voice over IP (VoIP)
Thanks to User Datagram Protocol, we can communicate via video call. The protocol facilitates real-time voice communication over the Internet, allowing for interactive conversations.
Applications like Skype use it to achieve real-time voice communication. Video conferencing tools like Microsoft Teams, Google Meet, and Zoom also rely on UDP to maintain real-time interaction.
Broadcasting/multicasting services
User Datagram Protocol supports packet switching. For example, Internet Protocol Television (IPTV) utilizes UDP to simultaneously multicast video content to multiple subscribers.
Other protocols, including DHCP, use User Datagram Protocol to broadcast messages across the network. This way, devices can automatically obtain IP addresses and other network configuration settings.
Virtual private networks (VPN)
Some virtual private networks are compatible with both TCP and UDP, but which you prefer will depend on what you need it for.
There are many instances where User Datagram Protocol is preferred. Most VPN services use it as the default protocol because of its speed.
Limitations of UDP
While UDP is well-suited for specific applications, it's important to remember its limitations.
- It's unreliable. User Datagram Protocol doesn't guarantee delivery, order, or duplicate protection of packets.
- It is not ideal for large data transfers. UDP is less efficient than TCP for large data transfers due to its lack of congestion control mechanisms.
- It has limited use cases. UDP falls short in a couple of use cases due to its unreliability. For applications requiring reliable data transmission, such as email, use TCP instead. Packet loss could lead to emails not reaching their intended recipients.
- It's vulnerable to cyber attacks. The lack of session management makes UDP susceptible to various security threats.
Is UDP secure?
The risk of packet loss isn’t always a big issue, but User Datagram Protocol's stateless nature provides an opportunity for cybercriminals. It becomes difficult to distinguish between legitimate and malicious traffic.
Common UDP-based DDoS attacks include:
- UDP flood attacks. An attacker sends many UDP packets to random ports on a target system to overwhelm its resources.
- Amplification attacks. In this type of attack, the attacker sends small protocol requests to a server that elicits larger responses using a spoofed IP address as the source address.
- Application-layer attacks. Attackers can exploit vulnerabilities in applications using UDP. For example, poorly implemented handling of UDP packets can lead to buffer overflow attacks.
However, you can employ various mitigation strategies to protect against these vulnerabilities. One limits the rate at which a source sends ICMP responses during a session. It usually occurs at the operating system level to disrupt DDoS attacks that require ICMP responses.
Configuring firewalls to filter suspicious UDP traffic based on source IP addresses, port numbers, or other characteristics can also help mitigate attacks.
Comparing TCP vs. UDP
Although Transmission Control Protocol and User Datagram Protocol aren’t the same, they share some similarities. They are transport layer protocols used for sending bits of data – packets – over the Internet.
The two protocols are members of the TCP/IP protocol suite. UDP and TCP depend on IP to route packets to the correct destination.
Despite these similarities, they have noticeable differences in handling data transmission. Transmission Control Protocol is a connection-oriented, reliable, but slow protocol, while User Datagram Protocol is fast, unreliable, and connectionless.
Another distinction is that UDP supports logical process-to-process communication, while TCP enables host-to-host communication.
Frequently asked questions
What are checksums in UDP protocol?
A checksum is a small piece of data, typically a 16-bit field in the UDP header, used for error detection. The checksum calculation is a way to ensure data integrity.
What is a UDP port?
A UDP port is a numerical identifier used in the protocol to distinguish different user requests and direct them to the correct server process.
What are port numbers for in UDP?
Port numbers address different functions at the source and destination of the datagram.
What does UDP stand for?
UDP stands for User Datagram Protocol.
What is QUIC protocol in UDP?
QUIC protocol is a new transport layer protocol that utilizes the User Datagram Protocol to establish connections and improve speeds.