School of Computing. Dublin City University.
Online coding site: Ancient Brain
coders JavaScript worlds
Bits of codeword are numbered: bit 1, bit 2, ..., bit n.
Check bits are inserted at positions 1,2,4,8,.. (all powers of 2).
The rest are the m data bits.
Each check bit checks (as parity bit) a number of data bits.
Each check bit checks a different collection of data bits.
Check bits only check data, not other check bits.
Number is sum of these: 1 2 4 8 16 Number: 1 x 2 x 3 x x 4 x 5 x x 6 x x 7 x x x 8 x 9 x x 10 x x 11 x x x 12 x x 13 x x x 14 x x x 15 x x x x 16 x 17 x x 18 x x 19 x x x 20 x x 21 x x x 22 x x x 23 x x x x 24 x x 25 x x x 26 x x x 27 x x x x 28 x x x 29 x x x x 30 x x x x 31 x x x x x ...
Check bit records odd or even parity of all the bits it covers, so any one-bit error in the data will lead to error in the check bit.Checked by check bit: 1 2 4 8 16 Bit: 1 (not applicable - this is a check bit) 2 (n/a) 3 x x 4 (n/a) 5 x x 6 x x 7 x x x 8 (n/a) 9 x x 10 x x 11 x x x 12 x x 13 x x x 14 x x x 15 x x x x 16 (n/a) 17 x x 18 x x 19 x x x 20 x x 21 x x x 22 x x x 23 x x x x 24 x x 25 x x x 26 x x x 27 x x x x 28 x x x 29 x x x x 30 x x x x 31 x x x x x 32 (n/a) ...
Assume one-bit error:
If any data bit bad, then multiple check bits will be bad
(never just one check bit).
Assume one-bit error:
(bits 1 to 3).000 001 010 011 100 101 110 111
Encode this such that a 1 bit error can be detected and corrected.
Add check bits:
(now have bits 1 to 6).cc0c00 cc0c01 cc0c10 cc0c11 cc1c00 cc1c01 cc1c10 cc1c11
Check bit 1 looks at bits 3 5.
0c0c00 0c0c01 1c0c10 1c0c11 1c1c00 (flip previous 4 bits) 1c1c01 0c1c10 0c1c11
Check bit 2 looks at bits 3 6.
000c00 010c01 100c10 110c11 111c00 (flip previous 4 bits) 101c01 011c10 001c11
Check bit 4 looks at bits 5 6.
000000 010101 100110 110011 111000 101101 011110 001011
Minimum distance 3.Distance from pattern: 0 1 2 3 4 5 6 7 Pattern: 0 000000 - 3 3 4 3 4 4 3 1 010101 3 - 4 3 4 3 3 4 2 100110 3 4 - 3 4 3 3 4 3 110011 4 3 3 - 3 4 4 3 4 111000 3 4 4 3 - 3 3 4 5 101101 4 3 3 4 3 - 4 3 6 011110 4 3 3 4 3 4 - 3 7 001011 3 4 4 3 4 3 3 -
List all patterns and find nearest one? Computationally expensive. Especially with longer strings (much more patterns).
With Hamming, can find nearest quickly by just looking at one pattern:
Check bit 1 - 1 - checks bits 3,5 - 1 0 - OK
Check bit 2 - 1 - checks bits 3,6 - 1 1 - WRONG
Check bit 4 - 0 - checks bits 5,6 - 0 1 - WRONG
The bad bit is bit 2 + 4 = bit 6. Data was corrupted. Data should be 100.
Check bit 1 - 0 - checks bits 3,5 - 1 0 - WRONG
Check bit 2 - 1 - checks bits 3,6 - 1 0 - OK
Check bit 4 - 0 - checks bits 5,6 - 0 0 - OK
The bad bit is bit 1. Check bit was corrupted. Data is fine.
i.e. If 1 bit error - can always tell what original pattern was.
Consider sending k codewords, each length n.
Arrange in matrix (as in diagram), each row is a codeword.
Matrix width n, height k.
Normally would transmit this row-by-row.
Trick: Transmit column-by-column.
If a burst of length k occurs in the entire k x n block
(and no other errors)
at most 1 bit is affected in each codeword.
So the Hamming code can reconstruct each codeword.
So the Hamming code can reconstruct the whole block.
Uses kr check bits to make blocks of km data bits immune to a single burst error of up to length k.