Error Detection and Correction

Error detection tells a receiver that data has changed. Error correction uses extra information to recover the original data within the limits of the code. A parity bit can flag a single flipped bit. Hamming code can locate and repair it. When a frame fails a check such as a CRC, the protocol can discard it or request another copy.

One flipped data bit
Sent1011
Received1111

The second bit changed. What can the receiver infer from its check bits?

What is the difference between error detection and correction?

The sender encodes a message into a codeword containing data and redundant check bits. At the receiver, a failed check is evidence of corruption. Repair requires enough redundancy to distinguish which original codeword was sent, or another copy from the sender.

Detect
“Something changed.” Even parity flags an odd number of flipped bits but cannot identify their positions.
Correct
“Bit 5 changed.” With one error, a Hamming decoder identifies the position from the failed checks and reverses the flip.
Retransmit
“Send that frame again.” Automatic repeat request (ARQ) replaces a missing or rejected frame when feedback and time permit.

What happens when the same two bits flip?

Send 1011 through three encoders. Each adds its own check bits. Change the same data positions in every transmission and leave the check bits alone.

Two flips. The first and second data bits change and 1011 arrives as 0111.

Single parity

Misses the error

Even count. Parity check passes.

Delivers 0111

Hamming (7,4)

Miscorrects the word

Syndrome 110. Decoder flips position 6.

Delivers 0101

Extended Hamming (8,4)

Rejects the word

Syndrome 110. Overall parity is even.

No payload delivered

The receiver sees only its received codeword. We know when it delivers the wrong answer because this experiment also records the transmitted message.

Error detection and correction techniques compared

Start with the job the receiver must do. A failed Ethernet frame check can justify dropping a frame. A memory controller usually needs the correct word on that same read.

What each method can tell the receiver
TechniquePurposeMain capabilityCommon uses
Parity (VRC)DetectAll odd numbers of flips; misses all even numbersSimple serial words
Two-dimensional parityDetect / correctLocates one flipped bit with complete row and column checksBlock checks, teaching
ChecksumDetectMany corruption patterns; cancellation and reordering can escapeInternet protocol checks
CRCDetectStrong burst-error detection; strength depends on generator and lengthEthernet frame check sequence
Hamming codeCorrectSingle-error correction (SEC)Short blocks, coding fundamentals
Extended HammingCorrect / detectSingle-error correction, double-error detection (SECDED)ECC memory
Reed–Solomon, LDPC, polar, convolutionalCorrect (FEC)Code-dependent multi-error recoveryStorage, radio, cellular, satellite
ARQRecover by retryResends missing or rejected framesTwo-way packet links

Correction capability depends on the actual code, decoder and error pattern. FEC is a category, not a single code; both Hamming and Reed–Solomon are FEC methods.

Error detection and correction simulator

Choose a code and enter your data, or start with a preset. Select any received bit to flip it. Compare the receiver’s decision with the message that was actually sent.

Extended Hamming (8,4)

4 data + 4 check bits
DataCheckFlippedCorrected
Transmitted codeword01100110
10Check21Check31Data40Check50Data61Data71Data80Check

Example: position 5 was flipped by the channel. Positions count from left to right.

Received codeword01101110
10Check21Check31Data40Check51Flip61Data71Data80Check
Decoder output01100110
10Check21Check31Data40Check50Fixed61Data71Data80Check
Corrected successfully. The receiver changed position 5 and recovered the original data 1011.
Flipped channel bits1 / 8Observed by the simulator
Syndrome (binary)101Check value 5 in decimal
Code rate50.00%4/8 information fraction
Added overhead100.00%Relative to original data
Recovered data1011Original: 1011
Receiver decisionCorrectNot a guarantee of correctness

Overall parity check: 1 (odd total, mismatch).

Educational bit-flip model, no analog channel or random noise. The receiver only uses the received bits and check rules; the simulator separately compares against the transmitted data to expose undetected errors and miscorrections. CRC here uses MSB-first, zero-initialized, unreflected polynomial division, not a named production CRC profile.

Types of errors in data communication

The number of changed bits and their positions both matter. A code designed for isolated bit flips may struggle with several closely spaced errors.

OriginalNo errors
10110010
Single-bit error1 changed bit
10100010
Burst errorLength 4, 3 flips
10011110
Illustrative received words compared with the same transmitted word. Marked positions differ from the original; the receiver normally does not know those positions.

Single-bit error

Exactly one bit changes. A single-error-correcting code can locate and repair that bit.

Multiple-bit and burst errors

Multiple bits change. A burst’s length is the span from the first changed bit to the last, including any unchanged bits in between. A four-bit burst need not contain four incorrect bits.

Random thermal noise can cause scattered bit errors, while fading, impulse noise or interference may produce bursts. Missing frames and out-of-order packets are separate protocol problems; bit-level checks alone cannot detect every such event. Learn how noise in communications affects SNR and BER.

An erasure gives the decoder extra information. If a symbol is missing or the receiver marks it unreliable, its position is known. For a block code of minimum distance d, unique recovery is guaranteed for e unknown errors and s known erasures when 2e + s < d. A distance-3 code can therefore recover one unknown bit error or two erased positions.

Parity checks: VRC, LRC, and two-dimensional parity

A parity bit makes the total count of 1s in a protected word even or odd. For even parity, the check bit is the XOR of the data bits. The receiver computes parity again over the complete word. Vertical redundancy check (VRC) commonly means adding a parity bit to each data unit.

Even parity
P = d1 ⊕ d2 ⊕ … ⊕ dk

⊕ means XOR (addition modulo 2). For odd parity, invert P.

Worked example: even parity of 1011001

The seven data bits contain four 1s. Add a 0 to make the count even.

Even-parity word4 ones
10110010
One flip3 ones · detected
10010010
Two flips4 ones · missed
10011010

A single flip changes the total to an odd number, so it is detected. Flipping two bits preserves even parity, so the corrupted word can pass. Single parity detects every odd number of flips, no even number, and cannot locate the error.

Longitudinal redundancy check (LRC) and two-dimensional parity

LRC typically adds a parity word across a group of equally sized data units. Combining column parity with a parity bit for each row produces two-dimensional parity. Under a single-bit-error assumption, the failed row and column intersect at the flipped bit.

One error: row and column fail

C1C2C3PRow1010OK0100FAIL1100OK0000OKOKOKFAILOKCol
Row 2 and column 3 identify the bad bit.

Four errors: the rectangle escapes

C1C2C3PRow0110OK1010OK1100OK0000OKOKOKOKOKCol
Each affected row and column has two flips, so all parity checks pass.

These examples use complete even row and column parity, including the corner bit. Multiple errors may produce ambiguous syndromes; the receiver must not assume every reported intersection represents a single error.

Internet checksum: add, fold, and complement

A checksum summarizes a block of data using arithmetic. For the 16-bit Internet checksum, split the protected bytes into 16-bit words, add them using one’s complement arithmetic (wrap a carry from the top back to the low bit), then complement the result. The checksum is included in the protected data according to the protocol.

Worked example: 16-bit one’s complement checksum

Let the words be ABCD and EF01 (hexadecimal).

Add the wordsABCD + EF01 = 19ACE
Wrap the carry9ACE + 1 = 9ACF
Complement all 16 bits~9ACF = 6530
Receiver’s folded sum9ACF + 6530 = FFFF

Checksum = 0x6530. In this example the receiver checks for a folded sum of all 1s (equivalently, a complemented result of zero).

Checksums are inexpensive and catch many common corruptions, but different word sequences can have the same sum. Swapping the two 16-bit words above changes their order without changing this checksum. The IPv4 header checksum and TCP/UDP Internet checksums use related one’s complement arithmetic with protocol-specific protected fields. See RFC 1071 for computation details.

Calculate a 16-bit Internet checksum

Each entry is a 16-bit word in hexadecimal. For an odd number of bytes, add a zero byte at the end for the calculation. For example, bytes 12 34 AB form the words 1234 AB00.

Checksum 0x6530 · Folded sum 0x9ACF

Show the running sum
  1. 0000 + ABCD = ABCD
  2. ABCD + EF01 = 19ACE → fold carry → 9ACF

Cyclic redundancy check (CRC) with a worked example

A CRC treats a bit string as coefficients of a binary polynomial. The transmitter appends the remainder of polynomial division by an agreed generator to the data. The receiver checks the resulting codeword against that same generator. Division uses XOR instead of ordinary subtraction, with no carries or borrows.

Systematic CRC encoding (simple zero-initialized form)
R(x) = [D(x)xr] mod G(x)
C(x) = D(x)xr + R(x)

G(x) is the generator of degree r; R(x) contains r check bits. All operations are over GF(2).

CRC solved example: data 1101, generator 1011

The generator is x³ + x + 1, so append three zeros to 1101. Perform modulo-2 division on 1101000.

Show the four XOR division steps

Starting word: 1101000 · Generator: 1011

Step 1 · XOR starting at position 1

Before1101000
⊕ Mask1011000
After0110000

Step 2 · XOR starting at position 2

Before0110000
⊕ Mask0101100
After0011100

Step 3 · XOR starting at position 3

Before0011100
⊕ Mask0010110
After0001010

Step 4 · XOR starting at position 4

Before0001010
⊕ Mask0001011
After0000001

3-bit remainder = 001

Remainder = 001; transmitted codeword = 1101001. Dividing the codeword by 1011 gives zero remainder. If position 5 flips, the received word is 1101101 and the remainder becomes 100, so the receiver detects an error.

Each displayed XOR mask is the generator shifted under the current leading 1. Leading zeros do not require XOR.

Which errors can a CRC detect?

A conventional generator with nonzero constant term and degree r detects every nonzero burst of length at most r. A generator containing the factor x + 1 detects every odd-weight error pattern. Longer burst and multi-bit guarantees depend on the polynomial and protected block length. Under suitable random-error assumptions an r-bit CRC has an approximate undetected-error probability of 2−r, but this is not a guarantee for arbitrary patterns.

For this simple example, an error polynomial of 0001011 (the generator itself) produces a zero remainder. The codeword changes from 1101001 to 1100010 and passes the check. CRC detection is strong, not infallible. Production CRCs also specify initialization, reflection, final XOR and byte order, so their check residues need not be zero.

Hamming code and SECDED: finding the bad bit

Hamming codes use overlapping parity checks to identify a single changed bit. The standard binary Hamming (7,4) code protects four data bits with three parity bits. With positions numbered from 1 on the left in this guide, parity bits occupy powers of two: 1, 2 and 4. Data bits occupy 3, 5, 6 and 7.

Number of Hamming parity bits
2r ≥ k + r + 1

Choose the smallest integer r satisfying this inequality for k data bits. For k = 4, r = 3, because 8 ≥ 4 + 3 + 1.

Hamming (7,4) encoding and parity positions

Codeword positionsPurple = parity
10213140506171
P1 covers positions 1, 3, 5, 7
1·3·5·7
P2 covers positions 2, 3, 6, 7
·23··67
P4 covers positions 4, 5, 6, 7
···4567
Each check covers positions with its corresponding bit set in the binary position number. P1, P2 and P4 use even parity.

Worked example: encode 1011 and correct bit 5

  1. Place data 1011 in positions 3, 5, 6 and 7, in that order.
  2. P1 = d3 ⊕ d5 ⊕ d7 = 1 ⊕ 0 ⊕ 1 = 0.
  3. P2 = d3 ⊕ d6 ⊕ d7 = 1 ⊕ 1 ⊕ 1 = 1.
  4. P4 = d5 ⊕ d6 ⊕ d7 = 0 ⊕ 1 ⊕ 1 = 0.
TransmittedCheck bits 1, 2, 4
10213140506171
ReceivedBit 5 flipped
10213140516171
CorrectedData 1011 recovered
10213140506171

At the receiver, recompute parity over positions {1,3,5,7}, {2,3,6,7} and {4,5,6,7}. The check bits are s1 = 1, s2 = 0, s4 = 1, giving syndrome s4s2s1 = 101₂ = 5. Flip bit 5, then extract positions 3, 5, 6 and 7 to recover 1011.

Important limitation: Standard Hamming (7,4) has minimum distance 3. It can detect all two-bit errors if used for detection alone, but a decoder that automatically corrects every nonzero syndrome may mistake two errors for one and output the wrong valid codeword. It does not simultaneously guarantee single-error correction and double-error detection.

Extended Hamming (8,4): single-error correction, double-error detection

Adding an overall even-parity bit at position 8 raises the minimum distance to 4. The three-bit syndrome from positions 1–7 and the overall parity check let the receiver distinguish one- and two-bit errors under the assumption that at most two bits are wrong.

Syndrome SOverall parity check PDecoder action (≤ 2 flips)
00Accept; no error indicated
Nonzero1Correct position S in bits 1–7
01Correct overall parity bit (position 8)
Nonzero0Flag double error; do not correct

Triple and higher error counts can cause miscorrections or false accepts. Use the simulator to see the difference between SEC and SECDED by injecting two errors into the same original data.

Forward error correction (FEC) vs. retransmission (ARQ)

FEC sends redundant information proactively so a receiver can recover data without requesting another copy when errors are within its capability. ARQ (automatic repeat request) uses detection, sequence information, acknowledgments and timeouts to recover by retransmission.

FEC: repair locally

Data + correction bits
Corrupted codeword
Decoder attempts repair
Best when retries are costly or impossible.

ARQ: request another copy

Data + error check
Invalid frame / timeout
Retry using feedback
Best when return communication is available.

Common forward error correction codes

Block codes
Map a fixed data block into a longer codeword. Hamming corrects a single bit; Reed–Solomon corrects symbol errors. For a conventional RS(n,k) code, up to floor((n−k)/2) unknown symbol errors can be corrected, under the usual bounded-distance model.
Convolutional codes
Produce redundant output using current and previous input bits. A Viterbi decoder can estimate the most likely transmitted sequence.
LDPC and polar codes
Modern code families used in high-performance digital links. LDPC uses sparse parity-check constraints and iterative decoding; polar coding constructs channels of different reliability. For example, 5G NR uses LDPC for shared-channel data and polar coding for certain control channels.

Common ARQ protocols

Stop-and-wait sends one outstanding frame at a time. Go-back-N uses a sliding window and can resend a rejected frame plus following frames. Selective repeat can resend specific missing or rejected frames. Hybrid ARQ combines FEC with retransmission and, in many designs, combines information from multiple received attempts.

Adding FEC can increase processing and coding delay, but it may reduce retry delay and improve usable throughput on noisy links. Interleaving spreads bursts across multiple codewords; it does not correct errors by itself and adds buffering latency.

Why interleave a code? Suppose four codewords can each correct one flipped bit. Send their bits in rotation: one from A, then B, C, D, and repeat. Four consecutive flipped channel bits now land one per codeword. The receiver reverses the ordering and each decoder can repair its own bit. Interleaving spreads a burst across codewords at the cost of buffering and delay.

Error-control formulas: Hamming distance, code rate and BER

Hamming distance

d(a,b) = wt(a ⊕ b)

Count the positions where two words differ. The minimum distance dmin is the smallest distance between distinct valid codewords.

For 101100 and 100110, positions 3 and 5 differ, so d = 2.

Guaranteed error capability

Detection: dmin − 1
Correction: ⌊(dmin − 1)/2⌋

These are separate bounded-error guarantees, not simultaneous maxima. To guarantee correcting t errors and detecting up to s errors in total (s ≥ t), use dmin ≥ t + s + 1.

Code rate and overhead

R = k/n
Overhead = (n − k)/k × 100%

k is information bits; n is transmitted codeword bits. Overhead here is relative to the original data, not the final codeword.

Bit error rate (BER)

BER = Nincorrect/Ncompared

Report whether BER is measured before or after decoding, and which bit population is used. Frame error rate (FER) instead measures erroneous frames out of frames evaluated.

Example: code overhead and information rate

For Hamming (7,4), the rate is 4/7 ≈ 0.5714. The data-relative overhead is 3/4 = 75%; redundancy occupies 3/7 ≈ 42.86% of each transmitted codeword. At a raw coded rate of 7 Mb/s, the nominal information rate is 4 Mb/s, excluding framing, retransmission and other overhead.

Hamming (7,4)
4 data3 check
Extended Hamming (8,4)
4 data4 check
Illustrative rate-3/4 FEC
75%25%
Codeword fractions (not data-relative percentage overhead). Greater redundancy alone does not establish better performance; code construction and channel conditions matter.

Example: probability of errors in a frame

If independent bit flips have probability p, an uncoded n-bit frame has probability 1 − (1 − p)n of containing at least one error. For p = 10−5 and n = 1,000 bits, the probability is about 0.995%. The chance of exactly one flip is np(1 − p)n−1. For a single-error-correcting codeword the probability of two or more flips is 1 − (1 − p)n − np(1 − p)n−1. This is the probability of exceeding the guaranteed one-bit correction capability, not necessarily the measured residual BER. Burst errors violate the independence assumption.

Applications in computers and communication networks

ETHERNET

Frame integrity

Ethernet uses a CRC-based frame check sequence to reject corrupted frames. Higher layers may retry depending on the protocol; the FCS itself does not reconstruct the frame.

MEMORY

ECC RAM and storage

SECDED and more advanced ECC schemes protect memory words. Storage systems may combine checksums, multi-symbol correction codes and redundancy across devices.

WIRELESS

Wi-Fi and cellular

Physical-layer codes improve reception while packet checks and retry mechanisms handle residual corruption. Systems can adapt modulation and code rates as link quality changes.

LONG-DISTANCE LINKS

Satellite and deep-space communication

Low received power and long round-trip delay make strong FEC especially valuable. Interleaving and suitable modulation/coding combinations help maintain reliable links.

How engineers choose an error-control scheme

Start with the permitted residual error rate and the link’s measured error pattern. Evaluate code rate, decoding complexity, block length, energy and latency together. If a return link exists, compare FEC with ARQ or hybrid ARQ; if not, prioritize appropriate FEC and independent integrity checks. Validate under realistic burst errors, fading and interference rather than relying solely on an independent-bit model.

CRC and checksums address accidental corruption. They are not authentication mechanisms: an attacker can deliberately change data and recompute a public check value. Use cryptographic authentication when malicious modification is a concern.

Frequently asked questions

Can CRC correct errors?

Typical communication protocols use CRC to detect corruption and reject the frame, not correct it. Although specialized algorithms may exploit known error constraints, a CRC check alone normally does not uniquely identify the original frame.

How many errors can Hamming code correct?

Standard Hamming codes with minimum distance 3 guarantee correction of one bit error. Extended Hamming codes with distance 4 support SECDED: correct one bit error and detect two, without miscorrecting the two-bit case.

Why is CRC usually stronger than a checksum?

A carefully chosen CRC polynomial can give explicit guarantees for burst errors and certain multi-bit patterns. An additive checksum can miss changes that cancel each other or reorder whole words. Compare exact algorithms and protected lengths, rather than assuming that every CRC is stronger than every checksum.

Can error detection guarantee perfect data?

No finite redundancy scheme can detect all possible corruptions of arbitrary severity. A damaged codeword may be changed into another valid one. Define bounded-error guarantees and measure the probability of undetected error for the intended channel.

How many check bits are needed for 8 data bits?

For a single-error-correcting shortened binary Hamming code, four check bits suffice. Three would give 8 syndromes for 12 possibilities (11 bit positions plus no error). Four give 16 syndromes for 13 possibilities. Adding an overall parity bit produces a 13-bit SECDED word with 8 data bits.

References and further study

The worked examples use even Hamming parity and number codeword positions from the left. These sources cover the underlying codes, their guarantees, and the Internet checksum convention.

Scroll to Top