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.
data 1011001 -> four ones -> parity 0 -> send 10110010Detects 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.
message + CRC, divided by the polynomial, leaves zero
anything else means corruptionCRC-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.
| Method | Overhead | Catches | Used by |
|---|---|---|---|
| Parity | 1 bit | odd numbers of flips | memory, serial links |
| Checksum | 16 bits | most, misses cancelling pairs | IP, TCP, UDP |
| CRC-32 | 32 bits | nearly everything | Ethernet, 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.