practical session 11 codes. hamming distance general case: the distance between two code words is...
Post on 21-Dec-2015
221 views
TRANSCRIPT
![Page 1: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/1.jpg)
Practical Session 11
Codes
![Page 2: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/2.jpg)
Hamming Distance
• General case: The distance between two code words is the amount of 1-bit changes required to reach from one word to the other.
• Binary case: Number of 1’s in the XOR between the words.
• Hamming Distance is the minimum distance between the code words.
![Page 3: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/3.jpg)
Hamming Distance
• Intuition (code graph):• Example: d=2
00
10 11
01
![Page 4: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/4.jpg)
Error Detection
• Hamming Distance: d.• Can Detect d-1 errors.
![Page 5: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/5.jpg)
Fixing Erasures
• Can fix d-1 erasures.
![Page 6: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/6.jpg)
Error Correction
• Can fix Errors2
1d
![Page 7: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/7.jpg)
Example
• Given four “data” words, can we use 5-bit code words for fixing 1 error?
• Answer: Yes. We need a hamming distance of 3 to fix 1 error. We can create code words with independent graph “spheres”.
![Page 8: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/8.jpg)
Parity Check
• The most basic error check.• Used to test one character.• Appended to the end of the message.• Can detect 1 error.• Example (Even parity):
10010100 1
10010000 1
![Page 9: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/9.jpg)
Block Character Checksum
• Uses vertical and horizontal parity bits to detect double errors.
• Used for transmitting a block of characters.• BCC is used to detect two errors.• Odd parity calculated for each row.• Even parity calculated for each column.
![Page 10: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/10.jpg)
BCC - Example
• Two errors in the character ‘N’.• Parity doesn’t change.• BCC changed.
![Page 11: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/11.jpg)
Cyclic Redundancy Check
• A CRC is an error-detecting code• An n-bit CRC, applied to a data block of
arbitrary length, will detect any single error burst not longer than n bits
• Will detect a fraction 1-2-n of all longer error bursts
• The simplest error-detection system, the parity bit, is in fact a trivial CRC: it uses the two-bit-long divisor 11.
![Page 12: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/12.jpg)
Calculation Steps - Sending
1. A generator is chosen.– This is a sequence of bits, of which the first and
last are 1.– This sequence is used with the bits of the
message to calculate a check sequence which has 1 fewer bits than the generator.
2. The check sequence is appended to the original message
![Page 13: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/13.jpg)
Calculation Steps - Receiving
• At the receiver, the same calculation is performed on the message and check sequence combined.
• If the result is 0 no transmission error is assumed to have occurred.
![Page 14: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/14.jpg)
Example
• Compute 8-bit CRC for an 8-bit message: ‘W’.• ASCII for ‘W’: 8710 = 5716
• Select Generator: CRC-8-ATM– Polynomial: x8 + x2 + x + 1– Corresponds to: 100000111
• Two different orders are possible for the message.– Msbit-first: 010101112 = x6 + x4 + x2 + x + 1
– Lsbit-first: 111010102 = x7 + x6 + x5 + x3 + x
![Page 15: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/15.jpg)
Example – Generating CRC Code
• We will focus on Msbit-first order.• Append 8 bits to message:• 0101011100000000• Perform long-division of message by
generator.– Quotient is not needed.– Instead of subtraction perform simple XOR.– CRC code is the reminder.
![Page 16: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/16.jpg)
Example – Generating CRC Code
0101011100000000 100000111
CRC Code: 10100010
100000111
001011011000000
100000111
0011010110000
100000111
01010101100
100000111
0010100010
xor
xor
xor
xor
![Page 17: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/17.jpg)
Example – Checking Message
• Similar to generating the CRC code.• Append CRC code to the message (instead of
0’s): 0101011110100010• Perform long division by the generator.• If the reminder is not 0: An error occurred.
![Page 18: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/18.jpg)
Example – Checking Message
0101011110100010 100000111
Result: 00000000
![Page 19: Practical Session 11 Codes. Hamming Distance General case: The distance between two code words is the amount of 1-bit changes required to reach from one](https://reader035.vdocument.in/reader035/viewer/2022062407/56649d5a5503460f94a3aa6b/html5/thumbnails/19.jpg)
CRC Polynomials (Common)
CRC-8-ATMx8 + x2 + x + 1
CRC-16-IBMx16 + x15 + x2 + 1
CRC-16-CCITTx16 + x12 + x5 + 1
CRC-32-IEEE 802.3x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1