UDP starts by naming the local endpoint numbers on each side.

highlighted = computed this step

Ports name local endpoints

A UDP header begins with two port fields. In this toy datagram, those fields name the sending endpoint and the receiving endpoint.

source port=40000,destination port=53\text{source port}=40000,\quad \text{destination port}=53
Ports in the headerThe UDP header and tiny payload are decoded from exact bytes.UDP header64 bits / 8 bytes0x9c400035000a779fbyte 0byte 1byte 2byte 310011100010000000000000000110101byte 4byte 5byte 6byte 700000000000010100111011110011111source-port40000destination-port53length10checksum0x779fPayload16 bits / 2 bytes0x6869byte 0byte 10110100001101001payload0x6869

Source port

The source port is 40000. It is a field in the UDP header, not a process lookup.

source port=40000\text{source port}=40000
Ports in the headerThe UDP header and tiny payload are decoded from exact bytes.UDP header64 bits / 8 bytes0x9c400035000a779fbyte 0byte 1byte 2byte 310011100010000000000000000110101byte 4byte 5byte 6byte 700000000000010100111011110011111source-port40000destination-port53length10checksum0x779fPayload16 bits / 2 bytes0x6869byte 0byte 10110100001101001payload0x6869

Destination port

The destination port is 53. At this toy level, that is the socket-side name the receiver checks.

destination port=53\text{destination port}=53
Ports in the headerThe UDP header and tiny payload are decoded from exact bytes.UDP header64 bits / 8 bytes0x9c400035000a779fbyte 0byte 1byte 2byte 310011100010000000000000000110101byte 4byte 5byte 6byte 700000000000010100111011110011111source-port40000destination-port53length10checksum0x779fPayload16 bits / 2 bytes0x6869byte 0byte 10110100001101001payload0x6869

Summary

UDP ports are exact header fields. This book does not model process discovery, firewall behavior, or NAT behavior.

400005340000\to53
Ports in the headerThe UDP header and tiny payload are decoded from exact bytes.UDP header64 bits / 8 bytes0x9c400035000a779fbyte 0byte 1byte 2byte 310011100010000000000000000110101byte 4byte 5byte 6byte 700000000000010100111011110011111source-port40000destination-port53length10checksum0x779fPayload16 bits / 2 bytes0x6869byte 0byte 10110100001101001payload0x6869