8

I am an electronic engineer and have not found it important to consider CRC from a purely mathematical perspective. However, I have the following questions:

  1. Why do we add n zeros to the message when we calculate the CRC, were n is the degree of the generator polynomial? I have seen this in the modulo-2 long division as well as the hardware implementation of CRC

  2. Why do we want that the generator polynomial be divisible by (x+1)?

  3. Why do we want that the generator polynomial not be divisible by x?

e-sushi
  • 12,227
  • 10
  • 35
  • 55
quantum231
  • 1,927
  • 3
  • 24
  • 45

1 Answers1

8
  1. We add n zeros when computing an n-bit CRC because, when appending the CRC to the message and sending the whole (a usual practice in telecoms):
    • That allows the receiving side to process the bits of the CRC just as the rest of the message is, leading to a known remainder for any error-free transmission. This is especially useful when the end of the message is indicated by something that follows the CRC (a common practice); on the receiving side it saves an n bit buffer, and on the transmit side it adds virtually no complexity (the extra terms of x(n) reduce to an AND gate forcing message bits to zero during CRC transmission, and the n extra reduction steps are performed as the CRC is transmitted).
      Mathematically, the CRC sent is (M(x) * x^n) mod P(x) = R(x) (perhaps, within some constant, or/and perhaps with some prescribed bits added at beginning of M(x), corresponding to an initialization of the CRC register), and the CRC computed on the receiving side is over the concatenation of M(x) and R(x), that is
      (M(x) * x^n + R(x)) mod P(x), which is zero (or said constant).
    • It insures that burst of errors affecting both the end of the message and the contiguous CRC benefit from the full level of protection afforded by the choice of polynomial. In particular, if we computed C(x) as M(x) mod P(x), flipping the last bit of M(x) and the last bit of C(x) would go undetected, when most polynomials used in error detection insure that any two-bit error is detected up to some large message size.
  2. It is common practice to have CRC polynomials used for error detection divisible by x+1, because it ensures that any error affecting an odd number of bits is detected. However that practice is not universal, and it would sometime prevents selection of a better polynomial for some useful definitions of better, including maximizing the length of message such that m errors are always detected (assuming no synchronization loss), for some combinations of m and n. In particular, if we want to be able to detect any 2-bit error for the longest message possible (which will be 2n-1 bits including n-bit CRC), we need the polynomial to be primitive, thus irreducible, thus (for n>1) not divisible by x+1.
  3. It is universal practice to have CRC polynomials used for error detection not divisible by x, because otherwise the last bit of CRC generated would be constant, and would not help towards detection of errors in the rest of the message+CRC.
fgrieu
  • 2,505
  • 1
  • 17
  • 45
  • 3
    Very good answer. +1. I would only add that adding _n_ zeros is part of the definition of a CRC, but almost never part of the implementation. A CRC in software or hardware can be and almost always is implemented to avoid those extra _n_ steps. For 3, I would say it is truly universal. It's not a CRC if the polynomial does not have a 1 term. – Mark Adler Jun 18 '16 at 00:38
  • @Mark Adler: incorporated your comments. I guess you are the Mark Adler from Adler-32 fame, kudos for that! – fgrieu Jun 18 '16 at 10:44
  • hmmmm I need to think more about the answer 2. By the way in 2 what do you mean by "it prevents the polynomial from being irreducible". Why do we want irreducible polynomial? – quantum231 Jun 18 '16 at 18:26
  • @quantum231: fixed my argument about 2, which was incorrect in its justification for sometime using irreducible polynomials. I now give at least one good reason: so that the polynomial can be primitive, so as to maximize the length of message for which all 2-bit errors are detected. – fgrieu Jun 19 '16 at 19:23