lecture 6: framing and error detection-data link layer functions

20
Lecture 6: Framing and Error Detection-Data Link Layer Functions

Upload: dorthy-griffith

Post on 03-Jan-2016

214 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Lecture 6: Framing and Error Detection-Data Link Layer

Functions

Page 2: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Review of Lecture 5

• Level 1: Physical or Hardware Layer– Deals with the transmission of bits

• Signal Generation and Modulation

• Encoding

• Implemented by adapters and device drivers

Page 3: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Review of Lecture 5

• Level 2: Data Link Layer– Deals with reliable transmission of data over a

single link (does not include routing over a network of links)

• Framing

• Error Detection

Page 4: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Review of Lecture 5

• Last time—Bit oriented protocol with sentinel strings (01111110 at beginning and end of frame

• Uses bit-stuffing to identify sentinel strings in the payload– Sender inserts zero after string of five 1’s– Receiver deletes stuffed bits

Header Body

8 16 16 8

CRCBeginningsequence

Endingsequence

Page 5: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Byte oriented framing-Byte counting approach

• include payload length in header– e.g., Digital Data Communication Message Protocol

(DDCMP)

– problem: count field corrupted– solution: catch when CRC fails

SY

N

Header Body

8 8 4214 168

SY

N

Cla

ss CRCCount

Page 6: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Byte-oriented framing: Sentinel Approach

DLE character precedes ETX within the body

Page 7: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Clock-based framing

– SONET: Synchronous Optical Network – each frame is 125us long– STS-n (STS-1 = 51.84 Mbps)

Overhead Payload

90 columns

9 rows

STS-1Hdr STS-1Hdr STS-1Hdr

STS-3cHdr

Page 8: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Error Detection and Correction

• Two dimensional Parity

• Cyclic Redundency Check

• Internet checksum

Page 9: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Two Dimensional Parity

Detects and corrects single bit errors

Detects 2 and 3 bit errors

Fails for 4 errors at the corners of box

Page 10: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Cyclic Redundancy Check

• Add k bits of extra data (the CRC field) to an n-bit message to provide error detection function

– For efficiency, want k << n

– e.g., k = 32 for Ethernet and n = 12,000 (1500 bytes)

Header Body

8 16 16 8

CRCBeginningsequence

Endingsequence

Page 11: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Polynomials with binary coefficients

• Represent n-bit message as n-1 degree polynomial– e.g., MSG=10011010 as M(x) = x7 + x4 + x3 + x1

• Addition (no carry) Subtraction (no borrow)– 10011010 00101110

10110100 10110100– 00101110 10011010 – A-B=AXORB

Page 12: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Polynomials with binary coefficients

• Multiplication 1110 The

usual 1110without 11100

carrying 1110

1110 1010100

Page 13: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Polynomials with binary coefficients

• Division 1110 The usual 11101010100 without the

1110 borrowing 1001 1110 1110 1110

0

1000

Page 14: Lecture 6: Framing and Error Detection-Data Link Layer Functions

CRC strategy

• Sender and Receiver know the “divisor polynomial”– e.g. C(x)=x3+x2+1=1101

• Send MessageCRC with CRC chosen so that the whole thing is evenly divisible by C(x)

• Receiver calculates the remainder of

MessageCRC/C(x) There’s an error if it is not zero

Page 15: Lecture 6: Framing and Error Detection-Data Link Layer Functions

CRC example

• Message=10011010 C=1101(3 rd order)

• MessageCRC=10011010XYZ

• Choose XYZ so that remainder is zero for MessageCRC/C

Page 16: Lecture 6: Framing and Error Detection-Data Link Layer Functions

CRC Example cont.

• 11111001 110110011010XYZ

1101 1001 1101

1000 1101

X=1 1011 Y=0 1101 Z=1 1100

1101 1xyz1101

• MessageCRC=10011010 101

Page 17: Lecture 6: Framing and Error Detection-Data Link Layer Functions

CRC Example cont.• 11111001

110110011010000 1101 1001 1101 1000

1101 1011 1101 1100

1101 1000 1101 101

• MessageCRC=10011010xor) 101

Page 18: Lecture 6: Framing and Error Detection-Data Link Layer Functions

CRC (cont)• Let k be the degree of some divisor polynomial

– e.g., C(x) = x3 + x2 + 1

• Transmit polynomial P(x) that is evenly divisible by C(x) – shift left k bits, i.e., M(x)xk

– subtract remainder of M(x)xk / C(x) from M(x)xk

• Receiver polynomial P(x) + E(x)– E(x) = 0 implies no errors

• Divide (P(x) + E(x)) by C(x); remainder zero if:– E(x) was zero (no error), or– E(x) is exactly divisible by C(x) (unlikely for CRC-32)

Page 19: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Selecting C(x)• All single-bit errors, as long as the xk and x0 terms have

non-zero coefficients.• All double-bit errors, as long as C(x) contains a factor with

at least three terms• Any odd number of errors, as long as C(x) contains the

factor (x + 1)• Any ‘burst’ error (i.e., sequence of consecutive error bits)

for which the length of the burst is less than k bits.

• Most burst errors of larger than k bits can also be detected

• See Table 2.6 on page 102 for common C(x)

Page 20: Lecture 6: Framing and Error Detection-Data Link Layer Functions

Internet Checksum Algorithm• View message as a sequence of 16-bit integers;

sum using 16-bit ones-complement arithmetic; take ones-complement of the result.

u_shortcksum(u_short *buf, int count){ register u_long sum = 0; while (count--) { sum += *buf++; if (sum & 0xFFFF0000) { /* carry occurred, so wrap around */ sum &= 0xFFFF; sum++; } } return ~(sum & 0xFFFF);}