CRC By Hand: A Guided Example

Apr 20, 2025

This is a practical guide to the Cyclic Redundancy Check (CRC). For a deep dive into the theory and math behind CRC, check out my the post Math Behind Cyclic Redundancy Check.

This post might be particularly helpful for those learning about CRC in a computer networking course.

CRC with Example

The data is D=1101011D = 1101011 and the generator is G=1001G = 1001.

Sender and Receiver...

Both have access to the generator polynomial: GG.

Both have access to the degree of GG. The degree is simply the number of bits minus 1(starting from the left most nonzero bit).

GG is a polynomial over GF(2)GF(2), which means it's coefficients are either 11 or 00.

For example, 1001x3+11001 \to x^3 + 1. So, when we see that GG is a 4 bit string, we say it is of degree r=3r = 3.

Sender

Need to transmit data DD encoded in a message TT so that the receiver can use GG on the message it receives, which may or may not be the same as TT, to check if there were any bit errors over transmission.

IDEA: Transform the data-polynomial DD into a message-polynomial TT that is divisible by the generator-polynomial GG and if any errors occur (changing the coefficients of the message-polynomial) then the received message-polynomial won't be divisible by GG (to some extent).

If we use a generator GG with r+1r+1 bits, then we can detect burst errors less than or equal to rr bits. In our example, this means we can detect up to 33 bit burst errors. This is what I mean by to some extent.

Walkthrough...

D=1101011x6+x5+x3+x+1D = 1101011 \to x^6 + x^5 + x^3 + x + 1.

Now shift DD rr times:

D2r=1101011000x9+x8+x6+x4+x3D\cdot 2^r = 1101011000 \to x^9 + x^8 + x^6 + x^4 + x^3.

And now we divide D2rD\cdot 2^r by GG to calculate the remainder RR. Note we are working over GF(2)GF(2), so we can simplify this by treating it like bitwise XOR operations.

1 1 0 1 0 1 1 0 0 0

1 0 0 1

----------

0 1 0 0                                    <- XOR result. Left most is 0, so drop it and carry down next bit.

  1 0 0 0                                  <- leftmost bit is 1. Now XOR with G again.

  1 0 0 1                                  <- and rinse and repeat...

  --------

  0 0 0 1

    0 0 1 1 

      0 1 1 1 

        1 1 1 0

        1 0 0 1 

        --------

        0 1 1 1 

          1 1 1 0

          1 0 0 1

          --------

          0 1 1 1

              1 1 1 0

              1 0 0 1

              --------

              0 1 1 1

Our remainder's degree will be one less than the degree of the generator, or 1 less bit. Take rr bits from RR and we have R=111x2+x+1R = 111 \to x^2 + x + 1.

Now craft the message-polynomial as such:

T=DR=D2r+R=1101011111x9+x8+x6+x4+x3+x2+x+1T = D || R = D\cdot 2^r + R = 1101011111 \to x^9 + x^8 + x^6 + x^4 + x^3 + x^2 + x + 1

TT is now divisible by GG and through some things explained only by mystical abstract algebra stuff, if you alter the coefficients of TT, it won't be divisible by GG (to some extent).

Receiver

Simply take your received message, TT' we will call it, and divide by GG. If T/G=0T'/G = 0, then we detect no errors and it's very likely that T=TT' = T.

If T/G0T'/G \neq 0 then we KNOW that TTT' \neq T, and thus, there was an error.

If there is no error, you retrieve DD from TT through simply stripping off the rr most bits. In our case, you strip off the 33 most bits.

No Errors

1 1 0 1 0 1 1 1 1 1

1 0 0 1

----------

0 1 0 0 

  1 0 0 0

  1 0 0 1

  --------

  0 0 0 1 

    0 0 1 1 

      0 1 1 1

        1 1 1 1 

        1 0 0 1

        --------

        0 1 1 0

            1 1 0 1 

            1 0 0 1

            -------

            0 1 0 0

              1 0 0 1

              1 0 0 1

              --------

              0 0 0 0 

R=0R = 0. No error detected.

Errors

1 0 1 1 0 1 1 1 1 1

1 0 0 1

--------

0 0 1 0  

  0 1 0 0  

    1 0 0 1  

    1 0 0 1  

    --------

    0 0 0 0  

        0 0 0 1  

            0 0 1 1 

              0 1 1 1 

                  1 1 1 1

                  1 0 0 1

                  --------

                  0 1 1 0

R=110R = 110. Error detected.