IT-2205 Lec 04 Error Detection & Correction-2
IT-2205 Lec 04 Error Detection & Correction-2
for
2nd Year 2nd Semester of B.Sc (Honors) in IT
Lecture: 04
Error Correction
Prepared by:
K M Akkas Ali
[email protected], [email protected]
Associate Professor
Institute of Information Technology (IIT)
Jahangirnagar University, Dhaka-1342
Lecture-04: Error Correction
Slide-2
Error Correction
Error correction enables reconstruction of the
original data.
In error correction, we need to know the exact number
of bits that are corrupted and more importantly, their
location in the message. The number of errors and the
size of message are important factors.
If we need to correct one single error in an 8-bit data unit, we
need to consider eight possible error locations; if we need to
correct two errors in a data unit of the same size, we need to
consider 28 possibilities.
Slide-3
Types of Error Correction
2. Retransmission:
It is a process of error correction in which the
receiver detects the occurrence of an error and asks
the sender to resend the message.
Resending is repeated until a message arrives that
the receiver believes is error-free.
Slide-4
Block Coding
In block coding,
The message to be sent is divided into blocks, each
of k bits, called datawords.
Then r redundant bits are added to each block to
make the length n = k + r. The resulting n-bit blocks
are called codewords.
Example: 4B/5B block coding
k = 4 and n = 5.
2k = 16 datawords and 2n = 32 codewords.
It is noted that 16 out of 32 codewords are used for message
transfer. The rest of the codewords (32-16=16) are either used
for other purposes or unused.
Slide-5
Process of Error Correction in Block Coding
Redundancy bits = r
Slide-9
Hamming Code
The most common types of error-correcting
codes used today are Hamming codes which is
devised by R. W. Hamming.
In the Hamming code, r parity bits are added to a k-bit
dataword, forming a new codeword of length n bits where n
= k + r.
The bit positions are numbered in sequence from 1 to n.
Those positions numbered with powers of two are reserved
for the parity bits. The remaining bits are the data bits. The
code can be used with words of any length.
These codes were originally designed with minimum
Hamming distance of 3, i.e., dmin = 3, which means that
they can detect up to two errors or correct one single error.
The Hamming code can be used for data words of any
length.
In general, for r check bits and k data bits, the total number
of bits, n = k + r, that can be in a coded word is at most
2r-1. In other words, the following relationship must hold:
Slide-10 n <= 2r – 1 [ i.e., k + r <= 2r – 1 ]
Hamming Code: Illustration
Illustrate the operation of Hamming code with a
data word of eight bits (i.e., k = 8 bits):
Let us assume that the dataword is 11000100.
The value of r (number of parity bits or check bits used) is
determined according to the following relationship:
n <= 2r – 1 [ k + r <= 2r – 1 ]
Here, dataword k is 8 bits, so r must be 4 bits or more.
We include four parity bits with this dataword and arrange
C = C8C4C2C1 = 0000
indicates that no error has occurred.
Slide-14
Hamming Code: Illustration
However, if the 4-bit binary number formed by the check
bits gives the position of the erroneous bit if only a single
bit is in error. For example, consider the following three
cases:
Slide-15
Hamming Code: Illustration
Evaluating the XOR of the corresponding bits, we
determine the four check bits to be as follows:
Position
n 7 6 5 4 3 2 1
What’s Data Data Data Parity Data Parity Parity
There Bit 4 Bit 3 Bit 2 Bit 3 Bit 1 Bit 2 Bit 1
(P3) (P2) (P1)
Using Hamming Code Check
Example-1:
Position
n 7 6 5 4 3 2 1
Word 0 1 0 All three
1 have 1 0 1
P1 is in position 1 so… Start at 1, check 1, skip 1, check 1 skip 1 etc..(
P2 is in position“Even
2 so… Parity”
Start at 2so this2,isskip
check a Correct
2 check 2 skip 2 rtc..(2
P1 0
P3 is in position 0 at 4, check
4 so…Start pattern 1 4(then we run1out of bits)
4 skip
P2 0 1 1 0
P3 0 1 0 1
Using Hamming Code Check
Example-2:
Again consider, the codeword: 0001101
Need to check that there is even parity for each of the
three parity bit pattern
Position
n 7 6 5 4 3 2 1
Word 0
P2 and P3 don’t have
0 0 1 1 0 1
“Even Parity” so this is NOT a
P1 is in position 1 so… Start at 1, check 1, skip 1, check 1 skip 1 etc..(
P1P2 is in correct
0 position 2 so…0Start at 2pattern 1 skip 2 check 2 1
check 2, skip 2 rtc..(2
P3 is in position 4 so…Start at 4, check 4 skip 4(then we run out of bits)
P2 0 0 1 0
x
P3 0 0 0 1
x
Hamming Distance
The Hamming distance between two words is the
number of differences between corresponding bits.
Example: Find the Hamming distance between two pairs of
words.
1. The Hamming distance d(10101, 11110) is 3 because
Alternate Method:
The numbers of 1s in the
nonzero codewords are 2,
2, and 2.
So dmin = 2. Table: A code for error correction
Slide-21
Minimum Hamming Distance
Example-2: Find the minimum Hamming distance of the
coding scheme shown in the table below:
Alternate Method:
The numbers of 1s in the
nonzero codewords are 3,
3, and 4.
So dmin = 3. Table: A code for error correction
Slide-22
Minimum Hamming Distance
Three parameters are required to define a
coding schemes.
1. Codeword size n
2. Dataword size k
3. The minimum Hamming distance dmin
Slide-23
Minimum Hamming Distance
Relationship between Hamming distance and error:
Hamming distance between the received codeword and
the sent codeword is the number of bits that are
corrupted.
Relationship between minimum distance and error:
To guarantee the detection of up to s errors in all cases,
Example-1:
Here dmin = 2
This code guarantees the detection of only a single error. For
Here dmin = 3
Example-3:
A code scheme has a Hamming distance dmin = 4. What is
the error detection and correction capability of this
scheme?
Solution:
This code guarantees the detection of up to three
errors (s = 3), but it can correct up to one error.
In other words, if this code is used for error
correction, part of its capability is wasted.
Error correction codes need to have an odd
minimum distance (3, 5, 7, . . . ).
Slide-26
Hamming Code
Relationship between m (minimum Hamming
distance) and n (codewords) in Hamming code is
n = 2m- 1
At first we have to choose an integer m>= 3
The values of n and k are then calculated from m as:
n = 2m- 1
k=n-m
The number of check bits r = m
For example, if m= 3, then
n = 2m- 1 = 23- 1 = 7
k=n–m= 7–3=4
Therefore, the Hamming code is expressed as
C(7, 4) with dmin = 3
Table below shows the datawords and codewords for
this code.
Slide-27
Hamming Code
Slide-28
Hamming Code
Slide-29
Hamming Code
Slide-30
Hamming Code: Example
Slide-31
Single-bit error
Slide-32
Error
Detection
Slide-33
Linear Block Code
A linear block code is a code in which the
exclusive OR (addition modulo-2) of two valid
codewords creates another valid codeword.
Simple Parity-Check code, Hamming code etc. are examples
of linear block codes.
Example-1: Consider the codes shown in the table below.
Determine whether they are linear block codes.
Solution:
The code scheme shown in the above table is a linear block
code, because the result of XORing any codeword with any
other codeword is a valid codeword. For example, the
XORing of the second and third codewords creates the fourth
Slide-34
Linear Block Code
Example-2: Consider the codes shown in the table below.
Determine whether they are linear block codes.
Solution:
The code scheme shown in the above table is a linear block
code, because the result of XORing any codeword with any
other codeword is a valid codeword. For example, the
XORing of the third and fourth codewords creates the second
one.
Slide-35