the data link layer goal –as reliable as possible, efficient communication point-to-point...

22
The Data Link Layer • Goal – As reliable as possible, efficient communication • Point-to-Point – single connection – bits arrive in order sent • Not necessarily reliable (unreliable)

Upload: annabel-allen

Post on 03-Jan-2016

216 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

The Data Link Layer

• Goal– As reliable as possible, efficient communication

• Point-to-Point– single connection– bits arrive in order sent

• Not necessarily reliable (unreliable)

Page 2: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Data Link Layer Problems

• Errors occur

• Finite data rate

• Propagation delays– Time required for signal to travel from source to

destination

Page 3: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Data Link Functions

• Well-defined interface to the network layer

• Grouping the bits of the physical layer into frames

• Handling transmission errors

• Regulating the rate of data flow

Page 4: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Services Provided to the Data Link Layer

• Unacknowledged connectionless

• Acknowledged connectionless

• Acknowledged connection-oriented

Page 5: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Unacknowledged Connectionless• Frames are independent

• No acknowledgment

• No connection

• Lost frames are not detected– may be detected in higher level layers

• Best when error rates are low

• Good when late data is not useful– speech, video

• Most LANs use this service

Page 6: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Acknowledged Connectionless(More Reliable)

• Each frame individually acknowledged

• Unacknowledged frames are eventually resent

• Good for unreliable channels– wireless for example

Page 7: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Acknowledged Connection-oriented Service

• Connection is established

• Each frame is numbered

• Every frame sent is guaranteed to be received eventually

• Frames guaranteed to arrive in correct order

• Provides a reliable bit stream

Page 8: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Framing

• Bit streams from physical layer are unreliable

• We would like to check for errors

• Sending a relatively small frame of bits, combined with some kind of data redundancy, allows us to provide some error checking

Page 9: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Methods that Break the Bitstream into Frames

• Character count

• Starting and ending characters with character stuffing

• Starting and ending flags with bit stuffing

• Physical layer coding violations

Page 10: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Big Problem:– How do we recover if we get out of sync?

Character Count

5 T h i s 9 M e s s a g e 2 S

Frames are prefixed by chars/frame

ASCII 5 84

count count countWhat happens if

we lose this character?

104 115101115105 9 77 2 83101115 10397 32

Page 11: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Start and End Characters with Character Stuffing

• Special ASCII characters signal start and end of frame

DLE Data Link Escape (ASCII = 16)

STX Start of text (ASCII = 2)

DLE Data Link Escape (ASCII = 16)

ETX End of text (ASCII = 3)

• But what if these flags occur in the data?– Use two DLE characters to send one data DLE

Page 12: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Examples of Char Stuffing

DLE STX T H I S M DLE ETX

X Y DLE STX DLE ETX 5

DLE STX X Y DLE DLE STX DLE DLE ETX 5 DLE ETX

T S H I M

Page 13: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Start and End Flags With Bit Stuffing

• Choose a bit sequence for start/end flag

• Example: 01111110Every time you see five 1’s in sequence in the

data, stuff a zero into the stream

Page 14: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Final Framing Method - Physical Layer Coding Violations

• Start/End flag consists of sequence that is illegal in the data

• Example:10 is 1

01 is 0

00 or 11 could be used as flags

Page 15: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Error Control

• Error Control provides feedback about the success of data transmission– frames may arrive correctly (receiver sends ack)– frames may arrive corrupted (receiver sends

negative ack)– frames may be lost (no ack is ever received)

• acks may be lost (no ack is ever received)

• No error control in unacknowledged connectionless service

Page 16: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Flow Control

• What happens if the sender can send data faster than the receiver can handle it?– Receiver buffers overflow– Data is lost or requires retransmission

• Solution: Flow control– Receiver specifies the number of frames that

may be transmitted (no more than can be held in its buffers). The sender cannot send more data until the receiver grants permission.

Page 17: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Error Detection and Correction

• Error rates are relatively low on digital networks and LAN’s

• Error rates are high on analog twisted pairs and wireless communication

• When errors occur, they tend to occur in bursts– More data blocks are correct– Errors are harder to detect

Page 18: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Definitions

• Error-correcting Codes – Codes that contain enough redundant

information to correct errors

• Error-detecting Codes– Codes that contain enough redundant

information to detect errors

Page 19: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Parity - a simple error detection mechanism

• The number of “1” bits in a fixed length bit sequence is either always even (even parity) or always odd (odd parity)

• Example (even parity, length = 8)

parity bit0101011001100101

0101111001000101 Any single

bit errors are detected

1101011101001101

Any even number of bit errors is not detected

1101011101001111

Any odd number of bit errors is

detected

Page 20: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Hamming Distance

• Frame codeword contains n = m + r total bits– where

• m is number of message bits

• r is number of redundant bits

• Hamming Distance– The number of bit positions in which two

codewords differ

• Hamming Distance of Complete Code– The minimum Hamming Distance between

codewords

01101000110 11010010100

Hamming distance = 6

Page 21: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Hamming Distance

• To detect d errors you need a Hamming distance (for the complete code) of d+1

• To correct d errors you need a Hamming distance (for the complete code) of 2d+1

Page 22: The Data Link Layer Goal –As reliable as possible, efficient communication Point-to-Point –single connection –bits arrive in order sent Not necessarily

Error Correcting Codes

• Consider an encoding scheme where these are the only valid codewords

0000000000 0000011111 1111100000 1111111111

• The Hamming distance of the complete code is 5

• We can correct d-bit errors where 2d+1 = 5

• We can detect d-bit errors where d+1 = 50000000000 with two errors 0000000101 (with < 3 errors must be 0)

0000000000 with three errors 0000011001 could be 0000000000 with three errors or 0000011111 with two errors.