Data Link Layer and Medium Access Sub Layer · Computer Networks

Cyclic Redundancy Check (CRC)

Watch lectures

Cyclic Redundancy Check (CRC)


1. Fundamentals of Cyclic Codes & CRC

Cyclic Redundancy Check (CRC) is a powerful, mathematically rigorous error-detecting code based on binary polynomial division. It is the dominant error-detection algorithm used in modern networking standards, including IEEE 802.3 Ethernet, Wi-Fi, HDLC, and ATM.

Why "Cyclic"?

In cyclic codes, if a codeword is cyclically shifted (rotated), the resulting binary string is also a valid codeword in the codebook.


2. Polynomial Representation of Bit Streams

In CRC, binary bit sequences are represented as polynomials in indeterminate xx with binary coefficients (00 or 11):

Bit String: 1 0 0 1 1 0 1  ⟹  1⋅x6+0⋅x5+0⋅x4+1⋅x3+1⋅x2+0⋅x1+1⋅x0=x6+x3+x2+1\text{Bit String: } 1\ 0\ 0\ 1\ 1\ 0\ 1 \implies 1\cdot x^6 + 0\cdot x^5 + 0\cdot x^4 + 1\cdot x^3 + 1\cdot x^2 + 0\cdot x^1 + 1\cdot x^0 = x^6 + x^3 + x^2 + 1
  • Highest power of xx present in the polynomial defines the Degree of the Polynomial (rr).
  • A polynomial of degree rr contains (r+1)(r + 1) binary coefficients.

3. Mathematical Mechanism of CRC

MermaidDiagram
Rendering diagram…

The Modulo-2 Division Rules:

  • Addition and Subtraction in Modulo-2 are identical and equivalent to the XOR operation (0⊕0=0, 0⊕1=1, 1⊕0=1, 1⊕1=00 \oplus 0 = 0,\ 0 \oplus 1 = 1,\ 1 \oplus 0 = 1,\ 1 \oplus 1 = 0).
  • There are no carries in addition and no borrows in subtraction.
  • If the leftmost bit of the current dividend is 1, the divisor aligns and XORs.
  • If the leftmost bit is 0, the divisor does not divide (or XORs with all 0s).

4. Complete Step-by-Step Solved Numerical

Problem Statement:

A sender wants to transmit the dataword D=100100D = 100100.
The Generator Polynomial is G(x)=x3+x2+1G(x) = x^3 + x^2 + 1.

  1. Find the transmitted CRC codeword.
  2. Verify that the receiver detects no error if the frame arrives uncorrupted.

Step 1: Determine the Divisor and Appended Zeros

  • Generator Polynomial: G(x)=x3+x2+0⋅x1+1  ⟹  1101G(x) = x^3 + x^2 + 0\cdot x^1 + 1 \implies \mathbf{1101} (4 bits).
  • Degree of G(x)G(x): r=3r = 3.
  • Append r=3r = 3 zeros to the dataword:
Dividend=100100000\text{Dividend} = 100100\mathbf{000}

Step 2: Modulo-2 Division at Sender

SVGVector Architecture Diagram (SVG)
1 1 1 0 1 1 <--- Quotient (Ignored) Divisor: +------------- 1 1 0 1 | 1 0 0 1 0 0 0 0 0 <--- Data + 3 Zeros ^ 1 1 0 1 ----------- 0 1 0 0 0 ^ 1 1 0 1 --------- 0 1 0 1 0 ^ 1 1 0 1 --------- 0 1 1 1 0 ^ 0 0 0 0 --------- 1 1 1 0 1 1 0 1 ------- 0 0 1 1 0 ^ 1 1 0 1 ----------- 0 0 1 <--- Remainder R (3 bits) = CRC
CRC Checksum R=001\text{CRC Checksum } R = \mathbf{001}

Step 3: Construct the Transmitted Codeword

Replace the 3 appended zeros with the 3-bit remainder:

Codeword T=Dataword+CRC=100100001\text{Codeword } T = \text{Dataword} + \text{CRC} = \mathbf{100100001}

Step 4: Verification at Receiver

The receiver divides the received codeword 100100001100100001 by the generator 11011101:

SVGVector Architecture Diagram (SVG)
1 1 1 0 1 1 Divisor: +------------- 1 1 0 1 | 1 0 0 1 0 0 0 0 1 1 1 0 1 ------- 1 0 0 0 1 1 0 1 ------- 1 0 1 0 1 1 0 1 ------- 1 1 1 0 0 0 0 0 ------- 1 1 1 0 1 1 0 1 ------- 0 1 1 1 1 1 0 1 ------- 0 0 0 <--- Remainder = 0 ===> ACCEPT!

Since the remainder is 000000, the frame is accepted as uncorrupted.


5. Standard Generator Polynomials in Networking

Name Polynomial Expression Degree (rr) Primary Industry Standard
CRC-8 x8+x2+x+1x^8 + x^2 + x + 1 8 ATM Header Error Control (HEC)
CRC-16 (ANSI) x16+x15+x2+1x^{16} + x^{15} + x^2 + 1 16 USB, Modbus, ANSI
CRC-CCITT x16+x12+x5+1x^{16} + x^{12} + x^5 + 1 16 HDLC, X.25, Bluetooth
CRC-32 x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1x^{32} + x^{26} + x^{23} + x^{22} + x^{16} + x^{12} + x^{11} + x^{10} + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1 32 IEEE 802.3 Ethernet, Wi-Fi, ZIP, PNG

6. Error-Catching Capabilities of CRC

A well-designed generator polynomial G(x)G(x) guarantees:

  1. Single-bit errors: Detected if G(x)G(x) has at least two non-zero terms (contains x0x^0).
  2. Double-bit errors: Detected if G(x)G(x) does not divide xt+1x^t + 1 for any t<frame lengtht < \text{frame length}.
  3. Odd number of errors: Detected if G(x)G(x) contains (x+1)(x + 1) as a mathematical factor.
  4. Burst errors of length ≤r\leq r: 100%100\% detected (where rr is the polynomial degree).
  5. Burst errors of length r+1r + 1: Detected with probability 1−(12)r−11 - \left(\frac{1}{2}\right)^{r-1} (99.9999998%99.9999998\% for CRC-32).

Frequently Asked Questions

QHow many redundant bits are appended to a dataword if the generator polynomial is $x^4 + x + 1$?

The degree of G(x)G(x) is r=4r = 4, so exactly 4 zeros are appended.

QWhy does modulo-2 division use XOR instead of ordinary subtraction?

In modulo-2 arithmetic over Galois Field GF(2)\text{GF}(2), addition and subtraction are identical and carryless, precisely mapping to the electronic logic of the XOR gate.

QWhat error types are guaranteed to be detected by CRC-32?

All single-bit errors, all double-bit errors, all odd numbers of inverted bits, and all burst errors up to 32 bits in length.

QHow does the receiver verify a CRC codeword?

It divides the whole received frame (data plus CRC) by the same generator using modulo-2 division. A remainder of zero means the frame is accepted; any non-zero remainder means it is discarded.

Student FinanceWeb Platform

Pocketly — Personal Finance for Students

Keep your hostel and college expenses under control. Track accounts, log spending in seconds, and stay within your monthly budget.

← All Computer Networks modules