UDP — User Datagram Protocol
For all its reliability, TCP is heavyweight: a handshake, timers, and a twenty-byte header. When an application would rather have speed and low overhead than guaranteed delivery, it reaches for UDP. This lesson covers the eight-byte header, the best-effort model, and exactly when each transport protocol is the right tool.
Connectionless by design
UDP is defined in RFC 768, and it fits on a single page because it does almost nothing. It takes the application’s data, adds ports so the receiver knows which service and socket the data belongs to, adds a length and a checksum, and hands the result to IP. There is no conversation, no state, and no second-guessing of the network.
- Connectionless — there is no setup. Each datagram is addressed and sent on its own.
- Best-effort — UDP hands the datagram to IP and hopes. Lost datagrams are simply lost.
- No ordering — datagrams may arrive out of order, and UDP does nothing about it.
- Minimal overhead — an 8-byte header versus TCP’s 20, and no state bookkeeping in the operating system.
- Message-oriented — UDP preserves the boundaries of each send; one send is one datagram (this is why a UDP unit is called a datagram, not a segment).
The UDP header (8 bytes)
The whole header is four 16-bit fields — two words — for a total of 8 bytes. Compare that with the TCP base header’s 20 bytes and the difference in philosophy is obvious.
UDP Header (RFC 768) 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Port | Destination Port | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Length | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Data ... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Header total = 2 + 2 + 2 + 2 = 8 bytes. Length covers header + data.
Field-by-field reference
Select any field in the explorer below to see its width and its job.
| Field | Bits | Bytes | Purpose |
|---|---|---|---|
| Source Port | 16 | 2 | Identifies the sending application or socket. Optional in one direction; if unused it is set to 0. |
| Destination Port | 16 | 2 | Identifies the service on the receiver (e.g. 53 for DNS). |
| Length | 16 | 2 | The length of the entire datagram in bytes: header + data. Minimum value is 8. |
| Checksum | 16 | 2 | Error check over a pseudo-header, the UDP header, and the data. Optional in IPv4; mandatory in IPv6. |
Notice the Length field counts the header too. A datagram carrying 100 bytes of payload has a Length of 108 (100 + 8). Because the field is 16 bits, the theoretical maximum datagram length is 65,535 bytes, although the practical size is dictated by the IP layer and the link MTU. The smallest possible datagram is the bare header: Length = 8, zero data.
Checksum and error handling
UDP does include a checksum, but its error handling is blunt. The receiver computes the checksum and compares it with the field:
- Checksum matches → the data is passed up to the application. UDP does not acknowledge it or remember it.
- Checksum fails → the datagram is silently discarded. UDP does not request a retransmission and does not notify the sender.
If the application cares about the loss, the application must detect it and retry — for example, DNS resends a query after a timeout, and a VoIP codec conceals a missing packet. In IPv4 the checksum is optional: a value of zero means “not computed.” In IPv6 there is no IP header checksum, so the UDP checksum is mandatory.
When UDP is the right choice
UDP wins whenever the conversation is short (a single request and reply), bandwidth-efficient, or time-sensitive (a retransmission would arrive too late anyway). Select a service to see why it fits.
| Service | Port(s) | Why UDP fits |
|---|---|---|
| DNS | 53 | One tiny query, one tiny reply; the app resends if there is no answer. |
| DHCP / DHCPv6 | 67 (server), 68 (client) | Broadcast discovery before the client has an address; no connection can be set up yet. |
| TFTP | 69 | Trivial file transfer where the application implements its own light acknowledgment. |
| SNMP | 161 (agent), 162 (traps) | Management polling is lightweight and periodic. |
| NTP | 123 | Time sync tolerates loss and prefers a fresh sample over an old retransmission. |
| syslog | 514 | Log messages are sent and forgotten. |
| VoIP / RTP | RTP uses a dynamic port (commonly 16384–32767) | Real-time audio; a late packet is useless, so retransmission is pointless. |
| Streaming media, online games | Varies | Continuous real-time flow where an occasional glitch beats added delay. |
TCP vs UDP
TCP and UDP are two answers to the same question: how should applications share the network? TCP optimises for correctness; UDP optimises for timeliness and simplicity.
| Property | TCP | UDP |
|---|---|---|
| Connection | Connection-oriented (3-way handshake) | Connectionless (no handshake) |
| Reliability | Reliable — acknowledgments and retransmission | Best-effort — no retransmission |
| Ordering | In-order delivery via sequence numbers | No ordering; datagrams may arrive out of order |
| Flow control | Yes (window size) | No |
| Congestion control | Yes | No |
| Header size | 20 bytes base (up to 60) | 8 bytes |
| Duplicate detection | Yes | No |
| Speed / overhead | Slower setup, higher overhead | Faster, minimal overhead |
| Typical uses | Web, email, file transfer, SSH, database | DNS, DHCP, TFTP, SNMP, VoIP, streaming, gaming |
Handshake vs blind send
The figure contrasts the two transports side by side. On the left, TCP spends three messages agreeing on the connection before a single byte of data moves. On the right, UDP sends its data immediately, with no preamble and no acknowledgment — it does not even know whether a listener exists.
Common pitfalls
- Calling a UDP unit a “segment.” TCP has segments; UDP has datagrams.
- Thinking the Length field counts only data. It counts header + data; the minimum is 8.
- Believing UDP is unreliable by accident. It is best-effort by design; the application decides whether to add reliability.
- Assuming UDP has no checksum. It does, and it is mandatory over IPv6.
- Forgetting the dual nature of DNS. DNS uses UDP for queries and TCP for large transfers — both on port 53.
Key terms
| Term | Meaning |
|---|---|
| UDP | User Datagram Protocol; connectionless, best-effort transport defined in RFC 768. |
| Datagram | A UDP data unit (header + data); the UDP equivalent of a TCP segment. |
| Connectionless | No handshake or connection state; every datagram is independent. |
| Best-effort | No guarantee of delivery, ordering, or duplicate suppression. |
| Length field | 16-bit UDP field giving header + data size; minimum 8. |
| RTP | Real-time Transport Protocol; carries voice/video over UDP, usually on a dynamic port. |
Review
Check what you have learned with these review questions.
Sources & references
- Postel, J. RFC 768: User Datagram Protocol (1980) — the entire specification, including the header format. rfc-editor.org/rfc/rfc768.
- Braden, R. RFC 1122: Requirements for Internet Hosts — Communication Layers (1989), Section 4.1.3 (UDP requirements, including the checksum). rfc-editor.org/rfc/rfc1122.
- Deering, S. & Hinden, R. RFC 8200: Internet Protocol, Version 6 (IPv6) Specification (2017) — the 40-byte fixed header and mandatory UDP checksum context. rfc-editor.org/rfc/rfc8200.
- IANA. Service Name and Transport Protocol Port Number Registry. iana.org.
- Cisco. CCNA (200-301) Exam Topics, TCP/IP transport. cisco.com.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.