Simplex stop and_wait_protocol

3,406 views 25 slides Aug 10, 2016
Slide 1
Slide 1 of 25
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25

About This Presentation

This presentation gives you the basic understanding about the simplex stop and wait protocol. It contains stop and wait ARQ and algorithms for stop and wait ARQ, and simplex stop and wait ARQ. Moreover it contains the case studies to make readers understand the protocol easily.


Slide Content

SIMPLEX STOP AND WAIT PROTOCOL by AF.Musfira 2010/ICT/38 STOP AND WAIT 8/10/2016 2010/ICT/38 1

Flow control deals with problem that sender transmits frames faster than receiver can accept, and solution is to limit sender into sending no faster than receiver can handle 8/10/2016 2010/ICT/38 2

Consider the simplex case: data is transmitted in one direction 8/10/2016 2010/ICT/38 3

Stop and wait: sender sends one data frame , waits for acknowledgement (ACK) from receiver before proceeding to transmit next frame – This simple flow control will break down if ACK gets lost or errors occur → sender may wait for ACK that never arrives 8/10/2016 2010/ICT/38 4

Simplex Protocol for a Noisy Channel For noisy link, pure stop and wait protocol will break down, and solution is to incorporate some error control mechanism 8/10/2016 2010/ICT/38 5

Automatic Repeat reQuest Is an error-control method for data transmission uses acknowledgements and timeouts to achieve reliable data transmission over an unreliable service. 8/10/2016 2010/ICT/38 6

STOP AND WAIT ARQ 8/10/2016 2010/ICT/38 7

Stop and wait with ARQ: Is an error control method, is incorporated with stop and wait protocol • A transmits frame one • B receives A1 • B generates ACK • ACK is lost • A times out, retransmits • B gets duplicate copy (sending on to network layer) 8/10/2016 2010/ICT/38 8

If error is detected by receiver, it discards the frame and send a negative ACK ( NAK ), causing sender to re-send the frame In case a frame never got to receiver, sender has a timer: each time a frame is sent, timer is set → If no ACK or NAK is received during timeout period, it re-sends the frame Timer introduces a problem: Suppose timeout and sender retransmits a frame but receiver actually received the previous transmission → receiver has duplicated copies To avoid receiving and accepting two copies of same frame, frames and ACKs are alternatively labeled 0 or 1: ACK0 for frame 1, ACK1 for frame 0 8/10/2016 2010/ICT/38 9

Frames Packet Error Free Packet Transmitter Receiver Information Frame Control Frame Timer is set after each frame transmission 8/10/2016 2010/ICT/38 10

Information Frame Acknowledgement Frame header Information Packet CRC Header CRC 8/10/2016 2010/ICT/38 11

Typically the transmitter adds a redundancy check number to the end of each frame. The receiver uses the redundancy check number to check for possible damage. If the receiver sees that the frame is good, it sends an ACK. If the receiver sees that the frame is damaged, the receiver discards it and does not send an ACK—pretending that the frame was completely lost, not merely damaged. 8/10/2016 2010/ICT/38 12

Need for sequence numbers 1 bit  sequence number  in the header of the frame, alternating (from 0 to 1) in subsequent frames. When the receiver sends an ACK, it includes the sequence number of the next packet it expects. This way, the receiver can detect duplicated frames by checking if the frame sequence numbers alternate. If two subsequent frames have the same sequence number, they are duplicates, and the second frame is discarded. Similarly, if two subsequent ACKs reference the same sequence number, they are acknowledging the same frame. 8/10/2016 2010/ICT/38 13

Case 1 Sender sends the frame 0 to the destination and simultaneously a timer is started. The destination accepts the frame since it was expecting frame 0 . Receiver sends an acknowledgement ACK 1 informing the sender that it has successfully received frame 0 and is expecting for frame 1. This acknowledgement reaches sender before the timer of frame 0 expires. 8/10/2016 2010/ICT/38 14

1 1 1 A B 1 1 1 1 1 1 Frame 0 ACK 1 Request Arrived Sn Sn Rn Sender Receiver Start Stop Arrived 8/10/2016 2010/ICT/38 15

Case 2 Sender sends frame 0 to the destination and simultaneously timer is started. Frame 0 is lost before reaching the destination. Since destination didn’t receive frame 0 no acknowledgement is sent. Eventually timer for frame 0 expires and sender resends frame 0. This process continues until it reaches acknowledgement for frame 1. 8/10/2016 2010/ICT/38 16

A B 1 1 1 Frame Request 1 1 1 1 1 1 1 1 1 Frame 0(resent ) ACK 1 timeout Arrived Sn Sn Rn Arrived Stop 8/10/2016 2010/ICT/38 17

Case 3 Sender sends frame 0 to the destination and simultaneously timer is started. The destination accepts the frame since it was expecting frame 0 . Receiver sends an acknowledgement ACK 1 informing the sender that it has successfully received frame 0 and is expecting for frame 1. The acknowledgement gets lost and it doesn’t reach the sender. Eventually timer for frame 0 expires and sender resends frame 0 . Now since the receiver is expecting for frame 1, it will safely discard the frame 0 and once again sends acknowledgement ACK 1 . 8/10/2016 2010/ICT/38 18

A B 1 1 1 Request Sn Start Frame 0 1 1 1 Rn Arrived ACK 1 Lost 1 1 1 1 1 1 1 1 1 Frame 0(resent ) ACK 1 Arrived Sn Sn Rn Discard, Duplicate timeout Stop 8/10/2016 2010/ICT/38 19

Sender-site algorithm for stop and wait ARQ Sn =0; Cansend =true; While(true) { Waitforevent() If(event( requesttosend )AND cansend ) { Getdata (); Makeframe ( Sn ); Storeframe ( Sn ) Sendframe ( Sn ); Starttimer () Cansend =false } 8/10/2016 2010/ICT/38 20

Contd Waitforevent (); if(event( arrivalnotification ) { Receiveframe ( ackno ); If( ackno == Sn ) { Stoptimer (); Purge(Sn-1); Cansend =true; } } If(event(timeout)) { Starttimer (); Resendframe (Sn-1); } } 8/10/2016 2010/ICT/38 21

Receiver-site algorithm for Stop and Wait ARQ Rn = 0; While (true) { WaitForEvent ( ); If (Event ( ArrivalNotification ) ) { ReceiveFrame ( ); If (corrupted (frame) ); sleep ( ); { ExtractData ( ); DelieverData ( ); Rn = Rn + 1; } SendFrame ( Rn ); } } 8/10/2016 2010/ICT/38 22

Advantages of Stop and Wait ARQ over simple Stop and Wait protocol It can be used for noisy channels It has both error and flow control mechanism It has a timer implementation 8/10/2016 2010/ICT/38 23

Efficiency is very less. Only 1 frame is sent at a time. Timer should be set for each individual frame. No pipelining. Sender window size is 1 ( disadvantage over go back n ARQ ). Receiver window size is 1 ( disadvantage over selective repeat ARQ). Disadvantages of Stop and Wait ARQ 8/10/2016 2010/ICT/38 24

THANK YOU 8/10/2016 2010/ICT/38 25