The UDP source port changes with the return address, while the destination port stays fixed.

highlighted = computed this step

NAT changes the source port

The UDP source port changes from 40000 to 62000.

400006200040000\to62000
Source port rewriteThe before and after UDP headers show the source port rewrite.Before UDP header64 bits / 8 bytes0x9c400035000a0ee0byte 0byte 1byte 2byte 310011100010000000000000000110101byte 4byte 5byte 6byte 700000000000010100000111011100000source-port40000destination-port53length10checksum0x0ee0After UDP header64 bits / 8 bytes0xf2300035000a3e9cbyte 0byte 1byte 2byte 311110010001100000000000000110101byte 4byte 5byte 6byte 700000000000010100011111010011100source-port62000destination-port53length10checksum0x3e9c

Destination port stays put

The destination port remains 53.

destination port=53\text{destination port}=53
Source port rewriteThe before and after UDP headers show the source port rewrite.Before UDP header64 bits / 8 bytes0x9c400035000a0ee0byte 0byte 1byte 2byte 310011100010000000000000000110101byte 4byte 5byte 6byte 700000000000010100000111011100000source-port40000destination-port53length10checksum0x0ee0After UDP header64 bits / 8 bytes0xf2300035000a3e9cbyte 0byte 1byte 2byte 311110010001100000000000000110101byte 4byte 5byte 6byte 700000000000010100011111010011100source-port62000destination-port53length10checksum0x3e9c

Length stays put

The UDP length is still 10, because the payload size did not change.

UDP length=10\text{UDP length}=10
Source port rewriteThe before and after UDP headers show the source port rewrite.Before UDP header64 bits / 8 bytes0x9c400035000a0ee0byte 0byte 1byte 2byte 310011100010000000000000000110101byte 4byte 5byte 6byte 700000000000010100000111011100000source-port40000destination-port53length10checksum0x0ee0After UDP header64 bits / 8 bytes0xf2300035000a3e9cbyte 0byte 1byte 2byte 311110010001100000000000000110101byte 4byte 5byte 6byte 700000000000010100011111010011100source-port62000destination-port53length10checksum0x3e9c

Summary

This toy NAT step rewrites the source port and keeps the destination port.

source port after=62000\text{source port after}=62000
Source port rewriteThe before and after UDP headers show the source port rewrite.Before UDP header64 bits / 8 bytes0x9c400035000a0ee0byte 0byte 1byte 2byte 310011100010000000000000000110101byte 4byte 5byte 6byte 700000000000010100000111011100000source-port40000destination-port53length10checksum0x0ee0After UDP header64 bits / 8 bytes0xf2300035000a3e9cbyte 0byte 1byte 2byte 311110010001100000000000000110101byte 4byte 5byte 6byte 700000000000010100011111010011100source-port62000destination-port53length10checksum0x3e9c