You are on page 1of 13

HAMMING

CODE
Description:

It is basically an error detection code technique.

It can be used to detect and correctbiterrors that can


occur when computer data is moved or stored.

Hamming code makes use of the concept


ofparityandparity bits, which are bits that are added
to data so that the validity of the data can be checked.
Condition and method of finding redundancy
bits:

2^r > m + r + 1

Where m=length of r=redundanc


message bits y bits
:
Find r:

r = 0,1,2,3,4 Respectively :
We will put the 2^0>7+0+1 : 1>8 :
false
value of r=0,1,.. 2^1>7+1+1 : 2>9 :
And find that value false
Likewise:
at which our 2^2>7+2+1 : 4>10:
false
condition got 2^3>7+3+1 : 8>11:
satisfied . Let m=7: false
2^4>7+4+1 : 16>12: r=4
TRUE
Example: 1101011
m=7,r=4(as we find previously)
As r=4 which means re have to
add 4 redundancy bits i.e.
r1 , r2 , r4 ,
r8

Total bits =m + r

=> 7+4 = 11
What we do is place redundancy bits in
our message as follows:
Find value of r1,r2,r4,r8:
1 1 0 r8 1 0 1 r4 1 r2 r1

For r1:

we skip and mark boxes with difference of 1 because


we are finding the value of r1.
Now count the no. of one(1) from marked boxes , if
counting is in even number than put 0(zero) as the
value of r1.
If not , i.e. number of one(1) is in odd numbers , put
1 as a value of r1.
As there are four 1 in total marked places, r1=0
Now we find r2:

we skip and mark boxes with difference of 2 because


we are finding the value of r2.

Again we count the no. of one(1) from marked


boxes , if counting is in even number than put
0(zero) as the value of r2.
0

As there are four 1 in total marked places, r2=0


Now we find r4 & r8 :

we skip and mark boxes with difference


of 4 and 8 respectively because we are
finding the value of r4 & r8.

Again we count the no. of one(1) from


marked boxes.

Value of r4=0 and r8=0.


Original message for sender
:
So the original message is:

11001010100

0 0 0 0
Error detection
Check the error and the bad bit:

Suppose the message code of 7 bit for error detection is 11001110100?

Sol: m=7 so r=4 i.e. r1 , r2, r4, r8

Now we check all redundancy bit codes:

Check with same approach:


As r1=0 which means no. of 1 is even but on checking no. of 1 is 4 which means bit r1 has no
error.
As r2=0 which means no. of 1 is even but on checking no. of 1 is 5 which means bit r2 has an
error.
As r4=0 which means no. of 1 is even but on checking no. of 1 is 3 which means bit r4 has an
error.
As r8=0 which means no. of 1 is even but on checking no. of 1 is 2 which means bit r8 has no
error.
Bits had error are- r2 & r4

So we add them i.e. 2+4=6

We have error in 6th bit of message.

Which is 1 and it should be 0.


1 1 0 0 1 1 1 0 1 0 0
11 10 9 r8 7 6 5 r4 3 r2 r1
Try more
question and
if you have
any query
let me know.

You might also like