Network Working Group A. Rijsinghani, Editor Request for Comments: 1624 Digital Equipment Corporation Updates: 1141 May 1994 Category: InformationalComputation of the Internet Checksum via Incremental Update
1. Introduction
Incremental checksum update is useful in speeding up several types of operations routinely performed on IP packets, such as TTL update, IP fragmentation, and source route update.
Rijsinghani [Page 1]
RFC 1624 Incremental Internet Checksum May 1994
For the sake of completeness, this memo briefly highlights key points from RFCs 1071 and 1141. Based on these discussions, an updated procedure to incrementally compute the standard Internet checksum is developed and presented.
2. Notation and Equations
Given the following notation:
3. Discussion
Although this equation appears to work, there are boundary conditions under which it produces a result which differs from the one obtained by checksum computation from scratch. This is due to the way zero is handled in one's complement arithmetic.
Rijsinghani [Page 2]
RFC 1624 Incremental Internet Checksum May 1994
RFC 1141 yields an updated header checksum of -0 when it should be +0. This is because it assumed that one's complement has a distributive property, which does not hold when the result is 0 (see derivation of [Eqn. 2]).
4. Examples
Consider an IP packet header in which a 16-bit field m = 0x5555 changes to m' = 0x3285. Also, the one's complement sum of all other header octets is 0xCD7A.
Rijsinghani [Page 3]
RFC 1624 Incremental Internet Checksum May 1994
HC' = ~(C + (-m) + m')
5. Checksum verification by end systems
If an end system verifies the checksum by including the checksum field itself in the one's complement sum and then comparing the result against -0, as recommended by RFC 1071, it does not matter if an intermediate system generated a -0 instead of +0 due to the RFC 1141 property described here. In the example above:
6. Historical Note
A historical aside: the fact that standard one's complement arithmetic produces negative zero results is one of its main drawbacks; it makes for difficulty in interpretation. In the CDC 6000 series computers [4], this problem was avoided by using subtraction as the primitive in one's complement arithmetic (i.e., addition is subtraction of the complement).
Rijsinghani [Page 4]
RFC 1624 Incremental Internet Checksum May 1994 7. AcknowledgmentsThe contribution of the following individuals to the work that led to this document is acknowledged:
8. Security Considerations
Security issues are not discussed in this memo.
9. Conclusions
It is recommended that either [Eqn. 3] or [Eqn. 4] be the implementation technique used for incremental update of the standard Internet checksum.
10. Author's Address
Anil Rijsinghani Digital Equipment Corporation 550 King St Littleton, MA 01460
Rijsinghani [Page 5]
RFC 1624 Incremental Internet Checksum May 1994 11. References[1] Postel, J., "Internet Protocol - DARPA Internet Program Protocol