Vous êtes sur la page 1sur 3

Name: Hayden Hodge

Log in:

hod0035

Date: October 25th, 2015

Report of Error Correction


Title: Hamming Code
Task: Detect and correct single bit errors
Scheme:

Introduction to problems:
When sending data between terminals, noise interference can corrupt the data. Using Hamming Code
we can both detect and also correct single bit errors. We can use multiple parity bits to not only detect
single bit errors, but correct them as well. This works on the principle of having each parity bit
covering a small portion of the data bits while overlapping in such a way to detect where exactly a
problem has occurred.
Elaboration:
It is common to use 7 bits of Hamming code, that is 4 bits of data and 3 parity bits. This is because
larger amounts of data have a higher chance of multiple-bit errors, while the 7 bit Hamming Code
remains efficient.
For an example, lets use 1011 as our data. This data does not go randomly into the 7 bit structure for
Hamming code, but rather in the third, fifth, sixth, and seventh bits from the right. This is because the
parity bits only go on bits numbered 2^n where n = 0,1, n. For our 7 bits, that is 2^0, 2^1, and 2^2,
or the first, second, and fourth bits from the right. The structure of the message we will send looks like
this :
[ Data 7 ] [ Data 6 ] [ Data 5 ] [ Parity 4 ] [ Data 3 ] [ Parity 2 ] [ Parity 1 ]
After filling in our data, it looks like this
[ 1 ] [ 0 ] [ 1 ] [ Parity 4] [ 1 ] [ Parity 2 ] [ Parity 1 ]

And now we have to determine the parity bits. For this to make sense, we must number each of the 7
bits 1 7 from the right in binary. That looks like this:
[ 111 ] [ 110 ] [ 101 ] [ 100 ] [ 011 ] [ 010 ] [ 001 ]
Each parity bit is responsible for a different slice of the data. Parity 1 is responsible for each bit
position with it's least significant bit equaling 1. That is 001, the parity bit itself, 011, 101, and 111, or
Data 3, Data 5, and Data 7. You can see that the last bit of each number = 1.
Parity 2 is responsible for each bit position with the second least significant bit equaling 1. That is 010,
itself, 011, 110, and 111, or Data 3, Data 6, and Data 7. You can see the middle bit of each number = 1.
Finally, Parity 4 is responsible for each bit position with the third least significant bit equaling to 1.
That is 100, itself, and 101, 110, and 111, or Data 5, 6, and 7. You can see that the first bit of each
number = 1.
Parity 1 covers Data 3, 5, 7
Parity 2 covers Data 3, 6, 7
Parity 4 covers Data 5, 6, 7
Now to determine the parity bits we look at each bit that they cover, and set the parity bit to equal 1 or
0 such that there is an even number of 1's in the group. For example :
Parity 1 covers Data 3, 5, 7. D3 = 1, D5 = 1, D7 = 1, so for there to be an even number of 1's, P1 must
be set to = 1.
Parity 2 covers Data 3, 6, 7. D3 = 1, D6 = 0, and D7 = 1, that is a 1, a 0, and a 1. For an even number
of 1's to exist in this group, P2 must be equal to 0.
We do the same with Parity 4, covering Data 5, 6, and 7. That is 1, 0, and 1, so P3 must equal 0.
Data = 1 0 1 1
1 x 1 1 P1 must equal 1
1 0 x 1 P2 must equal 0
1 0 1 x P4 must equal 0
Now, we can fill in the Parity Bits into our 7 bit message.
[ 1 ] [ 0 ] [ 1 ] [ Parity 4] [ 1 ] [ Parity 2 ] [ Parity 1 ]
[1][0][1][0][1][0][1]
Our new message is 1010101.
The purpose of all of that is that now, if there is a single bit error, the receiver can not only detect it, but
know where it is and fix it. Lets say there was an error and our message of 1010101 was received as
1110101. The receiver will first separate the data from the parity bits, knowing that from the right, the
third, fifth, sixth, and seventh bit are data. So the message he got is 1111. He now uses the parity bits to
check for errors.

Data = 1 1 1 1
1 x 1 1 P1 must equal 1 and it DOES
1 1 x 1 P2 must equal 1 BUT IT = 0 !!!
1 1 1 x P4 must equal 1 BUT IT = 0 !!!
We can see that there is an error because P2 and P4 both make an odd number of 1's with the bits the
are responsible for. But, where is it? Well, remember that P1 covers D3, 5, 7, P2 covers D3, 6, 7, and
P3 covers D5, 6, and 7.
D3 D5 D7 => P1 OKAY
D3 D6 D7 => P2 ERROR
D5 D6 D7 => P4 ERROR
We can see that based on P1, D3, D5, and D7 must be okay, and P2 and P4 are giving errors. We locate
the error based on what these groups have in common. If all 3 parity bits gave an error, it would mean
that D7 was an error because it is what all 3 groups have in common. But only P2 and P4 are giving
errors, and what they have in common besides D7 is D6, so D6 must be where there is an error. In this
case, D6 = 1, so we now know it must actually be a 0. After that change, we can check about and see
that parity bits show no errors.
Data = 1 0 1 1
1 x 1 1 P1 must equal 1 and IT DOES
1 0 x 1 P2 must equal 0 and IT DOES
1 0 1 x P4 must equal 0 and IT DOES
So therefore the receiver can know the correct message must be 1011.
Conclusion:
Hamming code is an ingenious way to use parity bits, not only recognizing the existence of an error but
where exactly that error is and therefore offering the possibility of correction.
References:
Ing. Nevlud Lectures
https://en.wikipedia.org/wiki/Hamming(7,4)
https://en.wikipedia.org/wiki/Hamming_code#Hamming_codes
http://www.nptel.ac.in/courses/106105080/pdf/M3L2.pdf
https://www.youtube.com/watch?v=1A_NcXxdoCc

Vous aimerez peut-être aussi