UDP checksum
The UDP checksum includes all the data in the UDP data packet, a pseudo-header, and an 8-bit word that makes up the number of 16-bit integers 0.
During verification calculation, the UDP protocol first constructs a pseudo header (this header does not exist at the time of sending), and then sets the validation field of the UDP packet to 0 and connects it to the pseudo header, add the UDP packet length to an integer multiple of 16 bits, calculate the checksum for the new structure based on the IP protocol checksum calculation method, and fill in the checksum field. The UDP pseudo-header and complement part are not transmitted, and their length is not included in the UDP packet length field.
UDP pseudo Header Format
0 |
8 |
16 |
31 |
Source IP Address |
Destination IP address |
0 |
Protocol code (17) |
UDP Packet Length |
It contains the source and destination IP addresses, and the protocol code is UDP protocol code 17. The length field is the value of the UDP packet length field of the UDP packet.
The purpose of the UDP pseudo-header is to allow the packet receiver to determine that the UDP packet sent and received comes from the correct source and is sent to itself. Because the UDP structure only contains the Source and Destination UDP port numbers, and there is no IP address information, the pseudo-header structure is used to calculate the checksum to determine the correctness of the packet.