Presentation is loading. Please wait.

Presentation is loading. Please wait.

COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science York University Section M Topics: 1.Flow Control and ARQ Protocols.

Similar presentations


Presentation on theme: "COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science York University Section M Topics: 1.Flow Control and ARQ Protocols."— Presentation transcript:

1 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

2 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

3 3 Basic Elements of ARQ Control frame Info frame Packet Data-link Network Error-free packet Data-link Network Information frame CRCHeaderPacket Control frame: ACKs CRCHeader Transmitter AReceiver 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

4 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 0Frame 1 ACK Frame 1 ACK Time Time-out Frame 2

5 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 0Frame 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 twice and ignores the second copy of Frame 1. Scenario III: Correct Operation for Scenario II Transmitter A Receiver B Frame 0Frame 1 ACK Frame 1 ACK Time Time-out Frame 2 ACK

6 6 Stop and Wait ARQ (3) Transmitter A Receiver B Frame 0 Frame 1 ACK 1 Time Time-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 ACK Frame 1 ACK Time Time-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 R next (indicating the frame number of the next information frame) to the ACK frames. Scenario IV: Timer expires prematurely

7 7 Stop and Wait ARQ (4): Protocol Description Initialization: Transmitter in Ready mode. Set transmitter-send-sequence number S last = 0 and receiver-sequence-number R next = 0. Transmitter:  Ready Mode: Transmitter A prepares the requested information frame S last with the sequence number (S last ) in the header, the packet data, and the CRC error detection code. Transmitter A then enters the wait mode and waits for acknowledgment ACK R next with R next = (S last + 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, S last information frame is retransmitted with the same sequence number (S last ). If correct acknowledgement ACK R next is received, then S last is set to R next 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 = R next, then the information frame is passed on to the higher layer, R next is updated to (R next + 1) mod 2, and ACK R next 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 R next is sent.

8 8 Stop and Wait ARQ (5): Window Operation State (0,0): Transmitter ready to transmit frame 0. S last R next 0 1 Timer State (0,1): Frame 0 transmitted but not acknowledged S last R next 0 1 Timer State (1,1): Transmitter gets ACK for Frame 0 before timer expires S last R next 0 1 Timer Successful operation : Frame 0 correctly received and acknowledged

9 9 Stop and Wait ARQ (5): Window Operation State (0,0): Transmitter ready to transmit frame 0. S last R next 0 1 Timer State (0,1): Frame 0 transmitted but not acknowledged S last R next 0 1 Timer State (0,0): Timer expires S last R next 0 1 Timer Unsuccessful operation: Frame 0 not received

10 10 Stop and Wait ARQ (7): State Diagram State Diagram (0,0) (0,1) (1,0) (1,1) Global State: (S last, R next ) Error-free frame 0 arrives at receiver ACK for frame 0 arrives at transmitter ACK for frame 1 arrives at transmitter Error-free frame 1 arrives at receiver Unsuccessful operation: Frame 0 incorrectly received Unsuccessful operation: Frame 1 incorrectly received

11 11 Stop and Wait ARQ (8): Performance t f Transmission delay Transmitter A Receiver B t prop Propagation delay t ack t proc Processing delay at Rx t prop Propagation delay t proc Processing delay at Tx t 0 = total time to transmit 1 frame First frame bit enters channel Last frame bit enters channel First ACK bit enters channel Last ACK bit enters channel Information Frame (n f bits) ACK Frame (n a bits) Case 1: No transmission errors occur Time of transmission: Number of information bits transmitted: Effective transmission rate : Transmission Efficiency: Effect of Frame overhead Effect of ACK overhead Effect of Delay-BW prod

12 12 Stop and Wait ARQ (9): Performance t f Transmission delay Transmitter A Receiver B t prop Propagation delay t ack t proc Processing delay at Rx t prop Propagation delay t proc Processing delay at Tx t 0 = total time to transmit 1 frame First frame bit enters channel Last frame bit enters channel First ACK bit enters channel Last ACK bit enters channel Information Frame (n f bits) ACK Frame (n a bits) Case 2: Transmission errors occur with probability P f The transmission efficiency is reduced by a factor of (1 – P f ) 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 10  6 and 10  4. Assume that the reaction time 2(t prop + t proc ) = 100ms.

13 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 (W s  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 = W s frames and begin retransmitting. A B fr 0 Time fr 1 fr 2 fr 3 fr 4 fr 5 fr 6 fr 3 ACK1ACK1 out of sequence frames Go-Back-4: 4 frames are outstanding; so go back 4 fr 5 fr 6 fr 4 fr 7 fr 8 fr 9 ACK2ACK2 ACK3ACK3 ACK4ACK4 ACK5ACK5 ACK6ACK6 ACK7ACK7 ACK8ACK8 ACK9ACK9

14 14 Stop-and-Wait vs. Go-Back N ARQ Go-Back-N ARQ: A B fr 0 Time fr 1 fr 2 fr 3 fr 0 Receiver is looking for R next =0 Out-of-sequence frames Four frames are outstanding; so go back 4 fr 2 fr 3 fr 1 fr 4 fr 5 fr 6 ACK1ACK1 ACK2ACK2 ACK3ACK3 ACK4ACK4 ACK5ACK5 ACK6ACK6 Stop-and-Wait ARQ: A B Time fr 0 fr 0 Time-out expires fr 1 Receiver is looking for R next =0 ACK1ACK1

15 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 W s 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: S last S last +W s  1... S recent Frames transmitted and ACKed Timer S last S last +1 S recent S last +W s  1 Timer... max Seq # allowed Receiver Receive Window: R next Frames received Receiver will only accept a frame that is error-free and that has sequence number R next When such frame arrives R next is incremented by one, so the receive window slides forward by one

16 16 Go-Back-N ARQ (4): Protocol Description Initialization: Assume window size = W s Transmitter: in Ready mode with S last = S recent = 0. Receiver: R next = 0. Transmitter: Ready Mode:  Transmitter A prepares frame S recent with the sequence number (S recent ) in the header, the packet data, and the CRC error detection code. A timer for the sent frame is started and S recent = (S recent + 1) modulo W s.  If S recent = (S last + W s  1) modulo W s, Transmitter A enters the wait mode. 1.If S recent ≠ (S last + W s  1) modulo W s, Transmitter A goes to the ready mode. Wait Mode: 1.If before timer expires, correct acknowledgement ACK R next is received with R next between S last and S recent, then S last is set to R next, and the transmitter returns to the ready mode (step 1). 2.If timer of S last expires, S recent is reset to S last 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 S last equals R next, then the information frame is passed on to the higher layer. R next is updated to (R next + 1) mod W s, and ACK R next 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 R next is sent.

17 17 Go-Back N ARQ (5): Maximum Window Size For m = log 2 (M) bits sequence no. field in the header, maximum window size is: (N < 2 m – 1). Frames are still labeled from 0 to 2 m – 1. A B fr 0 Time fr 1 fr 2 fr 3 fr 0 fr 1 fr 2 fr 3 ACK1ACK1 M = 2 2 = 4, Go-Back-4: ACK0ACK0 ACK2ACK2 ACK3ACK3 Transmitter goes back 4 Receiver has R next = 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 fr 0 Time fr 1 fr 2 fr 0 fr 1 fr 3 ACK1ACK1 M = 2 2 = 4, Go-Back-3: ACK2ACK2 ACK3ACK3 Transmitter goes back 3 Receiver has R next = 3, so it rejects the old frame 0 ACK3ACK3 ACK3ACK3 ACK0ACK0 fr 3

18 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: TfTf TfTf T proc T prop T out Info frameACK frame

19 19 Go-Back N ARQ (7): Performance Issues 1.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 T f, the transmission time. 2.Suppose that the probability of losing a frame due to error or packet losses = P f, 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 No. of Transmissions11 + W s 1 + 2W s 1 + 3W s 1 + 4W s 1 + 5W s Probability1  P f P f (1  P f )(P f ) 2 (1  P f )(P f ) 3 (1  P f )(P f ) 4 (1  P f )(P f ) 5 (1  P f )

20 20 Go-Back N ARQ (8): Performance Issues Activity 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 10  4. Assume that the window size W s is larger than the delay bandwidth product defined as the product of the reaction time with transmission rate.

21 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 fr 0 Time fr 1 fr 2 fr 3 fr 4 fr 5 fr 6 fr 2 ACK1ACK1 fr 8 fr 9 fr 7 fr 10 fr 11 fr 12 ACK2ACK2 NAK2NAK2 ACK7ACK7 ACK8ACK8 ACK9ACK9 ACK10ACK10 ACK11ACK11 ACK12ACK12 ACK2ACK2 ACK2ACK2 ACK2ACK2

22 22 Selective Repeat ARQ (2) Transmitter Buffers S last S last + W s  1... Send Window S recent Frames transmitted and ACKed Timer S last S last + 1 S recent S last + W s  1 Timer... Frames received Receiver Receive Window R next R next + W r  1 R next + 1 R next + 2 R next + W r  1... Buffers max Seq # accepted

23 23 Selective Repeat ARQ (3) 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 10  6 and 10  4. Comparison on Efficiency based on Activities 1, 3, and 4: PfPf Stop-and-waitGo-back-N ARQSelective Repeat ARQ 10  6 8.8%88.2%97% 10  5 8.0%45.4%89% 10  4 3.3%4.9%36%


Download ppt "COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science York University Section M Topics: 1.Flow Control and ARQ Protocols."

Similar presentations


Ads by Google