The Data Link Layer

a parity bit

Suppose you read a friend a string of yes/no answers over a noisy phone line, and you want them to catch if they mishear one. A simple trick: after the answers, you also tell them how many were yes, in a rough form — say, whether the count of yeses was even or odd. If their tally comes out a different parity than what you told them, they know they misheard at least one. A parity bit is exactly this: one extra bit added to a block of data that records whether the number of 1-bits in the block is even or odd.

Concretely, with even parity the sender counts the 1s in the data and sets the parity bit so the total number of 1s (data plus parity) is even. Send 1011001, which has four 1s, and the parity bit is 0 (total stays even); send 1011000, which has three 1s, and the parity bit is 1 to make four. The receiver recounts the 1s; if the total is odd, a bit flipped somewhere and the data is rejected. It is the cheapest possible error-detection scheme: one bit, one count.

The honest limit is severe. A single parity bit detects any ODD number of flipped bits, but is completely fooled by an EVEN number of flips — two bits flip and the parity is unchanged, so the error slips through. It also cannot say WHICH bit was wrong, so it cannot correct anything. That is why real links use stronger checks like the Internet checksum or a CRC; parity survives mainly in memory chips and as a teaching example, sometimes arranged in a two-dimensional grid that can locate and even correct a single-bit error.

Even parity over 1010101 (four 1s): parity bit = 0, so 10101010 is sent. If noise flips one bit and the receiver sees 10101011, it now counts five 1s — odd — and rejects the frame. But if TWO bits flip, the count stays even and the error goes undetected.

One flip is caught; two flips slip through. That is the parity bit's hard limit.

A single parity bit detects only an odd number of errors and corrects none. Two simultaneous flips are invisible to it — which is why it is the weakest detector and rarely the only check used on a real link.

Also called
parity check同位檢查