0% found this document useful (0 votes)
52 views35 pages

IT-2205 Lec 04 Error Detection & Correction-2

This document provides an overview of error correction techniques. It discusses: 1. The objectives of error correction which are to reconstruct the original data by knowing the number and location of corrupted bits. 2. The two main types of error correction - forward error correction which uses redundant bits to guess the message, and retransmission which detects errors and asks for resending. 3. Block coding which divides messages into blocks of datawords with redundant bits added to create codewords. Hamming codes are a common linear block code. 4. How Hamming codes work by adding parity bits to datawords based on their position as a power of 2, enabling detection and correction of single bit errors.

Uploaded by

Irfan Samin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views35 pages

IT-2205 Lec 04 Error Detection & Correction-2

This document provides an overview of error correction techniques. It discusses: 1. The objectives of error correction which are to reconstruct the original data by knowing the number and location of corrupted bits. 2. The two main types of error correction - forward error correction which uses redundant bits to guess the message, and retransmission which detects errors and asks for resending. 3. Block coding which divides messages into blocks of datawords with redundant bits added to create codewords. Hamming codes are a common linear block code. 4. How Hamming codes work by adding parity bits to datawords based on their position as a power of 2, enabling detection and correction of single bit errors.

Uploaded by

Irfan Samin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

IT-2205: Data Communication

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

Objectives of this Lecture:

 Introduction to error correction


 Types of error correction
 Block coding and process of error correction in block coding
 Hamming code and Hamming distance
 Linear block code

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

Error correction can be handled in two ways:


1. Forward error correction:
 It is a process of error correction in which the
receiver tries to guess the message by using
redundant bits.
 This method is used if the number of errors is small.

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

Figure: Structure of encoder and decoder in error correction


Example:
 Assume that each block of
datawords is 2 bits, i.e., k = 2.
 Redundant bits that is to be added
to each dataword is 3 bits, i.e., r =
3.
 Therefore, each codeword will be 5
bits, i.e., n = 5.
 Table shows the list of datawords
Table: A code for error correction
Slide-6
and codewords.
Error Correction in Block Coding
Example: How does the receiver correct an error without knowing what
was actually sent by the sender?
 Assume the dataword is 01. The sender creates the codeword 01011.
 Assume that the codeword is corrupted during transmission, and 01001
is received.
 First, the receiver finds that the received codeword is not in the table.
This means an error has occurred.
 The receiver, assuming that there is only 1 bit corrupted, uses the
following strategy to guess the correct dataword:

1. Comparing the received codeword with the first codeword in the


table (01001 versus 00000), the receiver decides that the first codeword
is not the one that was sent because there are two different bits. (the
same for third or fourth one in the table)
2. By the same reasoning, the original codeword can not be the third or
fourth one in the table.
2. The original codeword must be the second one in the table because this
is the only one that differs from the received codeword by 1 bit. The
receiver replaces 01001 with 01011 and consults the table to find the
Slide-7 dataword 01.
Single-bit Error Correction

To correct an error, the receiver reverses the


value of the altered bit. To do so, it must
know which bit is in error.
Number of redundancy bits needed
 Let data bits = m

 Redundancy bits = r

Total message sent = m+r


The value of r must satisfy the following
relation:
2r ≥ m+r+1
Slide-8
Single-bit Error Correction

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

the 12 bits as follows:

 The 4 parity bits P1, P2, P4 and P8 are in positions of


power of 2 i.e., 1, 2, 4, and 8, respectively. The 8 bits of the
data word are in the remaining positions.
Slide-11
Hamming Code: Illustration
Each parity bit is calculated according to this rule:
 r1 bit is calculated using all bits positions whose binary
representation includes a 1 in the rightmost position.
 r2 bit calculated using all the bit positions with a 1 in
the second position.
 r3 bit calculated using all the bit positions with a 1 in
the third position.
 r4 bit calculated using all the bit positions with a 1 in
the fourth position and so on.
 Therefore the various r bits are parity bits for different
combination of bits. The various combinations are:
r1 : bits 1, 3, 5, 7, 9, 11
r2 : bits 2, 3, 6, 7, 10, 11
r3 : bits 4, 5, 6, 7, 12
Slide-12 r4 : bits 8, 9, 10, 11
Hamming Code: Illustration
 Each parity bit is calculated as follows:

 Substituting the 4 parity bits in their proper positions, we


obtain the 12-bit composite word or codeword:

 This codeword is sent to the receiver and checked again


for errors.
Slide-13
Hamming Code: Illustration
 The parity of the word is checked over the same groups of
bits, including their parity bits. The four check bits are
evaluated as follows:

 A 0 check bit designates an even parity over the checked


bits, and a 1 designates an odd parity.
 Since the bits were written with even parity, the result,

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:

 In the first case, there is no error in the 12-bit word.


 In the second case, there is an error in bit position number
1 because it changed from 0 to 1.
 The third case shows an error in bit position 5 with a
change from 1 to 0.

Slide-15
Hamming Code: Illustration
 Evaluating the XOR of the corresponding bits, we
determine the four check bits to be as follows:

 Thus, for no error, we have C = 0000;


 With an error in bit 1, we obtain C = 0001; and with an error
in bit 5, we get C = 0101.
 Hence, when C is not equal to 0, the decimal value of C
gives the position of the bit in error. The error can then be
corrected by complementing the corresponding bit.
 Note that an error can occur in the data or in one of the
parity bits.
Slide-16
Using Hamming Code Check
 Lets start with 4 bits of Data
 This would require 3 parity bits (7bits total)
 Parity bits are placed in positions 2n
 Hamming Checks
 Start at n  Check n  Skip n
 E.g. Parity bit 2 is in position 2 so…
 Start at 2, check two positions, skip two positions, etc..
 2,3,6,7 are part of the pattern that P2 checks

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:

 Consider the codeword: 0101101


 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 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

2. The Hamming distance d(000, 011) is 2 because

Relationship between Hamming distance and error:


 Hamming distance between the received codeword and
the sent codeword is the number of bits that are
corrupted.
Slide-20
Minimum Hamming Distance
The minimum Hamming distance is the smallest
Hamming distance between all possible pairs in a set
of words.
Example-1: Find the minimum Hamming distance of the
coding scheme shown in the table below:

Therefore, minimum Hamming distance dmin= 2

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:

Therefore, minimum Hamming distance


dmin= 3

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

The coding scheme is expressed as:


C(n, k) with 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,

the minimum Hamming distance in a block code must


be dmin = s + 1

Example-1:
Here dmin = 2
 This code guarantees the detection of only a single error. For

example, if the third codeword (101) is


sent and one error occurs, the received
codeword does not match any valid
codeword. If two errors occur, the
received codeword may match a valid
Slide-24
codeword and the errors are not detected.
Minimum Hamming Distance
Example-2:

Here dmin = 3

 This code can detect up to two errors.


 When any of the valid codewords is sent, two errors

create a codeword which is not in the table of valid


codewords. The receiver cannot be fooled.
 However, some combinations of three errors change a

valid codeword to another valid codeword. The receiver


accepts the received codeword and the errors are
undetected.
Slide-25
Minimum Hamming Distance
To guarantee correction of up to t errors in all cases, the
minimum Hamming distance in a block code must be
dmin = 2t + 1

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

You might also like