gpt4 book ai didi

network-programming - ICMP 回显校验和

转载 作者:行者123 更新时间:2023-12-03 15:02:46 25 4
gpt4 key购买 nike

当校验和应包括数据部分,数据部分的大小可以是可变的,并且无法预测数据大小时,如何计算 ICMP 回显请求或回复的校验和?

这是documentation关于如何计算 ICMP header 的校验和。

ICMP Header Checksum. 16 bits. The 16-bit one's complement of the one's complement sum of the ICMP message, starting with the ICMP Type field. When the checksum is computed, the checksum field should first be cleared to 0. When the data packet is transmitted, the checksum is computed and inserted into this field. When the data packet is received, the checksum is again computed and verified against the checksum field. If the two checksums do not match then an error has occurred.

最佳答案

当发送方计算校验和时,该值被插入到零字段中。然后接收器执行相反的操作,它提取校验和,将字段置零并计算校验和,并将该字段设置为零。它将它计算的值与它提取的值进行比较。

传输双方计算校验和,字段为零。

更新

Scribd presentation 上有一个如何执行此计算的示例。 ,从幻灯片 44 开始。我还包括下面的相关示例幻灯片。

Figure 9.19 shows an example of checksum calculation for a simple echo-request message (see Figure 9.14). We randomly chose the identifier to be 1 and the sequence number to be 9. The message is divided into 16-bit (2-byte) words. The words are added together and the sum is complemented. Now the sender can put this value in the checksum field.



Ping Checksum calculation

您将 ICMP header 和数据拆分为 16 位字(使用 0x0000 作为校验和字段),获得这些字的总和,然后是总和的补码。然后将其插入校验和字段。

关于network-programming - ICMP 回显校验和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20247551/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com