Skip to main content

17. IPv4 Header Checksum Recalculation

17. IPv4 Header Checksum Recalculation

The IPv4 Header Checksum does not include data, but does include the ECN field in the IP header. When a router changes the ECN field in the IP header (e.g., sets the CE codepoint), the router MUST incrementally update the IP header checksum, following the procedures given in RFC 1141 [RFC1141]. RFC 1141 indicates that in the case where the original field has value m and the new value is m', the HC (header checksum) is adjusted as follows:

HC' = ~(~HC + ~m + m')

For an 8-bit field, the original and new values are used, zero-extended to 16 bits. For a 16-bit field, m and m' are treated as 16-bit integers. Addition is done using ones complement arithmetic, i.e., carry is added to the least significant bit of the sum.

Since the ECN field contains only the two least significant bits of the TOS byte, it is simplest to take the old TOS byte value as m and the new TOS byte value as m'.

Checksum recalculation is not required for IPv6, because the IPv6 header does not include a header checksum.