简体   繁体   English

ICMP标头校验和是否也包含数据?

[英]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. 作为家庭作业的一部分,我必须在Linux中编写一个C程序,使用原始套接字生成ICMP回复ICMP Echo请求。 Does the data in the ICMP Packet have to be included in the checksum as well? ICMP数据包中的数据是否也必须包含在校验和中? Or should I calculate the checksum for only the header? 或者我应该只计算标题的校验和?

It must be calculated from HEADER + DATA. 必须从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 : 引用RFC 792中的第14页(Echo或Echo Reply Message):

The checksum is the 16-bit ones's complement of the one's complement sum of the ICMP message starting with the ICMP Type. 校验和是从ICMP类型开始的ICMP消息的一个补码和的16位补码。 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. 此校验和可能在将来被替换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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