What is UDP?

UDP (User Datagram Protocol) is a fast, connectionless transport protocol that sends datagrams without handshakes, acknowledgments, retransmissions, ordering, or built-in flow and congestion control. Learn how UDP works at OSI Layer 4, UDP header fields (ports, length, checksum), key use cases like DNS, VoIP, online gaming, video streaming, IoT, and how to handle packet loss, jitter, MTU limits, NAT traversal, and security with QUIC, RTP/RTCP, and DTLS.

UDP (User Datagram Protocol) is a connectionless transport protocol that sends data without establishing connections or guaranteeing delivery. UDP prioritizes speed and efficiency over reliability, making it ideal for real-time applications.

Last updated: 2026-03-25

How UDP Works

UDP operates at the transport layer (OSI Layer 4) and provides minimal protocol overhead for data transmission.

UDP Characteristics:

Connectionless:

  • No handshake before data transmission
  • No connection state maintained
  • Send datagrams immediately without setup

Unreliable:

  • No acknowledgment of receipt
  • No retransmission of lost packets
  • No guarantee of delivery

Unordered:

  • Packets may arrive in any order
  • No sequence numbering
  • Application handles ordering if needed

Unregulated:

  • No flow control
  • No congestion control
  • Sender determines transmission rate

UDP Datagram Structure:

  • Source Port: Sending application (16 bits, optional)
  • Destination Port: Receiving application (16 bits)
  • Length: Total datagram size (16 bits)
  • Checksum: Error detection (16 bits, optional for IPv4)
  • Data: Application payload (variable, up to 65,507 bytes)

Total overhead: 8 bytes (vs. TCP’s 20+ bytes)

When to Use UDP

Use UDP when you need:

  • Minimal latency overhead (no handshake, no ACKs)
  • Real-time data transmission (streaming, gaming, VoIP)
  • Broadcasting or multicasting (one-to-many transmission)
  • Simple request-response with low payload
  • Applications tolerant of packet loss (1-5% acceptable)
  • High throughput without congestion control overhead
  • Custom reliability implemented at application layer

Do not use UDP when you need:

  • Guaranteed delivery of every packet
  • Ordered data transmission
  • Flow control to prevent overwhelming receivers
  • Congestion control to avoid network collapse
  • File transfer without corruption
  • Transaction integrity (financial, database)
  • Long-lived reliable connections

Signals You Need UDP

  • Real-time application where latency more critical than reliability
  • Streaming media (video, audio) where occasional gaps acceptable
  • Online gaming requiring fast updates, can interpolate missing data
  • DNS queries needing quick responses with small payloads
  • VoIP where slight audio gaps preferable to delay
  • Broadcasting to multiple recipients simultaneously
  • Application implements custom reliability mechanisms

UDP vs. TCP Comparison

FeatureUDPTCP
ConnectionConnectionlessConnection-oriented
ReliabilityUnreliableReliable (ACKs, retransmission)
OrderingUnorderedOrdered (sequence numbers)
Flow ControlNoneSliding window
Congestion ControlNoneSlow start, congestion avoidance
Overhead8 bytes header20+ bytes header
SpeedFast (no overhead)Slower (features overhead)
HandshakeNoneThree-way handshake
Use CaseReal-time, streamingReliable delivery, files

Throughput Comparison:

  • UDP: Limited only by network capacity and application
  • TCP: Limited by congestion control and flow control
  • Example: 100 Mbps link, UDP can use nearly 100 Mbps; TCP varies 10-95 Mbps based on congestion

Latency Comparison:

  • UDP: Immediate transmission (0 RTT)
  • TCP: 1.5 RTT for connection establishment + handshake time
  • Example: 50ms RTT network, UDP starts immediately; TCP requires 75ms before first data

UDP Use Cases

DNS (Domain Name System)

How it works:

  • Client sends UDP query to DNS server (port 53)
  • Server responds with single UDP packet
  • Typical payload: under 512 bytes (traditional) or under 4096 bytes (EDNS)

Why UDP:

  • Fast query-response
  • Small payload fits in single packet
  • Low latency critical for web browsing
  • DNS over TCP fallback for large responses

Trade-offs:

  • Packet loss causes timeout and retry
  • Application implements retry logic
  • Truncation bit signals need for TCP

VoIP (Voice over IP)

How it works:

  • Audio encoded in small packets (20-30ms)
  • Packets transmitted continuously via UDP
  • Receiver buffers, reorders, plays audio
  • Missing packets cause brief audio gaps

Why UDP:

  • Real-time: 150ms+ latency noticeable
  • Packet loss acceptable (interpolation)
  • Latency worse than gaps
  • Retransmitted packets arrive too late

Quality metrics:

  • Acceptable packet loss: 1-3%
  • Latency target: under 150ms one-way
  • Jitter: Variation in arrival times

Online Gaming

How it works:

  • Game state updates sent continuously
  • Client prediction and interpolation
  • Server authoritative state
  • Missing updates interpolated

Why UDP:

  • Real-time player movement
  • Fast response critical for gameplay
  • Can interpolate missing positions
  • Retransmitted state would be stale

Implementation:

  • Application implements reliability for critical events
  • Unreliable for frequent position updates
  • Sequence numbers for ordering (application layer)
  • Acknowledgments for important events only

Video Streaming

How it works:

  • Video encoded in segments
  • Transmitted via UDP packets
  • Client buffers before playback
  • Forward error correction adds redundancy

Why UDP:

  • High throughput needed
  • Late frames worse than missing frames
  • Can request missing I-frames
  • Retransmission would cause buffering

Techniques:

  • Forward Error Correction (FEC): Redundant data
  • Adaptive bitrate: Adjust quality to bandwidth
  • Buffer management: Balance latency vs. gaps

IoT and Sensor Data

How it works:

  • Sensors transmit readings via UDP
  • Aggregation at gateway or cloud
  • Time-series databases store data
  • Missing readings interpolated

Why UDP:

  • Low power consumption (no connection overhead)
  • Simple implementation on constrained devices
  • High volume of small packets
  • Occasional loss acceptable

Considerations:

  • Critical alerts may use TCP or reliable UDP
  • Time synchronization needs reliability
  • Configuration updates need guaranteed delivery

UDP Reliability Extensions

Application-Layer Reliability

Custom acknowledgments:

  • Application defines important packets
  • Receiver sends ACK for received packets
  • Sender retransmits unacknowledged packets
  • Selective reliability reduces overhead

Sequence numbers:

  • Add sequence numbers to UDP payloads
  • Receiver detects missing packets
  • Request retransmission for gaps
  • Reorder received packets

Forward Error Correction (FEC):

  • Add redundant data to transmissions
  • Recover from packet loss without retransmission
  • Trade bandwidth for reliability
  • Example: Send 6 packets for every 4 data packets

QUIC Protocol

What it is: UDP-based protocol providing TCP-like reliability with reduced latency.

Key features:

  • Built on UDP (no kernel changes needed)
  • Connection establishment: 0-RTT after initial connection
  • Multiplexed streams (no head-of-line blocking)
  • TLS 1.3 integrated
  • Better performance on mobile networks

Comparison:

  • TCP: 1.5 RTT for connection + TLS handshake
  • QUIC: 0-1 RTT for connection with TLS integrated
  • Overhead: Higher than TCP, lower than TCP+TLS

HTTP/3: Uses QUIC over UDP for web transport

RTP (Real-time Transport Protocol)

What it is: Protocol for real-time audio and video delivery over UDP.

Features:

  • Sequence numbers for ordering
  • Timestamps for playback synchronization
  • Payload type identification
  • SSRC (synchronization source) for stream identification

RTCP (RTP Control Protocol):

  • Quality feedback (packet loss, jitter)
  • Session management
  • Participant identification

DTLS (Datagram TLS)

What it is: TLS encryption for UDP datagrams.

Features:

  • Provides security for UDP
  • Similar to TLS for TCP
  • Handles packet loss and reordering
  • Used in WebRTC for secure communication

Metrics and Measurement

Performance Metrics:

Packet Loss:

  • Percentage of packets lost in transit
  • VoIP acceptable: under 3%
  • Video streaming acceptable: under 1% with FEC
  • Gaming acceptable: under 5% with interpolation

Latency:

  • One-way delay from sender to receiver
  • VoIP target: under 150ms
  • Gaming target: under 50ms for responsiveness
  • DNS target: under 100ms

Jitter:

  • Variation in packet arrival times
  • Affects real-time applications
  • VoIP acceptable: under 30ms
  • Gaming acceptable: under 50ms

Throughput:

  • Bits per second delivered
  • No congestion control means sender controls rate
  • Monitor network capacity to avoid overwhelming

UDP Traffic Statistics:

  • DNS: 5-10% of internet traffic
  • VoIP/Gaming: Growing percentage
  • Video streaming: Shifted to TCP (HTTP-based) for reliability
  • Overall UDP: ~15-20% of internet traffic

According to Sandvine, UDP traffic represents approximately 17% of global internet traffic, with DNS, gaming, and real-time communications as primary use cases.

Common Mistakes and Fixes

Mistake: Not implementing any reliability for important data Fix: Use selective reliability for critical packets. Implement ACK/retry at application layer. Use TCP for control channel, UDP for data.

Mistake: Sending faster than network capacity Fix: Implement rate limiting. Monitor packet loss. Back off when loss detected. Use congestion-aware protocols (QUIC, RTP with RTCP).

Mistake: Not handling packet ordering Fix: Add sequence numbers. Buffer and reorder at receiver. Define acceptable out-of-order window.

Mistake: Ignoring MTU limitations Fix: Limit UDP payload to 1472 bytes for Ethernet (1500 MTU - 20 IP - 8 UDP). Fragment larger payloads or use path MTU discovery.

Mistake: Not using checksums Fix: Always use UDP checksum. Detect corrupted packets. Application may add additional integrity checks.

Mistake: Assuming UDP always faster than TCP Fix: UDP faster for real-time, but TCP may be faster for bulk transfer due to congestion control preventing network collapse. Measure actual performance.

Mistake: Not considering firewall/NAT issues Fix: UDP may be blocked or require port forwarding. Implement hole punching for NAT traversal. Use STUN/TURN for VoIP/WebRTC.

Frequently Asked Questions

Why use UDP if it’s unreliable? Unreliability is acceptable for real-time applications where speed matters more than completeness. Latency from TCP reliability mechanisms (handshake, ACKs, retransmission) makes TCP unsuitable for time-sensitive data.

How do applications handle lost UDP packets? Applications ignore lost packets (audio gaps), interpolate missing data (video frames), request retransmission for critical data (custom reliability), or use forward error correction to recover without retransmission.

What is the maximum UDP packet size? Theoretical maximum: 65,535 bytes (IP limitation). Practical maximum: Path MTU (typically 1500 bytes on Ethernet). Recommended: 1472 bytes to avoid fragmentation (1500 - 20 IP header - 8 UDP header).

Can UDP be secure? Yes. Use DTLS (Datagram TLS) for encryption. Implement application-layer security. Use HTTPS over QUIC (HTTP/3). VPNs tunnel UDP securely.

Does UDP have congestion control? No. UDP has no built-in congestion control. Sender must implement rate limiting. Unregulated UDP can cause network collapse. QUIC adds congestion control to UDP.

How does UDP handle NAT traversal? NATs map internal IP:port to external IP:port. UDP hole punching: Both sides send packets to establish NAT mappings. STUN servers help discover public IP:port. TURN servers relay traffic if direct connection fails.

What is UDP hole punching? Technique for establishing direct UDP connection between clients behind NATs. Both clients send packets to each other’s public addresses simultaneously. NATs create mappings, allowing bidirectional communication.

Can UDP support multicast? Yes. UDP supports one-to-many communication via multicast addresses (224.0.0.0 to 239.255.255.255). TCP is unicast only. Multicast efficient for streaming to multiple recipients.

What percentage of internet traffic is UDP? Approximately 15-20% of internet traffic is UDP. DNS, VoIP, gaming, and QUIC-based HTTP/3 are primary uses. Growing with real-time applications.

How does QUIC improve on UDP? QUIC adds reliability, congestion control, and security (TLS 1.3) to UDP. Provides TCP-like guarantees with lower latency. Eliminates head-of-line blocking through multiplexed streams. 0-RTT connection establishment.

How This Applies in Practice

UDP enables real-time and high-performance applications:

Real-Time Communications:

  • VoIP prioritizes low latency over completeness
  • Video conferencing uses UDP with adaptive codecs
  • Screen sharing interpolates missing frames
  • WebRTC uses UDP (via RTP) for peer-to-peer

Online Gaming:

  • Player movements sent continuously via UDP
  • Server authoritative game state
  • Client prediction masks network latency
  • Important events (player kills, item pickups) use reliability

DNS Infrastructure:

  • Fast query-resolution critical for web performance
  • Fallback to TCP for large responses
  • DNS over HTTPS (DoH) uses TCP/TLS for privacy
  • DNS over QUIC (DoQ) uses UDP for speed and privacy

Streaming Media:

  • Live streaming uses UDP for real-time delivery
  • Adaptive bitrate adjusts to packet loss
  • Forward error correction adds resilience
  • Video-on-demand typically uses TCP (HTTP-based)

IoT Applications:

  • Sensors transmit frequent small readings
  • UDP reduces power consumption
  • Gateways aggregate and batch data
  • Critical alerts use TCP or reliable UDP

UDP on Azion

Azion optimizes UDP performance for real-time applications:

  1. UDP load balancing through Edge Application
  2. Global anycast network reduces UDP latency
  3. Edge Functions for UDP packet processing
  4. Real-Time Metrics monitor UDP traffic
  5. WebSocket support over TCP with fallback
  6. DNS services using optimized UDP handling

Azion’s edge network provides low-latency UDP delivery across 100+ global locations.

Learn more about Application Acceleration and Edge Application.


Sources:

stay up to date

Subscribe to our Newsletter

Get the latest product updates, event highlights, and tech industry insights delivered to your inbox.