58
Ch. 3 Data Link Layer 1 Chapter 3 Data Link Laye r 3.1 Data Link Layer Design Issues 3.2 Error Detection and Correction 3.3 Elementary Data Link Protocols 3.4 Sliding Windows Protocols 3.5 Protocol Specification and Verification 3.6 Example Data Link Protocols Ch. 4

Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Embed Size (px)

Citation preview

Page 1: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 1

Chapter 3   Data Link Layer 3.1 Data Link Layer Design Issues 3.2 Error Detection and Correction 3.3 Elementary Data Link Protocols 3.4 Sliding Windows Protocols 3.5 Protocol Specification and Verification 3.6 Example Data Link Protocols

Ch. 4

Page 2: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 2

3.1 Data Link Layer Design Issues 3.1.1 Services Provided to the Network Layer 3.1.2 Framing 3.1.3 Error Control 3.1.4 Flow Control

Page 3: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 3

3.1.1 Services Provided to the Network Layer (1)

Page 4: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 4

3.1.1 Services Provided to the Network Layer (2)

Three reasonable services:– Unacknowledged Connectionless– Acknowledged Connectionless– Acknowledged Connection-Oriented

Example– Routers connected by

point-to-point leased telephone lines

» 1: Hardware in Physical Layer

» 2: Software inData Link Layer

» 3: Software in Network Layer

ˇ ˇ

Page 5: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 5

3.1.2 Framing (1) Framing

– To break the bit stream into discrete frames– To specify destination and source addresses– To compute the checksum for each frame– To include other control messages– …

How to distinguish frames (to mark the start and the end of a frame)?– (1) Character count– (2) Starting and ending characters, with character stuffing– (3) Starting and ending flags, with bit stuffing– (4) Physical layer coding violation– (5) Hybrid

Page 6: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 6

3.1.2 Framing (2)– (1) Character count

Page 7: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 7

3.1.2 Framing (3)– (2) Starting and ending characters, with character

stuffing» IBM BISYNC SYNCSYNC SYNCFrame Contents (in character)

Page 8: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 8

3.1.2 Framing (4)– (3) Starting and ending flags, with bit stuffing

» IBM SDLC 01111110 Frame contents (in bit) 01111110

Insert 0after 5 consecutive 1’s

Page 9: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 9

3.1.2 Framing (5)– (4) Physical layer coding violation

» Manchester Encoding (used in 802.3)

Transition in the middle of every bit◆ In the middle of a bit:◆

0 – Ascending edge 1 – Descending edge

» Differential Manchester Encoding (used in 802.5)

Transition in the middle of every bit◆ In the start of a bit:◆

0 – Transition 1 – No transition

⊕ Transitions in the middle of every bit are synchronization

⊕ Constant Power consumption

∴Encoding Violation:

No transition in the middle of a bit?Hi-Hi or Lo-Lo

oo

oo

oox x x x

x

Page 10: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 10

3.1.3 Error Control (1) To ensure reliable delivery for reliable serv

ices– The sender put error detection code in the data

frame;

– And the receiver checks and sends back an acknowledgement (ACK, 回覆 )

(a) Positive ACK ( 正回覆 , PACK) *» If the data is correct, then the receiver ACKs;

If the data is not correct, then the receiver does not ACK.

» If the sender receives the PACK, then it can send the next data frame.

* Widely used

D

Data (1)

PACK (1)

Data (2)

S

Page 11: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 11

3.1.3 Error Control (2)» [Problem 1] What if the frame is not corre

ct or the frame is lost? No PACK is sent at all. The sender does not receive PACK and suspe

nds?

» [Solution 1] The sender keeps a timer ( 計時器 ). If the timer expires (timeout, 逾時 ),

the sender retransmits ( 重送 ) the frame.

– This method is called: Positive ACK. With Retransmission (PAR)或 Automatic Repeat reQuest (ARQ)

Timer out ReTx

D

Data (1)

Data (1)

S

Timer

Page 12: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 12

3.1.3 Error Control (3)» [Problem 2] What if the frame is not lost

but the PACK is lost? The data frame is correctly received. The sender times out and retransmit. The frame is duplicated.

» [Solution 2] Each frame contains a sequence number ( 序號 ).

The receiver checks for duplicated frame. If a frame is duplicated, the receiver discards t

he duplicated frames and sends PACK.

DS

Duplicate Discard& PACK

Timer out ReTx

Data (1)

PACK (1)

Data (1)

Timer

PACK (1)

Data (2)

Page 13: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 13

3.1.3 Error Control (4)(b) Negative ACK ( 負回覆 , NACK )

» If the data is correct, then the receiver does not ACK;If the data is not correct, then the receiver ACKs.

» If the sender receives the NACK, then it retransmit the frame.

» [Problem] What if the NACK is lost?

» [Solution] The receiver keeps a timer. When the timer exp

ires, it sends another NACK.

D

Data (1)

Data (2)

S

Time out & NACK (1)

D

Data (1)

Data (2)

S

NACK (1)

Data (3)

Data (1)

Page 14: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 14

3.1.4 Flow Control Goal

– To throttle the sender into sending no faster than the receiver can handle the traffic

Mechanisms– With feedback ( 有回饋 ), explicit ( 明確的 )

» The receiver sends a special feedback message to the sender, asking the sender to slow down or speed up the transmission

More accurate Increased traffic

– Without feedback ( 無回饋 ), implicit ( 隱含的 )» The transmitter decides by itself whether to slow down or speedup the tra

nsmission Less accurate No increased traffic

» Example: Flow control of TCP depends on how ACKs are received

Page 15: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 15

3.2 Error Detection and Correction (1) Two categories of Error Handling

– Error Correction ( 錯誤修正 ) » The sender includes enough redundant information along with each bloc

k of data to enable the receiver not only to detect an error but also to deduce the correct data

» More redundant information» No need for ACK-retransmission mechanism» Suitable for channels with high error rate, such as wireless networks

– Error Detection ( 錯誤偵測 )» The sender generates only enough redundancy to allow the receiver to de

tect an error, but not which error, and requests for a retransmission» Less redundant information» Need for ACK-retransmission mechanism» Suitable for channels with low error rate, such as wireline networks, such

as copper wire and optical fiber

Page 16: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 16

3.2 Error Detection and Correction (2)3.2.1 Error-Correcting Codes3.2.2 Error-Detection Codes

Page 17: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 17

3.2.1 Error-Correcting Codes (1) Codeword ( 字碼 )

– For a frame of bit stream (n bits), including m message bits and r redundant bits, i.e. n = m + r

Hamming distance ( 漢明距離 )– The number of bit positions in which two codewords differ

» Example 010111000 010001001 oooxxooox Hamming distance = 3∴

Error Handling vs. Hamming Code– Error Correcting Code

» To correct d errors 2d+1 codewords

– Error Detecting Code» To detect d errors d+1 codewords

Page 18: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 18

3.2.1 Error-Correcting Codes (2) Hamming Code ( 漢明碼 )

– For m message bits and r redundant bits( m + r + 1 ) 2≦ r

» Example: If m = 8 ( 8 + r + 1 ) 2≦ r r = 4

– At the sender(1) Bit Position

Number codeword bits: starting with bit 1 at left end (1 、 2 、 3 、… )

Place the redundant (check) bits (currently unknown) at bit 1, 2, 4, 8, …, 2n

Place the message bits (e.g. ‘H’ = 1001000) to the rest of the bits     1234567891011

Example :□□1□001□000

Page 19: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 19

3.2.1 Error-Correcting Codes (3)(2) Calculation of

redundant bits Group parity checks

(e.g. Even) Group policy:

Message bit = ΣParity bits 3 = 1 + 2 5 = 1 + 4 6 = 2 + 4 7 = 1 + 2 + 4 9 = 1 + 810 = 2 + 8 11 = 1 + 2 + 8

Parity Group: Group 1:   1 、 3 、 5 、 7 、9 、 11Group 2:   2 、 3 、 6 、 7 、 10 、 11Group 4:   4 、 5 、 6 、 7Group 8:   8 、 9 、 10 、 11  1234567891011 (Assume Even Parity)

 □□1□001□000 □ 1 0 1 0 0 Group 1  □1  01  00 Group 2     □001 Group 4        □000 Group 8 00 1   0

Transmit: 00110010000  

Page 20: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 20

3.2.1 Error-Correcting Codes (4)– At the receiver

» Counter b = 0» Repeat group parity check (for n = 1、 2、 4、 8、… )

If group n is in error, then b = b + n» If b = 0, then no error;

else bit b is not correct (b b)

 1234567891011 (Assume even Parity) 0011101000010 1 1 1 0 0 Group 1 2 01  01  00 Group 2 4   1101 Group 48       0000 Group 8  xo x   o

∴b = 1 + 4 = 5 is incorrect

Page 21: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 21

3.2.2 Error-Detecting Codes (1) Cyclic Redundant Code (CRC, 循環冗餘碼 )

– Treating bit strings as polynomials with coefficients of 0 and 1 only

» For example: 10011 as x4 + x + 1

– Polynomial arithmetic is done modulo 2 ( 模數 -2), i.e. no carry, no borrow Exclusive-OR (⊕,互斥或 )

» For Example 0+ 0---- 0

0+ 1---- 1

1+ 0---- 1

1+ 1---- 0

0- 0---- 0

0- 1---- 1

1- 0---- 1

1- 1---- 0

Page 22: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 22

3.2.2 Error-Detecting Codes (2)– Assume that

» Message bit string M(x)» Generator polynomial G(x), with the degree of r ( r + 1 bits)

– At the sender(1) xr M(x)

Append r bits of 0 to the message bit string

(2) xr M(x) ÷ G(x) With the quotient Q(x) and the remainder R(x)

(3) Transmit xr M(x) – R(x) Append R(x) to the message bit string

– At the receiver(1) Receive xr M(x) – R(x) (2) xr M(x) ÷ G(x)

With the quotient Q’(x) and the remainder R’(x)

(3) If R’(x) = 0, then CORRECT; else ERROR.

Page 23: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 23

3.2.2 錯誤偵測碼 (3)At the Sender

M(x) = 1101011011G(x) = 10011

011

Page 24: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 24

3.2.2 錯誤偵測碼 (4)At the receiver

1 1 1 0

1

1

1

0

0

0

0

1

0

0

0

0= 0(Correct)

Received

Page 25: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 25

3.2.2 錯誤偵測碼 (5)At the receiver

1 1 1 0

1

1

1

0

0

0

0

1

0

0

0

1 ≠ 0(Error)

0

0

0

1

1

1

1

1 0 0 1 1

1

Received

Page 26: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 26

3.2.2 Error-Detecting Codes (6) International Standards

– CRC-12» x12 + x11 + x3 + x2 + x1 + 1

– CRC-16» x16 + x15 + x2 + 1

– CRC-CCITT» x16 + x12 + x5 + 1

Implementation– By hardware (using shift register) - 1961

Page 27: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 27

3.3 Elementary Data Link Protocols 3.3.1 An Unrestricted Simplex Protocol 3.3.2 A Simplex Stop-and-Wait Protocol 3.3.3 A Simplex Protocol for a Noisy Channel

Page 28: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 28

3.3.1 An Unrestricted Simplex Protocol Protocol 1 (Utopia ,烏托

邦 )

Simplex ( 單工 )» Data in one direction

Error-free ( 無雜訊 ) channel

The sender sends infinite number of data with infinite transmission speed

The receiver receives infinite number of data and processes with infinite transmission speed

Page 29: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 29

3.3.2 A Simplex Stop-and-Wait Protocol Protocol 2

(Stop-and-Wait) Simplex ( 單工 )

» Data in one direction Error-free ( 無雜訊 ) channe

lThe sender sends infinite nu

mber of data with infinite transmission speed

The receiver receives infinite number of data and processes with infinite transmission speed

Flow control Stop-and-Wait

Page 30: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 30

3.3.3 A Simplex Protocol for a Noisy Channel Protocol 3 (PAR/ARQ)

Simplex ( 單工 )» Data in one direction

Error-free ( 無雜訊 ) channelThe sender sends infinite number of

data with infinite transmission speed

The receiver receives infinite number of data and processes with infinite transmission speed

– Frames may be corrupted or lost completely Error Control

– ARQ:» PACK» Timer» Retransmission» Sequence number

Page 31: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 31

3.4 Sliding Windows Protocols (1) 3.4.1 A One Bit Sliding Window Protocol 3.4.2 A Protocol Using Go Back n 3.4.3 A Protocol Using Selective Repeat

Page 32: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 32

3.4 Sliding Windows Protocols (2) Data transmission (according to data flow direction)

– Simplex ( 單工 ) » Data can only be transmitted in one direction

– Duplex( 雙工 )» Data can be transmitted in two direction» Half duplex ( 半雙工 )

Not at the same time, e.g. early military radio (77) and early walkie-talkine

» Full duplex ( 全雙工 ) At the same time, e.g. telephone and newer walkie-talkie

Piggybacking ( 搭便車 ) ACK– Put the ACK onto the next outgoing data frame in the opposite direction

» To avoid sending a distinct ACK frame (only a few bits for ACK and a large amount of bits for header and checksum)

– If no data frame to piggyback for a period of time, it sends a separate ACK frame.

Page 33: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 33

3.4 Sliding Windows Protocols (3) Sliding Window ( 活動視窗 )

» Sequence Number: n-bit field ( 0 ~ 2n-1 )

– Sending Window» The sender maintains a set of sequence numbers (SN) corresp

onding to frames it has sent but have not yet been acknowledged (outstanding frames)

Outstanding frames are stored in buffer for possible retransmission

» The windows size is varying The initial windows size is set to 0 The maximum allowable window size is:

– 2n -1 (Go-Back-N)– 2n /2 = 2n-1 (Selective Repeat)– n=3 7 (Go-Back-N) or 4 (Selective Repeat)

Page 34: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 34

3.4 Sliding Windows Protocols (4) Leading edge:

– When a frame is passed from the network layer

Frame SN Leading Edge SN

Leading Edge SN Leading Edge SN + 1 (forwarded by 1)

Buffer and send the frame

If the window size reaches the maximum allowable window size , close the network layer

Trailing edge:– When an ACK with SN equal to

the trailing edge:» Trailing Edge SN Trailing

Edge SN + 1 (forwarded by 1)

» Remove the frame from the buffer

Page 35: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 35

3.4 Sliding Windows Protocols (5)– Receiving Windows

» The receiver maintains a set of sequence number corresponding to frames that it is permitted to accept.

» Next Frame Expected» Go Back N

Window Size ≒ 1 On receiving a frame:

– If (SN == Trailing Edge)- Deliver the frame to the network layer- Leading Edge Leading Edge + 1- Trailing Edge Trailing Edge + 1

(Forward the window)- Send PACK (SN)

– If (SN != Trailing Edge) - Discard the frame

Page 36: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 36

3.4 Sliding Windows Protocols (6)» Selective Repeat

Window Size 2≒ n-1 (e.g. n=3 4) On receiving a frame:

– If SN [lies within the window] but [is not equal to the Leading Edge]

- Store the frame in the buffer

– If SN [equals to the Leading Edge]

- Deliver the frame and the kth consecutive frames in the buffer to the network layer

- Leading Edge Leading Edge + k + 1

- Trailing Edge Trailing Edge + k + 1(Forward the window by k + 1)

- Send PACK (SN + k) – the largest SN

Page 37: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 37

3.4 Sliding Windows Protocols (7) 範例

– 3-bit sequence number (0 ~7)– Maximum allowable

sending window size= 7 (Stop-and-wait)

= 4 (Go Back N)

– Maximum allowable receiving window size

= 1 (Stop-and-wait)

= 4 (Go Back N)

Page 38: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 38

3.4.1 A One Bit Sliding Window Protocol (1)

One bit sequence number (0 and 1) ∴Max Window = 1(stop-and-wait)

(Duplicate)

Normal

(Delayed)(Time-out→ReTx)

Page 39: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 39

3.4.2 A Protocol Using Go Back n (1) Transmission Delay vs. Bandwidth Utilization

– For example» Round-trip delay of a 50kbps satellite is 500ms

» A data frame 20ms

» 「 Stop and Wait 」 Protocol

» Pipelining ( 管線法 ) Allowing the sender to transmit up to w frames before blocking (without bei

ng ACKed), instead of just 1. Maximum allowable window size = w

↑ Data

0 20 250

Data ↑

270

ACK ↓

520

↓ ACK

Q: In 520ms, only one data frame is transmitted?A: Pipelining

Page 40: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 40

3.4.2 A Protocol Using Go Back n (2) Pipelining frames over an unreliable channel raise

s serious issues.– When the sender recognizes that one frame is damaged

or lost (i.e. time out), there are several frames already been sent. How does the sender retransmit?

(1) Go-Back-N ( 回到 -N)» Retransmit all the outstanding frames starting from the time-

out frame

(2) Selective Repeat ( 選擇性重送 )» Retransmit only the time-out frame, not all the other outstand

ing frames.

Page 41: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 41

3.4.2 A Protocol Using Go Back n (3) Go-Back-N

no need for receiver buffer unnecessary retransmission

1. Frame 2 in error2. Frame 2 times out3. Frame 2 ~ 8 retransmitted

Page 42: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 42

3.4.3 A Protocol Using Selective Repeat Selective Repeat

No unnecessary retransmission Receiver buffer is needed

1. Frame 2 in error2. Frame 2 times out3. Frame 2 retransmitted

Page 43: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 43

3.5 Protocol Specification and Verification

3.5.1 Finite State Machine Models 3.5.2 Petri Net Models

Page 44: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 44

3.5.1 Finite State Machine (1) Finite State Machine (FSM)

– FSM (Sender or Receiver) is in one of the states at any instant– Only a finite number of states are allowed.– When an event ( 事件 ) occurs, FSM may go from one state to another state

(so-called transition) 。 Transition table ( 轉態表 )

– A table recording all the possible events and the corresponding transitions (transferring from a state to a state)

State diagram ( 狀態圖 )– A directed graph showing the relations of transitions and the corresponding s

tates» States: represented as nodes» Transitions: represented as directed arcs

Simulation ( 模擬 )– To run a computer program to emulate all the possible occurrences of events

and transitions to verify the feasibility of the protocol

Page 45: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 45

3.5.1 Finite State Machine (2) State Diagram and Transition Table for Protocol 3

State: (Sending Window, Receiving Window, Channel)

*

*

*

*

Page 46: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 46

3.5.1 Finite State Machine (3) State Diagram and

Transition Table for Protocol 3 (Full Duplex)

Page 47: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 47

3.5.2 Petri Net Models (1) Four basic elements

– Place ( 地方 ): shown as circle, i.e. states– Transition ( 轉態 ): shown as horizontal or vertical bars– Arc ( 箭頭 ): representing input and output states (places) of a transition– Token ( 記號 ): shown as heavy dot, i.e. current state (place)

fire ( 轉態發射 )– If all the input places have tokens, then the transition is enabled;– One of the enabled transitions is fired:

the tokens in all of the input places are removed;all the output places are added with tokens.

Simulation ( 模擬 )– To run a computer program to emulate all the possible occurrences of events and tran

sitions (firings) to verify the feasibility of the protocol

Page 48: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 48

3.5.2 Petri Net Models (2) Petri Net for

Protocol 3 Algebraic Expression

for transition:(1) Transition 10: (Receive

0)CG DF

(2) Transition 3: (Receive 1)DA BE

(3) Transition 11: (Receive 1) EF DG

(4) Transition 1:BD AC (Receive 0)

Easier to program

Page 49: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 49

3.6 Example Data Link Protocols 3.6.1 HDLC – High-level Data Link Control 3.6.2 The Data Link Layer in the Internet 3.6.3 The Data Link Layer in ATM

Page 50: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 50

3.6.1 HDLC (1) High-level Data Link Control

– IBM SNA: SDLC (Synchronous DLC)– ANSI ADCCP (Advanced Data Communication

Control procedure)– ISO HDLC– CCITT LAP (Link Access Procedure) (in X.25)

LAPB Bit-Oriented Frame

format

Page 51: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 51

3.6.1 HDLC (2) Three kinds of frames

– (a) Information ( 資訊 )– (b) Supervisory ( 主控 )– (c) Unnumbered ( 未編號 )

Seq: Sequence Number Next: Piggybacking ACK P/F: Poll/Final

Computer Terminal Poll = 1 (polling terminal to transmit)

Computer Terminal Final = 0 (Data except the last) Final = 1 (The last data)

Page 52: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 52

3.6.1 HDLC (3) Type

– 0: RECEIVE READY (Non-piggybacking ACK)– 1: REJECT (i.e. Go-Back-N)– 2: RECEIVE NOT READY (Non-piggybacking ACK, suspend sending)– 3: SELECTIVE REJECT (i.e. Selective Repeat)

UNNUMBERED Frame– Goal: Control frames | data frames for unreliable connectionless service– Commands:

» DISC (Disconnect): Announcing it is going down» SNRM (Set Normal Response Mode): Connecting – Master/Slave» SABM (Set Asynchronous Balanced Mode): Connecting – Peer-to-Peer» FRMR (FRaMe Reject): Informing semantic error of control frame» UA (Unnumbered Acknowledgement): ACK of control frames» UI (Unnumbered Information): Information contained in control frames, passed t

o data link layer

Page 53: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 53

3.6.2 The Data Link Layer in the Internet (1)

Point-to-point communication is primarily used in two situations– (1) Between routers in different LANs (via leased

lines)– (2) Between home PCs and dial-up system (via

modems and telephone lines)

電話網路

LAN

LAN

LAN

LAN

SLIP/PPP

PPP

Page 54: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 54

3.6.2 The Data Link Layer in the Internet (2)

Point-to-Point Data Link Protocols– SLIP (Serial Line Internet Protocol) – PPP (Point-to-Point Protocol)

SLIP PPP

Old New

No error detection Error Detection

Support IP only Multiple protocols supported

Manual assigning IP address Automatic assigning IP address

Authentication not supported Authentication supported

Not a formal standard; phase-outA formal standard; phase-in (Windows 95/98/NT/2000 default)

Used in dial-up lines onlyUsed in both dial-up lines and leased lines between routers

Page 55: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 55

3.6.3 The Data Link Layer in ATM (1)

Sub-layers of the Physical layer in ATM– PMD (Physical Medium Dependent ,實體媒介相依 )

» Corresponding to OSI Physical layer

– TC (Transmission Convergence ,傳輸聚合 )» Corresponding to OSI Data Link Layer

▲▼

Page 56: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 56

3.6.3 The Data Link Layer in ATM (2)

Cell ( 細胞 )53 Bytes 5: Header 48: Payload ( 酬載 )

Header–VPI (Virtual Path Identification)

–VCI (Virtual Circuit Identification)

Interface–UNI(User-NetworkInterface)

–NNI (Network-NetworkInterface)

UNI

NNI

(Payload)

Page 57: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 57

3.6.3 The Data Link Layer in ATM (3)

VP ( 虛擬路徑 ) / VC ( 虛擬線路 )

VPI ( 虛擬路徑識別 ) / VCI ( 虛擬線路識別 )

(虛擬路徑 )

(虛擬線路 )

(傳輸路徑 )

Page 58: Ch. 3 Data Link Layer 1 Chapter 3 Data Link Layer 3.1 Data Link Layer Design Issues 3.1 3.2 Error Detection and Correction 3.2 3.3 Elementary Data Link

Ch. 3 Data Link Layer 58

3.6.3 The Data Link Layer in ATM (4)

HEC (Header Error Control)– The checksum only covers the first four header bytes, not the payload field– Why:

» ATM was designed for use over fiber, and fiber is highly reliable» No need to check the whole cell.» Save time

– Procedure» Divide the first 32 header bits by x8+x2+x+1» Add the constant 01010101 to the remainder

How to locate the cell boundaries in the incoming bit stream?– Using HEC

» The bit stream enter a 40-bit shift register» Check HEC» If no error, the buffer contains a valid cell» If error, the buffer does not hold a valid cell, all the bits are shift right one bit» The process is repeated until a valid HEC is located