国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 網(wǎng)絡通信 > 正文

RFC1141 - Incremental updating of the Internet checksum

2019-11-04 11:55:47
字體:
供稿:網(wǎng)友

  Network Working Group T. Mallory
Request for Comments: 1141 A. Kullberg
Obsoletes: RFC1071 BBN Communications
January 1990

Incremental Updating of the Internet Checksum

Status of this Memo

This memo correctly describes the incremental update PRocedure for
use with the standard Internet checksum. It is intended to replace
the description of Incremental Update in RFC1071. This is not a
standard but rather, an implementation technique. Distribution of
this memo is unlimited.

Description

In RFC1071 on pages 4 and 5, there is a description of a method to
update the IP checksum in the IP header without having to completely
recompute the checksum. In particular, the RFCrecommends the
following equation for computing the update checksum C' from the
original checksum C, and the old and new values of byte m:

C' = C + (-m) + m' = C + (m' - m)

While the equation above is correct, it is not very useful for
incremental updates since the equation above updates the checksum C,
rather than the 1's complement of the checksum, ~C, which is the
value stored in the checksum field. In addition, it suffers because
the notation does not clearly specify that all arithmetic, including
the unary negation, must be performed one's complement, and so is
difficult to use to build working code. The useful calculation for
2's complement machines is:

~C' = ~(C + (-m) + m') = ~C + (m - m') = ~C + m + ~m'

In the oft-mentioned case of updating the IP TTL field, suBTracting
one from the TTL means ADDING 1 or 256 as appropriate to the checksum
field in the packet, using one's complement addition. One big-endian
non-portable implementation in C looks like:

unsigned long sum;
iPPTr->ttl--; /* decrement ttl */
sum = ipptr->Checksum + 0x100; /* increment checksum high byte*/
ipptr->Checksum = (sum + (sum>>16)) /* add carry */

This special case can be optimized in many ways: for instance, you

can bundle updating and checking the ttl. Compiler mileage may vary.
Here is a more general and possibly more helpful example which
updates the ttl by n seconds:

UpdateTTL(iph,n)
strUCt ip_hdr *ipptr;
unsigned char n;
{
unsigned long sum;
unsigned short old;

old = ntohs(*(unsigned short *)&ipptr->ttl);
ipptr->ttl -= n;
sum = old + (~ntohs(*(unsigned short *)&ipptr->ttl) & 0xffff);
sum += ntohs(ipptr->Checksum);
sum = (sum & 0xffff) + (sum>>16);
ipptr->Checksum = htons(sum + (sum>>16));
}

Security Considerations

Security issues are not addressed in this memo.

Authors' Addresses

Tracy Mallory
BBN Communications Corporation
50 Moulton Street
Cambridge, MA 02238

Phone: (617) 873-3193

EMail: tmallory@CCV.BBN.COM

A. Kullberg
BBN Communications Corporation
50 Moulton Street
Cambridge, MA 02238

Phone: (617) 873-4000

EMail: akullberg@BBN.COM


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 新乐市| 佛学| 扎鲁特旗| 惠州市| 禹州市| 淳化县| 扎兰屯市| 贵溪市| 罗田县| 盱眙县| 新宾| 汝城县| 平遥县| 台山市| 石家庄市| 上思县| 嘉荫县| 盐边县| 杭锦旗| 湖南省| 山阳县| 邢台县| 分宜县| 浏阳市| 许昌市| 万载县| 中山市| 鄄城县| 永修县| 南安市| 台山市| 金坛市| 景谷| 化隆| 靖远县| 台东县| 宁乡县| 庆阳市| 交口县| 镇原县| 固原市|