HAMMING CODE
The Hamming code can be applied to data units of any length and uses the
relationship between data & redundancy bits.
For ex. A seven bit ASCII code requires four redundancy bits that can be added with
the original data bits.
The check bits are are numbered consecutively , starting with 1 bit at the left end.The
bits are powers of 2 ( 1,2,4,8,16 etc. .)
The rest ( 3,5,7,9, etc. ) are filled up with the m data bits ( i.e.user data ).
Each check bit forces the parity of some collection of bits, including itself, to be
even ( or odd ).
Check bit 1 covers bits 1, 3, 5 ...
Check bit 2 covers bits 2, 3, 6, 7, 10, 11 ...
Check bit 3 covers bits 4, 5, 6, 7, 12, 13 ...
Check bit 4 covers bits 8, 9, 10, 11, 12 ...
The r1 bit is calculated using all bit positions whose binary representation includes a
1 in the rightmost position.
The r2 bit is calculated using all positions with a 1 in the second position , and so on.
When a codeword arrives at receiving end , the receiver initializes the counter to
zero.
It then examines each check bit i.e. 1,2,4,8 to see if it has the correct parity.
If not ,it adds k to the counter. If the counter is zero after all the check bits have
examined , the code word is accepted as valid. If the counter is nonzero , it contains the
number of the incorrect bit.
For ex. 10010100101 is the received . After computation it was found that the bit no. 7
is inverted.
Hamming codes can only correct single errors. However, there is a trick that can be
used to permit hamming codes to correct burst errors.
0 0 0 1……. 1 r1
0 0 1 0……. 2 r2
0 0 1 1……. 3 r1 r2
0 1 0 0……. 4 r3
0 1 0 1……. 5 r1 r3
0 1 1 0……. 6 r2 r3
0 1 1 1……. 7 r1 r2 r3
1 0 0 0……. 8 r4
1 0 0 1……. 9 r1 r4
1 0 1 0……. 10 r2 r4
1 0 1 1……. 11 r1 r2 r4
1 1 0 0……. 12 r3 r4