com342 networks and data communications

13
http://www.eej.ulst.ac.uk/~ian/modules/ COM342 COM342_L4D 1/13 COM342 Networks and Data Communications Ian McCrum Room 5B18 Web site: http://www.eej.ulst.ac.uk Tel: 90 366364 voice mail on 6 th ring Email: [email protected] Lecture 4D: Further examples of Data encoding for error detection : CRC and Checksums This presentation Modified late on 30/10/05, explained CRC division

Upload: beau-johnson

Post on 30-Dec-2015

29 views

Category:

Documents


0 download

DESCRIPTION

COM342 Networks and Data Communications. Lecture 4D: Further examples of Data encoding for error detection : CRC and Checksums. Ian McCrum Room 5B18 Web site: http://www.eej.ulst.ac.uk Tel: 90 366364 voice mail on 6 th ring Email: [email protected]. This presentation - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: COM342 Networks and Data Communications

http://www.eej.ulst.ac.uk/~ian/modules/COM342 COM342_L4D 1/13

COM342Networks and Data Communications

Ian McCrum Room 5B18 Web site: http://www.eej.ulst.ac.ukTel: 90 366364 voice mail on 6th ring Email: [email protected]

Lecture 4D: Further examples of Data encoding for error detection : CRC and Checksums

This presentationModified late on 30/10/05, explained CRC division

Page 2: COM342 Networks and Data Communications

http://www.eej.ulst.ac.uk/~ian/modules/COM342 COM342_L4D 2/13

Cyclic Redundancy Codes (CRC)

• The CRC technique is used to protect blocks of data called Frames. Using this technique, the transmitter appends an extra n- bit sequence to every frame called Frame Check Sequence (FCS). The FCS holds redundant information about the frame that helps the transmitter detect errors in the frame. The CRC is one of the most used techniques for error detection in data communications. The technique gained its popularity because it combines three advantages:

• Extreme error detection capabilities.

• Little overhead.

• Ease of implementation.

Page 3: COM342 Networks and Data Communications

http://www.eej.ulst.ac.uk/~ian/modules/COM342 COM342_L4D 3/13

Basics

• widely used in practice (ATM, HDLC)

• ATM 5-byte header uses 8-bit CRC

• IEEE GCRC-32 , 32-bit CRC for Ethernet, etc.

• Although simple checksums are also used ,they are less efficient at detecting errors

• The basic idea of CRC algorithms is simply to treat the message as an enormous binary number, to divide it by another fixed binary number, and to make the remainder from this division the checksum. • Upon receipt of the message, the receiver can perform the same division and compare the remainder with the "checksum" (transmitted remainder).• There are a few additional points to bear in mind. The fixed binary number is defined in advance, although several versions exist. •The “division” is done in a simplified way, no carries are generated during the subtraction.

Page 4: COM342 Networks and Data Communications

http://www.eej.ulst.ac.uk/~ian/modules/COM342 COM342_L4D 4/13

CRC in Practice• International standards (CCITT) are defined for

CRC-8, CRC-12, CRC-16, and CRC-32– CRC-8: ATM header error control

– CRC-10: ATM AAL error detection (recommended)

– CRC-12: IBM Bisync error control

– CCITT-16: HDLC, XMODEM, V.41

– CCITT-32: IEEE 802, V.42, ATM AAL5

• Each standard CRC can detect: – ALL burst errors of < r+1 bits, and ALL odd number of

bit errors

– Bursts of > r+1 bits detected with P = 1 – 0.5r

Page 5: COM342 Networks and Data Communications

http://www.eej.ulst.ac.uk/~ian/modules/COM342 COM342_L4D 5/13

Internet checksum (RFC1071)

Sender:• treat segment contents as

sequence of 16-bit integers

• checksum: addition (1’s complement sum) of segment contents

• sender puts checksum value into UDP checksum field

Receiver:• compute checksum of received

segment

• check if computed checksum added to checksum field value gives zero

– NO - error detected

– YES - no error detected. But maybe errors nonetheless?

Goal: detect “errors” (e.g., flipped bits) in transmitted segment (note: in actual practice, used at transport layer only)

Page 6: COM342 Networks and Data Communications

http://www.eej.ulst.ac.uk/~ian/modules/COM342 COM342_L4D 6/13

Cyclic Redundancy Code (CRC)•CRCs treat a bit string as a polynomial code with coefficients of 0 and 1. A k-bit frame is regarded as the coefficient list for a polynomial of order k, ranging from xk-1 to x0, said to be of degree k-1. The leftmost bit is xk-1 the next is xk-2

•I.e 110001 has 6 bits and is said to be x5+x4+x0 or x5+x4+1

• This is only important because the divisor is specified in this way, in practice you convert it to a binary number and do calculation using binary…

•Binary arithmetic is needed but the division process is simplified. Subtraction is done without carries or borrows and so is actually an XOR operation or just a matter of letting a bit through or inverting it…and when you do the subtraction itself is slightly different

Page 7: COM342 Networks and Data Communications

http://www.eej.ulst.ac.uk/~ian/modules/COM342 COM342_L4D 7/13

The polynomial code (optional)•The transmitter and receiver must agree the polynomial code of the generator, normally called G(x).

•It will be a binary number that must begin and end with a ‘1’. It will have less bits than the data being protected

•Basic idea is to add extra bits after the data so that the complete new frame is divisible exactly by G(x). The receiver does the division and if the remainder is zero then all is ok

•We begin with data of m bits represented by M(x). Add r bits to this, initially zero in value, r is the degree of G(x)

•Since the early bits are zero we have changed M(x) to xr M(x)

•We divide xr M(x) by G(x) using module-2 division and

Page 8: COM342 Networks and Data Communications

http://www.eej.ulst.ac.uk/~ian/modules/COM342 COM342_L4D 8/13

This example from http://www.relisoft.com/Science/CrcNaive.html

The CRC algorithm requires the division of the message polynomial by the key polynomial. The straightforward implementation follows the idea of long division, except that it's much simpler. The coefficients of our polynomials are ones and zeros. We start with the leftmost coefficient (leftmost bit of the message). If it's zero, we move to the next coefficient. If it's one, we subtract the divisor. Except that subtraction modulo 2 is equivalent to exclusive or, so it's very simple.

Let's do a simple example, dividing a message 100110 by the key 101 also expressed as x2 + 1. Since the degree of the key is 2, we start by appending two zeros to our message.

1 0 1 ) 1 0 0 1 1 0 0 0 1 0 1

1 1 1

1 0 1

1 0 0

1 0 1

1 0 0

1 0 1

Remainder is 0 1 so transmit 1 0 0 1 1 0 0 1

Page 9: COM342 Networks and Data Communications

http://www.eej.ulst.ac.uk/~ian/modules/COM342 COM342_L4D 9/13

Book Example fig 3-7/p189

1 0 0 1 1

0 0 0 0 0

1 0 0 1 1

1 0 0 1 11 0 0 1 1

1 0 0 1 1

1 0 0 1 1

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 0 0 1

0 0 0 1 0

0 0 1 0 1

0 1 0 1 1

1 0 1 1 0

0 1 0 1 0

1 0 1 0 0

0 1 1 1 0

1 1 1 0

1 1 0 1 0 1 1 0 1 1 0 0 0 01 1 0 0 0 0 1 0 1

Remainder is 1 1 1 0

Replace these 4 zeros with the remainder

Transmit 11010110111110

G(x)=x4+x+1

Page 10: COM342 Networks and Data Communications

http://www.eej.ulst.ac.uk/~ian/modules/COM342 COM342_L4D 10/13

Cyclic Redundancy Code - Example

010

001

111

\/Q

00r 0's

1011PDU

101G

1101

1

101

1

101

0

00001R = T = 110110

Page 11: COM342 Networks and Data Communications

http://www.eej.ulst.ac.uk/~ian/modules/COM342 COM342_L4D 11/13

Cyclic Redundancy Code - Generators• CRC Generators are subject of design and standardization.

The goal here is to let them have strong properties like:– Detect all single and double errors– Detect all burst of 16 bits and less

• Example generators are:– CRC-8: 100000111– CRC-10: 11000110011– CRC-12: 1100000000101– CRC-16: 11000000000000101– CRC-CCITT (ITU-T): 10001000000100001– CRC-32:

100000100110000010001110110110111

We see why writing e.g CRC-CCITT as x16+x15+x2+1 is less error prone!

Page 12: COM342 Networks and Data Communications

http://www.eej.ulst.ac.uk/~ian/modules/COM342 COM342_L4D 12/13

Cyclic Redundancy Code - Advantages

• The capabilities of e.g. CRC-16:– All single errors are detected

– All double errors are detected

– All burst errors of 16 errors in a row are detected

– All errors with an odd number of bits

– There are more…

• Highly Efficient Codes– overhead of e.g. CRC-16 Code for a PDU of size 12000

(1500 bytes) as in Ethernet: 0.14 %

Page 13: COM342 Networks and Data Communications

http://www.eej.ulst.ac.uk/~ian/modules/COM342 COM342_L4D 13/13

Tutorials for Lecture 4D (CRC)

[2] What is the result of dividing (modulo-2) the polynomial x7+x5+1 by the generator polynomial x3+1?

[1] Write the bit pattern 10100001 and 1001 as polynomials

[3] Using the CRC generator 1001 generate the data to be transmitted if a data block is 1111000.

( answer 1111000110)

[4] What data is sent if a CRC of x4+x1+1 is used to protect a data block of 110101101?

Answer (1101011011111)