Why is the TCP checksum inverted

checksumspecificationstcp

From the Wikipedia page:

The checksum field is the 16 bit one's complement of the one's complement sum of all 16-bit words in the header and text.

Why, after summing the 16-bits in the header and text, is the one's complement taken to compute the TCP checksum?

Best Answer

The complement is taken to make checksum validation simpler — instead of calculating the checksum again and then comparing the calculated value with the checksum field in the header (which is in the middle of the summed data), it is possible to sum (using one's complement arithmetic) all 16-bit words in the header (including the checksum word) and compare the result with zero.

Related Topic