UDP
Also known as: User Datagram Protocol
User Datagram Protocol — a lightweight, connectionless transport protocol that delivers packets with minimum overhead but no reliability guarantees.
Last updated:
What is UDP?
UDP (User Datagram Protocol) is a connectionless, unreliable transport protocol defined in RFC 768 in 1980. Unlike TCP, UDP does not establish a connection before sending data, does not retransmit lost packets, does not enforce ordering, and does not check for duplicates. A UDP packet (called a datagram) is sent and forgotten. If the application needs reliability, it has to implement it on top.
That minimal design is exactly why UDP is preferred when latency, simplicity, or broadcast/multicast semantics matter more than guaranteed delivery.
What UDP is good at
- DNS queries — the round-trip cost of a TCP handshake would double or triple DNS latency for queries that fit in one packet
- Real-time media — a retransmitted video frame that arrives after its playback slot is worse than just dropping it
- Voice calls and video conferencing (VoIP, WebRTC) — where older data is useless
- Games — where the most recent position update matters far more than yesterday's
- Broadcast / multicast — TCP cannot do either; UDP can
- QUIC and HTTP/3 — Google's modern transport sits on UDP so it can implement its own improved congestion control and connection migration, bypassing ossified TCP behavior in middleboxes
UDP packet structure
A UDP datagram has an 8-byte header on top of the IP header:
| Field | Size | Purpose | |----------------|--------|---------| | Source Port | 2 bytes | Sender's port | | Destination Port | 2 bytes | Receiver's port | | Length | 2 bytes | Length of header + data | | Checksum | 2 bytes | Optional integrity check |
Compare that to TCP's 20+ byte header with sequence numbers, ACK numbers, flags, and window size. That's the overhead difference.
When TCP is the right choice instead
Use TCP when correctness matters — file transfer, web traffic, email, SSH. Use UDP when latency or simplicity matters more. HTTP/3 (QUIC) is an interesting middle ground: UDP transport, with TCP-equivalent reliability features built into the application layer.