written 2.6 years ago by |
A parity bit is a check bit, which is added to a block of data for error detection purposes. It is also used to validate the integrity of the data. The value of the parity bit is assigned either 0 or 1 that makes the number of 1s in the message block either even or odd depending upon the type of parity. Parity check is mostly suitable for single bit error detection only.
Because data transmission is not an entirely error-free process, data is not always received in the same way as it was transmitted thus a parity bit adds checksums into data that enable the target device to determine whether the data was received correctly or not.
The noise or electrical interference may sometimes interfere with the transmission of data, it is useful to have some way to easily detect errors in information as it is exchanged. One way to do this is to add an eighth bit to characters that are transmitted, called a parity bit. The parity bit is chosen such that all correctly transmitted characters will have either an even or odd number of ones.
There are two kinds of parity bits:
- Even parity: In even parity the number of bits with a value of one are counted. If that number is odd, the parity bit value is set to one to make the total number of ones in the set (including the parity bit) an even number. If the number of bits with a value of one is even, the parity bit value is set to zero, so that the total number of ones in the set (including the parity bit) remains an even number.
Odd Parity: In odd parity, if the number of bits with a value of one is an even number, the parity bit value is set to one to make the total number of ones in the set (including the parity bit) an odd number. If the number of bits with a value of one is odd, the parity bit value is set to zero, so that the total number of ones in the set (including the parity bit) remains an odd number.
Error Detection by Adding Parity Bit:
From Sender’s End: While creating a frame, the sender counts the number of 1s in it and adds the parity bit in following way
Case 1 even parity: If number of 1s is even, parity bit value is 0. If number of 1s is odd, parity bit value is 1.
Case 2 odd parity: If number of 1s is odd, parity bit value is 0. If number of 1s is even, parity bit value is 1.
From Receiver’s End: On receiving a frame, the receiver counts the number of 1s in it.
Case 1 even parity check: If the count of 1s is even, the frame is accepted, otherwise it is rejected.
Case 2 odd parity check: if the count of 1s is odd, the frame is accepted, otherwise it is rejected.