data link layer - computer sciencejorg/teaching/cs457/slides/datalink.pdf · main task of the data...

33
1 University of Virginia CS 457 - Computer Networks © Jorg Liebeherr, 1998 1 Data Link Layer Introduction Synchronization Error Detection Flow Control Error Control (via Retransmission) University of Virginia CS 457 - Computer Networks © Jorg Liebeherr, 1998 2 Introduction Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link Layer Physical Layer Network Layer Data Link Layer Physical Layer

Upload: lamnhi

Post on 04-Jun-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

1

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 1

Data Link Layer

IntroductionSynchronizationError Detection

Flow ControlError Control (via Retransmission)

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 2

Introduction

Main Task of the data link layer:n Provide error-free transmission over a link

Network Layer

Data Link Layer

Physical Layer

Network Layer

Data Link Layer

Physical Layer

Page 2: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

2

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 3

Introduction

n The PDU at the Data Link Layer (DL-PDU) is typicallycalled a Frame. A Frame has a header, a data field,and a trailer

n Example

011111108bits

Address8bits

Control8bits

Data>=0

Checksum16bits

011111108bits

Header Trailer

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 4

Framing

n Problem: Identify the beginning and the end of aframe in a bit stream

n Solution (bit-oriented Framing): A special bit pattern(flag) signals the beginning and the end of a frame(e.g., "01111110")

n Problem:– The sequence '01111110' must not appear in the

data of the frame

01111110 01111110Data

Page 3: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

3

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 5

Bit-Oriented Framing and Bit Stuffing

n 'Bit stuffing': If the sender detects five consecutive '1'it adds a '0' bit into the bit stream. The receiverremoves the '0' from each occurrence of thesequence '111110'

n Note: The flags itself are not bit-stuffed.

0110111111111111111100

0110111110111110111110100

Originalbit sequence:

After stuffing bitsat sender:

After stuffing bitsare removed by

receiver:0110111111111111111100

Stuffed bits

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 6

Error Control

Two basic approaches to handle bit errors:

– Error-correcting codes- Used if retransmission of the data is not possible- Data are encoded with sufficient redundancy to correct bit

errors- Examples: Hamming Codes, Reed Solomon Codes, etc.

– Error-detecting codes plus retransmission- Used if retransmission of corrupted data is feasible- Receiver detects error and requests retransmission of a

frame.

Page 4: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

4

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 7

Error Detection Techniques

n Error Detection Techniques:

– Parity Checks

– Cyclic Redundancy Check

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 8

Parity Checks

General Method:n Append a parity bit to the end of each character in a

frame such that the total number of '1' in a characteris:

- even (even parity) or- odd (odd parity)

n Example: With ASCII code, a parity bit can be attached to an 7-bit character

– ASCII "G" = 1 1 1 0 0 0 1– with even parity =– with odd parity =

Page 5: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

5

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 9

Cyclic-Redundancy Codes (CRC)

General Method:n The transmitter generates an n-bit check sequence

number from a given k-bit frame such that theresulting (k+n)-bit frame is divisible by some number

n The receiver divides the incoming frame by the samenumber

n If the result of the division does not leave aremainder, the receiver assumes that there was noerror

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 10

Cyclic-Redundancy Codes (CRC)

n CRC is used by all advanced data link protocols, forthe following reasons:– Powerful error detection capability– CRC can be efficiently implemented in hardware

n We discuss the CRC method in five easy steps:1. Prerequisites2. CRC Encoding Method3. Example4. Error Detection with CRC5. Capabilities of CRC

Page 6: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

6

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 11

Step 1: Prerequisites

n Modulo-2 Arithmetic:

n Examples of polynomials based on Modulo-2operations:1. (x+1)(x+1) =

2. (x2+1)(x3+x+1) =

3. If F(x) contains (x+1) as a factor, then F(1) = 0

+ 1 01 0 00 1 0

* 1 01 1 00 0 0

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 12

Step 2: CRC Encoding Method

n Let us view each block of data as a polynomial withbinary coefficients:1 0 1 1 0 1 is viewed as x 5 + x 3 + x 2 + 1

Define:n M(x) Data block is a polynomial (= Message, Frame)n P(x) "Generator Polynomial" which is known to both

sender and receiver (degree of P(x) is n)

Page 7: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

7

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 13

Step 2: CRC Encoding Method

(I) Append n zeros to M(x), i.e., M(x) xn

(II) Divide M(x) xn by P(x) and obtain: M(x) xn = Q(x) P(x) + R(x)(III) Set T(x) = M(x) xn + R(x). T(x) is the encoded

message

Note: T(x) is divisible by P(x). Therefore, if the received message does not contain an errorthen it can be divided by P(x).

n Exercise: Encode the frame 1 1 0 1 0 1 1 0 1 1

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 14

Step 3: Encoding

M (x) = x9 + x8 + x6 + x4 + x3 + x + 1- Generator polynomial is P(x) = x4 + x + 1- Degree of P(x) is 4

(I) M(x) x4 = x13 + x12 + x10 + x8 + x7 + x5 + x4

(II) M(x) x4 = Q(x) P(x) + R(x)=(x9 + x8 + x3 + x) P(x) + x3 + x2 + x

(III) T(x) = M(x) x4 + R(x)= x13 + x12 + x10 + x8 + x7 + x5 + X4 + x3 + x2 + x

Transmitted Bit Sequence: 1 1 0 1 0 1 1 0 1 1 1 1 1 0

Page 8: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

8

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 15

Step 4: Error Detection with CRC

n Errors can be expressed as Error Polynomials

n For example,Sent Message: 1 0 1 1 1 0 1Received Message: 1 1 1 1 0 0 1______________________________Error: 0 1 0 0 1 0 0

n In the example, the Error Polynomial E(x) is given by:

E(x) = x 5 + x 2

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 16

Step 5: Error Detection Capability of CRC

Note:

n Errors will not be detected by CRC ifE(x) / P (x) = B (x) + 0,i.e., E(x) contains P(x) as a factor

n Observe the following trade-off:– Large values of n introduce a lot of overhead, but

improve the error detection capability.

Page 9: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

9

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 17

n All single-bit errors are detected, if P(x) has a factorwith at least 2 terms:

E(x) = x i

If P(x) = (x+1)P’(x), then x i cannot contain (x+1)n All double-bit errors are detected if P(x) has a factor

with at least 3 termsE(x) = x i+x j = x j (x k+1) (for k = i-j, j<i)

n If P(x) does not divide (xk +1) for any k up to the max.frame length then all double errors can be detected.

P(x)= x15+ x14 +1 will not divide E(x)= x k + 1 for any k ≤ 32,768

Step 5: Error Detection Capability of CRCU

niversity of Virginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 18

Step 5: Error Detection Capability of CRC

n If P(x) contains (x+1) as a factor then all errors with“odd” number of bits are detected.– CRC detects 50% of all errors

n A CRC with n check bits will detect all burst errors oflength ≤ n bits.Burst Error of Length k: E(x)=x i(x k-1+ .... +1)

Page 10: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

10

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 19

Additional Facts on CRC

n CRC can be efficiently implemented in hardware by aset of XOR gates and a shift register

n The following generator polynomials are widely used:

CRC-12: P(x) = x 12 + x 11 + x 3 + x 2 + x + 1

CRC-16: P(x) = x 16 + x 15 + x 2 + 1

CRC-CCITT: P(x) = x 16 + x 12 + x 5 + 1

CRC-32: P(x) = x 32 + x 26 + x 23 + x 22 + x 16 + x 12 +x 11 + x 10 + x 8 + x7 + x 5 + x 4 + x 2 + x + 1

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 20

Flow Control

n Flow Control is a technique for speed-matching oftransmitter and receiver. Flow control ensures that atransmitting station does not overflow a receivingstation with data

n We will discuss two protocols for flow control:

– Stop-and-Wait Protocol

– Sliding Window Protocol

n For the time being, we assume that we have a perfectchannel between sender and receiver (no errors)

Page 11: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

11

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 21

Stop-and-Wait Flow Control

n Simplest form of flow control

n In Stop-and-Wait flow control, the receiver indicatesits readiness to receive data for each frame

n Operations:

1. Sender: Transmit a single frame

2. Receiver: Transmit acknowledgment (ACK)

3. Goto 1.

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 22

Analysis of Stop-and-Wait

Frame ACK

Frame ACK

Receiver

Sender

propagationdelay

Last bit received End of Transmit ofACK

Start Transmit End Transmit Last bit of ACK received

transmissiondelay

Page 12: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

12

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 23

Analysis of Stop-and-Wait

n Transmission delay is the time that the senderneeds to transmit a frame

n Transmission delay is dependent on the size of aframe and the maximum data rate

Example:Frame Size = 1000 bitData rate of network = 1 Mbps

Transmission delay = 1000 bit / 1 Mbps = 1 msec

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 24

Analysis of Stop-and-Wait

n Propagation delay is the time that a transmitted bitneeds to travel from sender to the receiver

n Propagation delay is only dependent on the speed ofthe transmission medium and the distance betweensender and receiver.

Speed of light: 300,000 km/sec,Speed in guided media (approx.): 200,000 km/sec

Example:Distance = 1000 kmPropagation delay = 1000 km / (200,000 km/sec)

= 5 msec

Page 13: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

13

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 25

Analysis of Stop-and-Wait

n Notation:

C = Channel capacity in bpsI = Propagation delayH = Number of bits in a frame headerD = Number of data bits in a frameF = Total length of a frame (F= D+H)A = Total length of an ACK frame

F/C = Transmission delay for a frame

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 26

Analysis of Stop-and-Wait

header dataH D

F

Data frame

Acknowledgement ACKA

CFI

delayontransmissidelaynpropagatioa /==

Page 14: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

14

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 27

Analysis of Stop-and-Wait

n Transmission of a frame (in Stop-and-Wait):

Receiver

Sender

I

Start Transmit0

End TransmitF/C

Last bit of ACK receivedF/C + 2I + A/C

last bitreceivedF/C + I

End ACKTransmit

F/C +I + A/C

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 28

n Efficiency of a protocol is the maximum fraction oftime when the protocol is transmitting data

n Efficiency of Stop-and-Wait Flow Control:

n Assuming that H and A are negligible we obtain:

Analysis of Stop-and-Wait

ICAFD

ICACFCD

efficiency22//

/++

=++

=

a

ICDDy efficiencnormalized

211

2 +=

+=

Page 15: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

15

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 29

Exercise 1

Satellite Link- Roundtrip propagation delay is 270 ms- Data rate is 56 kbps- Frame length is 4,000 bits (including header)- Lengths of ACK frames are negligible

n What is the value of “a”?n What is the efficiency of the satellite link if Stop-and-

Wait is used?

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 30

Exercise 2

Local Area Network (LAN)- Data rate is 10 (100) Mbps- Propagation rate is 200,000 km/sec- Length of the LAN is 10 km- Frame size is 500 bits (including header)- Length of ACK frames are negligible

n What are the values of “a” for the 10 and 100 MbpsLANs?

n How efficient are these LANs?n What is the minimum frame size in the LANs to reach

an efficiency of at least 80%?

Page 16: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

16

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 31

Sliding Window Flow Control

n Major Drawback of Stop-and-Wait Flow Control:

– Only one frame can be in transmission at a time

– This leads to inefficiency if a>1

n Sliding Window Flow Control– Allows transmission of multiple frames– Assigns each frame a k-bit sequence number– Range of sequence number is [0..2k-1], i.e., frames

are counted modulo 2k

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 32

Operation of Sliding Window

n Sending Window:- At any instant, the sender is permitted to send frames with

sequence numbers in a certain range

- The range of sequence numbers is called the sendingwindow

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

Frames alreadytransmitted

Window of frames that maybe transmitted

Framesequencenumber

Last frametransmitted

Window shrinks asframes are sent

Window expands asacknowledgements are

received

Page 17: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

17

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 33

Operation of Sliding Window

n Receiving Window:- The receiver maintains a receiving window corresponding

to the sequence numbers of frames that are accepted

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

Frames already received Window of frames that areaccepted by receiver

Last frameacknowledged

Window shrinks asframes are received

Window expands asacknowledgements are

sent

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 34

Operation of Sliding Window

n Operations at the sender:

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

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

send a single packet(with sequence number "0"):

Page 18: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

18

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 35

Operation of Sliding Window

n Operations at the sender:

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

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

Receive a singleacknowledgement (ACK 1)

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 36

Operation of Sliding Window

n Operations at the receiver:

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

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

Receive a single packet(with sequence number "0"):

Page 19: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

19

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 37

Operation of Sliding Window

n Operations at the receiver:

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

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

Transmit a singleacknowledgement ("ACK 1"):

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 38

Operation of Sliding Window

n How is “flow control” achieved?

– Receiver can control the size of the sendingwindow

– By limiting the size of the sending window dataflow from sender to receiver can be limited

n Interpretation of ACK N message:

– Receiver acknowledges all packets until (but notincluding) sequence number N

Page 20: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

20

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 39

Example

ReceiverTransmitter

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

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

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

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

F0F1F2

ACK4

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 40

Example Continued

ReceiverTransmitter

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

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

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

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

F3

ACK3F4F5F6

Page 21: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

21

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 41

Analysis of Sliding Windows

n Define:

– We use the same parameters for as in Stop-and-Wait

– To simplify notation we set:F/C = 1I = a (Normalization)

– W = Maximum window size (iddentical for senderand receiver)

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 42

Analysis of Sliding Windows

0 a

1st framereceiveda+1

...

0 1 2 W2a+1

1st ACKreceived

Receiver

Sender

Wth framereceiveda+W

Page 22: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

22

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 43

n If the window size is sufficiently large the sender cancontinuously transmit packets:

n W ≥ 2a+1: Sender can transmit continuously

n W < 2a+1:Sender can transmit W frames every 2a+1time units

Analysis of Sliding Windows

1 efficiency normalized =

2a1W

efficiency normalized+

=

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 44

ARQ Error Control

n Two types of errors:– Lost frames– Damaged Frames

n Most Error Control techniques are based on (1) ErrorDetection Scheme (e.g., Parity checks, CRC), and (2)Retransmission Scheme

n Error control schemes that involve error detection andretransmission of lost or corrupted frames are referredto as Automatic Repeat Request (ARQ) errorcontrol

Page 23: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

23

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 45

ARQ Error Control

n All retransmission schemes use all or a subset of thefollowing procedures:

– Receiver sends an acknowledgment (ACK) if aframe is correctly received

– Receiver sends a negative acknowledgment(NAK) if a frame is not correctly received

– The sender retransmits a packet if an ACK is notreceived within a timeout interval

– All retransmission schemes (using ACK, NAK orboth) rely on the use of timers

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 46

ARQ Error Control

n Note: Once retransmission is used, a sequencenumber is required for every data packet to preventduplication of packets

n Both ACKs and NAKs can be sent as special frames,or be attached to data frames going in the oppositedirection (Piggybacking)

01111110 Address Control Data Checksum 01111110

0 Send Seq.-No. P/F Recv Seq.-No.

For piggybacking

Page 24: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

24

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 47

ARQ Schemes

n The most common ARQ retransmission schemes:

– Stop-and-Wait ARQ

– Go-Back-N ARQ

– Selective Repeat ARQ

n The protocol for sending ACKs in all ARQ protocolsare based on the sliding window flow control scheme

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 48

Stop-and-Wait ARQ

n Stop-and-Wait ARQ is an addition to the Stop-and-Wait flow control protocol:

• Frames have 1-bit sequence numbers (SN = 0 or 1)• Receiver sends an ACK (1-SN) if frame SN is

correctly received• Sender waits for an ACK (1-SN) before transmitting

the next frame with sequence number 1-SN• If sender does not receive anything before a timeout

value expires, it retransmits frame SN

Page 25: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

25

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 49

Stop-and-Wait ARQ

Frame 1

n Lost Frame

A

B

AC

K 0

Frame 0

Timeout

AC

K 1

Frame 1

Frame 1 A

CK

0

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 50

Stop-and-Wait ARQ

Frame 1

n Lost ACK

A

B

AC

K 0

Frame 0

AC

K 1

Timeout

Frame 0 A

CK

1

Page 26: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

26

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 51

Go-Back-N ARQ

n Go-Back-N uses the sliding window flow controlprotocol. If no errors occur the operations are identicalto Sliding Window

n Operations:– A station may send multiple frames as allowed by the

window size

– Receiver sends a NAK i if frame i is in error. After that,the receiver discards all incoming frames until theframe in error was correctly retransmitted

– If sender receives a NAK i it will retransmit frame i andall packets i+1, i+2,... which have been sent, but notbeen acknowledged

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 52

Go-Back-N ARQ

Frame 0

n Lost FrameA

B

Frame 2

Frame 4

Frame 1

Frame 3

AC

K 3

Frame 5

Frame 6

NA

K 4

Frame 4

Frame 5

Frame 6

Frames 4,5,6are retransmitted

AC

K 6

Frames 5 and 6are discarded

Page 27: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

27

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 53

Go-Back-N ARQ

Frame 0

n Lost ACK

A

B

Frame 2

Frame 1

Frame 3

AC

K 3

Frame 0

Frame 5

Frame 4

Frame 3

Frame 4

Frames 0-4 are retransmitted

Timeout

Frame 1

Frame 2

AC

K 3

AC

K 5

Frames 3 and 4 are discarded

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 54

Details Go-Back-N ARQ

n Scenario 1:A transmits frame i, and B detects error in frame i, buthas received frames i-1, i-2,... correctly

è B sends NAKi

n Scenario 2:Frame i is lost or B does not recognize frame iAssume that A sends frame i+1 and B receives itè B sends NAKi, or A will timeout and retransmit frame i and all subsequent frames

A BFrame

Page 28: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

28

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 55

Details Go-Back-N ARQ

Scenario 3: B receives frame i and sends ACK(i+1) which is lost

è B may send an ACK(i+k) later which also acknowledges all frames <i+k (ACKs are “cumulative”)

orA retransmits frame i and all subsequent frames

Scenario 4: NAKi is lost

è A will eventually time out

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 56

Example of Go-Back-N ARQ

BA21

32

Framesreceived

Frames waitingfor ACK/NAK

3

ACK2frame 1 is correct, send ACK 2

BA3

2

43

4

NAK2frame 2 is in error, send NAK2

1

12

43

BA24

retransmit frame 2,3,4

13

n In Go-back-N, ifframes arecorrectly delivered,they are deliveredin the correctsequence

n Therefore, thereceiver does notneed to keep trackof `holes’ in thesequence ofdelivered frames

Page 29: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

29

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 57

Selective-Repeat ARQ

n Similar to Go-Back-N ARQ. However, the sender onlyretransmits frames for which a NAK is received

n Advantage over Go-Back-N:– Fewer Retransmissions.

n Disadvantages:– More complexity at sender and receiver

– Each frame must be acknowledged individually (nocumulative acknowledgements)

– Receiver may receive frames out of sequence

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 58

only Frame 4is retransmitted

Selective-Repeat ARQ

Frame 0

n Lost Frame

A

B

Frame 2

Frame 1

Frame 3

AC

K 2

Frame 5

Frame 6

AC

K 6

, NA

K 4

Frame 4

Frame 7

Frame 0

AC

K 7

AC

K 1

AC

K 3

AC

K 4

Frame 4

Frames 5 and 6are buffered

AC

K 5

AC

K 0

AC

K 1

Page 30: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

30

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 59

Example of Selective-Repeat ARQ

BA21

32

Framesreceived

Frames waitingfor ACK/NAK

3

ACK2frame 1 is correct, send ACK 2

BA3

2

43

4

NAK2frame 2 is in error, send NAK2

1

12

43

BA2

4retransmit frame 2

13

5

5

n Receiver mustkeep track of`holes’ in thesequence ofdelivered frames

n Sender mustmaintain one timerper outstandingpacket

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 60

Analysis of ARQ Protocols

n What is the efficiency of the discussed ARQprotocols?

n A number of assumptions:

– ACKs and NAKs are never lost, and frames arenot dropped.

– Sizes of ACKs, NAKs, and frame headers arenegligible.

Page 31: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

31

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 61

Analysis of Stop-and-Wait ARQ

n Parameters:

U= efficiencyTt= F/C transmission delay of a frameI= propagation delaya= I/Tt

P = Probability that a frame is in error

n Without Errors (P=0):

ITTU

t

t

2+=

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 62

n With Errors:

l Probability that k transmission attempts are needed tosuccessfully transmit a frame

n Expected number of attempts (=E[A]):

n Expected efficiency with errors

Analysis of Stop-and-Wait ARQ

-P)(Pk 1needed] attemptsP[k 1⋅= −

P)P(Pii]A[E

i −=−×−= ∑

= 11

111

aP

ITT)P(

)IT(]A[ETU

t

t

t

t

211

21

2 +−=

+⋅−=

+⋅=

Page 32: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

32

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 63

Without Errors

n W Tt > 2I + Tt

n W Tt < 2I + Tt

With Errors

n W Tt > 2I + Tt

n W Tt < 2I + Tt

Analysis of Go-Back-N ARQ

1=U

aWU

21+=

PU −=1

aPWU

21)1(

+−⋅=

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 64

Analysis of ARQ Protocols - Results

P=10-3

Page 33: Data Link Layer - Computer Sciencejorg/teaching/cs457/slides/datalink.pdf · Main Task of the data link layer: n Provide error-free transmission over a link Network Layer Data Link

33

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 65

Example DL Protocol: XModem

n XModem is a simple data link protocol which used to be popularfor communications over modems

n Xmodem uses Stop-and-Wait ARQ

n SOH: frame delimiter (start of header, “00000001”)

n NUM: 8-bit sequence number

n CNUM: bitwise complement of NUM

n Data: up to 128 bytes

n CKS: checksum = sum of the data field without overflow bit

1byte

SOH NUM CNUM Data CKS

1 <=128 11

University of V

irginia

CS

457 - Com

puter Netw

orks

© Jorg Liebeherr, 1998 66

XModem

n NAK: “00010101” sent every 15 sec when data is not received

n ACK: “00000110” sent if CKS is correct

n EOT: “00000100” end of transmission

n Variations of XModem:– XModem-CRC : uses CRC– YModem: allows to send 1,024 bytes of data in a

frame. Also: allows batch file transfers– ZModem