开发者

One's complement instead of just a sum of bits

A question in my universi开发者_JS百科ty homework is why use the one's complement instead of just the sum of bits in a TCP checksum. I can't find it in my book and Google isn't helping. Any chance someone can point me in the right direction?

Thanks, Mike


Since this is a homework question, here is a hint:

Suppose you calculated a second checksum over the entire packet, including the first checksum? Is there a mathematical expression which would determine the result?


Probably the most important is that it is endian independent.

Little Endian computers store hex numbers with the LSB last (Intel processors for example). Big Endian computers put the LSB first (IBM mainframes for example). When carry is added to the LSB to form the 1's complement sum) it doesn't matter if we add 03 + 01 or 01 + 03: the result is the same.

Other benefits include the easiness of checking the transmission and the checksum calculation plus a variety of ways to speed up the calculation by updating only IP fields that have changed.

Ref: http://www.netfor2.com/checksum.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜