Cyclic Redundancy Check (CRC) Example

Sean E. O'Connor

artifex@seanerikoconnor.freeservers.com

Abstract

We go through a complete example of CRC encoding and decoding.

1. An Example with CRC-16

The CRC-16 generator polynomial is

"crcExample_1.gif"

"crcExample_2.gif"

Let a sample message be "crcExample_3.gif", which we will encode as the coefficients of the polynomial,

"crcExample_4.gif"

"crcExample_5.gif"

Let's assume we are encoding the message bit stream "crcExample_6.gif".  The binary digits will be the coefficients of our message polynomial i(x), with the least significant bit being the constant term of the polynomial:

"crcExample_7.gif"

"crcExample_8.gif"

Enter the code's blocklength n and message length k, and compute the the number of parity bits n-k.

"crcExample_9.gif"

"crcExample_10.gif"

"crcExample_11.gif"

"crcExample_12.gif"

"crcExample_13.gif"

"crcExample_14.gif"

For systematic encoding, the parity is p(x) = [-"crcExample_15.gif" mod g(x) where we do modulo 2 arithmetic on the polynomial coefficients.

"crcExample_16.gif"

"crcExample_17.gif"

Writing the polynomial coefficients in binary we get the parity,
0011 0101 1100 1111"crcExample_18.gif"=35CF"crcExample_19.gif"

Compute the systematically encoded codeword
c(x) =  "crcExample_20.gif" + p(x).

"crcExample_21.gif"

"crcExample_22.gif"

Compute the shifted syndrome s'(x) = ["crcExample_23.gif" mod g(x), modulo 2 on the polynomial coefficients.  We should get zero.

"crcExample_24.gif"

"crcExample_25.gif"

Add error to the codeword.

"crcExample_26.gif"

"crcExample_27.gif"

Compute the shifted syndrome s'(x) = ["crcExample_28.gif" mod g(x) modulo 2 on the polynomial coefficients.  We should get a non-zero answer.

"crcExample_29.gif"

"crcExample_30.gif"

On the other hand, if we add a multiple of a codeword, we won't see the error.

"crcExample_31.gif"

"crcExample_32.gif"

"crcExample_33.gif"

"crcExample_34.gif"

2. An Example with CRC-32Q

"crcExample_35.gif"

"crcExample_36.gif"

"crcExample_37.gif"

"crcExample_38.gif"

Let a sample message be

"crcExample_39.gif"