Error Detection
Parity, checksums, CRC. Detecting corruption is cheaper than preventing it.
Level: intermediate
What is it?
Error detection adds redundant information to data so a receiver can detect some corruption. Common schemes include parity bits, checksums, and cyclic redundancy checks (CRCs); error correction adds enough structure to recover some errors without retransmission.
Why does it matter?
Physical links and storage systems can experience noise or corruption. Detecting errors prevents damaged data from being silently treated as correct, while higher-layer protocols can decide whether to discard, correct, or retransmit.
Mental model
The sender computes a check value from the data and sends both. The receiver recomputes or checks the value; a mismatch signals corruption, but a match does not mathematically prove that no error occurred.
How it works
- Parity detects some odd-numbered bit errors but misses many multi-bit patterns.
- Checksums summarize data using arithmetic; the detection strength depends on the algorithm and how it is used.
- CRC treats bits as a polynomial and detects broad classes of burst errors efficiently in hardware.
- Error-detection schemes have finite detection guarantees; they are not substitutes for cryptographic message authentication against attackers.
- Reliable protocols such as TCP may use checksums and retransmission, while Ethernet's FCS detects corrupt frames locally.
Steps
- The sender computes parity/checksum/CRC over the defined fields.
- The check bits/value travel with the data.
- The receiver validates the received data according to the same algorithm.
- If validation fails, the frame/message is rejected or a protocol-specific recovery action is taken.
Real-world usage
- Understanding Ethernet FCS, transport checksums, and storage checks.
- Choosing between detection, correction, and retransmission strategies.
Common mistakes
- Assuming a checksum proves data came from a trusted sender.
- Claiming parity detects every possible bit error.
- Confusing error detection with error correction or encryption.
Interview questions
Why is a CRC commonly used for frames?
It detects many common accidental and burst-error patterns efficiently and is straightforward to implement in hardware.
Does a checksum provide security against malicious tampering?
Not by itself; an attacker can often modify data and recompute a non-cryptographic checksum. Use cryptographic authentication when adversarial integrity matters.