What Is User Datagram Protocol (UDP)? Definition, Working, Applications, and Best Practices for 2022

User datagram protocol is used for time-critical online data transmissions, such as online gaming and DNS lookups.

Last Updated: August 17, 2022

User datagram protocol (UDP) is defined as a communication protocol that is used for time-critical data transmissions such as DNS lookups, online gaming, and video streaming. This article covers the definition, working, applications, and best practices of UDP.

What Is User Datagram Protocol (UDP)?

User datagram protocol (UDP) is used for time-critical data transmissions such as DNS lookups, online gaming, and video streaming. This communication protocol boosts transfer speeds by removing the need for a formal two-way connection before the data transmission begins.

In a UDP-enabled network connection, data transmission begins without the receiving party communicating an agreement to connect. Therefore, the network connections established using UDP are low-latency. Additionally, this makes it imperative for applications to be tolerant of data loss when relying on a UDP connection.

The more traditionally reliable transmission control protocol (TCP) transfers individual data packets between the sender and the receiver after establishing a secure two-way communication line. Conversely, UDP, as the name suggests, sends datagrams, which are independent, comprehensive messages. The arrival, time taken for transmission, or integrity of the contents of a datagram are not guaranteed.

However, this is not necessarily a bad thing. These attributes make UDP beneficial when latency needs to be minimized and packets being lost or reaching in a different order than users sent them in are not a concern. For instance, setups with numerous interconnected clients, where a lack of real-time error correction is not a challenge, are an ideal application for UDP.

Apart from the caveats mentioned above, UDP does not facilitate the retransmission of corrupted or lost data in transit. All these features lead to UDP being considered a ‘best-effort’ mode of data communication compared to TCP. In the next section, we’ll take a more detailed look at the differences between UDP and TCP.

See More: What Is a Content Delivery Network (CDN)? Definition, Architecture, and Best Practices

How Does UDP Work?

User datagram protocol is a standardized communication protocol that transfers data between computers in a network. However, unlike other protocols such as TCP, UDP simplifies data transfer by sending packets (or, more specifically, datagrams) directly to the receiver without first establishing a two-way connection. UDP does not indicate the transmission order for its datagrams or even confirm their arrival.

UDP features checksums for ensuring data integrity and port numbers for defining the role played by the data being transmitted. However, it does not feature a mandatory ‘handshake’ between the sender and the receiver before the commencement of data transfer.

This makes UDP less than ideal for transferring sensitive information, as the receiver may obtain data that is out of order, glitchy, or with blank spaces. As discussed above, UDP is seen in applications where sending data to its destination on time is more critical than transmitting it without any glitches.

UDP header

The UDP header packs metadata into datagrams and tells devices what to do with the transferred data. The header has four fields of 2 bytes each, as shown in the diagram below.

  • The source port defines the port of the sender device. Setting this field to 0 indicates that the sender is not expecting a response from the destination computer.
  • The destination port defines the port of the receiver device and can range from 0 to 65,535.
  • Length defines the value in bytes of the UDP header and payload data. This field’s limit is based on the underlying IP protocol for data transmission.
  • Finally, checksum enables the receiver to cross-check the integrity of both the header and the payload. It was optional in IPv4 and is mandatory in IPv6.

UDP vs. TCP

UDP serves as an alternative to transmission control protocol (TCP). While UDP is faster than TCP, it is also less reliable. Understanding the differences between the two helps gain an in-depth understanding of how UDP works.

TCP-powered data transmissions begin with the sender and receiver establishing a connection via an automated handshake. The actual transfer of the data starts only after the completion of this handshake. Conversely, UDP data transmission begins with the sender transferring data to the receiver without any handshake or confirmation.

UDP and TCP both run on top of IP, which is why they are sometimes known as UDP/IP and TCP/IP. However, while UDP supports process-to-process data transfer, TCP enables communication at the host-to-host level. Two services provided by UDP are not rendered by the IP layer: port numbers for distinguishing between different user requests and checksum for verifying data integrity.

As discussed above, the UDP header has four fields of 2 bytes each, making it a fixed 8-byte header. On the other hand, the size of the TCP header can range from 20 to 60 bytes. TCP also confirms the sequence in which one must receive the packets before the transmission’s commencement. Confirmation is also provided once the packages arrive as intended, and in case the correct transmission fails, TCP requests for the packages to be resent.

None of these processes exist in the case of UDP–there is no scope for sequence confirmation, receiver verification, or resend requests. Compared to TCP, UDP-backed applications must account for the risk of the abovementioned errors. In return, they are rewarded with swifter data transmission.

Is UDP inefficient?

UDP cannot be solely blamed for data loss. The metadata in the header is enough to transmit the information to its destination. Additionally, the chronological order in which the datagrams are sent should ideally be retained when received.

However, due to memory limitations, most network routers cannot provide receipts for arrival or packet sequencing. Also, data packets, in general, are sometimes lost or duplicated. TCP addresses these issues at the cost of increased latency, while UDP does not. This doesn’t make UDP bad–just better suited for different applications.

See More: What Is Software-Defined Networking (SDN)? Definition, Architecture, and Applications

Applications of User Datagram Protocol

Now that we understand how UDP works, let’s take a look at where this communication protocol is used:

1. Domain name system (DNS) lookup

Once a user enters a URL in their web browser, the IP address associated with the domain must first be found, after which one can send a GET request to the server. This entire process must not take more than a few milliseconds; otherwise, users will likely drop off. Therefore, the DNS protocol uses UDP to fetch websites for users quickly.

2. Streaming and gaming

Online gaming and video & audio streaming are more popular now than ever, leading companies to increase investments to improve the user experience for these entertainment activities. High latency leading to lag and buffering is a deal-breaker for most streaming and online gaming services users. UDP is used to address this issue. 

Whether it is online gaming, video playback, or audio streaming, some data loss does not negatively impact the perceived quality of the overall experience. However, as the popularity of these services increases, forward error correction methodologies are being implemented along with UDP to bolster the quality of video and audio. While this does not eliminate data loss, it does address it to a certain extent.

Let’s understand why using UDP does not impact the quality of video or audio to a great extent. Human eyes can register around 36 – 60 frames per second (fps). The average movie is recorded at 24 fps, although some entertainment organizations have considered increasing this number to 60 – 120 fps: the higher a movie’s fps, the greater the picture quality. Video games use 30 – 120 fps, with 60 fps being the average.

When a user is watching a video or playing a game with these high frame rates, they are not likely to notice data loss in the form of a few frames. However, they will likely see latency due to the frames coming in slowly. A new challenging dimension is added in the case of online gaming, where every second matters for players.

As the quality of the video, audio and gaming improves, streaming and playing online become a heavy-duty affair requiring swift data transmission. Here, the limitations of UDP also serve as its strengths, making it ideal for multiplayer games, streaming media, and voice over internet protocol (VoIP) services.

3. Swift data transfer

DNS lookups, gaming, and streaming all rely on UDP for its capability to transfer data swiftly. However, these are not the only applications where this facet of UDP is taken advantage of. UDP can be used in any application where transmitting data quickly is more important than doing so reliably.

4. Multicasting

UDP supports packet switching, making it ideal for multicasting applications. ‘One-to-many’ applications rely on UDP to transmit packets to several recipients simultaneously without the need to establish point-to-point connections beforehand. One copy of each datagram is sent to one multicast address in these instances. This copy is then distributed across receivers. This setup is beneficial for transmitting video and audio to multiple receivers (such as in distance learning), sending notifications, and monitoring status.

5. Virtual private networks (VPN)

While TCP is the standard for VPNs, some VPN services also offer data transmission over UDP as an option for users. This is because VPNs are increasingly being used for high-definition (HD) video streaming, thus introducing the need to address latency challenges associated with TCP.

6. Google QUIC

The Internet Engineering Task Force (IETF) officially adopted the Google Quick UDP Internet Connection (QUIC) protocol as a part of its internet standard in May 2021. QUIC is a UDP-powered transport protocol that is encrypted and optimized for HTTPS. QUIC combines UDP and TCP’s key advantages: low latency, fewer errors, and lighter data streams.

See More: What Is Network Traffic Analysis? Definition, Importance, Implementation, and Best Practices

UDP Best Practices for 2022

Before implementing a user datagram protocol for an application, enterprise users must research and brush up on the best practices. Documents such as UDP Usage Guidelines (RFC 8085) provide helpful insights into design guidelines for delivering applications through unicast UDP.

UDP Best Practices

UDP Best Practices

1. Account for path conditions and transport

UDP must tolerate numerous internet path conditions and should leverage full-featured transport such as TCP.

The characteristics of internet paths can differ widely in terms of bandwidth availability, transmission delays, reordering probabilities, congestion levels, loss rates, or supported message sizes. It is also possible for the same internet path to feature varying conditions as time passes. As such, applications should be designed to avoid making assumptions regarding the characteristics of a particular path.

Such applications must instead leverage mechanisms that allow for the safe operation of varying path conditions. One can achieve this by carefully probing the current internet path used for communications. Following this process helps establish a transmission behavior that is sustainable and fair for other traffic on the same path.

2. Implement congestion control

A correctly configured UDP setup should control the rate of transmission and be able to exercise congestion control across traffic. Suppose UDP is implemented in an application or protocol that does not use congestion control, the rate at which UDP datagrams are transmitted to the destination host need to be controlled.

Applications should exercise congestion control on all UDP traffic transmitted to a destination, regardless of how this traffic is generated. For instance, applications that fork several worker processes or otherwise leverage numerous sockets for datagram generation should exercise congestion control across traffic.

Users must not view congestion control as an additional feature for applications. Instead, one must implement it across the application design, similar to implementing security aspects.

3. Bolster bulk transfer applications

When implementing UDP for bulk transfers, users should consider implementing TCP-friendly rate control (TFRC) or leverage bandwidth similar to TCP in other ways.

Applications that execute a peer-to-peer transfer of bulk data using UDP and thus exchange numerous UDP datagrams per round trip time (RTT), should adopt TFRC, window-based congestion control similar to TCP, or another application that complies with the principles of congestion control.

A key advantage of TFRC is its ability to provide congestion control and fairness that complies with the other transport protocols of IETF. If a bulk-transfer application does not implement TFRC or TCP-like windowing, a congestion control scheme that uses bandwidth fairly along with TCP should be considered instead.

You should also monitor packet loss to ensure that the packet-loss rate does not exceed tolerable parameters. One can gauge the acceptable packet loss threshold by measuring whether a TCP flow on the same network path under similar conditions leads to an average throughput that, when calculated using a sensible timescale, is not exceeded by that of the UDP flow.

Finally, if a bulk-transfer application does not adopt a congestion control mechanism, it can choose to transmit using reserved path capacity instead. This works for some restricted networking environments but is otherwise unsafe. Suppose UDP traffic from such an application seeps into an unprovisioned network path; it might negatively impact the performance of other traffic on the same path and could even lead to congestion collapse.

4. Streamline low data volume applications

UDP setups configured for non-bulk transfers should gauge RTT and transmit a maximum of 1 datagram/RTT. An alternative is to transfer a maximum of 1 datagram every 3 seconds and back-off retransmission timers following loss.

Implementing TFRC or a similar congestion control scheme for an application that, on average, exchanges minimal UDP datagrams with a destination, showcases limited benefits for the network. This is because the congestion control performed by those mechanisms shows efficacy solely for longer transmissions.

However, applications that transmit a limited number of datagrams should exercise control over transmission behavior and limit the number of datagrams sent per RTT to less than one, on average. One should maintain an estimate of the RTT for any destination as well.

5. Secure overall network

Finally, implementing UDP must come with an overall sense of security for the network.

Adopting a firewall is the most common way to establish the first few lines of network defense. Firewalls work by isolating networks from one another and are either included in other network systems such as routers and servers or come as standalone devices. A firewall can be hardware-based or software-based.

Additionally, users can implement an intrusion detection system (IDS) to boost cybersecurity levels. IDS works by spotting human or software intruders and prompting security teams to remove them. Setting up an IDS allows users to spot attacks faster than manually. It is an economical and safe method for securing the network and complying with regulatory obligations.

An intrusion prevention system (IPS) is similar but more advanced than an IDS. Intrusion prevention systems not only spot intrusions but also thwart them. An IPS essentially combines an IDS’s capabilities with those of a firewall. However, implementing IPS at scale can lead to ballooning IT costs.

Network access control (NAC) solutions work by ensuring that only the endpoints that comply with the organization’s security policy can access network resources. Advanced NAC tools can even enforce compliance measures and repair non-compliant endpoints automatically. NAC implementation aims to ensure all internal security measures are in place before an endpoint can access an unsecured external network.

Spam filters are a helpful way to prevent unwanted emails from reaching user mailboxes. This solution filters out emails based on automated pattern analysis and uses policies set by the vendor or enterprise.

See More: What Is Network Behavior Anomaly Detection? Definition, Importance, and Best Practices for 2022

Takeaway

Simple yet functional, UDP is valuable for data transmission for time-sensitive services such as live conferences, online gaming, and video streaming. UDP is ideal for specific business use cases where speed is a priority over the reliability of data transfer.

UDP avoids problems with latency and is leveraged to provide users with seamless streaming experiences. Enterprise users can choose between UDP and TCP based on the use case.

Did this article help you gain a comprehensive understanding of user datagram protocol? We would love to hear your feedback—let’s connect on FacebookOpens a new window , TwitterOpens a new window , or LinkedInOpens a new window ! 

MORE ON NETWORKING

Hossein Ashtari
Interested in cutting-edge tech from a young age, Hossein is passionate about staying up to date on the latest technologies in the market and writes about them regularly. He has worked with leaders in the cloud and IT domains, including Amazon—creating and analyzing content, and even helping set up and run tech content properties from scratch. When he’s not working, you’re likely to find him reading or gaming!
Take me to Community
Do you still have questions? Head over to the Spiceworks Community to find answers.