This preview shows page 1. Sign up to view the full content.
Unformatted text preview: 7.1 Adler-32 Checksum Many checksum algorithms compute the hash of a message by adding together bits of the
message. Usually the bits are collected into 8-bit bytes or 32-bit words and the addition is
performed 8 or 32 bits at a time. A simple checksum isn’t very robust when there is more
than one error: it’s all too easy for the second error to mask the ﬁrst error, e.g., an earlier
1 that was corrupted to 0 can be offset in the sum by a later 0 corrupted to a 1. So most
checksums use a formula where a bit’s effect on the sum is dependent on its position in the
message as well as its value.
The Adler-32 checksum is an elegant and reasonably effective check-bit computation
that’s particularly easy to implement in software. It works on 8-bit bytes of the message,
assembled from eight consecutive message bits. Processing each byte (D1 , D2 , . . . , Dn ),
compute two sums A and B :
A = (1 + sum of the bytes) mod 65521 = (1 + D1 + D2 + . . . + Dn ) mod 65521 B = (sum of the A values after adding each byte) mod 65521 = ((1 + D1 ) + (1 + D1 + D2 ) + . . . + (1 + D1 + D2 + . . . + Dn )) mod 65521 After the modulo operation the A and B values can be represented as 16-bit quantities.
The Adler-32 checksum is the 32-bit quantity (B 16) + A.
The Adler-32 checksum requires messages that are several hundred bytes long before
it reaches its full effectiveness, i.e., enough bytes so that A exceeds 65521.2 Methods like
the Adler-32 checksum are used to check whether large ﬁles being transferred have errors;
Adler-32 itself is used in the popular zlib compression utility and (in rolling window form)
in the rsync ﬁle synchroniza...
View Full Document
This document was uploaded on 02/26/2014 for the course CS 6.02 at MIT.
- Fall '13