Introduction
The cyclic redundancy check is the error-detecting code used in the trailer of almost every link-layer frame: Ethernet's 32-bit frame check sequence (FCS) is a CRC, and so are the checks in Wi-Fi, HDLC and PPP. It treats the frame as a long binary polynomial, divides it by a fixed generator polynomial using arithmetic modulo 2, and sends the remainder. The receiver repeats the division over the whole received frame; a non-zero remainder means an error.
A CRC is preferred over parity and the Internet checksum because, for the same number of check bits, it catches far more error patterns, in particular all burst errors of length up to the number of check bits when the generator has a constant term, which is how errors on real links tend to look. It is also cheap in hardware: a shift register with a few XOR gates computes it at line rate.
Three tasks recur: compute the transmitted frame (do the division), decide whether a received frame is accepted, and decide which error patterns a given generator detects.
Prerequisites
- Error Detection: Parity, Hamming Distance and Internet Checksum: Hamming distance, burst errors, what "detect" means.
- Modulo-2 arithmetic: addition and subtraction are both XOR; there are no carries or borrows.
Core concepts
Bit strings as polynomials
A bit string is the polynomial with coefficients in . For example 1011 is and 10011 is . The degree is the highest power with coefficient 1.
| Term | Meaning |
|---|---|
| The message (data bits), bits | |
| Generator, degree , so it is written with bits; both its highest and lowest bits are 1 in practice | |
| Remainder, exactly bits (pad with leading zeros) | |
| Transmitted frame: followed by , bits | |
| Error pattern: the bits that flipped; received frame is |
Degree versus length. A generator of degree has bits and produces check bits. CRC-32 has a degree-32 generator (33 bits) and a 32-bit FCS.
Modulo-2 long division
At each step, if the leading bit of the current window is 1, XOR the generator into it (the quotient bit is 1); if it is 0, XOR zeros (the quotient bit is 0). Then move one position right. The last bits after the final step are the remainder. Only the remainder matters; the quotient is discarded.

Algorithms and pseudocode
Bit strings are indexed from the left starting at 1; XOR acts bit by bit.
CRC-REMAINDER(M, G) // M: m bits, G: r+1 bits with G[1] = 1
r <- length(G) - 1
A <- M followed by r zeros // A[1 .. m+r]
for i <- 1 to m
if A[i] = 1 then
for j <- 1 to r + 1
A[i + j - 1] <- A[i + j - 1] XOR G[j]
return A[m+1 .. m+r] // the r-bit remainder
CRC-SEND(M, G)
return M followed by CRC-REMAINDER(M, G)
CRC-CHECK(T, G) // T: received m+r bits
divide T itself (no zeros appended) by G as above, for i <- 1 to m
return (last r bits are all 0)For the software shown ( message bits, degree generator), copying/appending and storage cost . Best time is ; worst time is bit operations, with average requiring a bit distribution. A table-driven version can process a byte per step. Streaming hardware instead uses an -bit shift register with feedback XORs, typically processing one input bit per clock; that is a different cost/storage model.
Mathematical explanation
Why the frame divides evenly. Appending zeros is multiplication by . Write with . Then
because modulo 2. So divides every correct frame.
When an error is missed. The receiver divides ; since , the remainder is that of alone. An error is undetected exactly when divides . Every undetected-error case follows from this.
Detection guarantees (for a generator of degree ):
| Error pattern | Detected when | |
|---|---|---|
| Single bit | has at least two terms (always true in practice) | |
| Two bits | has a constant term and does not divide for any up to the frame length (for example, has a primitive factor of degree and the frame is shorter than bits) | |
| Any odd number of bits | divides : then , but for odd weight, so | |
| Burst of length | , | has a constant term: then and because |
| Burst of length | Missed only if : fraction of such bursts | |
| Burst longer than | Missed with fraction of such patterns |
Parity is the special case . The remainder of divided by is , the number of 1s in the message modulo 2: a one-bit CRC with generator 11 is an even parity bit.
Worked examples
Example 1: computing the CRC
Message 11010110, generator 1011 (, ). Append three zeros: 11010110000. XOR 1011 under the leading 1 at positions 1, 2, 3, 4, 6 and 8 (Figure 1); the windows starting at positions 5 and 7 begin with 0, so their quotient bits are 0. Quotient 11110101, remainder 111. Transmitted frame: 11010110111.
Example 2: a degree-4 generator
Message 101101, generator 10011 (). Append four zeros: 1011010000. The division, with the five-bit window under each leading 1:
| Step | Leading 1 at position | Window | After XOR with 10011 | Whole string afterwards |
|---|---|---|---|---|
| 1 | 1 | 10110 | 00101 | 0010110000 |
| 2 | 3 | 10110 | 00101 | 0000101000 |
| 3 | 5 | 10100 | 00111 | 0000001110 |
Positions 2, 4 and 6 begin with 0, so the quotient is 101010. The remainder is the last four bits, 1110, and the frame is 1011011110.
Example 3: the receiver's view
The receiver of Example 1 divides 11010110111 by 1011 and gets remainder 000: accepted. If bit 5 flips (received 11011110111), the remainder is non-zero: rejected. If the error pattern is 00000101100, which is , the received word 11010011011 leaves remainder 000 and the error is not detected: an error that is a multiple of the generator always escapes.
Example 4: what a generator guarantees
has a constant term and degree 3, so it catches every burst of length 3 or less. It is not divisible by (it has three terms, so ), so it does not catch every odd-weight error: the error pattern 1011 itself (weight 3) is missed. (11101) does catch all odd-weight errors and all bursts up to length 4.
Example 5: bursts and two-bit errors for 10011
, so . A burst of length has its first and last bits set, so there are patterns of each length.
| Burst length | Patterns | Undetected |
|---|---|---|
| 1 to 4 | 1, 1, 2, 4 | 0 |
| 5 | 8 | 1: 10011 itself |
| 6 | 16 | 1: 110101, which is |
| 7 | 32 | 2 |
Shifting a burst multiplies it by , which does not change whether divides it, so these counts hold at every position in the frame. The undetected fractions are for , and for the longer bursts, as in the table of detection guarantees.
A two-bit error escapes exactly when divides . For this generator the smallest such is 15, so every two-bit error in a frame of at most 15 bits is caught, while two flipped bits exactly 15 positions apart escape. Because has three terms, : is not a factor, and the weight-3 error 10011 escapes.
Related material. CRC-32 as used by Ethernet
CRC-32 uses the degree-32 generator with hexadecimal coefficients 04C11DB7 (top bit implicit). Real implementations also preset the register to all ones, process each byte least significant bit first, and complement the result, so the FCS is not the plain remainder of the textbook division. The standard check value is: the CRC-32 of the nine ASCII bytes "123456789" is CBF43926.
Important properties and observations
- The remainder always has exactly bits. Keep leading zeros: a remainder of 11 with is written 011.
- The receiver does not append zeros. It divides the received bits directly.
- Undetected means divisible. To find an undetected error, take any non-zero multiple of as the error pattern.
- Linearity. The CRC of equals CRC() CRC() for equal-length messages (plain division, no preset). This is why a table-driven implementation works.
- CRC and the checksum. The CRC protects one link and every receiving interface tests it; TCP and UDP use the Internet checksum end to end; the IPv4 header checksum is hop by hop. A frame with a good CRC can still be corrupted inside a router's memory.
Common misconceptions.
- "A degree- generator has bits." It has bits and produces check bits.
- "Any generator catches all odd-weight errors." Only if is a factor.
- "CRC can correct errors." A CRC is used only for detection in networking.
GATE examination perspective
- Compute the frame. Append zeros, divide modulo 2, write the -bit remainder after the message. Check by dividing the frame: remainder zero.
- Accept or reject. Divide the received frame without appending zeros.
- Which errors are detected. Use the table: bursts when has a constant term; odd weight if ; a pattern is missed exactly when it is a multiple of .
- Bit counting traps. Degree versus number of bits; the number of check bits equals the degree.
- Burst counting. For , there are burst patterns of length ; for , there is one. For either case, the undetected ones are the multiples of of that length (Example 5).
- Parity as CRC. Generator 11 gives one even parity bit.
Summary
Sources
- A. S. Tanenbaum, D. J. Wetherall, Computer Networks, 5th ed., Pearson, 2011: Section 3.2.2 (Error-Detecting Codes, including the CRC).
- J. F. Kurose, K. W. Ross, Computer Networking: A Top-Down Approach, 8th ed., Pearson, 2021: Section 6.2.3 (Cyclic Redundancy Check (CRC)).
- B. A. Forouzan, Data Communications and Networking, 5th ed., McGraw-Hill, 2013: Chapter 10 (Error Detection and Correction; cyclic codes).