简体   繁体   中英

Does the ICMP Header Checksum include the data as well?

As part of a homework assignment, I have to write a C program in Linux that generates ICMP replies to ICMP Echo requests using raw sockets. Does the data in the ICMP Packet have to be included in the checksum as well? Or should I calculate the checksum for only the header?

It must be calculated from HEADER + DATA. When performing the calculation, let the checksum be zero, then replace it afterwards.

Quoting page 14 (Echo or Echo Reply Message) from the RFC 792 :

The checksum is the 16-bit ones's complement of the one's complement sum of the ICMP message starting with the ICMP Type. For computing the checksum , the checksum field should be zero. If the total length is odd, the received data is padded with one octet of zeros for computing the checksum. This checksum may be replaced in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM