UDP Header Structure and Fields
What you'll learn: You'll see exactly how UDP's minimal 8-byte header organizes the four essential fields that make connectionless communication work.
The Simplest Transport Header
Unlike TCP's complex 20+ byte header with sequence numbers, acknowledgments, and flow control fields, UDP takes a radically different approach: minimalism. The entire UDP header is just 8 bytes (64 bits), containing only the bare essentials needed to deliver a datagram to the right application.
The Four Fields
The UDP header consists of exactly four 16-bit (2-byte) fields in this order:
1. Source Port (16 bits)
Identifies the sending application's port number. This is technically optional—if the sender doesn't expect a reply, this field can be set to zero.
2. Destination Port (16 bits)
Identifies which application on the receiving host should get the data. This is the only required field for delivery.
3. Length (16 bits)
Specifies the total length of the UDP datagram in bytes, including both the 8-byte header and the data payload. Minimum value is 8 (header only, no data).
4. Checksum (16 bits)
Optional error detection for the header and data. If not used, it's set to zero (though IPv6 requires it). Detects corruption but provides no correction or retransmission.
Why So Simple?
Think of UDP like a postcard: you write the destination address (port), optionally add a return address (source port), and drop it in the mail. There's no tracking, no confirmation of delivery, no sequence numbering. This simplicity means less overhead, faster processing, and lower latency—perfect for real-time applications that can tolerate some data loss.
Key Takeaway: UDP's 8-byte header contains just four fields—source port, destination port, length, and checksum—reflecting its design philosophy of minimal overhead for fast, connectionless communication.