核心 · Key Idea
In one line: UDP sets up no connection, doesn't guarantee delivery or order, but has only an 8-byte header and fires-and-forgets. Real-time use cases (DNS / video / voice / gaming / QUIC) almost all pick it.
What it is#
UDP datagram format:
+-----------------+----------------+
| src port (16) | dst port (16) |
+-----------------+----------------+
| length (16) | checksum (16) |
+-----------------+----------------+
| data |
+----------------------------------+
8-byte header + data — no sequence, no ACK, no retransmit.
Analogy#
打个比方 · Analogy
UDP is a walkie-talkie: hold the button and shout. Heard it? lucky. Missed it? not retried. Realtime beats complete.
Key concepts#
ConnectionlessConnectionless
No handshake before sending — any host just sends.
DatagramDatagram
UDP data has boundaries — one send = one recv.
UnreliableUnreliable
No retransmit on loss; the application must handle it.
Out-of-orderOut-of-order
Packets may arrive in any order; the application must sort.
Broadcast / MulticastBroadcast / Multicast
UDP supports both natively; TCP doesn't (point-to-point only).
How it works#
The OS hands the UDP packet to the listening process — no connection, no state.
Practical notes#
- Typical protocols: DNS (simple Q&A), DHCP, SNMP, NTP, VoIP (RTP), QUIC (HTTP/3 underlying).
- UDP doesn't natively give half-duplex / order / reliability — build them in the app (QUIC does this).
- Less NAT-friendly: routers maintain UDP entries by timeout (TCP has SYN/FIN); timeouts vary widely — pain point for P2P.
- MTU sensitive: large UDP fragments easily; keep payload within MTU (typically 1472 IPv4, 1452 IPv6).
- Capture:
tcpdump 'udp port 53'to see DNS.
Easy confusions#
UDP
The barebones transport itself.
Reliability is the app's call.
Reliability is the app's call.
QUIC
Implements reliability / encryption / multistream **on top of** UDP.
HTTP/3 uses it instead of TCP.
HTTP/3 uses it instead of TCP.