Skip to content

hop 6 of 32 · 5 min

Noticing that a frame arrived wrong

Signals get corrupted. A bit flips, and the receiver has no way to know unless the sender included something to check against.

Parity

Add one bit making the total number of ones even.

code
data 1011001  ->  four ones  ->  parity 0  ->  send 10110010

Detects any odd number of flipped bits and misses every even number. One bit of overhead and roughly a 50 percent chance of missing a burst error, which is why it is not used alone on a network.

Checksum

Add the data up in fixed size words and send the total. This is what IP and TCP use.

It catches most single bit errors and misses a whole class: two errors that cancel out, and any reordering of words, because addition does not care about order.

Cyclic redundancy check

Treat the message as a large binary number, divide by an agreed polynomial, and send the remainder.

code
message + CRC, divided by the polynomial, leaves zero
anything else means corruption

CRC-32 detects all single and double bit errors, all odd numbers of errors, and every burst shorter than 33 bits. Missing a longer burst has a probability of about one in four billion.

It is also cheap in hardware, being shifts and XORs, which is why every Ethernet frame carries one and why it is done at line rate.

MethodOverheadCatchesUsed by
Parity1 bitodd numbers of flipsmemory, serial links
Checksum16 bitsmost, misses cancelling pairsIP, TCP, UDP
CRC-3232 bitsnearly everythingEthernet, disks, ZIP

Detecting is not correcting

All three only say "this is wrong". The response is to discard the frame and let a higher layer notice something is missing and ask again.

Forward error correction sends enough redundancy to repair the damage without asking. It costs bandwidth permanently, and it is the right trade when asking again is impossible or too slow: deep space probes, live audio, QR codes that still scan with a corner torn off.

The rule is about the round trip. If retransmitting is cheap, detect and ask again. If it is expensive or impossible, pay upfront for correction.

Layers repeat the check

Ethernet has a CRC, IP has a header checksum, TCP has a checksum, TLS has an authentication tag. That looks wasteful and is not: each layer only protects its own hop or its own concern, and a frame can be corrupted inside a router after Ethernet checked it and before the next link recomputes.