DLL Protocols

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 24

Chapter 3

The Data Link Layer


Elementary Data Link Protocols

• The physical layer, data link layer, and network


layer are independent processes that communicate
by passing messages back and forth
• The data link layer accepts a packet, it encapsulates
the packet in a frame by adding a data link header
and trailer
• Thus Frame with some control info in header and
some checksum in trailer
• Frame is transmitted to the receiver, checksum is
computed at both side from error detecting
Elementary Data Link Protocols

• Receiver has nothing to do, it just wait for


something to happened.
• After arrival of frame it get from the layer-1,
process on frame and sent packet to the network
layer only information part
• Network layer must never given any part of the
frame header to distinguish the layers protocol
• Frames are transfer between layer 1 & 2, while
packets are transfer between layer 2 & 3
Protocol Definitions

Continued 

Some definitions needed in the protocols to follow.


These are located in the file protocol.h.
Protocol
Definitions
(ctd.)

Some definitions
needed in the
protocols to follow.
These are located in
the file protocol.h.
Elementary Data Link Protocols

• Some declarations are common to many protocols


in C, like data structures and procedures or library
routines.
• <protocol.h> header file is used for this
• Five data structures : boolean, seq_nr, packet,
frame_kind, and frame

• enum type and takes either T or F


Elementary Data Link Protocols
• typedef unsigned int seq_nr;
• A seq_nr is a small integer used to number the
frames, from 0 up to and including MAX_SEQ
• typedef struct{char data[MAX_PKT]} packet;
• A packet is the unit of information exchanged
between the network layer and the data link layer, it
contains MAX_PKT bytes
• A frame composed of four fields: kind, seq, ack, and
info, the first three contain control information and
the last contains actual data to be transferred. These
control fields are collectively called the frame
header.
Elementary Data Link Protocols

• kind field tells whether there are any data in the


frame, seq and ack fields are used for sequence
numbers and acknowledgements, info field of a
data frame contains a single packet, with variable
length.
Elementary Data Link Protocols
• Following library functions are used by almost
protocols
• void wait_for_event (event_type *event);
• This function for waiting the receiver for
something to happen, returns when something has
happened (like frame arrived).
• Finally the variable event of event_type tells what
happened,
• For e.g .event = frame_arrival,
event = chksum_err, etc.
Elementary Data Link Protocols
• void from_network_layer(packet *p);
• void to_network_layer (packet *p);
• Used by data link layer for pass packet to and from
data link layer to network layer, this functions are
used to pass the packets between layers
• void from_physical_layer (frame *r);
• void to_physical_layer (frame *s);
• Used to pass frames between layers
• This functions deal with the interface available
between the corresponding layers
Elementary Data Link Protocols
• For preventing the loses frames, data link layer must
start an internal timer when send a frame, if no reply
within a interval, clock times out
• void start_timer (seq_nr k);
• void stop_timer (seq_nr k);
• used to turn the timer on and off, after start the clock
running enable the time out event, and stop the clock
that disable the time out event
• void start_ack_timer(void);
• void stop_ack_timer(void);
• to start and stop auxiliary timer used to generate ack
under some conditions.
Elementary Data Link Protocols
• void enable_network_layer(void);
• void disable_network_layer(void);
• That allow and forbid the network layer for causing
a network_layer_ready event
• Data link layer enable n/w layer, then it has a
packet to be sent, event = network_layer_ready
• When network layer is disable it not sent such
event, it is prevented from swamping with packets
from it has no buffer space
• #define inc(k) if(k<MAX_SEQ) k++ else k=0
• Macro used to inc the sequence no by k
Elementary Data Link Protocols

• An Unrestricted Simplex Protocol


• A Simplex Stop-and-Wait Protocol
• A Simplex Protocol for a Noisy Channel
Unrestricted
Simplex
Protocol
Unrestricted Simplex Protocol
• A protocol that is as simple as it can be
• Data are transmitted in one direction only
• Both the transmitting and receiving network layers
are always ready
• Processing time can be ignored, and Infinite buffer
space is available
• And assume that the communication channel
between the data link layers never damages or loses
frames so assume to be error free
• So this protocol is known as unrealistic or
unrestricted simplex protocol
Unrestricted Simplex Protocol
• Protocol consists of two distinct procedures, a sender
and a receiver
• Sender runs in the data link layer of the source
machine, and the receiver runs in the data link layer
of the destination machine
• No sequence numbers or acknowledgements used
• The only event type possible is frame_arrival
• Sender side three actions performed: go fetch a
packet from network layer, construct an outbound
frame using variable s, and send the frame.
• Only info field is used here because no error and
flow control is required
Unrestricted Simplex Protocol
• The receiver is equally simple
• Initially, it waits for something to happen, the only
possibility being the arrival of a frame
• Frame arrives, wait_for_event() returns
event=frame_arrival, call to from_physical_layer()
and puts frame in the variable r
• Finally, the data portion is passed on to the network
layer, by calling to_network_layer(), and the data
link layer settles back to wait for the next frame
Simplex
Stop-and-
Wait
Protocol
A Simplex Protocol for a Noisy Channel

A positive
acknowledgement
with retransmission
protocol.
Continued 
A Simplex Protocol for a Noisy Channel (ctd.)

A positive acknowledgement with retransmission protocol.


Sliding Window Protocols

• A One-Bit Sliding Window Protocol


• A Protocol Using Go Back N
• A Protocol Using Selective Repeat
Sliding Window Protocols (2)

A sliding window of size 1, with a 3-bit sequence number.


(a) Initially.
(b) After the first frame has been sent.
(c) After the first frame has been received.
(d) After the first acknowledgement has been received.
A One-Bit Sliding Window Protocol (2)

Two scenarios for protocol 4. (a) Normal case. (b) Abnormal


case. The notation is (seq, ack, packet number). An asterisk
indicates where a network layer accepts a packet.
A Protocol Using Go Back N

Pipelining and error recovery. Effect on an error when


(a) Receiver’s window size is 1.
(b) Receiver’s window size is large.

You might also like