c++ - 确定是否使用 Boost.Asio 计算 UDP 校验和

标签 c++ boost udp boost-asio checksum

我确实发现了一些其他相关问题,但没有真正给出我正在寻找的答案。

我将 Boost.Asio 与 ip::udp::socket ( http://www.boost.org/doc/libs/1_57_0/doc/html/boost_asio/reference.html ) 一起使用

从此页面:http://en.wikipedia.org/wiki/User_Datagram_Protocol#IPv4_Pseudo_Header :它指出 UDP 校验和对于 IPv4 是可选的。

查看 https://www.rfc-editor.org/rfc/rfc768似乎只有启用调试时才会出现这种情况?

另请参阅:http://www.boost.org/doc/libs/1_57_0/doc/html/boost_asio/reference/basic_datagram_socket/debug.html

将调试设置为 false 是否足以确保计算 UDP 校验和,或者如何 100% 确保计算 UDP 校验和,以便在使用 UDP/IPv4 时可以安全地忽略底层数据包协议(protocol)中的校验和计算?

我知道 UDP/IPv6 保证校验和计算,但我不能限制我的系统仅使用 IPv6。

最佳答案

使用tcpdump/wireshark/ethereal/等工具。转储实际流量。

在我看来,校验和实际上可能是在驱动程序级别处理的。你可以使用例如ethertool 启用它们 (? http://www.linuxquestions.org/questions/linux-networking-3/help-needed-disabling-tcp-udp-checksum-offloading-in-debian-880233/ )

确实是Wireshark FAQ有一个关于此的条目:

You see the "incorrect" checksums due to a feature called TCP checksum offloading. The checksum fields for outgoing TCP packets are not pre-calculated by the operating system but set to 0 and left for calculation by the NIC processor. ¹

来源:https://serverfault.com/a/288493

关于c++ - 确定是否使用 Boost.Asio 计算 UDP 校验和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30117414/

相关文章:

c++ - libboost 1.62 错误选项 --log_sink

C++ boost库shared_memory_object undefined reference 'shm_open'

c++ - Boost UDP 套接字的性能 - 吞吐量低?

c++ - 通过队列传递信息时如何避免向下转型?

c++ - 如何使用套接字 c/C++ 以 block 的形式发送文件?

c++ - 我应该看到 std::bind 和 boost::bind 之间的显着差异吗?

c++ - boost::date_time::days_until_weekday 的编译错误

C# UDP Socket 不监听响应?

c++ - p2p 开源库 tcp/udp 组播支持

c++ - Visual Studio 2017 C++ linux 应用程序, header 未复制到目标