A Basic Error Detection Method
Parity checking detects transmission errors by constraining the total number of '1's in each data block. It does not correct errors. It gives the receiver a basic way to determine whether a data block was corrupted during transmission. The core idea is to add one extra bit, the parity bit, to each block of data.
This method adds only a small amount of to achieve a basic level of integrity checking.
How Parity Check Works
The sender and receiver must first agree on which type of parity to use. There are two options: even parity or odd parity.
Even Parity
The goal is to ensure that the total number of '1's in the data block (including the parity bit) is an even number.
- If the original data has an odd number of '1's, the parity bit is set to 1.
- If the original data has an even number of '1's, the parity bit is set to 0.
Odd Parity
The goal is to ensure that the total number of '1's in the data block (including the parity bit) is an odd number.
- If the original data has an odd number of '1's, the parity bit is set to 0.
- If the original data has an even number of '1's, the parity bit is set to 1.
Even Parity Example
- Sender's side: Consider the 7-bit ASCII code for the letter 'K', which is .
- Count the '1's in : There are four '1's.
- Since four is an even number, the sender sets the parity bit to 0.
- The transmitted 8-bit block is followed by .
- Receiver's side: The receiver gets the 8-bit block .
- It counts the total number of '1's: There are four '1's.
- Since four is an even number, it matches the agreed-upon even parity. The parity check accepts the block as valid.
Limits of a Parity Check
A single parity check cannot detect an even number of bit errors. The following example uses data , an even parity bit , and the transmitted block .
One-Bit Error
During transmission, a single bit flips. The receiver gets .
- The receiver counts the '1's: there are now five.
- Five is an odd number. This does not match the agreed-upon even parity.
- Result: The parity check detects the error. The receiver can mark the data as corrupt and request a retransmission.
Two-Bit Error
During transmission, bits at positions 4 and 5 flip. The receiver gets .
- The receiver counts the '1's: there are now four.
- Four is an even number. This matches the agreed-upon even parity.
- Result: No error is detected, even though the data is wrong. The receiver accepts the corrupted data as valid.
With one parity bit, the parity check detects any odd number of errors (1, 3, 5, etc.). It does not detect an even number of errors (2, 4, 6, etc.).