1 / 25

Data Link Layer

Data Link Layer. Sliding window. Think the frames the sender has to send as a continuous stream. The window contains the current frame being sent and is not acked yet. Every ack (Expc) moves the window forward one frame. Correctness Part is Done!.

mahola
Télécharger la présentation

Data Link Layer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Link Layer

  2. Sliding window • Think the frames the sender has to send as a continuous stream. The window contains the current frame being sent and is not acked yet. Every ack (Expc) moves the window forward one frame.

  3. Correctness Part is Done! • So our Protocol 3 will work without causing errors. ARQ. (automatic repeat request) • So the next step is the optimization. • Any one sees the problem?

  4. Optimization • Consider an example of • 500ms delay. 50kbps. Each frame is 1000 bits.

  5. Large link delays • 500ms delay. 50kbps. Each frame is 1000 bits. • What is the link efficiency? • The time to send 1000 bits is 1000/50,000=20ms. • At time 520 ms, the receiver gets the entire frame, and send ACK back. Assume ACK is small. • At time 1020ms, the sender gets the ACK, and sends the next frame.

  6. Solution • So, increase the window size from 1 to n. • Would want to have a large window size whenever the bandwidth delay product is large. • If bandwidth is large, sending is fast • If delay is large, even a moderate bandwidth will cause a poor efficiency

  7. Question • Given link speed and link delay, how large should the window be to achieve 100% efficiency?

  8. Sender window • The sender has a window from m+1 to m+n means that • the sender has received ack from the receiver for frame up to m, • the sender is allowed to send m+1, m+2, …, m+n. These packets can be outstanding without ack. • Sender has to maintain the sender window (buffering all outstanding frames), maintain timeout for all outstanding frames. • The size of the sender window is determined by the bandwidth and link delay

  9. Go-Back-N • Let’s first consider the receiver’s window size is only 1. • This is called Go-Back-N.

  10. Go-Back-N (Protocol 4) Sender. while (1) { If network layer got data, if current window not full yet, read data, send to physical layer with the 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 no more than the m acked. Forward window to m+1. If timeout for frame m, resend all frames in the window with frame ID no less than m. } Receiver while (1){ Wait to get data from the physical layer (blocked here until data got). After getting data: (1) If the data is with the expected frame ID m, give the frame to the network layer, increment the frame ID by one; (2) Send the ACK with the current frame ID. } • Note: assuming the sequence number is the frame ID.

  11. Go-Back-N • Two new things. • Cumulative ACK • Resend every frame after the timeout frame

  12. Go-Back-N

  13. Go-Back-N • What if ACK is lost?

  14. Go-Back-N • Works fine is error is rare. Achieves full capacity. • Else wastes bandwidth.

  15. Sequence Number • If the sequence number field is large enough, just use frame ID as sequence number. • Else, how many bits do we need?

  16. Sequence number • Using the sequence number is to make sure that the receiver can be sure that a received frame is not a duplicate of some other frames. • Using finite number of bits means that some frames will have the same sequence number. • So, should make sure that the receiver is sure that when a frame with seq#m is received, the sender has got ACK for all previous frames with the same seq#.

  17. Sequence Number • Say the sequence number field is 2 bits. • Will this be true if the window size is 4? • No, because the sender may send 0,1,2,3. Then the receiver sends ACK0,1,2,3. If one of the ACK got through, the sender will send frame 4 with seq#0. If none of the ACK got through, the sender will send frame 0 with seq#0.

  18. Sequence number • Solution? • Use window size less than 4. Say, 3. • Now, if the receiver gets frame 0,1,2, it sends ACK0,1,2. Then, if it receives a frame with seq#0 again, will it be able to tell whether it is a new frame or a retransmission? • Yes, because the receiver will accept frame with seq#3 first. It knows that if the sender sends seq#3, it must have got ack for frame 0.

  19. Protocol 5 – Selective Repeat • Further optimization. • Receiver has a window greater than 1. Don’t discard frames simply because some earlier frames was damaged. • If a frame times out, only retransmit that frame.

  20. Protocol 5 – Selective Repeat Sender. while (1) { If network layer got data, if current window not full yet, read data, send to physical layer with the 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 no more than the m acked. Forward window to m+1. If timeout for frame m, resend frame m. } Receiver while (1) { Wait (blocked here) and 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, and deliver to the network layer all frames between the beginning of the old receiver window and the new receiver window – 1, inclusive. Send ACKm (m+1= the beginning of the current receiver window). } • Note: assuming the sequence number is the frame ID.

  21. The Timer • Each packet in the sender’s window should have a timer. • If the window contains F0,F1,F2,F3. Could it happen that the when the timer for F0 expires, the timer for F1 has not expired yet? Yes, e.g., when you do not send the frames one-by-one. • Could it happen that the timer for F1 expires but the timer for F0 has not? Yes, if F0 has been retransmitted before.

  22. Sequence Number • If the sequence number field is 3 bits, how large should the sender/receiver window be? • Should the receiver have 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.

  23. 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.

  24. 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-2W+1. If W <=N/2, the sender must have got ACK for x-N.

  25. Piggybacking • Considered only one direction. Bidirection. • Piggybacking • Combining ACK with data • When no data? • Wait some time and ACK anyway. • Internet. PPP.

More Related