登录
首页 » Windows Socket编程 » 计算校验和 校验和算法描述:为保证网络上传输的数据的可靠性,在许多协议中都设置了校验和项,例如:IPv4、ICMPv4、IGMPV4、ICMPv6、UDP...

计算校验和 校验和算法描述:为保证网络上传输的数据的可靠性,在许多协议中都设置了校验和项,例如:IPv4、ICMPv4、IGMPV4、ICMPv6、UDP...

于 2022-01-26 发布 文件大小:86.86 kB
0 215
下载积分: 2 下载次数: 1

代码说明:

计算校验和 校验和算法描述:为保证网络上传输的数据的可靠性,在许多协议中都设置了校验和项,例如:IPv4、ICMPv4、IGMPV4、ICMPv6、UDP和TCP 等等。计算这些校验和的算法称为网际校验和算法,简单来说就是:把被校验的数据16位进行累加,然后取反码,若数据字节长度为奇数,则数据尾部补一个字节的0以凑成偶数。 由于从输入文件读入的数据不能直接满足计算校验和的条件,所以首先对从文件读入缓冲区的数据进行预处理,即读入缓冲区时忽略空格。由于累加是按16位进行的,所以每次从缓冲区中读出4个字符,并将字符转换成对应的16进制数字,如此依次累加,直至数据全部读完。 还有一种情况,即如果数据长度为奇数个字节,则需要判断,并补0累加。程序中利用的是缓冲区长度计数器i和当前读取到计数器j判断数据长度是否为奇数。即如果数据长度为偶数,则读完数据时当前读取到计数器j的值应与缓冲区长度i相等,而如果数据长度为奇数,则读完数据时,当前读取到计数器j>缓冲区长度i,此时需将缓冲区中剩余的两个字符读出,并补0,转换成相应16进制数以后参与累加。 当累加结束后,将累加和的16位以上数据位移下再进行一次累加,并对最后累加和取反即得所求校验和。 -calculated checksum checksum algorithm Description : To ensure the network transmission of data reliability, in many of the agreements are set up and calibration, for example : IPv4, ICMPv4, IGMPV4, ICMPv6. UDP and TCP so on. Calculating checksum algorithm called the Internet checksum algorithm, the simple answer is : as has been the calibration data for 16 cumulative, and then take the anti-code, if the data byte length of the odd, data will make up the tai

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • 物理数据迁移器 可以作为pc机之间的数据中转
    物理数据迁移器 可以作为pc机之间的数据中转-physical data transfer device can be used as PCs interchange of data between
    2022-02-06 06:37:09下载
    积分:1
  • icmp开发
    icmp开发-icmp development
    2022-09-16 07:40:02下载
    积分:1
  • 获得本机的MAC地址,已经生成有可执行文件
    获得本机的MAC地址,已经生成有可执行文件-Access to the machine
    2023-01-12 17:30:04下载
    积分:1
  • Now, given a simple example, the sample can catch all through local LAN data pac...
    下面就给出一个简单的示例,该示例可以捕获到所有经过本地网卡的数据包,并可从中分析出协议、IP源地址、IP目标地址、TCP源端口号、TCP目标端口号以及数据包长度等信息。-Now, given a simple example, the sample can catch all through local LAN data packets can be analyzed from the agreement, IP source address, IP destination address, source port TCP, the TCP port number and the objective data packet length, and other information.
    2022-07-15 22:24:29下载
    积分:1
  • full name in English : Vitci Eshop, the Chinese name : Victoria C Mall, which is...
    * VITCIE 的英文全称为:Vitci Eshop,中文名称为:维C商城,是一款基于php+Mysql的网络商城. * * VITCIE 具有以下特点: * * 1. 基于Php+Mysql+FreeBSD系统构建,稳定/强大/低廉; * * 2. 采用流行的模版编译系统,轻松拥有美观实用的用户界面; * * 3. 内建语言包替换模块,轻松实现多语言版本; * * 4. 拥有强大的数据备份功能; * * 5. 独创的商品参数模版系统,不同类别商品具体参数的维护将变得极之容易。-full name in English : Vitci Eshop, the Chinese name : Victoria C Mall, which is a php Mysql online marketplace.** VITCIE have the following characteristics :** 1. Php Mysql based on FreeBSD system builders, stability/powerful/low;** 2. to use the popular templates Compiler easily have aesthetic and practical user interface;** 3. Built-language pack replacement modules, easier and more language versions;** 4. powerful data backup function;** 5. original merchandise parameters template system, different categories of products to safeguard the specific parameters will become very easy.
    2022-10-04 01:00:03下载
    积分:1
  • Delphi實現局域網遠端開機
    遠端喚醒(Wake On Lan,WOL)是許多網管人員喜歡使用的功能之一。有了遠端喚醒,對於不需要
    2022-02-25 04:06:10下载
    积分:1
  • Winsock
    WINsock 例子-WINsock
    2022-08-08 17:24:34下载
    积分:1
  • 注重实用,学习的好例子,IPmon IP嗅探技术软件源码
    注重实用,学习的好例子,IPmon IP嗅探技术软件源码-Focus on practical, learning a good example, IPmon IP sniffer software source
    2022-05-04 22:01:33下载
    积分:1
  • VB拦截数据包,在XP下可以直接运行。 VB拦截数据包,在XP下可以直接运行。...
    VB拦截数据包,在XP下可以直接运行。 VB拦截数据包,在XP下可以直接运行。-VB intercept packets in XP can be run directly. VB intercept packets in XP can be run directly.
    2022-03-17 02:02:16下载
    积分:1
  • 一个简单的vc下UDP客户端序,客户端需输入对方IP
    一个简单的vc下UDP客户端程序,客户端需输入对方IP-Vc under a simple UDP client program, the client must enter each other
    2022-03-21 08:01:12下载
    积分:1
  • 696516资源总数
  • 106633会员总数
  • 4今日下载