1 © unitec new zealand crc calculation and hammings code

20
1 © Unitec New Zealand CRC calculation and Hammings code

Upload: cordelia-mcdonald

Post on 21-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 © Unitec New Zealand CRC calculation and Hammings code

1© Unitec New Zealand

CRC calculationand Hammings code

Page 2: 1 © Unitec New Zealand CRC calculation and Hammings code

CRC

• The cyclic redundancy check, or CRC, is a technique for detecting errors in digital data, but not for making corrections when errors are detected.

• It is used primarily in data transmission.

• The cyclic redundancy check, or CRC, is a technique for detecting errors in digital data, but not for making corrections when errors are detected.

• It is used primarily in data transmission

2© Unitec New Zealand

Page 3: 1 © Unitec New Zealand CRC calculation and Hammings code

CRC process

3© Unitec New Zealand

Page 4: 1 © Unitec New Zealand CRC calculation and Hammings code

Binary Division

• The CRC is based on binary division. In CRC a sequence of redundant bits, called the CRC or the CRC remainder is appended to the end of a data stream.

• The resulting data becomes exactly divisible by a second, predetermined binary number.

• In reference to the CRC data transmitted is termed frame transmitted

4© Unitec New Zealand

Page 5: 1 © Unitec New Zealand CRC calculation and Hammings code

Polynomial generator

• The Polynomial Generator is used to calculate a binary equivalent. – Present powers are identified as 1 and a absent powers as 0.

• A CRC Generator uses modulo-2 division.

5© Unitec New Zealand

Page 6: 1 © Unitec New Zealand CRC calculation and Hammings code

Example 1

• The following is the procedure for sending the data below with the given polynomial generator.

• Data to be sent: 11011

• Polynomial generator: x4 + x2 +11.

1 Take the polynomial generator and work out its corresponding binary representation by identifying the absent powers

• Polynomial = x4 + x2 +1 = x4 + 03+ x2 + 01+1

• Divisor = 10101 ;this is the digital representation of the polynomial generator.

6© Unitec New Zealand

Page 7: 1 © Unitec New Zealand CRC calculation and Hammings code

2. A Frame Check Sequence (FCS) which equates to the highest power of the polynomial generator – (4 in the example above and represented as four zeros -0000). The FCS is added to the data resulting in

3. Ok so we now have the data to be sent which is 11011 and the polynomial generator which is x4 + 03+ x2 + 01+1 or in its binary form 10101 and the Frame Check Sequence (FCS) which is 0000. Now all we need to do is get the CRC.

The CRC is calculated by dividing the binary representation of the polynomial into the DATA + FCS using modulo-2 arithmetic.

On the next slide is a table, which will help you out with modulo-2 arithmetic

7© Unitec New Zealand

Page 8: 1 © Unitec New Zealand CRC calculation and Hammings code

Modulo 2 arithmetic

8© Unitec New Zealand

• Modulo 2 arithmetic is an XOR computation

Page 9: 1 © Unitec New Zealand CRC calculation and Hammings code

example

9© Unitec New Zealand

Note as X4 is the highest power in the polynomial generatorSo we have four 0’s in the FCS

Page 10: 1 © Unitec New Zealand CRC calculation and Hammings code

Checking the CRC

• We calculated the CRC by dividing the binary representation of the polynomial into the data and the FCS. So we end up with 1001 which is the CRC.

• Now we have the CRC for the data which has been sent all that is left to do is check the CRC and find out if the data has been received correctly.

• We do this exactly like the CRC Generator. If the remainder is all 0s, the CRC is dropped and the data is not corrupted, if the remainder is not = 0s, the data is corrupted.

10© Unitec New Zealand

Page 11: 1 © Unitec New Zealand CRC calculation and Hammings code

Example CRC check

11© Unitec New Zealand

• Note the remainder

is 0000 after this

calculation

Page 12: 1 © Unitec New Zealand CRC calculation and Hammings code

Practice problems

• 1: Data: 11011; Polynomial x3+x2+1. What is the checksum?

• 2: Data: 11001; Polynomial x3+x2+1. What is the checksum?

• 3: Data: 110101; Polynomial x4+x2+1. What is the checksum?

12© Unitec New Zealand

Page 13: 1 © Unitec New Zealand CRC calculation and Hammings code

Hammings error code

• Hamming Code is type of Error Correcting Code (ECC)

• Provides error detection and correction mechanism

• Adopt parity concept, but have more than one parity bit

• In general hamming code is code word of n bits with m data bits and r parity (or check bits)

• i.e. n = m + r

• Can detect D(min) – 1 errors

• Can correct errors

• Hence to correct k errors, need D(min) = 2k + 1

• Need a least a distance of 3 to correct a single bit error

13© Unitec New Zealand

Page 14: 1 © Unitec New Zealand CRC calculation and Hammings code

Hammings use of parity bits

• Hamming Code for single-bit error correction is the most commonly used

• Experiments (IBM study) show 98% time there are single-bit errors

• Need determine r for m-data bits that provides code words of n-bits that has single-bit correction capabilities

14© Unitec New Zealand

Page 15: 1 © Unitec New Zealand CRC calculation and Hammings code

Example: Generation of 12-bit Code word

• 8-bit data needs 4 parity bits, total of 12-bit code word

• Using our code words of length 12, number each bit position starting with 1 in the low-order bit

• Each bit position corresponding to power of 2 will be occupied by a parity or check bit

• All other bit positions are for the data to be encoded

• Each parity bit calculates the parity for some of the bits in the code word

15© Unitec New Zealand

Page 16: 1 © Unitec New Zealand CRC calculation and Hammings code

Example: location of parity bits in 12-bit Code word

• We then write each bit position, 1 through 12, in powers of 2

• 1 (= 20) contributes to all of the odd-numbered digits

• Hence parity at position 1 will based on bits in position 3, 5, 7,9, 11

• And so on…

16© Unitec New Zealand

Page 17: 1 © Unitec New Zealand CRC calculation and Hammings code

Example: 12-bit Code word

17© Unitec New Zealand

• 2 (= 21) contributes to positions 2, 3, 6, 7, 10, and 11

• Position 2 will contain the parity for bits 3, 6, 7, 10, and 11

• For the bit values shown, we have a parity value of 0 in the second bit position using even parity

• Even parity = XOR i.e. 0 ^ 1 ^ 0 ^ 0 ^ 1 = 0

Page 18: 1 © Unitec New Zealand CRC calculation and Hammings code

Example: 12-bit Code word

• The completed code word is shown above:

• Bit 1 checks the positions 3, 5, 7, 9, and 11, so its value is 1

• Bit 2 checks the positions 3, 6, 7, 10, and 11, so its value is 0

• Bit 4 checks the positions 5, 6, 7, and 12, so its value is 1

• Bit 8 checks the positions 9, 10, 11, and 12, so its value is also 1

18© Unitec New Zealand

Page 19: 1 © Unitec New Zealand CRC calculation and Hammings code

Using Hammings to identify an error

• Suppose an error occurs in bit 5, as shown above

• Our parity bit values are:

• Bit 1 checks positions, 3, 5, 7, 9, and 11. Its value is 1, but should be 0.

• Bit 2 checks positions 3, 6, 7, 10, and 11. The zero is correct.

• Bit 4 checks positions 5, 6, 7, and 12. Its value is 1, but should be 0

• Bit 8 checks positions 9, 10, 11, and 12. This bit is correct.

19© Unitec New Zealand

Page 20: 1 © Unitec New Zealand CRC calculation and Hammings code

• Parity bits 1 and 4 both check position 5 and 7

• Since parity bit 2 checks bit 7 and indicates no error occurred in the subset of bits it checked that means that error occurred in bit 5

• If we change bit 5 to a 1, all parity bits check and our data is restored

20© Unitec New Zealand

Example: 12-bit Code word