BSD Checksum - Description of The Algorithm

Description of The Algorithm

As mentioned above, this algorithm computes a checksum by segmenting the data and adding it to an accumulator that is circular right shifted between each summation. To keep the accumulator within return value bounds, bit-masking with 1's is done.

Example: 4-bit checksum using 4-bit sized segments (big-endian:Endianness)

Input: 101110001110

Loop 1:

checksum: 0000 seg: 1011

a) Circular shift checksum:

0000 -> 0000

b) Add seg and bitmask:

0000 + 1011 = 1011 -> 1011 & 1111 = 1011

Loop 2:

checksum: 1011 seg: 1000

a) Circular shift checksum:

1011 -> 1101

b) Add seg and bitmask:

1101 + 1000 = 10101 -> 10101 & 1111 = 0101

Loop 3:

checksum: 0101 seg: 1110

a) Circular shift checksum:

0101 -> 1010

b) Add seg and bitmask:

1010 + 1110 = 11000 -> 11000 & 1111 = 1000

Checksum: 1000

Read more about this topic:  BSD Checksum

Famous quotes containing the words description of the, description of and/or description:

    Do not require a description of the countries towards which you sail. The description does not describe them to you, and to- morrow you arrive there, and know them by inhabiting them.
    Ralph Waldo Emerson (1803–1882)

    To give an accurate description of what has never occurred is not merely the proper occupation of the historian, but the inalienable privilege of any man of parts and culture.
    Oscar Wilde (1854–1900)

    It is possible—indeed possible even according to the old conception of logic—to give in advance a description of all ‘true’ logical propositions. Hence there can never be surprises in logic.
    Ludwig Wittgenstein (1889–1951)