Tutorial 6.2: Error Detection and Error Correction Techniques

Table of Contents

Learning Objectives

Upon completion of this tutorial, you should be able to:

Overview

Bit errors are an unavoidable reality in data communication. Signals can be corrupted by attenuation, noise, interference, and other physical phenomena. The link layer must detect—and in some cases correct—these errors to ensure reliable data transfer. This tutorial covers the fundamental error-detection and error-correction techniques used at the link layer. We begin with simple parity checks, progress through checksums, and culminate with the powerful Cyclic Redundancy Check (CRC), which is the most widely used error-detection technique in modern networks. We also explore error correction via Hamming codes and forward error correction (FEC), and discuss performance trade-offs and implementation considerations.

Detailed Technical and Theoretical Content

1. The Error Problem and Detection Principles

1.1 Sources of Bit Errors

Bit errors occur when the signal representing a bit is distorted sufficiently that the receiver misinterprets it. Common causes:

1.2 The Error Detection Framework

The basic approach to error detection is to add redundant information to the data. The sender computes a function of the data and appends the result. The receiver recomputes the function and compares. If they match, the data is assumed error-free.

Let D be the data (k bits). The sender adds an error-detection code EDC of length n bits. The transmitted frame is (D, EDC). The receiver receives (D', EDC') and checks whether the relationship holds. If not, an error is detected.

Important: Error detection is not 100% reliable. Some error patterns may go undetected if they transform the data+EDC into another valid codeword. The goal is to make the probability of undetected errors extremely small.

1.3 Error Detection vs. Error Correction

Aspect Error Detection Error Correction
Goal Detect that an error has occurred Identify and fix the error
Action Request retransmission or drop frame Correct the error locally
Overhead Lower Higher (more redundant bits)
Use case Most links (with retransmission) Links where retransmission is costly (e.g., satellite, deep-space)
Examples Parity, checksum, CRC Hamming codes, Reed-Solomon, LDPC

2. Parity Checking

2.1 Single-Bit Parity

Single-bit parity adds one parity bit to a block of data. The parity bit is chosen so that the total number of 1s (including the parity bit) is even (even parity) or odd (odd parity).

Example (Even Parity):

Limitation: Detects only odd numbers of bit errors. If two bits are flipped, parity remains unchanged.

2.2 Two-Dimensional Parity

Data bits are arranged in a matrix (e.g., m rows × n columns). Parity bits are computed for each row (row parity) and each column (column parity). This allows detection of more error patterns, and importantly, correction of single-bit errors (by identifying the row and column where parity fails).

Example (4×4 data matrix with row/column parity):

1 0 1 0 | 0 (row parity)
0 1 1 1 | 1
1 1 0 0 | 0
0 0 1 1 | 0
---------
1 0 1 0 | 1 (col parity)

If a single bit flips, the error is located at the intersection of the row and column with incorrect parity.

Limitation: Some multi-bit errors (e.g., two errors in the same row and same column) may go undetected.

2.3 Probability of Undetected Error for Parity

For a random error pattern, the probability that a single-bit parity check fails to detect an error is approximately 1/2 for any even number of errors. Two-dimensional parity has a lower undetected error probability but still not as low as CRC.

3. Checksums

3.1 Internet Checksum

The Internet checksum is used in IP, TCP, and UDP headers. It is based on one's complement arithmetic.

Procedure:

  1. Treat data as a sequence of 16-bit words.
  2. Sum all words using one's complement addition (carry bits are added back).
  3. Take the one's complement of the sum; this is the checksum.
  4. Sender places checksum in header.
  5. Receiver computes the sum (including checksum) and checks if result is all 1s (0xFFFF).

Example (simplified, 8-bit words): data = 10011001, 01010101, 00110011. Sum = 10011001 + 01010101 = 11101110; +00110011 = 100100001 → wrap carry to get 00100010; ones complement = 11011101 (checksum). Receiver sums all words + checksum = 11111111 (all ones).

Limitations:

3.2 Comparison with CRC

Checksums are weak compared to CRC but are easier to compute in software. They are often used in protocols where error rates are low and speed is critical, while CRC is used in hardware-based link layers.

4. Cyclic Redundancy Check (CRC)

4.1 Principles of CRC

CRC is based on polynomial arithmetic over GF(2) (i.e., modulo-2). The data is treated as a polynomial whose coefficients are the bits. The sender and receiver agree on a generator polynomial, G(x), of degree r. The sender appends r zero bits to the data (multiply by x^r) and divides by G(x) using modulo-2 division. The remainder is the CRC bits (r bits). The transmitted frame is the original data followed by the remainder. The receiver divides the received polynomial by G(x). If the remainder is zero, the frame is accepted; otherwise, an error is detected.

4.2 CRC Calculation Step-by-Step

  1. Choose G(x) of degree r (e.g., G = 10011 for r=4).
  2. Append r zeros to the data D to get D × 2^r.
  3. Perform modulo-2 division of D × 2^r by G. The remainder is the CRC bits (r bits).
  4. Transmit D followed by the remainder.
  5. Receiver divides received polynomial by G; remainder 0 ⇒ no error detected.

Example: D = 1101011011, G = 10011 (degree 4). Append 4 zeros: 11010110110000. Divide modulo-2:

         1100001010
        ------------
10011 ) 11010110110000
         10011
         -----
          10011
          10011
          -----
             10110
             10011
             -----
              10100
              10011
              -----
               1110   (remainder)

Remainder = 1110. Transmitted frame = 1101011011 1110.

4.3 Common Generator Polynomials

Protocol Polynomial CRC bits
Ethernet (CRC-32) 0x04C11DB7 (standard) 32
Wi-Fi (CRC-32) same as Ethernet 32
HDLC (CRC-16) 0x1021 16
USB (CRC-5) 0x05 5
Bluetooth (CRC-16) 0x1021 16

4.4 Error Detection Capabilities of CRC

4.5 Mathematical Analysis of CRC

Let the transmitted polynomial be T(x) = D(x) · x^r ⊕ R(x), where R(x) is the remainder. Since R(x) is the remainder of D(x)·x^r divided by G(x), we have T(x) ≡ 0 (mod G(x)). If an error polynomial E(x) is added (XOR) to the transmission, the received polynomial is T(x) ⊕ E(x). The receiver divides by G(x); the remainder is E(x) mod G(x). An error is undetected iff E(x) is divisible by G(x). The probability that a random error polynomial is divisible by G(x) is 1/2^r (since there are 2^r possible remainders). This holds for burst errors longer than r, but shorter bursts are guaranteed detected.

4.6 Choosing a Generator Polynomial

Key criteria:

5. Error Correction: Hamming Codes

5.1 Hamming Distance

The Hamming distance between two codewords is the number of bit positions in which they differ. To detect d errors, the minimum Hamming distance must be at least d+1. To correct d errors, it must be at least 2d+1.

5.2 Hamming Code Construction

Hamming codes add parity bits at positions that are powers of 2 (1, 2, 4, 8, ...). For a code with m parity bits and n total bits, the number of data bits is n - m, with n = 2^m - 1. The most common is Hamming(7,4) with 7 total bits (4 data, 3 parity).

Encoding for Hamming(7,4):

Decoding: The receiver checks each parity bit. If a parity check fails, the parity bit's position indicates the error location (e.g., if p1 and p2 fail, error at position 1+2=3). The error is then corrected by flipping the bit.

5.3 Extended Hamming Codes

An extra parity bit can be added to detect double-bit errors, turning Hamming codes into SECDED (Single Error Correction, Double Error Detection).

5.4 Limitations of Hamming Codes

6. Forward Error Correction (FEC)

FEC uses error-correcting codes to allow the receiver to correct errors without retransmission. Common FEC techniques include:

FEC adds significant overhead but is essential for links with high latency or where retransmission is impossible.

7. Performance Analysis and Trade-offs

7.1 Overhead Comparison

Technique Overhead (bits) Typical use
Single-bit parity 1 bit per block Simple links
Two-dimensional parity (m+n) bits per block Memory systems
Checksum (16-bit) 16 bits per segment Transport layer
CRC-32 32 bits per frame Ethernet, Wi-Fi
Hamming(7,4) 3 bits per 4 data bits (75% overhead) Single-bit error correction

7.2 Probability of Undetected Error

For CRC-32, P(undetected) ≈ 2^(-32) ≈ 2.33e-10 for random errors. For Internet checksum, it is higher (approximately 2^(-16) but worse due to structure). For parity, it is about 1/2 for even errors.

7.3 Latency Considerations

Error correction can increase latency because the receiver must process the code before delivering data. Error detection with retransmission may also increase latency if retransmissions are needed.

8. Advanced Topics: CRC Implementation and Hardware

8.1 CRC Hardware Implementation

CRC is typically implemented in hardware using a Linear Feedback Shift Register (LFSR). The LFSR performs the modulo-2 division in a shift register with XOR gates. This is very efficient and can run at line speed.

8.2 CRC in Network Processors

Many network interface cards (NICs) and switches compute CRC in hardware, offloading the CPU.

8.3 CRC and Ethernet

Ethernet uses CRC-32 with polynomial 0x04C11DB7. The frame trailer contains the FCS (Frame Check Sequence) which is the CRC. The receiver checks the FCS; if invalid, the frame is discarded.

9. Error Detection in Practice: Ethernet, Wi-Fi, and Beyond

10. Case Study: Error Control in Deep-Space Communication

Deep-space missions (e.g., Voyager, Mars rovers) face extremely long propagation delays (hours), making retransmission impractical. They rely heavily on FEC (e.g., convolutional codes, Reed-Solomon, and Turbo codes) to correct errors without retransmission. The link layer must include powerful error correction to ensure data integrity.


Quiz

Question 1: What is the fundamental limitation of single-bit parity checking?

Answer

(b) It can only detect an odd number of bit errors. Single-bit parity cannot detect errors where an even number of bits are flipped.

Question 2: What advantage does two-dimensional parity have over single-bit parity?

Answer

(c) It can correct single-bit errors. Two-dimensional parity allows the receiver to identify the exact row and column where a single-bit error occurred, enabling correction.

Question 3: What is the generator polynomial used in CRC?

Answer

(b) A polynomial agreed upon by sender and receiver used for division. The generator polynomial G is agreed upon; the sender appends CRC bits so that the resulting polynomial is divisible by G.

Question 4: A CRC with a generator polynomial of degree r can detect all burst errors of what maximum length?

Answer

(a) r bits. A CRC with generator polynomial of degree r can detect all burst errors of length ≤ r bits.

Question 5: Which error-detection technique is most commonly used at the link layer in Ethernet?

Answer

(d) CRC-32. Ethernet uses a 32-bit Cyclic Redundancy Check (CRC-32) for error detection.

Question 6: What does the receiver do when it detects an error in a frame?

Answer

(c) Signals for retransmission or drops the frame. Depending on the protocol, the receiver may request retransmission or simply discard the corrupted frame.

Question 7: What is the relationship between Hamming distance and error correction capability?

Answer

(c) To correct d errors, Hamming distance must be ≥ 2d + 1. This ensures that the erroneous codeword is closer to the original than to any other codeword.

Question 8: Why is error detection not 100% reliable?

Answer

(b) Some error patterns can produce the same EDC as the correct data. Certain error patterns may transform the data plus EDC into another valid codeword, leading to undetected errors.

Question 9: What is the Internet checksum used for?

Answer

(b) Transport-layer error detection in TCP and UDP. The Internet checksum is used at the transport layer (and network layer) for error detection, not typically at the link layer.

Question 10: What is the probability that a CRC with r bits misses a burst error longer than r bits (assuming random errors)?

Answer

(b) 2^(-r). A CRC with r bits will miss a longer burst error with probability approximately 2^(-r) because there are 2^r possible remainders.

Question 11: In the Hamming(7,4) code, how many parity bits are used for 4 data bits?

Answer

(b) 3. Hamming(7,4) has 3 parity bits and 4 data bits, totaling 7 bits.

Question 12: What is the Hamming distance required to detect 3 errors?

Answer

(b) 4. To detect d errors, minimum distance must be at least d+1, so for d=3, distance ≥ 4.

Question 13: Which of the following is a property of CRC-32 used in Ethernet?

Answer

(b) It detects all single-bit and two-bit errors. CRC-32 with a properly chosen polynomial can detect all single-bit and two-bit errors, and all burst errors up to 32 bits.

Question 14: What is the main difference between Go-Back-N and Selective Repeat ARQ in the context of error recovery?

Answer

(b) Selective Repeat retransmits only lost frames, Go-Back-N retransmits all frames from the lost one onward. This is the key efficiency difference.

Question 15: In CRC, why is the generator polynomial often chosen to have factor (x+1)?

Answer

(b) To detect all odd numbers of errors. A polynomial with factor (x+1) has the property that any error polynomial with an odd number of terms is not divisible by G, thus odd errors are detected.

Question 16: What is the checksum field in the TCP header used for?

Answer

(a) To detect errors in the TCP segment. The TCP checksum covers the header and data to detect corruption.

Question 17: What is the role of the Frame Check Sequence (FCS) in an Ethernet frame?

Answer

(b) It is the CRC for error detection. The FCS (Frame Check Sequence) is a 32-bit CRC that allows the receiver to detect errors.

Question 18: In a two-dimensional parity scheme with m rows and n columns, how many parity bits are added?

Answer

(a) m + n. One parity bit per row and one per column, so m + n parity bits are added.

Question 19: What is the primary reason for using FEC (Forward Error Correction) in satellite communications?

Answer

(b) To avoid retransmission due to long propagation delay. Satellite links have high latency, so retransmission is costly; FEC allows errors to be corrected immediately.

Question 20: Which of the following error detection methods is most suitable for hardware implementation at high speeds?

Answer

(c) CRC using LFSR. CRC can be implemented efficiently in hardware using a Linear Feedback Shift Register, making it suitable for high-speed links.

Question 21: What is the effect of using a generator polynomial that is not primitive on CRC performance?

Answer

(b) It may increase the probability of undetected errors. A non-primitive polynomial may have weaker detection properties for certain error patterns.

Question 22: How many bits of overhead does a 32-bit CRC add to a frame with a 1500-byte payload?

Answer

(d) Both (b) and (c) are correct. CRC-32 adds 32 bits (4 bytes) of overhead, which is about 0.2% of 1500 bytes.

Question 23: In the Hamming code, if the parity checks indicate errors at positions 1, 2, and 4, what is the error bit position?

Answer

(c) 7. The error position is the sum of the parity bit positions that indicate an error: 1+2+4 = 7.

Question 24: What is the primary disadvantage of using error correction instead of error detection with retransmission?

Answer

(c) Higher overhead and complexity. Error correction codes require more redundant bits and more complex encoding/decoding, but they eliminate the need for retransmission.

Question 25: Which of the following can be detected by a single-bit parity check?

Answer

(c) All odd-numbered errors. Single-bit parity detects any odd number of bit errors; it misses even-numbered errors.

Exercises

Exercise 1: Parity Calculation

Calculate the even parity bit for the following data blocks:

  1. 1011010
  2. 1100111
  3. 0001111
  4. 11110000
Solution
  1. 1011010 has four 1s (even) → parity bit = 0.
  2. 1100111 has five 1s (odd) → parity bit = 1 (to make even).
  3. 0001111 has four 1s (even) → parity bit = 0.
  4. 11110000 has four 1s (even) → parity bit = 0.

Exercise 2: CRC Calculation

Given D = 101001, G = 1101 (degree 3), calculate the CRC bits and the transmitted frame. Show all steps.

Solution

Step 1: Append 3 zeros: 101001000

Step 2: Modulo-2 division:

         110101
        --------
1101 ) 101001000
        1101
        ----
         1110
         1101
         ----
           110
           000
           ---
            1100
            1101
            ----
               100
        

Remainder = 100 (3 bits).

Transmitted frame = 101001 100.

Verification: 101001100 divided by 1101 yields remainder 0.

Exercise 3: Two-Dimensional Parity

Given the following 4×4 data matrix, add row and column parity bits (even parity):

1 0 1 0
0 1 1 1
1 1 0 0
0 0 1 1
    
Solution

Row parities:

Column parities:

Complete matrix:

1 0 1 0 | 0
0 1 1 1 | 1
1 1 0 0 | 0
0 0 1 1 | 0
---------
0 0 1 0 | 1 (overall parity)
        

Exercise 4: Checksum Calculation

Calculate the Internet checksum (using 8-bit one's complement addition) for the following data words: 10011001, 01010101, 00110011.

Solution

Step 1: Sum (one's complement addition):

10011001 + 01010101 = 11101110

11101110 + 00110011 = 100100001 → wrap carry: 00100001 + 00000001 = 00100010

Step 2: One's complement: ~00100010 = 11011101

Checksum = 11011101.

Verification: receiver sums all words + checksum: 10011001+01010101+00110011+11011101 = 11111111 (all ones) → error-free.

Exercise 5: Error Detection Analysis

A system uses CRC with generator G = 1011. The received frame is 101001101. Was an error detected? Show your work.

Solution

Divide 101001101 by 1011:

         100101
        --------
1011 ) 101001101
        1011
        ----
         0001
         0000
         ----
           0010
           0000
           ----
             0101
             0000
             ----
               1011
               1011
               ----
                  0
        

Remainder = 0 → no error detected (frame accepted as error-free).

Exercise 6: Hamming Code Encoding

Encode the data 1011 using Hamming(7,4) code. Show the codeword.

Solution

Data bits: d1=1, d2=0, d3=1, d4=1 (positions 3,5,6,7).

Codeword = p1 p2 d1 p3 d2 d3 d4 = 0 1 1 0 0 1 1 → 0110011.

Exercise 7: Hamming Code Decoding and Correction

You receive the Hamming(7,4) codeword 0110010 (instead of 0110011). Identify and correct the error.

Solution

Received: 0 1 1 0 0 1 0 (positions 1..7).

Error position = 1+2+4 = 7. Flip bit 7: 0 becomes 1 → corrected codeword = 0110011.

Exercise 8: CRC Generator Selection

Explain why a generator polynomial like G(x)=x+1 is not sufficient for most link-layer CRC needs, despite detecting odd errors.

Solution

G(x)=x+1 (i.e., 11 in binary) has degree 1, so it can only generate a 1-bit CRC. It detects all odd numbers of errors but cannot detect any even number of errors. Moreover, it cannot detect burst errors of length >1. For modern links, we need robust detection of multi-bit and burst errors, hence higher-degree polynomials like CRC-16 or CRC-32 are used.

Exercise 9: Efficiency of Stop-and-Wait with CRC

Consider a link with data rate 1 Mbps, RTT 50 ms, and frame size 1000 bytes. The CRC overhead is 4 bytes. What is the maximum effective throughput if using stop-and-wait flow control (ignore processing)? Assume no errors.

Solution

Frame size = 1000 + 4 = 1004 bytes = 8032 bits.

Transmission time = 8032 / 1e6 = 0.008032 s = 8.032 ms.

RTT = 50 ms. Utilization U = T_frame / (T_frame + RTT) = 8.032 / (8.032 + 50) ≈ 0.1384.

Effective throughput = U × data rate = 0.1384 × 1 Mbps = 138.4 kbps.

Note: This is the throughput of the link layer; the actual useful data throughput would be lower due to retransmissions if errors occur.

Exercise 10: CRC Hardware Implementation

Describe the basic structure of an LFSR used for CRC-3 with generator polynomial G=1011. How many shift registers and XOR gates are needed?

Solution

For G=1011 (degree 3), the LFSR has 3 shift registers (flip-flops) for the remainder. The polynomial is x^3 + x + 1 (since 1011 corresponds to coefficients for x^3, x^2, x^1, x^0: 1,0,1,1). The feedback taps are at positions 0 (x^0) and 1 (x^1) (and also the x^3 term which is the feedback from the last register). The LFSR uses XOR gates at the feedback path. Specifically, the input to the first register is the XOR of the incoming data bit and the feedback from the last register, and the feedback also XORed with the taps. The number of XOR gates is equal to the number of nonzero terms in the polynomial minus 1 (for degree>0). Here we have three nonzero terms (x^3, x, 1) so two XOR gates are needed.

Exercise 11: Probability of Undetected Error

Calculate the probability that a CRC-16 (with r=16) misses a random burst error longer than 16 bits. Express as a percentage.

Solution

Probability ≈ 2^(-16) = 1 / 65536 ≈ 0.00001526, which is about 0.001526%.

Exercise 12: Performance Trade-off

A link has a bit error rate (BER) of 10^-5. Each frame is 1000 bytes. Without error detection, what is the probability that a frame arrives without errors? With CRC-32 that detects errors, what is the probability that a frame has an undetected error (assume CRC catches all errors except with probability 2^-32)?

Solution

Frame size in bits = 1000*8 = 8000 bits.

Probability of no error = (1 - BER)^8000 ≈ (0.99999)^8000 ≈ exp(-0.08) ≈ 0.9231.

Probability that a frame is corrupted = 1 - 0.9231 = 0.0769.

With CRC-32, the probability of undetected error = P(corrupted) × 2^-32 ≈ 0.0769 × 2.33e-10 ≈ 1.79e-11. Very small.

Exercise 13: Checksum Weakness

Give an example of two 16-bit words that have the same Internet checksum when one is the bitwise complement of the other.

Solution

If we have two words A and B such that B = ~A (bitwise NOT). For example, A = 0xFFFF, B = 0x0000. The sum A + B = 0xFFFF, which has ones complement 0x0000. The checksum for both would be 0x0000? Actually, the checksum is the ones complement of the sum. For a single word, the checksum is ~A. If we send A and checksum ~A, the receiver sums A + ~A = 0xFFFF, which is correct. However, if two words are complements, they cancel, and the checksum may be the same as for other combinations. For example, with words A and B, the sum A+B could be the same as C+D, so errors could be undetected.

Exercise 14: CRC Error Detection Capability

If a generator polynomial has the factor (x+1), what types of errors are guaranteed to be detected?

Solution

Any error pattern with an odd number of errors is guaranteed to be detected because (x+1) divides E(x) only if E(1)=0, which means the number of terms in E(x) is even. Thus, odd number of errors yields E(1)=1, so not divisible by (x+1), hence detected.

Exercise 15: Hamming Distance

What is the Hamming distance of the Hamming(7,4) code? How many errors can it detect and correct?

Solution

The minimum Hamming distance of Hamming(7,4) is 3. Therefore, it can detect up to 2 errors (d-1 = 2) and correct 1 error (floor((d-1)/2) = 1).

Homework

Homework 1: Compare and contrast CRC with checksums. In what scenarios would each be preferred? Discuss the strengths and weaknesses of each, including detection power, overhead, implementation complexity, and typical use cases.

Answer

Similarities: Both are error-detection techniques that add redundant information.

Differences:

Aspect CRC Checksum
Mathematics Polynomial division over GF(2) Integer addition (ones complement)
Detection power Excellent (detects all single, double, odd, and burst errors ≤ r) Moderate (can miss errors that preserve sum)
Overhead Typically 16, 32, or 64 bits 16 bits (Internet checksum)
Implementation Efficient in hardware (LFSR), slower in software Simple in software, less efficient in hardware
Use case Link layer (Ethernet, Wi-Fi, HDLC) Transport/network layer (TCP, UDP, IP)

Preferred scenarios: CRC is preferred when high reliability is required and hardware is available. Checksum is preferred in software-based protocols where simplicity and speed are more important than ultimate detection power.

Homework 2: Calculate the CRC for D = 1101011011 and G = 10011. Show all steps of the modulo-2 division. Then, if the receiver receives 1101011011 1110 (i.e., the correct CRC), verify that the remainder is zero. What if the received frame is 1101011011 1111 (one bit error in CRC)? Show the remainder.

Answer

Division steps:

         1100001010
        ------------
10011 ) 11010110110000
         10011
         -----
          10011
          10011
          -----
             10110
             10011
             -----
              10100
              10011
              -----
               1110
        

Remainder = 1110. Transmitted = 1101011011 1110.

Verification: Divide 11010110111110 by 10011 → remainder 0.

If received is 1101011011 1111 (last bit flipped), divide 11010110111111 by 10011. We can compute remainder: (previous remainder 1110) XOR (error pattern 0001) modulo G? Actually, the error pattern E=0001 at the end. The remainder would be E mod G = 0001 mod 10011 = 0001 (since degree <4). So remainder=0001, indicating error detected.

Homework 3: Explain why the probability of undetected error in CRC is approximately 2^(-r). What assumptions does this make? In practice, is the probability higher or lower for a well-chosen generator polynomial?

Answer

The probability is 2^(-r) because there are 2^r possible remainders when dividing by G (degree r). For a random error pattern, all remainders are equally likely. The error is undetected iff the remainder is 0, which occurs with probability 1/2^r.

Assumptions: The error pattern is random and uniformly distributed over all possible error patterns. Also assumes the data length is large enough.

In practice: For a well-chosen generator polynomial (e.g., primitive polynomials), the actual probability may be even lower than 2^(-r) for many common error patterns. However, the theoretical upper bound is 2^(-r), and it is a good approximation for random errors.

Homework 4: Design a simple error-correcting code using Hamming's method for 4 data bits. Show how it can detect and correct a single-bit error. Provide the encoding and decoding process with an example.

Answer

Hamming(7,4) code:

Encoding example: data = 1011 → d1=1,d2=0,d3=1,d4=1 → p1=1⊕0⊕1=0, p2=1⊕1⊕1=1, p3=0⊕1⊕1=0 → codeword = 0110011.

Decoding: Compute syndromes: s1 = p1 ⊕ d1 ⊕ d2 ⊕ d4, s2 = p2 ⊕ d1 ⊕ d3 ⊕ d4, s3 = p3 ⊕ d2 ⊕ d3 ⊕ d4. If all zero, no error. Otherwise, error position = s1 + 2*s2 + 4*s3 (1-indexed). Correct the bit.

Example with error: Received 0110010 (bit 7 flipped). Compute: s1 = 0⊕1⊕0⊕1=0? Wait, recalc: p1=0, d1=1,d2=0,d4=1 → s1=0⊕1⊕0⊕1=0; s2=1⊕1⊕1⊕1=0? Actually 1⊕1=0, 0⊕1=1, 1⊕1=0 → s2=0; s3=0⊕0⊕1⊕1=0? 0⊕0=0, 0⊕1=1, 1⊕1=0 → s3=0. That would indicate no error, but there is an error? Let's recalc carefully. Received: positions: 1:p1=0, 2:p2=1, 3:d1=1, 4:p3=0, 5:d2=0, 6:d3=1, 7:d4=0 (since error). s1 = p1 ⊕ d1 ⊕ d2 ⊕ d4 = 0⊕1⊕0⊕0 = 1. s2 = p2 ⊕ d1 ⊕ d3 ⊕ d4 = 1⊕1⊕1⊕0 = 1 (since 1⊕1=0, 0⊕1=1, 1⊕0=1). s3 = p3 ⊕ d2 ⊕ d3 ⊕ d4 = 0⊕0⊕1⊕0 = 1. So error position = 1+2+4 = 7, correct bit 7 to 1 → original.

Homework 5: Research the CRC-32 polynomial used in Ethernet. What is its hexadecimal representation, and why was this specific polynomial chosen? Discuss its properties regarding error detection.

Answer

CRC-32 polynomial (standard Ethernet, FDDI, PNG, ZIP, etc.):

G(x) = x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1

Hexadecimal representation: 0x04C11DB7 (with reversed bit order for some implementations).

Why chosen:

Properties: detects all single-bit, two-bit, odd-numbered errors, and burst errors up to 32 bits. Probability of undetected error for longer bursts is about 2^-32.

Homework 6: Compare the error detection capabilities of single-bit parity, two-dimensional parity, checksum (16-bit), and CRC-32. For each, state the types of errors it can detect and the approximate undetected error probability.

Answer
Technique Detectable errors Undetected probability (approx)
Single-bit parity All odd-numbered errors ~1/2 for even errors
Two-dimensional parity All single-bit, most multi-bit, can correct single-bit ~1/4 for some patterns
Checksum (16-bit) Many errors, but can miss some (e.g., swapping) ~2^-16 ≈ 1.5e-5
CRC-32 All single, double, odd, burst ≤32, most others ~2^-32 ≈ 2.3e-10

Homework 7: In a network using CRC-16, what is the probability that a frame with a 1500-byte payload and a 2-byte CRC has an undetected error if the bit error rate is 10^-6? Assume that any error pattern is equally likely and that CRC catches all errors except with probability 2^-16.

Answer

Frame size = 1500 + 2 = 1502 bytes = 12016 bits.

Probability that a frame has at least one bit error = 1 - (1 - 10^-6)^12016 ≈ 1 - exp(-0.012016) ≈ 0.01194.

Probability of undetected error = P(frame has error) × 2^-16 ≈ 0.01194 × 1.5259e-5 ≈ 1.82e-7.

So about 1 in 5.5 million frames would have an undetected error.

Homework 8: Explain the concept of "Hamming distance" and its importance in error detection and correction. Give an example of a code with distance 2 and what it can detect.

Answer

The Hamming distance between two codewords is the number of positions in which they differ. The minimum Hamming distance of a code is the smallest distance between any two distinct codewords.

If the minimum distance is d, then:

Example: A code with distance 2 can detect single-bit errors (t=1, d≥2) but cannot correct them. A simple parity check code has distance 2.

Homework 9: Describe the operation of a Linear Feedback Shift Register (LFSR) used for CRC computation. Draw a diagram for a CRC-3 with generator polynomial x^3 + x + 1.

Answer

An LFSR consists of a shift register with feedback taps that are XORed with the input. For CRC, the shift register holds the current remainder. The data bits are shifted in one by one. At each step, the leftmost bit (MSB) is XORed with the incoming data bit, and the result determines the feedback. The shift register is updated.

For G(x) = x^3 + x + 1 (binary 1011), the LFSR has 3 registers (r2, r1, r0). The feedback is the XOR of the input bit, the current r0 (x^0 tap), and the current r1 (x^1 tap). The new r2 = feedback, new r1 = old r2, new r0 = old r1. The XOR gates are at the taps.

Diagram: [r2] ← [r1] ← [r0] ← (input ⊕ r0 ⊕ r1) and shift.

Homework 10: In the context of forward error correction, discuss the trade-offs between code rate and error correction capability. Provide an example where a lower code rate is preferable.

Answer

Code rate = k/n, where k is data bits and n is total bits (data + parity). A lower code rate means more redundancy, which provides stronger error correction but reduces throughput. For example, a rate 1/2 convolutional code can correct more errors than a rate 3/4 code.

Lower code rate is preferable in environments with very high error rates or when retransmission is expensive, such as deep-space communication, satellite links, or underwater acoustic channels. In such cases, the extra redundancy is justified to avoid retransmission.

Homework 11: A network designer is choosing between CRC-16 and CRC-32 for a low-speed link with rare errors. Which would you recommend and why? What about a high-speed link?

Answer

For a low-speed link with rare errors, CRC-16 might be sufficient because the probability of undetected error is already very low, and the overhead (2 bytes) is smaller than CRC-32 (4 bytes). This saves bandwidth. For a high-speed link, especially if the frame error rate is higher, CRC-32 provides better protection with minimal relative overhead (e.g., 4 bytes vs 1500 bytes is 0.27%). In modern networks, CRC-32 is preferred for robustness, and the overhead is negligible.

Homework 12: Explain the concept of "burst error" and why CRC is particularly effective against them. How does the degree of the generator polynomial relate to burst detection?

Answer

A burst error is a contiguous sequence of bits in which the first and last bits are in error, and the intervening bits may or may not be in error. CRC is effective because it detects all burst errors of length ≤ r (where r is the degree of the generator polynomial). This is because any burst of length ≤ r can be represented as E(x) = x^i · B(x) where B(x) has degree < r. If G has degree r, it cannot divide such an E(x) unless B(x)=0, which would mean no error. So CRC guarantees detection of these bursts.

Summary

This tutorial provided a comprehensive treatment of error detection and correction techniques at the link layer:

These concepts are critical for ensuring data integrity in networks. In the next tutorial, we will explore Multiple Access Protocols, which govern how nodes share a communication medium.

👤