侧边栏壁纸
  • 累计撰写 185 篇文章
  • 累计创建 77 个标签
  • 累计收到 18 条评论

目 录CONTENT

文章目录

Wireshark抓包报:Header checksum: 0x0000 [incorrect, should be 0xxxxx

码峰
2022-09-21 / 0 评论 / 0 点赞 / 2,036 阅读 / 582 字 / 正在检测是否收录...
广告 广告

问题描述

在使用Wireshark抓包,发现本机发送的包有校验和失败的问题:Header checksum: 0x0000 [incorrect, should be 0x506b (maybe caused by “IP checksum offload”?)],开始以为是发送的代码有问题,但接收方却能正常收到包,并且抓包并没有校验和异常。如下图所示:
image-1663834538948

原因分析

查到相关资料:http://forums.whirlpool.net.au/forum-replies-archive.cfm/1265837.html

a lot of modern network cards use TCP/IP checksum offloading, inwhich case Windows doesn’t bother generating a checksum for eachoutbound packet and the network card adds them just beforetransmission.
This reduces the amount of work that the computer’s CPU has todo, but the problem is that Wireshark can only intercept packets atthe OS level, and hence thinks the checksums are invalid (when infact the problem is that they haven’t been added yet).

大概意思就是操作系统偷懒,把计算校验和的工作丢给网卡来做,网卡在包发出去时才加上校验和,Wireshark是在操作系统层抓包,包的校验和还没计算和添加包包里面,默认是0x0000,于是认为在Wireshark中认为header checksum incorrect。

如何避免

其实,这个并不是问题,但由于这个校验和问题在Wireshark抓包列表中可能会干扰到我们正常判断是否有异常包(校验和问题等),所以在测试环境中,可以让操作系统加上校验和。
具体操作过程如下:

  • 单击 开始,单击 运行,键入 regedit,然后单击 确定。
  • 找到以下注册表子项:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
  • 在右窗格中确保 DisableTaskOffload 注册表项存在。如果此项不存在,请创建DisableTaskOffload,DWORD类型的键值
  • 修改DisableTaskOffload数值为1

重启系统,即可让操作系统给发送的网络包加上校验和,此时在Wireshark中就没有校验和错误的问题了。

警告

禁用TaskOffload可以显著提高了系统性能,禁用后系统性能会明显下降,除非您必须这样做才能进行测试或故障排除。
参照说明:https://learn.microsoft.com/en-us/previous-versions//cc959732(v=technet.10)?redirectedfrom=MSDN

本文地址:https://www.cfnotes.com/archives/163 转载请注明出处。

0
广告 广告

评论区