CS485 Sylabus

CRC encoding procedure

• Generator polynomial

• Generator polynomial:

 Generator polynomial = the divisor polynomial in the polynomial division operation

• Obvious fact:

 The sender and the receiver must use the same generator polynomial to encode/decode the messages.

• How to use CRC code

• How the sender transmits a message:

Explanation:

 The sender divides the message by the generator polynomial The sender includes the remainder of the division in the transmitted message

Explanation:

 The receiver divides the message + CRC code (remainder) by the same generator polynomial The receiver will assume there is no bit error(s) if the remainder of the division is equal to 0

• Encoding procedure of the Cyclic Redundancy Check (CRC) codes

• The CRC encoding procedure:

1. Let:

 ``` N = length of the generator polynomial = number of bits in the generator polynomial ```

2. Append N−1 ZERO (0) bits to the end of the input message.

3. Divide the messages + (N-1) ZEROs by the generator polynomial.

Note:

 The division operation will use the XOR operation as the subtract operation

4. Append the remainder of the "division" to the input message

 The resulting message is the CRC protected message

• Example: computing the CRC code (= check sum) for a message

 ``` Generator polynomial: x3 + x2 + 1 Genenrator polnomial in bit string: 1101 (1101 represents the polynomial: 1×x3 + 1×x2 + 0×x1 + 1×x0) N = 4 (because Generator polynomial has 4 terms, or bits in "1001") Input message: x4 + 1 Input message in bit string: 10001 Computing the CRC (check sum) for the message 10001 using Gen Polyn 1101: 1. Add N-1 (= 3) ZERO's bits to message: Message + 3 ZEROs = 10001000 2. Compute CRC by dividing "message + 3 zeros" by generator polynomial: 00011 ---------------- 1101 / 10001000 1101 <----- **** see Note below !! **** ---- (XOR) 1011 1101 ---- (XOR) 1100 1101 ---- (XOR) 000100 <---- remainder = 100 CRC = 100 3. CRC protected message = 10001100 ```

• Note: how to perform the "division"

• Whenever the leading bit of the divident = 1, you get a 1 in the quotient.

Example:

 ``` 1 ------------ 1101 / 10001000 // Even when 1000 < 1101 !!! 1101 ----- XOR 0101 ```

• The division uses the XOR operation as subtraction

• A longer example....

• Example:

 ``` CRC generator polynomial: 11011 (N = 5) Message: 11100110 1. Add 4 0-bits to the message: 11100110 --> 111001100000 2. Divide: 10101110 --------------- 11011 / 111001100000 11011||||||| ------v|||||| 1111|||||| 0000|||||| ------v||||| 11111||||| 11011||||| ------v|||| 1000|||| 0000|||| -----v||| 10000||| 11011||| ------v|| 10110|| 11011|| ------v| 11010| 11011| ------v 00010 00000 ----- 0010 3. CRC protected message = 111001100010 ```

• Property of a CRC protected message

• Recall: how is the CRC code computed

 ``` ------------------------------ CRC-polynomial / Original-Message + 000..000 .... ----------------------------- CRC-code ```

• A CRC protected message consists of:

 ``` Original-Message + CRC-code ```

• Property of every CRC protect message:

• The remainder of a CRC protected message divided by the CRC polynomial (used in the encoding) is:

 Always equal to ZERO !!!

In formula:

 ``` (Original-Message + CRC-code) % CRC-polynomial == 0 !!! ```

Reason:

 ``` Since: ------------------------------ CRC-polynomial / Original-Message + 000..000 .... ----------------------------- CRC-code We will have: ------------------------------ CRC-polynomial / Original-Message + CRC-code .... |||||||| VVVVVVVV ----------------------------- CRC-code XOR CRC-code ----------------- 000..000 ```

(The dvision will now bring down the value "CRC-code" which will be subtracted from the remaining value "CRC-code" --- therefore producting the final remainder 0)

• Example:

• Previously, we have computed the CRC code for a message

 ``` CRC generator polynomial: 11011 (N = 5) Message: 11100110 CRC code = 0010 CRC protected message = 111001100010 ```

• CRC check:

 ``` Divide: Received message 111001100010 by CRC polynomial 11011 (don't care about the quotient) ---------------- 11011 / 111001100010 11011 ------ 11111 11011 ---------- 10000 11011 --------- 10110 11011 ------- 11011 11011 ------ 000000 <--- Remainder = 0 !! ```