Hamming Code in Computer Network with Example

Hamming Code in Computer Network:

Hamming code is an error correction method in that some redundant bits are placed along with data bits to form a code word. It requires adding additional parity bits with the data. Hamming code is mainly used in error correction code (ECC) RAM.

Steps of Hamming Code calculating r-value:

1. All ‘d’ values are replaced by original message bits.
2. All ‘r’ values are replaced by 0’s. This forms the initial code word.

Hamming Code in Computer Network with Example

3. C1, C2, C3, C4 are recalculated as given below to form even parity bits:

C1 = C1 ⊕ C3 ⊕ C5 ⊕ C7 ⊕ C9 ⊕ C11

C2 = C2 ⊕ C3 ⊕ C6 ⊕ C7 ⊕ C10 ⊕ C11

C4 = C4 ⊕ C5 ⊕ C6 ⊕ C7

C8 = C8 ⊕ C9 ⊕ C10 ⊕ C11

Where ⊕ the sign indicates XOR operation.

Checking for error:

Receiver does the step 3 operation stated above on codeword C. After this operation, the bit combination represents a binary number corresponding to a decimal number. If the decimal number is 0 then there is no error. Otherwise, if the decimal number is n then it is concluded that the n-th bit is error-bit.

Example:

Hamming Code in Computer Network with Example

C is recalculated as shown below:
C1 = 0 ⊕ 1 ⊕ 0 ⊕ 1 ⊕ 0 ⊕ 1 = 1

C2 = 0 ⊕ 1 ⊕ 1 ⊕ 1 ⊕ 0 ⊕ 1 = 0

C4 = 0 ⊕ 0 ⊕ 1 ⊕ 1 = 0

C8 = 0 ⊕ 0 ⊕ 0 ⊕ 1 = 1

So, the code word sent is 10011100101

Suppose the 7th bit has undergone an error.

The Receiver computes as follows:
C1 = 1 ⊕ 1 ⊕ 0 ⊕ 0 ⊕ 0 ⊕ 1 = 1

C2 = 0 ⊕ 1 ⊕ 1 ⊕ 0 ⊕ 0 ⊕ 1 = 1

C4 = 0 ⊕ 0 ⊕ 1 ⊕ 0 = 1

C8 = 1 ⊕ 0 ⊕ 0 ⊕ 1 = 0

∴ C8C4C2C1 = 0111