Messages in this thread | | | Subject | Re: Lockless file reading | From | Valdis.Kletnieks@vt ... | Date | Thu, 28 Aug 2003 02:01:07 -0400 |
| |
On Thu, 28 Aug 2003 06:17:46 +0300, Timo Sirainen said:
> How about checksum[n] = data[n-1] ^ data[n]? That looks like it would > work.
Unfortunately, if you swap the contents of 'n' and 'n-1', the ^ remains the same, as it's a commutative operation.
If you want to go down this route, you *really* want to use at least a CRC here, and understand *why* the incremental computation of the IP header checksum works at all (hint - the fact it's so simple puts a significant upper bound on the error-detection strength of the checksum...)
1071 Computing the Internet checksum. R.T. Braden, D.A. Borman, C. Partridge. Sep-01-1988. (Format: TXT=54941 bytes) (Updated by RFC1141) (Status: UNKNOWN)
1141 Incremental updating of the Internet checksum. T. Mallory, A. Kullberg. Jan-01-1990. (Format: TXT=3587 bytes) (Updates RFC1071) (Updated by RFC1624) (Status: INFORMATIONAL)
1624 Computation of the Internet Checksum via Incremental Update. A. Rijsinghani, Ed.. May 1994. (Format: TXT=9836 bytes) (Updates RFC1141) (Status: INFORMATIONAL)
http://www.ietf.org/rfc/rfc1071.txt http://www.ietf.org/rfc/rfc1141.txt http://www.ietf.org/rfc/rfc1624.txt [unhandled content-type:application/pgp-signature] | |