Java Programs
Java Programs
The idea behind CRC calculation is to look at the data as one large binary number. This number is
divided by a certain value and the remainder of the calculation is called the CRC. Dividing in the CRC
calculation at first looks to cost a lot of computing power, but it can be performed very quickly if we
use a method similar to the one learned at school. We will as an example calculate the remainder for
the character 'm'—which is 1101101 in binary notation— by dividing it by 19 or 10011. Please note
that 19 is an odd number. This is necessary as we will see further on. Please refer to your
schoolbooks as the binary calculation method here is not very different from the decimal method
you learned when you were young. It might only look a little bit strange. Also notations differ
between countries, but the method is similar.
With decimal calculations you can quickly check that 109 divided by 19 gives a quotient of 5 with 14
as the remainder. But what we also see in the scheme is that every bit extra to check only costs one
binary comparison and in 50% ofthe cases one binary subtraction. You can easily increase the
number of bits ofthe test data string—for example to 56 bits if we use our example value
"Lamme"r—t and the result can be calculated with 56 binary comparisons and an average of 28
binary subtractions. This can be implemented in hardware directly with only very few transistors
involved. Also software algorithms can be very efficient. All of the CRC formulas you will encounter
are simply checksum algorithms based on modulo-2 binary division where we ignore carry bits and in
effect the subtraction will be equal to an exclusive or operation. Though some differences exist in the
specifics across different CRC formulas, the basic mathematical process is always the same: ∙ The
message bits are appended withc zero bits; this augmented message is the dividend ∙
Apredetermined c+1-bit binary sequence, called thegenerator polynomial , is the divisor ∙ The
checksum is the c-bit remainder that results from the division operation
Table 1 lists some of the most commonly used generator polynomials for 16- and 32-bit CRCs.
Remember that the width of the divisor is always one bit wider than the remainder. So, for example,
you’d use a 17-bit generator polynomial whenever a 16-bit checksum is required