UDP
Datagrams with ports and a checksum. No connection, no retransmission, no congestion control.
Level: beginner
What is it?
User Datagram Protocol (UDP) is a connectionless transport protocol that carries datagrams between application endpoints using port numbers. It provides minimal transport framing and checksum-based error detection in common cases, but does not provide reliable delivery, ordering, retransmission, or congestion control by itself.
Why does it matter?
UDP lets applications choose the reliability, timing, and congestion behavior they need. DNS, streaming media, gaming, and real-time communication often benefit from avoiding built-in retransmission delay, but the application must be designed for loss and rate control.
Mental model
UDP delivers independent datagrams rather than a reliable byte stream. A receiver may get a datagram, miss one, or receive them in a different order; transport does not repair those conditions automatically.
How it works
- UDP preserves datagram boundaries, unlike TCP's byte stream.
- Ports allow the OS to demultiplex datagrams to sockets or application endpoints.
- A checksum helps detect corruption according to the protocol's rules; it does not guarantee delivery.
- Applications needing reliability can add acknowledgements, retries, ordering, or congestion handling, but must design these carefully.
- QUIC runs over UDP while implementing substantial transport reliability, encryption, and congestion control in user space.
Steps
- A client sends a UDP datagram to server IP and port 53.
- The IP layer routes it toward the destination.
- The receiving host uses the destination port to deliver the datagram to the appropriate socket.
- If the reply is lost, UDP itself does not retransmit; the application decides what to do.
Real-world usage
- DNS queries, real-time media, telemetry, and latency-sensitive applications.
- Choosing between message datagrams and reliable byte streams.
- Understanding why QUIC can use UDP while still offering reliable streams.
Common mistakes
- Saying UDP never has congestion control at the application/protocol stack level; it has none built into basic UDP, but applications may implement it.
- Assuming a checksum provides cryptographic integrity or authentication.
- Using retries without limits and causing congestion amplification.
Interview questions
What does UDP guarantee?
Basic UDP provides datagram transport and port-based demultiplexing, but not reliable delivery, ordering, retransmission, or built-in congestion control.
Why does QUIC use UDP?
UDP offers a deployable datagram substrate while QUIC implements its own secure connection, streams, reliability, and congestion-control behavior above it.