IP/IGMP/UDP checksum algorithm and algorithm: the IP, IGMP, UDP, and TCP packet headers both have validation fields, and their algorithms are the same. The range of IP, IGMP, UDP, and TCP checksum: only the length of the packet header. When sending data, in order to calculate the packet inspection. Perform the following steps: 1. Set the checksum field to 0; 2. Regard the data to be verified as a number in the unit of 16 bits, sum the binary anticode in sequence (the overflow bit must be added to the low position); 3. Save the obtained result to the checksum field. When receiving data, the test and calculation of data packets are relatively simple. follow the steps below: 1. Regard the header as a 16-bit number, and perform the binary anticode summation in turn, including the checksum field; 2. Check whether the calculated checksum is 0. 3. If the value is 0, the checksum is correct. Otherwise, the checksum is incorrect. The protocol stack must discard this packet. Note: Both of the above schemes can correctly implement the checksum field. The result of first obtaining the inverse sum is the same as that of first seeking and then obtaining the inverse result. Note: The overflow bits must be added to the low level for the above two implementation schemes, such as while (cksum> 16) {cksum = (cksum> 16) + (cksum & 0 xffff );}. When the packet header size is transferred, the actual packet header size is enough. The advantage of using back-code Summation for checksum is that it does not depend on the system as a large-end or small-end. That is, no matter whether you are a sender's computer or receiver, do not call htons or ntohs. You can directly obtain the correct result through the above algorithm. To solve this problem, you can give an example by yourself. When we use the reverse code to sum up, we exchange the 16-digit byte order and get the same result, but the byte order is also exchanged accordingly; however, if you use the source code or the supplementary code to sum up, the result may be different.