Cyclic redundancy check (CRC, also polynomial codes) is a powerful error detection coding used in Ethernet and WiFi. It consists of two main components:

  • data bits that we want to protect.
  • bit pattern (called a generator) that is agreed by both parties (usually specified in some external pre-determined specification). It consists of bits.
    • The IEEE standard has 32-bits.

The core goal is that we choose CRC bits such that is exactly divisible by (mod 2). On the receiver side, we divide by . If there’s a non-zero remainder, then we’ve detected an error. We can detect all burst errors less than bits.

Specification

The sender wants to compute such that:

where the essentially functions as a bitshift. Or equivalently (by XOR both sides):

which says that if we want to divide by , we want the remainder to satisfy:

Procedure

We are given , , and .

  • We first compute . This is a leftwards bitshift by bits.
  • Then, we perform a binary long division of .
  • We discard the result. Whatever is the remainder is