1 / 25

Data Link Layer

Data Link Layer. Data link layer. The communication between two machines that can directly communicate with each other. Basic property If bit A is sent before bit B, bit A will be received earlier than bit B Fundamental constraints Errors Computers have different capabilities

Download Presentation

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. Data link layer • The communication between two machines that can directly communicate with each other. • Basic property • If bit A is sent before bit B, bit A will be received earlier than bit B • Fundamental constraints • Errors • Computers have different capabilities • Delay is not zero

  3. Data link layer framing • What the data link layer does is to encapsulate the packets from the network layer into frames and send out these frames. • So we will discuss how to deliver these frames.

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

  5. Flag Bytes • Add special bytes to the beginning and the end of the frame. • What if the data contains the flag bytes? • Add ESC byte to each flag or ESC in the data. Stuffing. • Any time you see an ESC, the next byte is either ESC or FLAG naturally occurred in the data.

  6. Using Bits • More flexibility gained by sending bits. Using 01111110 as the flag bits. • If the data contains “011111”, add a 0 after the fifth 1. When the receiver sees in the data part “0111110,” it removes the last 0. • What if the original data contains “0111111”? • It will be stuffed as “01111101”, and won’t be regarded as the flag. The receiver will destuff it back into “0111111.” • What if the original data contains “0111110”? • It will be stuffed as “01111100”. The receiver will destuff it back into “0111110.”

  7. Date Link Layer Error detection • So the frames are sent. At the receiver side, how do you know that you received the frame correctly? • Using the error control code discussed last time. • Calculate the syndrome, if it is 0, then assume no error, if it is not zero, then some error. • Could this scheme give you the wrong judgment sometime? Can it be 100% accurate?

  8. Data Link Layer Protocols

  9. Data link layer protocols • Assume that the physical layer, the data link layer, and the network layer are three processes and communicate with each other. • Assume that the sender always has enough data to send. • Assume that the machines don’t crash. • Assume that the data flows only one direction (simplex).

  10. Protocol 1. • Your protocol really depends on the world you live in. • If (1) the link never screws up your bits, and (2) the receiver’s network layer process reads the bits infinitely fast, what should be your protocol?

  11. Protocol 1 • Sender. • Grab data from the network layer. • Send to physical layer. Goto 1. • Receiver • Get data from the physical layer • Give it to the network layer. Goto 1.

  12. Protocol 2 • Now remove assumption (2). The receiver’s network layer process is not infinitely fast. • How to design the protocol? • Note that the receiver may not be able to process a frame if it is still working on a frame received earlier.

  13. Protocol 2 • The receiver must provide some kind of acknowledgements. If the receiver never tells the sender anything, the sender has no way of knowing whether this speed is too high or too low. • The simplest form of ack is the receiver sends back an ack every time he receives a frame. • The sender waits for this ack to start sending the next frame. • Called “stop and wait.”

  14. Protocol 2 • Sender. • Grab data from the network layer and send to physical layer. • Wait (blocked here) for ack. • After getting ACK, goto 1. • Receiver • Wait (blocked here) for data. • After getting the data, give it to the network layer and send ack. Goto 1.

  15. Protocol 3 • Now, let’s remove assumption (1). There is now noise in the channel and frames could be corrupted. Both the data frame and the ack frame. • How to design your protocol? What are the considerations? • When a frame is lost, how can the sender know?

  16. Protocol 3 • So we can add a timer. If the sender does not receive the ack before the timer expires, he knows something is wrong and resend this frame. • How long should the timer be set? • Problems?

  17. Protocol 3 • A sent B frame F. • B received the frame. Sent ack to A. Ack got lost. • A time out. Resend F. • B received F. AGAIN!

  18. Sequence Number • Every frame has a sequence number. • Sender says I am sending the frame with sequence number m. • Receiver acks saying that I have successfully received the frame with sequence number m, please send me frame with sequence number m+1. • This will solve the duplication problem.

  19. Protocol 3 • Sender. • Grab data from the network layer. • Send to physical layer with the current sequence number S and start timer. • Wait for ACK. • If got an ACKm (expecting m+1), m:=m+1, repeat 1. • Else, timeout, repeat 2. • Receiver • Wait for data. • Get data from the physical layer. If it is with the expected sequence number m, give it to the network layer, m:=m+1. • send ACKm-1 (expecting m). Goto 1.

  20. Protocol 3 • Question 1. After sender sends frame m, will he receive Expc for lower than m? Will it receive Expc higher than m+1?

  21. Protocol 3 • Answer. No. Because when sender sent frame m, he must have received Expc from the receiver of m. Receiver keeps the sequence number and won’t decrease it. And it will not receiver Expc higher than m+1, because m+1 has not been sent yet.

  22. Protocol 3 • Question 2. After sending out an Expc of m+1, what are the possible frames the receiver can receive?

  23. Protocol 3 • Answer. The only possible frames he could receive is m or m+1. • In what case he receives m? (ACKm gets lost) In what case he receives m+1 (when everything goes fine)? Why can’t he receive m-1 (Because when sender sends m, he knows that m-1 is received correctly.)? Why can’t he receive m+2 (because sender won’t send m+2 before the receiver sends ACKm+1)?

  24. Protocol 3 • Question 3. How many bits should the sequence number have?

  25. Protocol 3 • Answer. 1 bit. At any time, there are only two possible frames both for the sender and the receiver.

More Related