views:

278

answers:

2

A question in my university 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

+2  A: 

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

Mitch Wheat
+4  A: 

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?

Heath Hunnicutt
Yep. Thanks for the tip.
Mike