Error Control and Detection using Hamming Code: Single Error Correction and Detection, Study notes of Computer Science

The concept of error control and detection using hamming code, a technique for detecting and correcting single errors in digital data transmission. The principles behind hamming code, the calculation of parity bits, and the process of error detection and correction.

Typology: Study notes

Pre 2010

Uploaded on 03/28/2010

koofers-user-mnd
koofers-user-mnd 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 140
Class Notes 3
1 Error Correction and Detection
A variety of factors such as faulty components and inadequate design tolerances can result in
errors appearing in the information b eing processed by a computer. Such errors frequently occur
in information transmission between two relatively distant points.
One of the simplest and most widely used techniques for error control is using a single
parity
bit
C
0
. This parity bit is appended to an
n
bit input word
X
=(
X
0
X
1
:::X
n
1
) to form an (
n
+1)
bit word
X
=(
X
0
X
1
:::X
n
1
C
0
). The value assigned to bit
C
0
makes the total number of bits in
X
even (if we are using even parity) or odd (in the case of odd parity). Thus, at the receiving
end, an error can be detected by taking an
exclusive-or
of all the bits received (
X
).
Note that this simple technique of error control allows only detection of an error. It is not
possible to determine the bit in error (or the p osition of the error). Hence, it is not p ossible to
correct the error at the receiving end. This leads to retransmission of the information. In addition,
this parity only provides single error detection (or in fact, an odd number of errors can be detected).
It does not detect multiple errors (even in number).
The parity-checking concept can be easily extended to detection of multiple errors, or to the
location of single or multiple errors. These goals can be achieved by providing additional parity bits,
each of whichcheck the parity of a subset of the bits in
X
. For example, if we can deduce (from
the parity bits) that bit
X
i
is in error, then the error can be corrected by simply complementing
that bit, thus proving single error correction. Let
c
be the number of parity bits required to achieve
single error correction with
n
-bit data words. Clearly, the check bits must be able to distinguish
between (
n
+
c
) possible error location and the single error-free case. Hence,
2
c
n
+
c
+1
It can be proved that this code is
Single Error Correcting Double Error Detecting (SECDED)
code.
This is also known as
Hamming Code
.
The key question that remains to be answered is: How to generate the value of
c
parity bits
that are appended to
X
=(
x
0
x
1
:::x
n
1
) to obtain
X
? Also, how to obtain the location of error
from
X
? The process is illustrated in the following example:
Let
n
=4. Then,
c
= 3 (since, 2
3
4+3+1). Let
M
=(
m
0
m
1
m
2
m
3
) be the message bits and
let the three parity bits be (
p
0
p
1
p
2
). Organize the bits as follows:
POSITION 7 6 5 4 3 2 1
BIT
m
0
m
1
m
2
p
0
m
3
p
1
p
2
pf3

Partial preview of the text

Download Error Control and Detection using Hamming Code: Single Error Correction and Detection and more Study notes Computer Science in PDF only on Docsity!

CS 140 Class Notes 3

1 Error Correction and Detection

A variety of factors such as faulty comp onents and inadequate design tolerances can result in errors app earing in the information b eing pro cessed by a computer. Such errors frequently o ccur in information transmission b etween two relatively distant p oints.

One of the simplest and most widely used techniques for error control is using a single parity bit C 0. This parity bit is app ended to an n bit input word X = (X 0 X 1 :::Xn 1 ) to form an (n + 1) bit word X  = (X 0 X 1 :::Xn 1 C 0 ). The value assigned to bit C 0 makes the total numb er of bits in X  even (if we are using even parity) or o dd (in the case of o dd parity). Thus, at the receiving end, an error can b e detected by taking an exclusive-or of all the bits received (X  ).

Note that this simple technique of error control allows only detection of an error. It is not p ossible to determine the bit in error (or the p osition of the error). Hence, it is not p ossible to correct the error at the receiving end. This leads to retransmission of the information. In addition, this parity only provides single error detection (or in fact, an o dd numb er of errors can b e detected). It do es not detect multiple errors (even in numb er).

The parity-checking concept can b e easily extended to detection of multiple errors, or to the lo cation of single or multiple errors. These goals can b e achieved by providing additional parity bits, each of which check the parity of a subset of the bits in X . For example, if we can deduce (from the parity bits) that bit Xi is in error, then the error can b e corrected by simply complementing that bit, thus proving single error correction. Let c b e the numb er of parity bits required to achieve single error correction with n-bit data words. Clearly, the check bits must b e able to distinguish b etween (n + c) p ossible error lo cation and the single error-free case. Hence,

2 c^  n + c + 1

It can b e proved that this co de is Single Error Correcting Double Error Detecting (SECDED) co de. This is also known as Hamming Code.

The key question that remains to b e answered is: How to generate the value of c parity bits that are app ended to X = (x 0 x 1 :::xn 1 ) to obtain X ? Also, how to obtain the lo cation of error from X ? The pro cess is illustrated in the following example:

Let n = 4. Then, c = 3 (since, 23  4 + 3 + 1). Let M = (m 0 m 1 m 2 m 3 ) b e the message bits and let the three parity bits b e (p 0 p 1 p 2 ). Organize the bits as follows:

POSITION 7 6 5 4 3 2 1

BIT m 0 m 1 m 2 p 0 m 3 p 1 p 2

Then, the check bits (p 0 p 1 p 2 ) can b e computed as follows:

p 2 = m 3  m 2  m 0 (1)

p 1 = m 3  m 1  m 0 (2)

p 0 = m 2  m 1  m 0 (3)

Note that one change in data bits pro duces at least two changes in check bits. Similarly, two changes in data bits pro duce at least one change in check bits. Hence, the minimum distance b etween two valid co de words is three. (Recall that the distance b etween two words is equal to the numb er of bits that need to b e ipp ed to obtain one numb er from other. For example, the distance b etween 0110 and 0101 is 2.) As a result, it is a single-error-correcting co de.

The p osition of the single error can b e detected using vector (c 0 c 1 c 2 ) derived as follows:

c 2 = p 2  m 3  m 2  m 0 (4)

c 1 = p 1  m 3  m 1  m 0 (5)

c 0 = p 0  m 2  m 1  m 0 (6)

Thus, if c 0 = c 1 = c 2 = 0, then there is no single error. The general technique to obtain these equation is describ ed as follows:

  1. Given n (the numb er of bits in the message), compute c using 2 c^  n + c + 1. Let (n + c) b e the total numb er of bits. Lab el the p osition of bits from 1 through (n + c) from right to left. For example, for n = 4, we get c = 3. Hence, we lab el these 7 bit p ositions from 1 through 7 (from right to left) as follows:

POSITION 7 6 5 4 3 2 1

  1. Position the c parity bits in the lo cations marked with a numb er that is a p ower of 2. Place the message bits in other p ositions. Hence, our example b ecomes as follows:

POSITION 7 6 5 4 3 2 1 BIT m 0 m 1 m 2 p 0 m 3 p 1 p 2

  1. To nd the equation for the parity bit in p osition 2 i^ , do the following: