You are on page 1of 17

Hamming Code

By





Introduction


A Hamming code is a linear error detecting code.


It was developed by Richard Hamming.

An error-correcting code is an algorithm for
expressing a sequence of numbers such that any
errors which are introduced can be detected and
corrected (within certain limitations) based on the
remaining numbers.
Introduction

Hamming codes can detect upto double bit
errors and correct single bit error in a
dataword.

It is more efficient than Parity code and
Repetition code.


Coding and decoding algorithm

Mark all bit positions that are powers of two as
parity bits. (Positions 1, 2, 4, 8, 16, 32, 64, etc.)
All other bit positions are for the data to be encoded.
(positions 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17,
etc.)
Eg: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
17 18 19 20 .


Coding and decoding algorithm

Each parity bit calculates the parity for some of the
bits in the code word. The position of the parity bit
determines the sequence of bits that it alternately
checks and skips.
Lets parity bits are denoted by p1, p2, p4, p8, p16,
p32etc.



Coding and decoding algorithm

P1 : check 1 bit, skip 1 bit, check 1 bit, skip 1 bit
and so on.
P2 : check 2 bits, skip 2 bits, check 2 bits, skip 2 bits,
etc.
P4 : check 4 bits, skip 4 bits, check 4 bits, skip 4 bits,
etc.

Position 8: check 8 bits, skip 8 bits, check 8 bits, skip
8 bits etc.





Coding and decoding algorithm
Example

Lets consider Hamming(11,7) code

Here no. of data bits = 7

Parity bits= 11-7 = 4

Total no. of bits = 11



Example

Let the 7 bit data be 0110101


Example

The new data word (with parity bits) is now
"10001100101".
Lets assume that the LSB of the data gets corrupted
and becomes "10001100100".

Now we apply reverse of the encoding algorithm to
detect and correct the received data.


Example
Example

So the error bit is the 11 th bit.

So corrected received data is 10001100101

The actual data is 0110101(Ignoring parity
bits)

Hamming code with an extra parity
Addition of an extra parity-checking bit to the
end of the string which checks the entire
string.

This will increase the error detection to 2 bit
errors.

Applications

They are widely used in computer memory
(RAM).
They are extremely common in the DRAM of
computers used in satellites and space probes.
Also used in NAND Flash memories to ensure
data integrity.
Hamming codes along with other codes are
now-a-days being used in image processing,
data hiding and data compression also.
Advanced application

Researches are going on applying Modified
Hamming codes in optical channels with
quantum noises and external noises.
Modified Hamming codes will be able to
exclude almost all errors on an optical
channel.

Thank You

You might also like