Data Link Layer - Computer Networks
Data Link Layer - Computer Networks
1 2 3 4 5
1) character count
Bit stuffing
(a) The original data.
(b) The data as they appear on the line.
(c) The data as they are stored in receiver’s memory after
destuffing.
Error Control:
Next problem: How to make sure all frames are eventually
delivered to the network layer at the destination, and in the
proper order.
The protocol calls for the receiver to send back special control
frames bearing positive and negative acknowledgements about
the incoming frames
Error Control:
If the sender receives a positive acknowledgement about a
frame ,it knows the frame has arrived safely.
on the other hand, a negative acknowledgement means that
something has gone wrong, and the frame must be transmitted
again.
An additional complication comes from hardware troubles.
Managing the Timers and sequence numbers so as to ensure
that each frame is ultimately passed to the network layer at the
destination exactly once.
Error Control:
Maintaining Timers for Error Control: When a sender
transmits a frame, it generally also starts a timer .
The timer is set to expire after an interval long enough for the
frame to reach the destination, be processed there ,and have
the acknowledgement to propagate back to the sender.
Normally, the frame will be correctly received and the
acknowledgement will get back before the timer runs out ,in
which case the timer will be cancelled.
However, if either the frame or the acknowledgement is lost
,the timer will go off ,alerting the sender to a potential
problem .the obvious solution is to just transmit the frame
again.
Sequence number is used to recognize the duplicate packet.
Flow control:
A sender that systematically wants to transmit
frames faster than the receiver can accept them..
When the sender is running on a fast (or lightly
loaded) computer and the receiver is running on a
slow (or heavily loaded machine)
The sender keeps pumping the frames out at a higher
rate until the receiver is completely swamped.
Even if the transmission is error free ,at a certain
point the receiver will simply be unable to handle the
frames as they arrive and will start to lose someone
To Prevent above situation two approaches are used
• Feedback- based flow control
• Rate-based flow control
For e.g.
On a reliable medium : Error Detection is sufficient where
the error rate is low and asking for retransmission after
Error Detection would work efficiently
In contrast, on an unreliable medium : Retransmission after
24=16>=12+4+1
16>=17
Take n=5
25=32>=12+5+1=18
packet
frame
In parts (a) and (b) transmitting station A acts the same way,
but part (b) receiving station B accepts frame 1 twice.
A simplex protocol for a Noisy Channel
The channel is noisy, frames may be damaged or lost
Good scene : data frame reaches intact, ack sent back and
received, next frame sent
Bad scene :
Data frame damaged or lost ..hence no ack – sender times
out and resends .. No problems
Data frame reaches intact but Ack lost .. Times out
source Destination
Ack(frame1)+Frame2
• When a data frame arrives, instead of immediately sending a separate
control frame, the receiver restrains itself and waits until the network layer
passes it the next packet.
• The acknowledgement is attached to the outgoing data frame
• Disadv: This technique is temporarily delaying outgoing
acknowledgements.
• If the datalinklayer waits longer than the senders timeout period, the
frame will be retransmitted.
Sliding window protocols:
Rule: sender waiting a fixed number of milliseconds. If a
new packet arrives quickly the acknowledgement is
piggybacked onto it. other wise if no new packet has arrived
by the end of this time period ,the data link layer just sends a
separate acknowledgement frame.
In sliding window protocol each frame contains a sequence
number ranging from 0 up to some maximum.
The maximum is usually 2n-1 so the sequence number fits
nicely in an n-bit field.
The stop-and-wait sliding window protocol uses n=1
restricting the sequence numbers 0 and 1.
The sender must keep all these frames in its memory for
possible retransmission
Sliding window protocols:
Thus if the maximum window size is n, the sender needs n
buffers to hold the unacknowledged frames
3 bit field -000
001
010..etc
here n=3 i.e. 23-1=7
window size is 0 to 7
Sliding window :: sender has a window of frames and maintains a
list of consecutive sequence numbers for frames that it is
permitted to send without waiting for ACKs.
receiver has a window that is a list of frame sequence numbers it is
permitted to accept.
Note – sending and receiving windows do NOT have to be the same
size.
Sliding window protocols:
Bits 8 8 8 >= 0 16 8