Data Link Layer - PowerPoint PPT Presentation

About This Presentation
Title:

Data Link Layer

Description:

Data Link Layer * * * * * * * * * * * * What if when the receiver gets m-1, but took a while to send ACKm. The sender timeouts, and resends m-1. – PowerPoint PPT presentation

Number of Views:164
Avg rating:3.0/5.0
Slides: 26
Provided by: zhen6
Learn more at: http://www.cs.fsu.edu
Category:
Tags: data | layer | link

less

Transcript and Presenter's Notes

Title: Data Link Layer


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

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

6
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. Or, a
    FLAG is a real FLAG if not proceeded by ESC.

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

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 dont 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 receivers 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 receivers
    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, lets 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 m1.
  • This will solve the duplication problem.

19
Protocol 3
  • Sender (maintains m as the sequence number up
    to which has been ACKed)
  • Grab data from the network layer.
  • Send to physical layer with the current sequence
    number , i.e., m1 and start timer.
  • Wait for ACK.
  • If got an ACKm1, mm1, repeat 1.
  • Else, timeout, repeat 2.
  • Receiver (maintains m as the sequence number up
    to which has been received)
  • Wait for data.
  • Get data from the physical layer. If it is with
    the expected sequence number, i.e., m1, give it
    to the network layer, mm1.
  • send ACKm. Goto 1.

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

21
Protocol 3
  • Answer. No. Because when sender sent frame m, he
    must have received ACK from the receiver of m-1.
    Receiver keeps the sequence number and wont
    decrease it. And it will not receive ACK higher
    than m, because m1 has not been sent yet.

22
Protocol 3
  • Question 2. After sending out an ACKm, what are
    the possible frames the receiver can receive?

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

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.
Write a Comment
User Comments (0)
About PowerShow.com