It consists of four fields each of 2 bytes in length –
- Source Port(16 bits) – This field identifies the sender’s port. Cleared to zero if not used.
- Destination Port(16 bits) – This field identifies the receiver’s port.
- Length(16 bits) – The length in bytes of the UDP header and the encapsulated data. The minimum value for this field is 8.
- Checksum(16 bits) – The checksum field may be used for error-checking of the header and data. This field is optional in IPv4, and mandatory in IPv6. The field carries all-zeros if unused. Needed with zero bytes at the end to make a multiple of two bytes. If the checksum is cleared to zero, then checksum is disabled. If the computed checksum is zero, then this field must be set to 0xFFFF.
Related – TCP HEADER