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

FieldOffsetSizeTypeDescription
Source Port
source_port
0 bits16 bitsuint16Source port number (0-65535)
Known values: 53=DNS, 67=DHCP Server, 68=DHCP Client, 80=HTTP, +4 more
Destination Port
dest_port
16 bits16 bitsuint16Destination port number (0-65535)
Known values: 53=DNS, 67=DHCP Server, 68=DHCP Client, 80=HTTP, +4 more
Length
length
32 bits16 bitsuint16Length of UDP header and data in bytes (minimum 8)
Checksum
checksum
48 bits16 bitsuint16hexChecksum 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)