免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4711 | 回复: 0
打印 上一主题 下一主题

IP Header Checksum 的计算 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-11-15 15:13 |只看该作者 |倒序浏览

                                此前看过某帖谈起IP报头的CheckSum,我们知道IP是不可靠的,IP报头的差错控制,只有依靠CheckSum来控制整个传输过程中IP报头的可靠性,整个IP报头结构如下:

RFC 791 -- Internet Protocol 对CheckSum字段是这样描述的:
  The Header Checksum provides a verification that the information used
  in processing internet datagram has been transmitted correctly.  The
  data may contain errors.  If the header checksum fails, the internet
  datagram is discarded at once by the entity which detects the error.
  The internet protocol does not provide a reliable communication acility.  There are no acknowledgments either end-to-end or hop-by-hop.  There is no error control for data, only a header checksum.  There are no retransmissions.  There is no flow control.
  Errors detected may be reported via the Internet Control Message Protocol (ICMP) [3] which is implemented in the internet protocol module.
IP Header CheckSum的计算描述如下:
The checksum algorithm is:
      The checksum field is the 16 bit one's complement of the one's
      complement sum of all 16 bit words in the header.  For purposes of
      computing the checksum, the value of the checksum field is zero.
看着挠头,但基本意思是CheckSum是把IP Header里其它字段值进行sum,找了一些Sniffer包中的IP Header
来求和,结果与CheckSum字段不同,而且明显也不是16个bit的值;
今天在www.netexpert.cn偶尔发现结果,计算方式如下:

以上图为例,图中阴影区域为IP Header各字段值,CheckSum为0x8b4f
4500
0028
6bab
4000
8006
8b4f --这是CheckSum结果
3b4e
331c
cf2e
+c63c
-----
374ad
3+74ad=74b0
7    4    b    0
0111 0100 1011 0000
求反码
1000 1011 0100 1111
8    b    4    f
               
               
               
               
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/26393/showart_200726.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP