Selective Repeat Selective Repeat Protocol 5 Further optimization

  • Slides: 11
Download presentation
Selective Repeat

Selective Repeat

Selective Repeat (Protocol 5) • Further optimization. • Receiver has a window greater than

Selective Repeat (Protocol 5) • Further optimization. • Receiver has a window greater than 1. • Don’t discard frames simply because some earlier frames was damaged. 2/22/2021 4: 07: 18 PM

Selective Repeat Sender. while (1) { If network layer got data, if current window

Selective Repeat Sender. while (1) { If network layer got data, if current window not full yet, read data, send to physical layer with the current frame ID. Start timer. Increment frame ID by one. If got ACKm, if m is outside the window, don’t do anything. If m is inside the window, consider all frames in the window with frame ID less than the m acked. Forward window to m. If timeout for frame m, resend m. } Receiver while (1) { Get frame from the physical layer. If it is within the receiver window and hasn’t been received before, fill in the slot, and forward the beginning of the receiver window if necessary. Deliver to the network layer all frames between the beginning of the old receiver window and the new receiver window – 1, inclusive. Send ACK (Expc = the beginning of the current receiver window). } • Note: assuming the sequence number is the frame ID. 2/22/2021 4: 07: 18 PM

The Timer • Each packet in the sender’s window should have a timer. •

The Timer • Each packet in the sender’s window should have a timer. • If the window contains F 0, F 1, F 2, F 3. Could it happen that the when the timer for F 0 expires, the timer for F 1 has not expired yet? Yes, if you do not send the frames one-by-one. • Could it happen that the timer for F 1 expires but the timer for F 0 has not? Yes, if F 0 has been retransmitted before. 2/22/2021 4: 07: 18 PM

Sequence Number • If the sequence number field is 3 bits, how large should

Sequence Number • If the sequence number field is 3 bits, how large should the sender/receiver window be? • Should the receiver has a different window size than the sender? No, larger --- makes no sense, the sender is not going to send that many outstanding frames, smaller --- wrong, because the receiver will discard such packets. • Window size should be 4. 2/22/2021 4: 07: 18 PM

Sequence Number • For 0 to be in my window again, I must have

Sequence Number • For 0 to be in my window again, I must have forwarded to 5. When I forwarded to 5, I must have got 4. I got 4 because the sender sent 4. The sender sent 4 only if it got ACK for 0. 2/22/2021 4: 07: 18 PM

Sequence Number • A proof. • Let the sequence number be log_2{N} bits. Let

Sequence Number • A proof. • Let the sequence number be log_2{N} bits. Let the window size be W, where W <= N/2. • Suppose the receiver gets a frame with sequence number m. He thinks it is for frame x. Could he actually receive frame x-N (with the same seq#)? • No. Because when x is in his window, the window has forwarded to x-W+1, at least. So he has got x-W. The sender has sent x-W. The sender will do so only if it has got ACK for x-2 W+1. If W <=N/2, the sender must have got ACK for x-N. 2/22/2021 4: 07: 18 PM

Selective Repeat 2/22/2021 4: 07: 19 PM

Selective Repeat 2/22/2021 4: 07: 19 PM

Piggybacking • Considered only one direction. Bidirection. • Piggybacking – Combining ACK with data

Piggybacking • Considered only one direction. Bidirection. • Piggybacking – Combining ACK with data – When no data? • Wait some time and ACK anyway. • Internet. PPP. 2/22/2021 4: 07: 20 PM

Framing • How does the receiver know where is the start and where is

Framing • How does the receiver know where is the start and where is the end of a frame? • Counter. Tell the receiver how many bytes there are in this frame. Problems? • The counter part could be corrupted and you are done.

Flag Bytes • Add special bytes to the beginning and the end of the

Flag Bytes • Add special bytes to the beginning and the end of the frame. • Problems? • What if the data contains the flag bytes? • Add ESC byte to each flag or ESC in the data. Stuffing.