Error correction coding - Hamming code

A. Hamming code

Hamming code can only find double-bit errors and correct single-bit errors

II. Works

"Movable body hair and pull", as Hamming code check code is a multiple, which is the code bit codeword information is simultaneously performed a plurality of checksum verification

III. Workflow

1. Determine the checksum bits

Hamming inequality 2 ^ r> = k + r + 1, r is the redundant information bits, k information bits
eg: data to be transmitted is D = 101101
bits k = 6 the data
satisfies inequality r is a minimum 4
D = 101101 is the Hamming code should have 6 + 4 = 10, 6 where the original data, check code 4

2. Determine the location of the data and check code

The above example is that D = 101101, assuming that four check code are P1, P2, P3, P4, from left to right as the data D1, D2 ... D6
check code must be in a position of 2n th power, the first 16, 32, ... bits (corresponding to 2 ^ 02 ^ 12 ^ 22 ^ 32 ^ 42 ^ 5 ......, from the leftmost bits from the ), so to know the distribution of the location information code, i.e., non-2n th position, as in the first 3,5,6,7,9,10,11,12,13, ... bit (from the most digits to the left plays)
that is

                     
Data bits 1 2 3 4 5 6 7 8 9 10
Code P1 P2 D1 P3 D2 D3 D4 P4 D5 D6
The actual value 1 0 1 1 0 1

3. The calculated value of the checksum

                                                D=101101
                     
Binary 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010
Data bits 1 2 3 4 5 6 7 8 9 10
Code P1 P2 D1 P3 D2 D3 D4 P4 D5 D6
The actual value 0 0 1 0 0 1 1 1 0 1

Can be seen that the first bit P1 corresponding to binary 1 (see several binary words are to see the last data bit was a few binary format) can be found D1, D2, D4, D5 corresponding to the first bit is a binary 1, then check codes P1 data D1, D2, D4, D5
so that all parity bits to XOR = 0 (i.e., with different 0. 1)
. 1. 1 0 0
P1⊕D1⊕D2⊕D4⊕D5⊕ = 0 can be derived = 0 Pl
1 0 0
Similarly P2 corresponding to a second binary bit is 1, the parity data P2 to the code Dl, D3, D4, D6
1 1 1 1
P2⊕D1⊕D3⊕D4⊕D6⊕ be = 0 Release = 0 P2
0 1 0
third Similarly P3 is the corresponding binary 1, then the code P3 check data D2 of, D3, D4
0 1 1
P3⊕D2⊕D3⊕D4 = 0 = 0 can be derived P3
1 0
Similarly P4 check data D5, D6
0. 1
P3⊕D5⊕D6 = 0 = 0 can be derived P4
. 1
specific calculation method I refer to the http://www.cnblogs.com/scrutable/p/6052127. html, namely

p1(第1个校验位,也是整个码字的第1位)的校验规则是:从当前位数起,校验1位,然后跳过1位,再校验1位,再跳过1位,....。这样就可得出p1校验码位可以校验的码字位包括:第1位(也就是p1本身)、第3位、第5位、第7位、第9位、第11位、第13位、第15位,...。然后根据所采用的是奇校验,还是偶校验,最终可以确定该校验位的值。

p2(第2个校验位,也是整个码字的第2位)的校验规则是:从当前位数起,连续校验2位,然后跳过2位,再连续校验2位,再跳过2位,……。这样就可得出p2校验码位可以校验的码字位包括:第2位(也就是p2本身)、第3位,第6位、第7位,第10位、第11位,第14位、第15位,...。同样根据所采用的是奇校验,还是偶校验,最终可以确定该校验位的值。

p3(第3个校验位,也是整个码字的第4位)的校验规则是:从当前位数起,连续校验4位,然后跳过4位,再连续校验4位,再跳过4位,……。这样就可得出p4校验码位可以校验的码字位包括:第4位(也就是p4本身)、第5位、第6位、第7位,第12位、第13位、第14位、第15位,第20位、第21位、第22位、第23位,...。同样根据所采用的是奇校验,还是偶校验,最终可以确定该校验位的值。

p4(第4个校验位,也是整个码字的第8位)的校验规则是:从当前位数起,连续校验8位,然后跳过8位,再连续校验8位,再跳过8位,……。这样就可得出p4校验码位可以校验的码字位包括:第8位(也就是p4本身)、第9位、第10位、第11位、第12位、第13位、第14位、第15位,第24位、第25位、第26位、第27位、第28位、第29位、第30位、第31位,...。同样根据所采用的是奇校验,还是偶校验,最终可以确定该校验位的值。

Summing up the appeal Hamming code 0010011101 101101

4. Inspection and Correction

                                               D=101101
                     
Binary 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010
Data bits 1 2 3 4 5 6 7 8 9 10
Code P1 P2 D1 P3 D2 D3 D4 P4 D5 D6
The actual value 0 0 1 0 0 1 1 1 0 1

Therefore, the Hamming code 0010011101 101101
assumed fifth error, so the received data bits 00,101,111,101
all parity bits to be exclusive-OR operation
0 0. 1. 1. 1
P1⊕D1⊕D2⊕D4⊕D5⊕ =. 1
. 1 0 11

0 1 1 1 1
P2⊕D1⊕D3⊕D4⊕D6=0
1 0 1 0

0 1 1 1
P3⊕D2⊕D3⊕D4=1
1 0 1

0. 1. 1
P3⊕D5⊕D6 = 0 = 0
. 1 0
from P1 to P4 0101 available write, i.e., a binary sequence 0101, the corresponding binary 5 exactly, to find the location of such errors, the syndrome is the fifth i.e.

Guess you like

Origin www.cnblogs.com/buxiu888/p/12587759.html