Coding Theory and Cryptography
Chapter Six
Error Detection & Correction - Part2
Instructor: Newroz N. AbdulrazaqScience College- Department of Computer Science & I.T.
8 May 2020 Sallahaddin University- Erbil Slide #1
Text Book: Introduction to Cryptography with Coding Theory by wade Trappe + Educational Websites.
8 May 2020 Sallahaddin University- Erbil Slide #2
Chapter 6:
Error Correction Technique
Overview:
- Error Detection Techniques… Cont.
- Structure of encoder and decoder in error correction. - Error Correction Techniques.
8 May 2020 Sallahaddin University- Erbil Slide #3
Error Detection Techniques… Cont.
3
Cyclic Redundancy Check
1) The sender performs binary division of the data segment by the divisor. It then appends the remainder called CRC bits to the end of the data segment.
8 May 2020 Sallahaddin University- Erbil Slide #4
Example:
Generate CRC for the message (hi) using the
Divisor 11011 and index the letters a-z from 0-25
respectively.
Solution:
Convert the message (hi) to binary form:
8 May 2020 Sallahaddin University- Erbil Slide #5
Append (number of divisor bits-1) Zero’s to the binary message:
Solution:
1111000
0000
11011
11011
1001010
00
111011
011110
1001010
011011
0
111011
011110
111011
00101
Since divisor=11011, so we have 5 bits – 1=4 bits should be add to the message: 11110000000
CRC
Hence, 11110000101
8 May 2020 Sallahaddin University- Erbil Slide #7
Error Correction Techniques
Backward Error Correction (Retransmission)
✓ If the receiver detects an error in the incoming frame, it requests the sender to retransmit the frame.
✓ It is a relatively simple technique. But it can be efficiently used only where retransmitting is not expensive as in fiber optics. ✓ There are two ways in which the return channel can be used to
8 May 2020 Sallahaddin University- Erbil Slide #8
Error Correction Techniques
Forward Error Correction
✓ If the receiver detects some error in the incoming frame, it executes error-correcting code that generates the actual frame. ✓ This saves bandwidth required for retransmission.
8 May 2020 Sallahaddin University- Erbil Slide #9
Hamming Distance
In information theory, the Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different.
Example: Find Hamming distance between 1101101 and 1011100?
1
1
0
1
1
0
1
1
0
1
1
1
0
0
8 May 2020 Sallahaddin University- Erbil Slide #10
Minimum Hamming Distance
➢ The minimum Hamming distance is the smallest Hamming distance between all possible pairs.
8 May 2020 Sallahaddin University- Erbil Slide #11
Minimum Hamming Distance
➢ To design a code that can detect d single bit errors, the minimum Hamming distance for the set of codewords must be
d + 1
8 May 2020 Sallahaddin University- Erbil Slide #12
Hamming Code
➢ The most common types of error-correcting codes used in RAM are based on the codes devised by R. W. Hamming.
➢ In the Hamming code, k parity bits are added to an n-bit data word, forming a new word of n + k bits. The bit positions are numbered in sequence from 1 to n + k.
➢ Those positions numbered with powers of two are reserved for the parity bits. The remaining bits are the data bits.
8 May 2020 Sallahaddin University- Erbil Slide #13
Hamming Code
Example : Generate hamming code for data 1110 using even parity?
Solution: Since the data word =1110, so n=4 number of bits.
If we use k=3, 23 = 8 ≥ 3 + 5 = 8.
Calculate the number of Parity bits that is needed for generate a 4 bit data word using the condition: 2𝑘 ≥ 𝑘 + 𝑛 + 1.
2𝑘 ≥ 𝑘 + 5. ∴ 𝑘 = 3 𝑖𝑠 𝑎 𝑣𝑎𝑙𝑖𝑑 𝑝𝑎𝑟𝑖𝑡𝑦 𝑛𝑢𝑚𝑏𝑒𝑟
8 May 2020 Sallahaddin University- Erbil Slide #14
1
2
3
4
5
6
7
Rearrange Bit positions:
2
02
12
2P
1P
2D
1P
3D
2D
3D
4P
1P
21
P
31
1
0
P1 = XOR of bits (P1, 3, 5, 7) = P1⊕1⊕1⊕0
The position of the parity bit determines the sequence of bits that it alternately checks and skips.
P1=0
P2 = XOR of bits (P2, 3, 6, 7) = P2⊕1⊕1⊕0 P2=0
P3 = XOR of bits (P3, 5, 6) = P3⊕1⊕1 P3=0
8 May 2020 Sallahaddin University- Erbil Slide #15
Example : Check if the message 0010100 is transmitted correctly or not? If not, correct it? Using hamming code with even parity.
Solution:
1
2
3
4
5
6
7
0
0
1
0
1
0
0
C1 =XOR of bits (1, 3, 5, 7) =0 ⊕ 1 ⊕ 1 ⊕ 0 = 0 C2 =XOR of bits (2, 3, 6, 7) =0 ⊕ 1 ⊕ 0 ⊕ 0 = 1 C3 =XOR of bits (4, 5, 6) =0 ⊕ 1 ⊕ 0 = 1 Rearrange C3C2C1 =110 ≡10 6 𝐸𝑟𝑟𝑜𝑟 𝑖𝑛 𝑝𝑜𝑠𝑖𝑡𝑖𝑜𝑛 68 May 2020 Sallahaddin University- Erbil Slide #16
Example : what is the data word for the code word 010111010101 for H(12,4)?
Solution:
Hence, the message 01100101 is the original message
1
2
3
4
5
6
7
8
9 10 11 12
0
1
0
1
1
1
0
1
0 1 0 1
8 May 2020 Sallahaddin University- Erbil Slide #17
Home Works:
Q2) Create a codeword for (Kurd) using Hamming odd parity for
each character?
Q3) what is the dataword for the following codeword 101001110111? Q4) Check if there is an error for the following code word and then
correct it using even parity: a. 011110010100
b. 001110010110
8 May 2020 Sallahaddin University- Erbil Slide #18