the data link layer

74
The Data Link Layer Chapter 3

Upload: montana

Post on 16-Mar-2016

43 views

Category:

Documents


1 download

DESCRIPTION

The Data Link Layer. Chapter 3. The Model. transport layer protocol. hostA. hostB. DLL protocol. DLL protocol. node1. node2. node3. logical path. Logical path. physical path. physical path. data link/logical link = ( physical ) link + procedure. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The Data Link Layer

The Data Link Layer

Chapter 3

Page 2: The Data Link Layer

The Model

hostA hostB

node1 node2 node3DLL protocol DLL protocol

logical path Logical path

physical path

data link/logical link = ( physical ) link + procedure digital channel provided by DLL

physical line DLL protocol

physical path

transport layer protocol

Page 3: The Data Link Layer

Data Link Layer Design Issues(p176)

• Services Provided to the Network Layer• Framing• Error Control• Flow Control

Page 4: The Data Link Layer

Functions of the Data Link Layer(p176)

• Provide service interface to the network layer• Dealing with transmission errors• Regulating data flow

• Slow receivers not swamped by fast senders

Page 5: The Data Link Layer

Functions of the Data Link Layer (2)

Relationship between packets and frames.

Page 6: The Data Link Layer

Services Provided to Network Layer

(a) Virtual communication.(b) Actual communication.

Page 7: The Data Link Layer

Services Provided to Network Layer(2)• Unacknowledged connectionless service

• Low error-rate line or real-time traffic • Acknowledged connectionless service

• Wireless system• Acknowledged connection-oriented service

• Transfer have 3 phases: connection setup, transmit & receive, connection release

Page 8: The Data Link Layer

Services Provided to Network Layer (3)

Placement of the data link protocol.

Page 9: The Data Link Layer

Framing method(p179)• 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

Character count

A character stream. (a) Without errors. (b) With one error.

Page 11: The Data Link Layer

Character stuffing

(a) A frame delimited by flag bytes.(b) Four examples of byte sequences before and after stuffing.

Page 12: The Data Link Layer

Character stuffingBisync

帧首同步字符 帧尾数据

传输帧填充字符

SYN SYN DLE STX A DLE DLE B DLE DLE C DLE ETX

Page 13: The Data Link Layer

Bit stuffing

Bit stuffing(a) The original data.(b) The data as they appear on the line.(c) The data as they are stored in receiver’s memory after destuffing.

Page 14: The Data Link Layer

Bit stuffingHDLC

帧首

01111110 01111101101111100 01111110

帧尾数据

填充位

Page 15: The Data Link Layer

Physical layer coding violation

ManchesterManchester

differentialdifferentialManchesterManchester

Page 16: The Data Link Layer

Error control(p182)• Provide sender with some feedback( positive or negative

acknowledgements)• When sender transmit a frame, it starts a timer• To prevent duplicate frames accepted by receiver, sender

assigns sequence numbers to each frame

Page 17: The Data Link Layer

Flow control• Fast sender could swamp the slow receiver• Throttle the sender with a kind of feedback mechanism

Page 18: The Data Link Layer

Error Detection and Correction

• Error-Correcting Codes• Error-Detecting Codes

Page 19: The Data Link Layer

Error-Correcting Codes• Hamming distance

The number of bit positions in which two codeword differ • To detect d errors, you need a distance d + 1 code

• A code with a single parity bit has a distance 2, so it can be used to detect single errors

• To correct d errors, you need a distance 2d + 1 code• Consider n bits codeword with m bits message bits and r

check bits, each 2m legal messages requires n+1 bit patterns, total number of bit patterns is 2n ,so we must have (n + 1)2m <=2n ,or (m+r+1)2m<=2n

Page 20: The Data Link Layer

Error-Correcting Codes-1

Use of a Hamming code to correct burst errors.

Page 21: The Data Link Layer

Error-Correcting Codes-2• m=7, r=4, the bits that are power of 2 are check bits• Since 3=1+2, 5=1+4, 6=2+4, 7=1+2+4, 9=1+8, 10=2+8, 11=1+2+8• Compute check bits using following equation

• b1=b3+b5+b7+b9+b11• b2=b3+b6+b7+b10+b11• b4=b5+b6+b7• b8=b9+b10+b11

• Hamming codes can only correct single errors, we can use interleave method to correct burst errors,

Page 22: The Data Link Layer

Error-Detecting Codes• Generator polynomial G(x)• Algorithm for computing the checksum:

• Let r be the degree of G(x). Append r zero bits to the low-order end of the frame so it now contains m+r bits and corresponds to the polynomial xrM(x).

• Divide the bit string corresponding to G(x) into the bit string corresponding to xrM(x), using modulo 2 division.

• Substract the remainder (which is always r or fewer bits) from the bit string corresponding to xrM(x) using modulo 2 substration. The result is the checksummed frame to be transmitted. Call its polynomial T(x).

Page 23: The Data Link Layer

Error-Detecting Codes-1

Calculation of the polynomial code checksum.

Page 24: The Data Link Layer

Elementary Data Link Protocols

• An Unrestricted Simplex Protocol• A Simplex Stop-and-Wait Protocol• A Simplex Protocol for a Noisy Channel

Page 25: The Data Link Layer

Protocol Definitions(p194)

Continued

Some definitions needed in the protocols to follow. These are located in the file protocol.h.

Page 26: The Data Link Layer

Protocol Definitions(ctd.)

Some definitions needed in the

protocols to follow. These are located in the file protocol.h.

Page 27: The Data Link Layer

Unrestricted Simplex Protocol

从主机取数据上交主机

DATA1

DATA4

DATA3

DATA2

结点 A 结点 B

理想信道

Page 28: The Data Link Layer

Unrestricted Simplex Protocol(p196)

Page 29: The Data Link Layer

Simplex Stop-and-Wait Protocol

从主机取数据上交主机

DATA1

DATA2

结点 A 结点 B

ACK

ACK

具有简单流量控制的数据链路层协议

Page 30: The Data Link Layer

Simplex Stop-and-

Wait Protocol(p198)

Page 31: The Data Link Layer

A Simplex Protocol for a Noisy Channel

frame i ACK

i

frame I+1 AC

Ki+1

frame i+2

frame i+2 ACK

i+2

frame i+3

ACK

i+3

frame i+3 ACK

i+3

发送方

接收方

超时 超时

帧丢失 重发 ACK丢失 重发,丢弃重复帧

Page 32: The Data Link Layer

A Simplex Protocol for a Noisy Channel(p201)

A positive acknowledgement

with retransmission protocol.

Continued

Page 33: The Data Link Layer

A Simplex Protocol for a Noisy Channel (ctd.)

A positive acknowledgement with retransmission protocol.

Page 34: The Data Link Layer

Sliding Window Protocols

• A One-Bit Sliding Window Protocol• A Protocol Using Go Back N• A Protocol Using Selective Repeat

Page 35: The Data Link Layer

Sliding Window Protocols (2)(p204)

A sliding window of size 1, with a 3-bit sequence number.(a) Initially.(b) After the first frame has been sent.(c) After the first frame has been received.(d) After the first acknowledgement has been received.

Page 36: The Data Link Layer

A One-Bit Sliding Window Protocol(p205)

Continued

Page 37: The Data Link Layer

A One-Bit Sliding Window Protocol (ctd.)

Page 38: The Data Link Layer

A One-Bit Sliding Window Protocol (2)(p207)

Two scenarios for protocol 4. (a) Normal case. (b) Abnormal case. The notation is (seq, ack, packet number). An asterisk indicates where a network layer accepts a packet.

Page 39: The Data Link Layer

A Protocol Using Go Back N(p208)

Pipelining and error recovery. Effect on an error when(a) Receiver’s window size is 1.(b) Receiver’s window size is large.

Page 40: The Data Link Layer

Sliding windowPremise: In ARQ protocol , we must limit the maximum frames

sent continuously, because sequence also take frame spaceSending window: size is WT , the maximum frames can be sent

before ACK frame receivedReceiving window: size is WR , the maximum frames can be received

WT+WR<=2n

WT<=2n-1

Page 41: The Data Link Layer

Sliding window(2)

0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 70 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

Frames sent successfully

Frames sent without receiving ACK and frames

will be send

lower uppersequence

Sending buffer

0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 70 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

Frames received correctly

Frames will be received

sequence

Receivingbuffer

lower upper

Page 42: The Data Link Layer

Sliding window(3)

0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 70 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 70 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 70 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 70 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 70 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 70 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

0,1,2 0,1,2

ACK3ACK3

3,4,5,6 3,4,5,6

ACK7ACK7

Page 43: The Data Link Layer

Sliding window(4)

WT = 5 WR = 1

send 0 and 1

0 12345

6 7

H

T

0 14 235

6 7

H

Tsend 2, receive ACK0

receive 0 ,send ACK0

Initially

H

0 12345

6 7

T

initially

receive 1,send ACK1

H01

234567

T

01

234567

H

T

01234

56 7

H

T

Page 44: The Data Link Layer

Sliding window(5)

send 3, 4

timeout,retransmit 1

receive ACK1

Receive 3,but not 2

接收到重传的帧 1

receive 2

H

0 12345

6 7

T

H

0 12345

6 7T

0 12345

6 7

H

T

H 0 12345

6 7T

H

0 12345

6 7T

0 1234

567

H

T

discard 3

discard 1, retransmit ACK1

Page 45: The Data Link Layer

Sliding Window Protocol

Using Go Back N(p210)

Continued

Page 46: The Data Link Layer

Sliding Window Protocol Using Go Back N

Continued

Page 47: The Data Link Layer

Sliding Window Protocol Using Go Back N

Continued

Page 48: The Data Link Layer

Sliding Window Protocol Using Go Back N

Page 49: The Data Link Layer

Sliding Window Protocol Using Go Back N (2)(p213)

Simulation of multiple timers in software.

Page 50: The Data Link Layer

A Sliding Window Protocol Using Selective Repeat(p216)

Continued

Page 51: The Data Link Layer

Continued

A Sliding Window Protocol Using Selective Repeat (2)

Page 52: The Data Link Layer

A Sliding Window Protocol Using Selective Repeat (3)

Continued

Page 53: The Data Link Layer

A Sliding Window Protocol Using Selective Repeat (4)

Page 54: The Data Link Layer

A Sliding Window Protocol Using Selective Repeat (5)(p218)

(a) Initial situation with a window size seven.(b) After seven frames sent and received, but not acknowledged.(c) Initial situation with a window size of four.(d) After four frames sent and received, but not acknowledged.

Page 55: The Data Link Layer

Performance Stop-and-wait without error

Page 56: The Data Link Layer

Performance Stop-and-wait without error(2)

Page 57: The Data Link Layer

Performance Stop-and-wait with error

Page 58: The Data Link Layer

Performance

Page 59: The Data Link Layer

Protocol Verification

• Finite State Machined Models• Petri Net Models

Page 60: The Data Link Layer

Finite State Machined Models

(a) State diagram for protocol 3. (b) Transmissions.

Page 61: The Data Link Layer

Petri Net Models

A Petri net with two places and two transitions.

Page 62: The Data Link Layer

Petri Net Models (2)

A Petri net model for protocol 3.

Page 63: The Data Link Layer

Example Data Link Protocols

• HDLC – High-Level Data Link Control• The Data Link Layer in the Internet

Page 64: The Data Link Layer

HDLC

Frame format for bit-oriented protocols.

Page 65: The Data Link Layer

HDLC (2)

Control field of (a) An information frame.(b) A supervisory frame.(c) An unnumbered frame.

Page 66: The Data Link Layer

HDLC(3)• Information - data to be transmitted to user (next layer up)

• Flow and error control piggybacked on information frames

• Supervisory - ARQ when piggyback not used• Unnumbered - supplementary link control• Three phrases

• Initialization• Data transfer• disconnect

Page 67: The Data Link Layer

HDLCexample of operation

Page 68: The Data Link Layer

HDLCexample of operation(2)

Page 69: The Data Link Layer

The Data Link Layer in the Internet

A home personal computer acting as an internet host.

Page 70: The Data Link Layer

SLIP – Serial Line Internet Protocol

• RFC1055• Framing: Character Stuffing

• use 0xC0 as a flag char• use 0xDB 0xDC to replace 0xC0• use 0xDB 0xDB to replace 0xDB

• Problems• no error control• only support IP• don’t assign IP address dynamically• no authentication• different version exist

Page 71: The Data Link Layer

PPP – Point to Point Protocol

The PPP full frame format for unnumbered mode operation.

Page 72: The Data Link Layer

PPP – Point to Point Protocol (2)

A simplified phase diagram for bring a line up and down.

Page 73: The Data Link Layer

PPP – Point to Point Protocol (3)

The LCP frame types.

Page 74: The Data Link Layer

PPP CHAP Example

CHAP_REQUEST(Challenge_ID,server_name)

CHAP_RESPONSE(response,client_name)

CHAP_SUCCESS/CHAP_FAILURE

SiSi

server

SiSi

client