Fletcher checksum
A Fletcher checksum combines a running sum of data words with a running sum of that first sum to make the result sensitive to word order.
Classic two-sum variants use one's-complement addition, equivalent to residues modulo 2^w-1 for w-bit words. For word x, update A=A+x, then B=B+A. A 16-bit result normally uses two 8-bit sums; RFC 1146 instead names the algorithm by its word width. [1] [2]
Order sensitivity has limits. With 8-bit words, 00 00 00 55 and 55 00 00 00 both give A=85, B=85 modulo 255. The moved value differs by 85 across three positions, so the change in B is 3*85=255. The original checksum stays unchanged. [3]
Interoperability requires the word width, byte order, starting values, padding, zero representation and output layout. HDF5 1.14.6 initializes both sums to zero, reads 16-bit words high byte first and pads an odd final byte in the high position. [4]
Adler-32 instead processes bytes modulo the prime 65521. OpenZFS Fletcher-4 uses four 64-bit accumulators over 32-bit words; its four-word output is not classical Fletcher-32. [5] [6]
RFC 1146's alternate TCP checksum options became Historic in 2011. Its algorithm description is not a recommendation to replace today's TCP checksum. [7]
Relations
- related
- Checksum, Adler-32, Hash collision, HDF5, Cyclic redundancy check
Advantages
- Two running sums can be maintained as successive words arrive, without retaining the full message. [1]
Limitations
- A match is not proof of byte identity or authentication, and checksum width alone does not specify an undetected-error probability. [3, 2]
- The worked swaps are constructed arithmetic examples, not measurements of device faults or tests of an HDF5 file or ZFS pool. [3]
Citations
- RFC 1146: TCP Alternate Checksum Options, appendices I-II (1990)
- Koopman, Driscoll and Hall: DOT/FAA/TC-14/49, sections 2.4, 3.6 and 3.10.3 (2015)
- Hesela: Fletcher word-order arithmetic, explicit model and exhaustive pair checks
- HDF5 1.14.6: H5_checksum_fletcher32 implementation
- RFC 1950: ZLIB Compressed Data Format Specification version 3.3, Adler-32
- OpenZFS zfs-2.3.4: scalar Fletcher-4 implementation
- RFC 6247: Moving Undeployed TCP Extensions to Historic Status (2011)
Sources & caveats
- Primary-source synthesis and exact arithmetic. The FAA report compares error-detection methods under explicit models, not observed storage-fleet failure rates. Its relevant methodology and Fletcher sections were reviewed; its simulations were not rerun.
- The model canonicalizes each sum to a residue. It separately exposes end-around-carry zero encodings, so a normalized pair must not be treated as a complete wire-format specification. [3]