The Hamming Code
The Hamming Code
The Hamming Code
, ,
and
are given.
C1
C
2
0 0 0 1 1 1 1 i3
T
H V = 0 = 0 1 1 0 0 1 1 C 4 = 0
1 0 1 0 1 0 1 i5
i6
i
7
(5.1)
(5.2)
C4 = i5 + i 6 + i 7
The sum is made in twos modulus.
1st Example:
For n=7, k=4, m=3 and the information sequence i=1010, find the code word V.
Solution:
We notice that there are 4 information symbols: , , , . The code word V can be
written in literary form: V=
code word and 3 control bits. It results that the control matrix H will have 3 lines and 7
columns.
The computing relations of the control bits result from the coding relation (5.1) :
C1 = i3 + i5 + i 7 = 1 + 0 + 0 = 1
C2 = i3 + i 6 + i 7 = 1 + 1 + 0 = 0
C4 = i5 + i 6 + i 7 = 0 + 1 + 0 = 1
The code word results:
V=1011010
5.2.2 The decoding of the single error correcting Hamming code
we can calculate the corrector of the Hamming code with the relation:
z4
'T
z = H V = z 2
z1
(5.3)
(5.4)
ordering number of the column with the least significant bit in line m.
From the relation (5.3) it results:
z 4 = C '4 + i5' + i '6 + i 7'
z 2 = C '2 + i3' + i '6 + i '7
'
1
'
3
'
5
z1 = C + i + i + i
(5.5)
'
7
The decimal decoding of the corrector z indicates the errors position, if there is only one
error in the word V. It will be wrong, the symbol with the index r, given by the relation:
r = 4z 4 + 2z 2 + z1
(5.6)
z = H V ' = H ( V + ) = H T = h r
where the errors position is computed with the relation (5.6).
Remark: In case there are two errors, there is the possibility that no error is corrected and a
third symbol is wrong, resulting three wrong symbols at the reception.
2nd Example:
V = 1 0 0 1 0 0 1
The relation (5.5) will become:
z 4 = C'4 + i5' + i 6' + i 7' = 1 + 0 + 0 + 1 = 0
z 2 = C'2 + i3' + i '6 + i '7 = 0 + 0 + 0 + 1 = 1
z1 = C1' + i 3' + i5' + i 7' = 1 + 0 + 0 + 1 = 0
The necessary and sufficient condition for this code to be able to simultaneously
correct maximum t errors and detect maximum e errors is that the minimum distance of the
code to be:
d t + e + 1 = 1 + 2 + 1 = 4,
e>t
5.3.1 The coding of the single correcting Hamming code and detector of double errors
In order to exclude the single correcting Hamming codes disadvantage (to have
additional errors at the exceeding of the correction codes capacity, t>1 ) and to make it more
useful in practical applications, the code was modified in the sense of increasing the
minimum distance from d=3 to d=4, which permits double errors detection.
The increasing of the code distance from 3 to 4 was made by adding a supplementary
control symbol named parity control symbol and the code words structure becomes:
V = C0 C1C2i3C 4i5i6i7
The control matrix modifies and has the structure:
0
0 H 0
'
H =
=
1 1 0
0
0
1
1
0
1
0
1
0
1
1
1
1
0
0
1
1
0
1
1
1
1
0
1
1
1
1
0
0
H' VT =
0
Or in explicit form:
0 0 0 1 1 1
0 1 1 0 0 1
1 0 1 0 1 0
1 1 1 1 1 1
C0
C
1
1 C2
1 i3
=0
1 C4
1 i5
i
6
i 7
(5.7)
C1 = i3 + i5 + i7
C2 = i3 + i 6 + i 7
(5.8)
C4 = i5 + i 6 + i 7
C0 = C1 + C2 + i3 + C 4 + i5 + i 6 + i 7
3rd Example:
Consider the following information sequence i=1010, find the code word V.
Solution:
We notice that there are 4 information symbols: , , , . The code word V can be written
in literary form: V=
word and 4 control bits. It results that the control matrix H will have 4 lines and 8 columns.
The control bits computing relations result from the coding relation (5.8):
C1 = i3 + i5 + i 7 = 1 + 0 + 0 = 1
C2 = i3 + i 6 + i 7 = 1 + 1 + 0 = 0
C4 = i5 + i 6 + i 7 = 0 + 1 + 0 = 1
C0 = C1 + C2 + i3 + C4 + i5 + i6 + i 7 = 1 + 0 + 1 + 1 + 0 + 1 + 0 = 0
The code word results:
V=01011010
5.3.2 The decoding of the single error correcting Hamming code and detector of double
errors
z4
T
z z
Z = H' V' = = 2
z 0 z1
z 0
(5.9)
Where:
z = 0
z0 = 0
there are no errors or there are no code detectable errors.
2nd Case:
z 0
z0 = 0
we detect the double errors.
3rd Case:
z = 0
z 0 = 1
the symbol
is wrong.
4th Case:
z 0
z 0 = 1
there is a correctable error.
The symbol with the index r-1 will be wrong and r is given by the relation:
r = 4z 4 + 2z 2 + z1 + z 0
4th Example:
V = 0 1 0 0 1 0 1 0
The relation (5.5) will become:
z 4 = C'4 + i5' + i '6 + i '7 = 1 + 0 + 1 + 0 = 0
z 2 = C'2 + i3' + i '6 + i '7 = 0 + 0 + 1 + 0 = 1
z1 = C1' + i 3' + i5' + i 7' = 1 + 0 + 0 + 0 = 1
z 0 = C '0 + C1' + C 2' + i3' + C '4 + i 5' + i 6' + i 7' = 0 + 1 + 0 + 0 + 1 + 0 + 1 + 0 = 1
It results that we are in the 4th case and we have a correctable error.
Therefore it results that r:
r = 4z 4 + 2z 2 + z1 + z 0 = 4 0 + 2 1 + 11 + 1 = 4
So the symbol with the index r-1 will be wrong, meaning 4-1=3, .
The error word results:
=00010000
(5.10)
We can write:
V = V ' + = 01001010 + 00010000 = 01011010
The information sequence results:
i = i3i5i 6i7 = 1010
5.4 Practical work
5.4.1 Launch the executable Hamming.exe from the Hamming directory and afterwards type
the password TTI. Run the program by selecting the option Demonstratie for all the four
cases presented.
5.4.2 Verify with this program all the examples seen and selecting one by one the codes
presented.
5.4.3 For each code choose a coding or a decoding example that are similar with the ones in
the paper, with the remark that the information sequence, at coding, has to contain 11 bits
and the received word, at decoding, has to contain 15/16 bits. We carry out the
coding/decoding and after that we verify the results using the program.
5.4.4 At the end you will give a test on your accumulated knowledge during this laboratory.
The result of the test will be described by a mark computed by the computer.