Feb 272012

It was quite hard for me to find a good resource on how to calculate the IP header checksum.

The RFC 791 only says:

The checksum algorithm is:
The checksum field is the 16 bit one’s complement of the one’s complement sum of all 16 bit words in the header. For purposes of computing the checksum, the value of the checksum field is zero.

I used the implementation of Ken Christensen as a reference and was able to get a valid checksum. You can find my algorithm over at Google Code.