DD
DevDash

UDP

Protocol

Definition

User Datagram Protocol (UDP) is a connectionless, best-effort transport-layer protocol. UDP sends packets without establishing a connection or guaranteeing delivery, order, or duplicate protection. This makes UDP faster than TCP and suitable for real-time applications.

UDP Header Structure and Datagram Format

Eight bytes. That is the entire UDP header, compared to TCP's 20 or more bytes. The header contains exactly four fields: source port (16 bits), destination port (16 bits), length (16 bits for the total datagram size with a minimum of 8), and checksum (16 bits, optional in IPv4 but mandatory in IPv6). The payload follows immediately with no framing overhead. No connection state. No sequence numbers. No acknowledgment numbers. No window size negotiation. No options. This is why UDP is substantially faster than TCP for latency-sensitive applications. Each UDP datagram is self-contained and independently routed, meaning packets in the same logical session may travel completely different network paths, arrive out of order, be duplicated, or be lost entirely without any notification reaching either side of the communication. The theoretical maximum UDP payload is 65,507 bytes (65,535 minus 8 bytes of UDP header and 20 bytes of IP header), but practical limits are much lower because most Ethernet networks have an MTU of 1,500 bytes, giving roughly 1,472 bytes of UDP payload before the IP layer must fragment the packet across multiple datagrams.

When to Use UDP vs TCP

TCP guarantees ordered delivery, retransmission of lost packets, flow control, and congestion control. The cost of these guarantees is latency (a round-trip time is needed for the SYN-ACK handshake, plus additional round trips for retransmissions), memory for per-connection state, and CPU for processing acknowledgments. UDP guarantees nothing. The benefit is low latency, no connection establishment overhead, and support for broadcast and multicast addressing. Choose UDP when latency matters more than completeness: in VoIP or live video, a dropped frame produces a brief glitch but continuing playback is far preferable to waiting for a retransmission. Choose UDP when the application implements its own reliability: QUIC builds ordered delivery and congestion control on top of UDP. Choose UDP for stateless request-response patterns that fit in a single datagram: DNS sends a question and gets an answer without paying a TCP handshake cost. Choose TCP when every byte must arrive correctly (file downloads, database queries, SSH sessions), when ordering is required, or when you need network-level flow control on a congested path.

UDP in Modern Protocols: QUIC and HTTP/3

HTTP/3 runs over QUIC, which is built on top of UDP. QUIC implements reliability, stream ordering, congestion control, and TLS 1.3 encryption at the application level rather than relying on the OS TCP stack. This design eliminates head-of-line blocking: in HTTP/2 over TCP, a single lost packet stalls all multiplexed streams. In QUIC, each stream is independent so one lost packet only delays that stream. QUIC also enables 0-RTT connection establishment on repeat visits, where the client can send application data in the very first packet to a previously visited server. Connection migration is another advantage: a QUIC connection can move from Wi-Fi to cellular without reconnecting, because QUIC identifies connections by a connection ID rather than the IP/port tuple. DNS over HTTPS, DNS over TLS, and DNS over QUIC are all available as encrypted DNS alternatives. WebRTC (real-time video and audio in browsers) uses SRTP over UDP with DTLS for key exchange and encryption. DTLS (Datagram TLS) provides the same security guarantees as TLS but adapted for the unreliable datagram environment of UDP.

Related Tools

Frequently Asked Questions

Related Terms

Want API access + no ads? Pro coming soon.