UDP
ProtocolDefinition
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
TCP
Transmission Control Protocol (TCP) is a connection-oriented, reliable transport-layer protocol. TCP guarantees ordered delivery of packets, retransmits lost packets, and provides flow control and congestion control. It is used for HTTP, HTTPS, SSH, SMTP, and most reliable internet communications.
DNS
The Domain Name System (DNS) is the internet's distributed directory service that translates human-readable domain names (example.com) to IP addresses (93.184.216.34). DNS uses a hierarchical system of servers: root servers → TLD servers → authoritative nameservers.
IP Address
An Internet Protocol (IP) address is a unique numerical label assigned to each device on a network. IP addresses enable routing of data packets across the internet. IPv4 uses 32-bit addresses (e.g., 192.168.1.1); IPv6 uses 128-bit addresses (e.g., 2001:db8::1).
IPv4
IPv4 (Internet Protocol version 4) uses 32-bit addresses allowing ~4.3 billion unique addresses. Originally deemed sufficient, address exhaustion led to NAT (Network Address Translation) and ultimately IPv6. IPv4 remains dominant despite IPv6 adoption growing steadily.