Protocol Tutorial
UDP Header Format
Complete guide to UDP header structure: source port, destination port, length, and checksum fields. Understand how UDP provides lightweight connectionless transport.
Protocol Overview
User Datagram Protocol (RFC 768)
Header Size: 8 bytes (64 bits)
Fields: 4
Endianness: big
Spec: RFC 768
Header Fields
| Field | Offset | Size | Type | Description |
|---|---|---|---|---|
Source Port source_port | 0 bits | 16 bits | uint16 | Source port number (0-65535) Known values: 53=DNS, 67=DHCP Server, 68=DHCP Client, 80=HTTP, +4 more |
Destination Port dest_port | 16 bits | 16 bits | uint16 | Destination port number (0-65535) Known values: 53=DNS, 67=DHCP Server, 68=DHCP Client, 80=HTTP, +4 more |
Length length | 32 bits | 16 bits | uint16 | Length of UDP header and data in bytes (minimum 8) |
Checksum checksum | 48 bits | 16 bits | uint16hex | Checksum for error detection (optional in IPv4, mandatory in IPv6) |
Common UDP Mistakes
- 1Forgetting that UDP checksum is optional in IPv4 but mandatory in IPv6
- 2Assuming UDP preserves message boundaries (it does, but intermediate devices may fragment)
- 3Not checking the Length field matches actual payload size
- 4Confusing source and destination port numbers in packet analysis
- 5Assuming UDP is completely unreliable (it is connectionless, but checksum provides basic integrity)
Related Resources
Quick Facts
ProtocolUDP
Header Size8 bytes
Fields4
Endiannessbig
SpecificationRFC 768