📖 CRC (Cyclic Redundancy Check): Sender divides data (plus appended zeros) by a fixed generator polynomial using XOR (modulo-2) division. The remainder is attached to the data. Receiver divides again; remainder 0 means no error.
Step 1 — Choose generatorGenerator 1011 (x³ + x + 1) has 4 bits, so degree n = 3.
Step 2 — Append zerosData 1001 + three zeros = 1001000.
Step 3 — XOR divisionDivide 1001000 by 1011 (subtract = XOR, no borrow).
| Step | Bits taken | XOR with | Result → remainder |
|---|
| 1 | 1001 first 4 bits | 1011 leading bit 1 | 0010 → 010 |
| 2 | 0100 010 + next bit 0 | 0000 leading bit 0 | 0100 → 100 |
| 3 | 1000 100 + next bit 0 | 1011 leading bit 1 | 0011 → 011 |
| 4 | 0110 011 + next bit 0 | 0000 leading bit 0 | 0110 → 110 |
✅ Rule: leading bit 1 → XOR with the generator (1011). Leading bit 0 → XOR with 0000. After the last bit, the remainder 110 is the CRC.
Step 4 — SendCodeword = data + CRC = 1001110. Receiver divides by 1011 and gets remainder 000, so frame is accepted.
📖 Hamming Code (7,4): Adds parity bits at positions that are powers of 2 (1, 2, 4). Each parity bit checks a fixed group of positions, so the failing checks point to the exact error position.
| Parity bit | Checks positions |
|---|
| p1 | 1, 3, 5, 7 |
| p2 | 2, 3, 6, 7 |
| p4 | 4, 5, 6, 7 |
💡 Hamming Example (even parity)- Data bits d3 d5 d6 d7 = 1 0 1 1
- p1 = parity of (d3, d5, d7) = (1, 0, 1) → 0
- p2 = parity of (d3, d6, d7) = (1, 1, 1) → 1
- p4 = parity of (d5, d6, d7) = (0, 1, 1) → 0
- Codeword (position 1 to 7) = 0110011
- Bit 6 flips → received 0110001. Re-check: p1 ok, p2 fails, p4 fails
- Syndrome (p4 p2 p1) = 110 = 6 → flip bit 6 back to correct
✅ CRC: catches all burst errors up to length n, very reliable, cheap in hardware.
❌ CRC cannot correct errors, only detect. Hamming corrects 1 bit but cost is extra parity bits.