This is a reconstruction of http://www.roman10.net/2011/11/27/how-to-calculate-iptcpudp-checksumpart-2-implementation/ The site is gone so I took it from the archive for the sake of C Programming TCP Checksum's answer Enjoy! All credits go to https://github.com/roman10.
This is a follow up of the previous post, how to calculate IP/TCP/UDP checksum part 1 — theory.
To calculate the IP checksum, one can use the code below,