UDP: What It Is, Connectionless Protocol and How It Works

Author: IT Sectr Published: 2026-03-06 Reading time: 8 min

UDP (User Datagram Protocol) is a connectionless data transmission protocol operating over IP and providing minimal latency when sending datagrams. Unlike TCP, UDP does not guarantee delivery, packet ordering, or protection against duplication. According to IETF RFC 768 (2024), UDP handles more than 40% of global internet traffic due to video calls, streaming, and DNS queries.

Key Takeaways

  • UDP is a connectionless protocol that sends datagrams without delivery confirmation
  • Minimal latency is achieved through the absence of handshake, congestion control, and retransmissions
  • Used in video calls, online games, DNS, DHCP, and streaming
  • UDP datagram header is only 8 bytes compared to 20–60 bytes for TCP
  • Packet loss is compensated at the application layer through FEC, retransmission, or data redundancy

What Is UDP?

UDP (User Datagram Protocol) is one of the key transport layer protocols of the TCP/IP model, designed by David Reed in 1980. It provides a minimal data transmission mechanism: the application sends a datagram, and the protocol does not track whether it reached the recipient.

The UDP header consists of only four fields: source port, destination port, length, and checksum. Each field occupies 2 bytes, so the total header size is 8 bytes. For comparison, a TCP header without options is 20 bytes, and with options — up to 60 bytes.

The protocol does not support fragmentation at its own level — if a datagram exceeds the MTU (Maximum Transmission Unit), it is fragmented at the IP level. If one fragment is lost, the entire datagram is discarded, as UDP cannot request retransmission of individual fragments. Developers must control the datagram size — for mobile networks, the MTU is often 1400 bytes, so the maximum size should not exceed this value.

How UDP Works

An application using UDP creates a socket with the SOCK_DGRAM type, specifies the port and destination IP address, and sends a datagram. The protocol adds a minimal header and passes the packet to the IP layer. The recipient listens on its port and extracts data from incoming datagrams.

UDP does not perform congestion control — the application can send datagrams at the maximum speed supported by the network. This can lead to channel congestion, but in real-time scenarios such aggressiveness is justified: for a video call, a data stream with possible losses is more important than stopping transmission.

python
import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(b'Hello, UDP!', ('192.168.1.100', 8888))
sock.close()

In this example, a SOCK_DGRAM socket is created for UDP. The sendto method sends a datagram without establishing a connection — you only need to know the recipient's IP and port. The recvfrom method on the server side returns both the data and the sender's address for the response. UDP sockets on mobile platforms are configured similarly but require additional permissions: on iOS, NSAppTransportSecurity must be added for unencrypted UDP connections, and on Android, the INTERNET permission in the manifest.

UDP Pros and Cons

Choosing UDP is justified in scenarios where speed is more critical than reliability. The protocol does not waste time on connection setup, acknowledgments, and retransmissions — this provides minimal latency but requires the developer to handle losses independently.

AdvantagesDisadvantages
Low latency — no handshakeNo delivery guarantee
Smaller header — 8 bytesNo congestion control
Broadcast and multicast supportPossible packet duplicates
Datagram independence — no queuingDatagram size limited by MTU

In mobile applications, UDP is used through frameworks like WebRTC, which add loss control, adaptive bitrate, and jitter buffer on top of UDP. This provides the speed benefits without the drawbacks of the bare protocol.

Another important aspect of UDP is the absence of congestion control. In TCP, the Slow Start and Congestion Avoidance algorithms reduce the transmission speed upon packet loss to avoid network overload. UDP lacks such mechanisms, so developers must implement their own rate control strategies — for example, adaptive bitrate in video calls or rate limiting in game servers to prevent excessive network congestion.

Where UDP Is Used

UDP is indispensable in scenarios where latency tolerance is more important than packet loss tolerance. Let's explore the main areas of protocol application in mobile and web development.

Audio and Video Streaming

The RTP and RTSP protocols, running over UDP, are used for transmitting real-time audio and video streams. WebRTC — the standard for video calls in browsers and mobile applications — uses UDP as the primary transport for media data and TCP for signaling. Losing one packet in 30 fps video is unnoticeable to the user, unlike the delay of retransmission, which causes noticeable freezing of the picture.

Online Games

Multiplayer shooters and MOBAs require latency under 50 ms for proper synchronization. UDP transmits player positions, shots, and events faster than TCP, and packet loss is simply ignored — the next update will arrive in 16–33 ms. Popular game engines, including Unity and Unreal Engine, use UDP through their own transport layers with added reliability for critical events via application-level acknowledgments.

DNS and DHCP

DNS queries use UDP on port 53 because each query is a single small datagram (typically up to 512 bytes). If no response arrives, the client simply retries the query after a timeout, which is faster than establishing a TCP connection with its three-way handshake. DHCP also works over UDP, as the client does not yet have an IP address and cannot establish a TCP connection, while broadcast UDP packets allow finding a DHCP server on the local network.

UDP vs TCP Comparison

The choice between UDP and TCP is a trade-off between speed and reliability. Each protocol is optimal for its class of tasks, and understanding their differences helps make the right architectural decisions when designing network communication in mobile applications.

CriterionUDPTCP
Connection setupNot requiredThree-way handshake
Header8 bytes20–60 bytes
Delivery guaranteeNoYes, with acknowledgment
OrderingNoYes
Congestion controlNoYes (AIMD, Slow Start)
Use casesStreaming, games, DNSWeb, email, files, API

Mobile projects often use a hybrid approach: TCP for reliable requests (authentication, data loading) and UDP for media streams. QUIC — a modern protocol from Google running over UDP — combines UDP speed with TCP reliability and is already used in HTTP/3.

UDP Code Example

Let's look at a simple UDP server in Python that receives messages from clients and sends a response. The server listens on port 8888 and processes incoming datagrams in an infinite loop.

python
import socket

server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server.bind(('0.0.0.0', 8888))
print('UDP server started on port 8888')

while True:
    data, addr = server.recvfrom(1024)
    print(f'Received from {addr}: {data.decode()}')
    server.sendto(b'OK', addr)

The server creates a UDP socket, binds to port 8888, and waits for incoming datagrams. recvfrom returns the data and the client's address, allowing a response via sendto. Unlike TCP, the server does not maintain connection state — each datagram is processed independently. This makes UDP servers scalable: a single server can handle millions of clients without allocating memory for each individual connection, which is important for DNS servers and game matchmaking systems.

In mobile development, UDP is often used through high-level libraries. For example, CocoaAsyncSocket for iOS provides UDP sockets with delegates and GCD for asynchronous event handling. On Android, the DatagramSocket class is part of the standard java.net library and requires no additional dependencies. For Flutter, there is the udp package, which provides a simple interface for sending and receiving datagrams without configuring native sockets.

It is important to note that many mobile networks and corporate firewalls block UDP traffic, especially on ports above 1024. If your application uses UDP, you must provide a fallback to TCP or check protocol availability via STUN servers, as WebRTC does. On iOS, the system Network.framework with NWConnection supports both TCP and UDP, automatically choosing the optimal protocol based on availability. For real-time applications, it is also recommended to implement adaptive bitrate, which lowers stream quality upon packet loss, ensuring continuous playback even on unstable channels with high error rates.

Frequently Asked Questions

How does UDP differ from TCP?

UDP does not establish a connection and does not guarantee packet delivery, making it faster than TCP. The UDP header is 8 bytes compared to 20–60 bytes for TCP. UDP is suitable for streaming and games, while TCP is for web requests and file transfers.

What is a datagram in UDP?

A datagram is an independent data packet with a UDP header (source port, destination port, length, checksum). Each datagram is processed independently, without relation to previous ones. The datagram size is limited by the network MTU and by specification — up to 65507 bytes.

How is reliability ensured when using UDP?

UDP does not provide reliability at the transport level — it is implemented by the application. Developers add sequence numbers, checksums, retransmission requests, and error correction. FEC (Forward Error Correction) allows recovering lost packets without retransmission.

When should UDP not be used?

UDP is not suitable for scenarios where data integrity is critical: file transfers, bank transactions, REST APIs. In these cases, TCP guarantees that every byte arrives in the correct order. UDP is also not recommended on unstable channels with high loss rates.

What is QUIC and how is it related to UDP?

QUIC is a transport protocol running over UDP, developed by Google and standardized by IETF as RFC 9000. It combines UDP speed with TCP reliability, supports multiplexing without head-of-line blocking, and has built-in encryption. HTTP/3 uses QUIC as its transport layer.

Summary

  • UDP is a connectionless protocol with minimal latency and an 8-byte header
  • Does not guarantee delivery, packet order, or protection against duplication
  • Used in video calls, online games, DNS, DHCP, and streaming
  • Choosing UDP or TCP depends on the speed versus reliability trade-off for each scenario
  • Packet loss is compensated at the application layer through FEC, retransmission, or redundancy
  • QUIC over UDP combines UDP speed with TCP reliability in the HTTP/3 protocol
  • Developers must control datagram size and provide fallback to TCP when UDP is blocked or filtered on the network

We will develop a mobile application turnkey

IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.

Discuss the project

Read also