计算 UDP 数据报校验和的最佳方法?
Best way to calculate UDP datagram checksum?
计算 UDP 数据报校验和的最佳方法是什么?在 Python
的 MD5、SHA256 或任何其他方法中,哪种方法肯定有助于识别损坏的数据包?此外,我的数据报格式为:
packet = struct.pack('HH', seq_num, checksum) + payload
,其中 payload
是我发送给接收者的消息。那么,在这种情况下,我应该为数据包计算校验和吗?
None 个。校验和只是字节的简单数学 sum,而不是 hash.
刚刚阅读 wikipedia's page for UDP:
“Checksum is the 16-bit one's complement of the one's complement sum of a pseudo header of information from the IP header, the UDP header, and the data, padded with zero octets at the end (if necessary) to make a multiple of two octets. ”
提示cf that answer for an implementation
计算 UDP 数据报校验和的最佳方法是什么?在 Python
的 MD5、SHA256 或任何其他方法中,哪种方法肯定有助于识别损坏的数据包?此外,我的数据报格式为:
packet = struct.pack('HH', seq_num, checksum) + payload
,其中 payload
是我发送给接收者的消息。那么,在这种情况下,我应该为数据包计算校验和吗?
None 个。校验和只是字节的简单数学 sum,而不是 hash.
刚刚阅读 wikipedia's page for UDP:
“Checksum is the 16-bit one's complement of the one's complement sum of a pseudo header of information from the IP header, the UDP header, and the data, padded with zero octets at the end (if necessary) to make a multiple of two octets. ”
提示cf that answer for an implementation