CS 3413 Data Communications Notes: Data Link Layer Protocols
This material is taken from the Networks book of Tanenbaum
Stop and Wait Code
protocol.h
Sequential Receive Code
Nonsequential Receive Code
Protocol Model:
- The protocols are event driven.
- The network layer provides the data to send in the form of packets.
- The network layer generates a network_layer_ready event
when it has data to send.
- from_network_layer provides the packet which becomes the info
field of the frame.
- to_network_layer is used when a frame come in form the network
to give it to the network layer.
- The physical layer provides frames from the network.
- The physical layer generates a frame_arrival event when a frame
is available from the network.
- from_physical_layer provides the frame.
- Other events are: timeout and chksum_err.
- Look at protocol.h.
Sequential Receive (Protocol 5 in Tanenbaum)
This protocoal handles pipelining.
This is important if the propagation delay is large compared to
the frame time.
Idea:
- Sequence numbers can have more than one bit.
- Calculate round trip propagation delay in terms of frame time.
- Be prepared to send that many frames without an ack.
- If timing is right first ack will come in at just the right time.
Piggyback Acks:
- Use when the protocol is bidirectional.
- Both hosts are senders and receivers.
- Used when both hosts have a lot of data to send.
- An ack for the last frame correctly received is send along with a
data frame.
- Frame have a type:
- data: also contains an ack
- ack: contains no data
- nak: negative ack (used in the next protocol)
This protocol (Protocol 5, Sequential Receive):
- This protocol uses piggyback acks.
- In this protocol the receiver expects frames to come in in the right order.
- If they do not, throw away other frames.
- This has a receiver window of size 1, but the sender window may be larger.
- It can be very efficient if the error rate is low.
- However, it handles errors in an inefficient way.
Some features of this protocol 5:
- A host must keep track of sequence numbers for sending and receiving.
- Can disable network layer so it does not overwhelm DLL.
- There is a timer for each sequence number.
- There is a buffer for each sending sequence number
- The send buffers contain packets, not frames.
- Max number of outstanding frames is MaxSeq, not MaxSeq+1:
- Suppose MaxSeq = 7
- Send frames 0 through 7
- Ack frame 7
- Send frames 8 through 15 (seq numbers 0 - 7)
- Frames 8 through 15 get lost
- Ack frame 7 again (piggybacked on a data frame)
- Sender thinks ack 7 is for frame 15
Problem: What to do if receiver does not have a data frame to send?
      What should it do about sending an Ack?
Protocol 5 does not handle this.
Some important variables in this protocol:
- sender next_frame_to_send: a sequence number
- sender ack_expected: sequence number of first buffered frame
- sender nbuffered: number of unacked frames
- sender buffer: array of frames not acked
- receiver frame_expected: sequence number of only frame to be received
What does this protocol have to do for each of the following events:
- network layer ready
- frame arrival
- checksum error
- timeout
Nonsequential Receive (Protocol 6 in Tanenbaum)
- Allows for frames which are not data frames.
- Receiver has Ack timer to send Ack if no data to send for a while.
- The Ack timer is started with start_ack_timer.
- The Ack timeout event is called network_layer_idle.
- Receiver can send NAK if a receive error occurs or frames arrive out
of order.
Possible receive errors:
- Checksum error
- Frame out of order
Note: This version only sends Naks for frame_expected
It keeps a single boolean variable, no_nak,
which is true if no NAK has
been sent for frame_expected, so multiple Naks are not sent.
- Sender's window starts at zero and grows to some maximum MaxSeq
- Receiver's window size is always fixed at some value
- Receiver has multiple buffers
- Each buffer has a bit, arrived, indicating if it is full
- When a frame comes in, if it is in the receiving window and not already
present, it is stored.
- When the first frame of the receiver's window comes in,
it and all frames
consecutively after it are sent to the network layer and the window is
adjusted.
- Note: Receiver's window cannot exceed half of number of sequence numbers.
This is because when the receiver advances its window, the new set of
sequence numbers cannot overlap the old one.
Example:
- Suppose 3-bit sequence numbers and receiver's and sender's window both
size 7.
- Sender can send up to 7 frames which are not acknowledged.
- Sender sends 0-6
- Receiver can accept 0-6.
- 0-6 received and sent to network layer,
- receiver advances window to 7,0,1,2,3,4,5
- All acks for 0-6 are lost.
- Sender times out and resends 0 (also 1,2,3,4,5,6).
- Receiver receives 0 which is in its window, and acks 6 again.
- Sender advances sending window to 7,0,1,2,3,4,5
- Sender sends 7.
- Receiver receives 7. It now can send 7 and 0 to network layer.
- Unfortunately, this is the wrong 0.
The following are the events for protocol 6.
What needs to be done in each case?
- network layer ready
- frame arrival
- checksum error
- timeout
- ack timeout
Run the network protocol simulator remotely