# Error Detection
## What is Error Detection
Error detection is the process of determining whether data has been altered or corrupted during transmission. When data travels over a network, it can be affected by electrical noise, signal attenuation, interference, and other physical phenomena that may flip bits, causing a 0 to become a 1 or vice versa. Error detection techniques add redundant information to the transmitted data that allows the receiver to determine whether the received data matches what was sent. If an error is detected, the frame is discarded and may be retransmitted.
## Parity Check
The simplest error detection method is the parity check. In even parity, the sender counts the number of 1 bits in the data and appends a parity bit that makes the total number of 1 bits, including the parity bit, an even number. In odd parity, the total number of 1 bits including the parity bit is made odd. The receiver recalculates the parity and compares it to the received parity bit. If they do not match, an error has occurred. The limitation is that parity can only detect an odd number of bit errors. If two bits are flipped, the parity appears correct and the error goes undetected.
## Checksum
A checksum is calculated by dividing the data into a series of fixed-size blocks, summing the blocks, and appending the result as a checksum value. The receiver performs the same calculation and compares the result to the received checksum. If they differ, an error has occurred. Checksums are more effective than simple parity but can still miss certain patterns of errors. The Internet Checksum used in IP and TCP headers uses one's complement arithmetic.
## Cyclic Redundancy Check
The Cyclic Redundancy Check or CRC is the most powerful and widely used error detection method in networking. CRC treats the data as a large binary number and divides it by a generator polynomial. The remainder of this division, which is always smaller than the generator polynomial, is the CRC value. This CRC value is appended to the data. The receiver performs the same division and checks whether the remainder is zero. If the remainder is not zero, an error has occurred. CRC can detect all single-bit errors, all double-bit errors, all burst errors shorter than the degree of the generator polynomial, and most longer burst errors. Ethernet uses a 32-bit CRC.
## Error Correction vs Error Detection
Error detection only identifies that an error has occurred. To fix the error, the receiver must request retransmission. Error correction, also called forward error correction, adds enough redundant information to allow the receiver to not only detect but also correct certain errors without retransmission. Error correction requires more redundant bits than error detection but is valuable in situations where retransmission is impractical, such as satellite communication or one-way broadcasts.Back to Subject