23
COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science York University Section M Topics: 1. Flow Control and ARQ Protocols 2. Stop-and-Wait ARQ 3. Go-Back N ARQ 4. Selective Repeat ARQ Garcia: Section 5.2

COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

  • Upload
    toki

  • View
    42

  • Download
    0

Embed Size (px)

DESCRIPTION

COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science York University Section M Topics: Flow Control and ARQ Protocols Stop-and-Wait ARQ Go-Back N ARQ Selective Repeat ARQ Garcia: Section 5.2. Automatic Repeat Request (ARQ). - PowerPoint PPT Presentation

Citation preview

Page 1: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

COSC 3213: Computer Networks IInstructor: Dr. Amir Asif

Department of Computer ScienceYork University

Section M

Topics:1. Flow Control and ARQ Protocols 2. Stop-and-Wait ARQ3. Go-Back N ARQ4. Selective Repeat ARQ

Garcia: Section 5.2

Page 2: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

2

Automatic Repeat Request (ARQ)

1. ARQ combines error detection and retransmission to ensure accurate data delivery despite transmission errors and PDU losses.

2. Basic goals of ARQ include: Error free, sequence-ordered delivery of PDU.

No duplication of PDU. Flow control when one of the host is slower.

3. Basic elements of the ARQ protocol includes: Error-detecting code with high probability of error detection.

Positive Acknowledgment (ACK) to indicate correct reception of a PDU. Negative Acknowledgment (NAK) to indicate error in a PDU or loss of a PDU. Timeout mechanism to cover scenarios where PDU is lost.

4. Recall that the error detection is performed by the data-link and transport layers. In our explanation, we will refer to the implementation of the ARQ protocol in the data-link layer. The same procedure can be used at the transport layer.

5. We will analyze three different ARQ protocols: Stop-and-Wait ARQ Go-Back N ARQ Selective Repeat ARQ

Page 3: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

3

Basic Elements of ARQ

Control frame

Info framePacket

Data-link

Network

Error-free packet

Data-link

Network

Information frame

CRCHeader Packet

Control frame: ACKs

CRCHeader

Transmitter A Receiver B

1. The network layer passes the packet to be transmitted to the data-link layer.2. The data-link layer encapsulates the packet into an information frame adding: (i) a header containing the sequence number of the frame and (ii) a trailer containing the CRC code.3. The physical layer is responsible for the delivery of the frame

4. The physical layer passes the info frame to data-link.5. The data-link extracts the sequence number from the header and the CRC code from the trailer.6. If no error is detected, the info packet is passed to the network layer and an ACK frame is transmitted to the transmitter

Page 4: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

4

Stop and Wait ARQ (1)

1. Transmitter A transmits an information frame 0 to the receiver and starts a timer.

2. Transmitter A stops and waits for the ACK frame from Receiver B.

3. If an ACK frame is received from Receiver B before the timer expires, Transmitter A starts transmission of the next information frame.

4. If the timer expires without receiving an ACK frame is received, Transmitter A retransmits the information frame 0.

Scenario I: Information Frame 1 gets lost.

Transmitter A

Receiver B

Frame 0 Frame 1

ACK

Frame 1

ACK

Time

Time-out

Frame 2

Page 5: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

5

Stop and Wait ARQ (2)

1. Loss of ACK frame leads to duplication of Frame 1 at Receiver B.

2. To avoid duplication in cases where ACK frames are lost, we add a sequence number S last

(indicating the current information fame number) to the header of the information frame.

Scenario II: ACK of Frame 1 gets lost

Transmitter A

Receiver B

Frame 0 Frame 1

ACK

Frame 1

ACK

Time

Time-out

Frame 2

ACK

1. Despite duplicate reception of Frame 1, Receiver B recognizes that same frame is received twiceand ignores the second copy of Frame 1.

Scenario III: Correct Operation for Scenario II

Transmitter A

Receiver B

Frame 0 Frame 1

ACK

Frame 1

ACK

TimeTime-out

Frame 2

ACK

Page 6: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

6

Stop and Wait ARQ (3)

Transmitter A

Receiver B

Frame 0 Frame 0 Frame 1

ACK 1

TimeTime-out

Frame 1

1. Despite duplicate reception of Frame 0, Receiver B ignores the second copy of Frame 0.

2. Transmitter A retransmits Frame 1 since it does not receive ACK 2.

Scenario V: Correct Operation for Scenario IV

ACK 1

Transmitter A

Receiver B

Frame 0 Frame 0

ACK

Frame 1

ACK

TimeTime-out

Frame 2

1. Transmitter assumes that Frame 1 is received correctly and proceeds with transmission of Frame 2.

2. To avoid loss of frames because of premature time-outs, we add a sequence number Rnext

(indicating the frame number of the next information frame) to the ACK frames.

Scenario IV: Timer expires prematurely

Page 7: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

7

Stop and Wait ARQ (4): Protocol Description

Initialization:

Transmitter in Ready mode.

Set transmitter-send-sequence number Slast = 0 and receiver-sequence-number Rnext = 0.

Transmitter: Ready Mode: Transmitter A prepares the requested information frame Slast with the sequence number

(Slast ) in the header, the packet data, and the CRC error detection code. Transmitter A then enters the wait mode and waits for acknowledgment ACK Rnext with Rnext = (Slast + 1) mod 2.

Wait Mode: During the wait stage, Transmitter A does not accept packets from the upper layer. If an acknowledgement is not received or if it is incorrectly received , Transmitter A stays in the wait mode till the timer expires out. If the timer times-out, Slast information frame is retransmitted with the same sequence number (Slast). If correct acknowledgement ACK Rnext is received, then Slast is set to Rnext and the transmitter returns to ready mode and the start of step 1.

Receiver: Receiver B is always in the ready mode. When a frame arrives, the frame is checked for errors.

If no error is detected and the received frame number is the expected number S last = Rnext, then the information frame is passed on to the higher layer, Rnext is updated to (Rnext + 1) mod 2, and ACK Rnext sent.

If the received information frame has errors, the frame is discarded with no action taken.

If the received information frame has no errors but incorrect sequence number, ACK Rnext is sent.

Page 8: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

8

Stop and Wait ARQ (5): Window Operation

State (0,0): Transmitter ready to transmit frame 0.

SlastRnext

0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

Timer

State (0,1): Frame 0 transmitted but not acknowledged

SlastRnext

0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

Timer

State (1,1): Transmitter gets ACK for Frame 0 before timer expires

SlastRnext

0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

Timer

Succ

essf

ul o

pera

tion

: Fra

me

0 co

rrec

tly

rece

ived

and

ack

now

ledg

ed

Page 9: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

9

Stop and Wait ARQ (5): Window Operation

State (0,0): Transmitter ready to transmit frame 0.

SlastRnext

0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

Timer

State (0,1): Frame 0 transmitted but not acknowledged

SlastRnext

0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

Timer

State (0,0): Timer expires

SlastRnext

0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

Timer

Uns

ucce

ssfu

l ope

rati

on: F

ram

e 0

not r

ecei

ved

Page 10: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

10

Stop and Wait ARQ (7): State Diagram

State Diagram

(0,0) (0,1)

(1,0) (1,1)

Global State:(Slast, Rnext) Error-free frame 0

arrives at receiver ACK forframe 0arrives attransmitter

ACK forframe 1arrives attransmitter

Error-free frame 1arrives at receiver

Unsuccessful operation:Frame 0 incorrectly received

Unsuccessful operation:Frame 1 incorrectly received

Page 11: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

11

Stop and Wait ARQ (8): Performance

tf

Transmissiondelay

Transmitter A

Receiver B

tprop

Propagation delay

tack tproc

Processingdelay at Rx

tprop

Propagationdelay

tproc

Processing

delay at Tx

t0 = total time to transmit 1 frame

First frame bit enters channelLast frame bit enters channel

First ACK bit enters channelLast ACK bit enters channel

Information Frame (nf bits)

ACK Frame (na bits)

R

n

R

nttttttt af

procpropackfprocprop 22220

Case 1: No transmission errors occurTime of transmission:

Number of information bits transmitted:

Effective transmission rate :

Transmission Efficiency:

of nn

oofeff tnnR 0

f

procprop

f

a

f

o

n

Rtt

nn

nn

eff RR 20 11

Effect of Frame overhead

Effect of ACK overhead

Effect of Delay-BW prod

Page 12: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

12

Stop and Wait ARQ (9): Performance

tf

Transmissiondelay

Transmitter A

Receiver B

tprop

Propagation delay

tack tproc

Processingdelay at Rx

tprop

Propagationdelay

tproc

Processing

delay at Tx

t0 = total time to transmit 1 frame

First frame bit enters channelLast frame bit enters channel

First ACK bit enters channelLast ACK bit enters channel

Information Frame (nf bits)

ACK Frame (na bits)

Case 2: Transmission errors occur with probability Pf

The transmission efficiency is reduced by a factor of (1 – Pf) to

Transmission Efficiency:

Activity 1: Assume that the information frames are 1250 bytes long with 25 bytes of overhead. The ACK frames are assumed to be 25 bytes long. Calculate the transmission efficiency of the Stop and Wait ARQ in a 1 Mbps transmission system assuming: (a) no transmission errors; and (b) transmission errors with a bit error rate of 106 and 104. Assume that the reaction time 2(tprop + tproc) = 100ms.

f

procprop

f

a

f

o

n

Rtt

nn

nn

feff PRR 20 111

Page 13: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

13

Go-Back-N ARQ (1)

1. Stop-and-Wait ARQ is highly inefficient especially at high bit error rates.

2. Go-back-N ARQ improves Stop-and-Wait ARQ by not waiting and allowing multiple information frames to be transmitted without acknowledgment.

3. Frames 0 to (Ws 1) are transmitted without any acknowledgement.

4. If ACK for frame 0 arrives before window is exhausted, transmitter continues to transmit.

5. If ACK for frame 0 is not received, transmitted goes back by N = Ws frames and begin retransmitting.

A

B

fr0 Time

fr1

fr2

fr3

fr4

fr5

fr6

fr3

ACK1

out of sequence frames

Go-Back-4: 4 frames are outstanding; so go back 4

fr5

fr6

fr4

fr7

fr8

fr9

ACK2

ACK3

ACK4

ACK5

ACK6

ACK7

ACK8

ACK9

Page 14: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

14

Stop-and-Wait vs. Go-Back N ARQ

Go-Back-N ARQ:

A

B

fr0

Timefr1

fr2

fr3

fr0

Receiver is looking for

Rnext=0

Out-of-sequence frames

Four frames are outstanding; so go back 4fr2

fr3

fr1

fr4

fr5

fr6

ACK1

ACK2

ACK3

ACK4

ACK5

ACK6

Stop-and-Wait ARQ:

A

B

Timefr0

fr0

Time-out expiresfr1

Receiver is looking for

Rnext=0

ACK1

Page 15: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

15

Go-Back N ARQ (3)1. Go-Back N ARQ fails if the total number of frames to be transmitted are less than the window size

Ws and one of the frames get lost.

2. Retransmissions will not be triggered since the window size at the transmitter is not exceeded.

3. To resolve the problem, we associate a timer with each transmitted frame.

4. Go-back-N is triggered as soon as one of the timers expires.

most recent transmission

oldest un-ACKed frame

Transmitter

Buffers:

Send Window:

Slast Slast+Ws1

...

Srecent

Framestransmittedand ACKed

Timer Slast

Slast+1

Srecent

Slast+Ws1

Timer

Timer

......

max Seq # allowed

ReceiverReceive Window:

Rnext

Framesreceived

Receiver will only accepta frame that is error-free and that has sequence number Rnext

When such frame arrives Rnext is incremented by one, so the receive window slides forward by one

Page 16: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

16

Go-Back-N ARQ (4): Protocol Description

Initialization: Assume window size = Ws

Transmitter: in Ready mode with Slast = Srecent = 0. Receiver: Rnext = 0.

Transmitter:

Ready Mode:

1. Transmitter A prepares frame Srecent with the sequence number (Srecent ) in the header, the packet data, and the CRC error detection code. A timer for the sent frame is started and Srecent = (Srecent + 1) modulo Ws.

2. If Srecent = (Slast + Ws 1) modulo Ws, Transmitter A enters the wait mode.

3. If Srecent ≠ (Slast + Ws 1) modulo Ws, Transmitter A goes to the ready mode.

Wait Mode:

1. If before timer expires, correct acknowledgement ACK Rnext is received with Rnext between Slast and Srecent, then Slast is set to Rnext , and the transmitter returns to the ready mode (step 1).

2. If timer of Slast expires, Srecent is reset to Slast and the transmitter returns to the ready mode (step 1)

Receiver:

1. Receiver B is always in the ready mode. When a frame arrives, the frame is checked for errors.

If no error is detected and the received frame number Slast equals Rnext, then the information frame is passed on to the higher layer. Rnext is updated to (Rnext + 1) mod Ws, and ACK Rnext sent.

If the received information frame has errors, the frame is discarded with no action taken.

If the received information frame has no errors but incorrect sequence number, ACK Rnext is sent.

Page 17: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

17

Go-Back N ARQ (5): Maximum Window SizeFor m = log2(M) bits sequence no. field in the header, maximum window size is: (N < 2m – 1).

Frames are still labeled from 0 to 2m – 1.

A

B

fr0

Timefr1

fr2

fr3

fr0

fr1

fr2

fr3

ACK1

M = 22 = 4, Go-Back-4:

ACK0

ACK2

ACK3

Transmitter goes back 4

Receiver has Rnext= 0, but it does not know whether its ACK for frame 0 was received, so it does not know whether this is the old frame 0 or a new frame 0

A

B

fr0

Timefr1

fr2

fr0

fr1

fr3

ACK1

M = 22 = 4, Go-Back-3:

ACK2

ACK3

Transmitter goes back 3

Receiver has Rnext= 3 , so it rejects the old frame 0

ACK3

ACK3

ACK0

fr3

Page 18: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

18

Go-Back N ARQ (6): Calculation of Time-out

1. The time-out value of the information frame should exceed the duration required to receive a frame acknowledgement once an information frame is transmitted.

2. Value of Time-out:

Tf Tf TprocTpropTprop

Tout

Info frame ACK frame

procfpropout TTTT 222

Page 19: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

19

Go-Back N ARQ (7): Performance Issues1. If there were no time-out because of lost or erroneous information or ACK frames, the time to transmit

an information frame in steady state will approach Tf , the transmission time.

2. Suppose that the probability of losing a frame due to error or packet losses = Pf , then the following table for successful transmission of the information frame can be constructed

Activity 2: Show that the average no. of attempts for successful delivery of an information frame is

with the average time required to transmit an information frame in Go-back-N ARQ is

and the efficiency og Go-back-N ARQ is

Sf

f WP

P

11attempts of no. Average

No. of Transmissions 1 1 + Ws 1 + 2Ws 1 + 3Ws 1 + 4Ws 1 + 5Ws

Probability 1 Pf Pf (1 Pf) (Pf )2(1Pf) (Pf )3(1Pf) (Pf )4(1Pf) (Pf )5(1Pf)

Sf

fGBN W

P

Pt

11

.111

100

ffS

n

n

t

nn

effGBN P

PWRR

Rs

f

GBN

f

Page 20: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

20

Go-Back N ARQ (8): Performance IssuesActivity 3: Repeat Activity 1 for Go-back-NARQ.

Assume that the information frames are 1250 bytes long with 25 bytes of overhead. The ACK frames are assumed to be 25 bytes long. Calculate the transmission efficiency of the Go-back-N ARQ in a 1 Mbps transmission system with reaction time of 100ms assuming a bit error rate of 10 6 and 104. Assume that the window size Ws is larger than the delay bandwidth product defined as the product of the reaction time with transmission rate.

Page 21: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

21

Selective Repeat ARQ

1. Go-back-N ARQ is inefficient because of the need to transmit all frames subsequent to an error frame.

2. An alternative to Go-back-N ARQ is the selective repeat ARQ.

3. Selective repeat ARQ has three differences from Go-back ARQ.

Receiver window size is increased so that out of order error-free frames can be accepted

Retransmission mechanism is modified so that individual frames can be retransmitted

In addition to ACK command, the receiver can also send a NACK command corresponding to the frame not received in a sequence of frames

A

B

fr0 Time

fr1

fr2

fr3

fr4

fr5

fr6

fr2

ACK1

fr8

fr9

fr7

fr10

fr11

fr12

ACK2

NAK2

ACK7

ACK8

ACK9

ACK10

ACK11

ACK12

ACK2

ACK2

ACK2

Page 22: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

22

Selective Repeat ARQ (2)

Transmitter

Buffers

Slast Slast+ Ws1

...Send Window

Srecent

Framestransmittedand ACKed

Timer Slast

Slast+ 1

Srecent

Slast+ Ws 1

Timer

Timer

...

...

Framesreceived

Receiver

Receive Window

Rnext Rnext + Wr1

Rnext+ 1

Rnext+ 2

Rnext+ Wr 1

...

Buffers

max Seq # accepted

Page 23: COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science

23

Selective Repeat ARQ (3)

ff

SR

f

fSR

mRS

Pn

n

P

tt

WW

11:Efficiency

1:Timeon Transmissi Average

2:Size WindowMaximum

0

1

Activity 4: Repeat Activity 1 for Selective Repeat ARQ.

Assume that the information frames are 1250 bytes long with 25 bytes of overhead. The ACK frames are assumed to be 25 bytes long. Calculate the transmission efficiency of the Selective Repeat ARQ in a 1 Mbps transmission system with reaction time of 100ms assuming a bit error rate of 106 and 104.

Comparison on Efficiency based on Activities 1, 3, and 4:

Pf Stop-and-wait Go-back-N ARQ Selective Repeat ARQ

106 8.8% 88.2% 97%

105 8.0% 45.4% 89%

104 3.3% 4.9% 36%