Data Link Control 2
Data Link Control 2
CSC 225
Bit stuffing: (a) the original data (b) Data on the line ©
data in the receiver’s memory
b) Framing
Adv:
• The boundary between two frames can be unambiguously
recognized by the flag pattern.
• If the receiver looses track of where it is, all it has to do is
to scan the input for flag sequence, since they can only
occur at frame boundaries and never within data
• Many data link layer protocols use: character count with
one of the other methods.
• When a frame arrives the count field is used to locate the
end of the frame. Only if the appropriate delimeter is
present at that position and the checksum is correct, is the
frame accepted as valid.
Framing
Questions from Chapter 3: Computer networks by Andrew
Tanenbaum
• Q1
• Q2
• Q3
• Q4: One of your classmates has pointed out that it is
wasteful to end each frame with a flag byte and then
begin the next one with a second flag byte. One flag
byte could do the job as well and a byte saved is a byte
earned. Do you agree?
• Q5
c) Error control
• Acknowledgements
• Timers
• Sequence numbers
c) Error control
• The usual way to ensure reliable delivery is to provide
sender with some feedback about what is happening on the
other end of the line.
• This is especially so for connection oriented service.
• The receiver sends back to the sender a special control frame
bearing positive or negative acknowledgement about the
incoming frames.
c)Error control
• Positive acknowledgement about a frame informs the
sender that the frame arrived safely
• A negative acknowledgement means that something has
gone wrong and the frame must be transmitted again
c)Error control
• Timers are introduced into the data link layer to deal with
the possibility of lost frames.
• Lost frames may lead to a sender hanging forever
waiting for a positive or negative acknowledgement
• The timer is set to go off after an interval long enough for
the frame to reach the destination, be processed there and
have the acknowledgement propagate back to the sender.
c)Error control
• Normally the frame will be correctly received and the
acknowledgement will get back before the timer runs out
in which case it will be cancelled.
• If either the frame or acknowledgement is lost, the timer
will go off, alerting the sender to a potential problem.
• The sender retransmits the frame.
c)Error control
• Retransmission of frames may lead to multiple deliveries
of a frame to the network layer.
• To avoid this, sequence numbers are generally assigned to
outgoing frames so that the receiver can distinguish
retransmissions from originals.
• Duties of data link layer ensure that each frame is
ultimately passed to the network layer at the destination,
exactly once, no more and no less.
d) Flow Control
• Receiver:
• Valid Frame:
• When a valid frame (error free frame) arrives at the receiver, its
sequence number is checked to see if it is a duplicate.
• If it is a duplicate it is discarded.
• If it is not, it is passed to the network layer, the expected
sequence number is incremented modulo 2 and
• In either case, the receiver returns an ACK frame.
• Damaged frame
• If a frame with error is received at the destination, the frame is
discarded
Stop and Wait Protocols
• Sender
• Valid Ack
• On receipt of a valid (error free ) ACK frame, sender transmits
another frame. Sequence number is incremented prior to this.
• Damaged Ack
• If damaged ACK frame is received by the sender, the frame is
discarded.
• The sending station will time out and resend the same frame
• Lost Ack
• If no ACK frame arrives at all, after a while the sender will time out
and send the frame again. The process will be repeated again until the
frame finally arrives intact.
Stop and Wait Protocols
• Sender
• Damaged frame
• Source waits for an ACK. If no ACK is received by the time the timer
expires, the same frame is sent again
•
Stop and Wait Protocols
• Adv
• Simple
• Disadv:
• Low Link Utilization:
Stop and Wait Protocols
• Flow control
▪ In stop and wait protocol, flow of frames across the
link is automatically tightly controlled’.
▪ This is because after a frame is transmitted by a sender,
it must wait until an acknowledgment is returned by the
receiver before transmitting the next frame.
Sliding window protocols
Sliding window protocols
• With sliding window protocols link utilization is much
improved at the expense of increased buffer storage
requirements.
• Full duplex transmission is required is required for its
implementation.
Sliding window protocols
• Sender:
• The sender maintains a sending window. At any instant in time, the sender
maintains a list of consecutive sequence numbers corresponding to frames
it is allowed to send. The frames are said to fall within the sending
window.
• The sender is allowed to transmit a series of frames (within the window)
without waiting for an acknowledgement.
• Therefore a number of unacknowledged frames may be outstanding at
any time.
• The number of outstanding unacknowledged frames is determined by
the sending window size.
• Since the frames currently within the sender’s window may ultimately be
lost or damaged in transit the sender must keep all frames in memory for
possible retransmission.
Sliding window protocols
• Receiver:
• The receiver similarly maintains a receiving window corresponding to the number
of consecutive frames it is able to accept.
• Any incoming frame falling outside the receiving window is discarded.
• Note: In all cases, corrupted frames are discarded and retransmission requests
are triggered only after the next error free frame is received.
• Each frame arriving at the receiver that falls within the receiver’s window is
acknowledged.
• An ACK frame contains the ID of the frame which it acknowledges.
• The receiver must be able to receive frames equal to the maximum receive
window size beyond the one it has last acknowledged.
• Note: The sender’s window and the receiver’s window need not have the
lower and upper limits or even the same size.
• A frame that falls within the receiver’s window may be:
• In sequence or
• Out of sequence
Sliding window protocols
• Receiver:
• On receipt of the next in-sequence frame, the receiver delivers the
packet to the network layer and acknowledges the frame.
• As the receiver acknowledges frames, it advances its receive
window to enable it receive new frames.
Sliding window protocols
• Receiver:
• On receipt of an out of sequence frame one of the two
retransmission strategies may be followed.
• Receiver detects the receipt of an out-of-sequence frame and
requests the sender to retransmit all outstanding
unacknowledged frames from the last correctly received, and
hence acknowledged, frame- go back-N
• Receiver detects and requests the retransmission of just those
frames in the sequence that are corrupted – selective repeat.
Meanwhile out of sequence frames will be buffered until the
next in sequence frame is received.
Sliding window protocols
• Sender
• As an acknowledgement arrives, the sender discards the buffered
frame that has been acknowledged.
• An acknowledgement for a frame whose sequence number is equal
to the lower edge of the window causes the window’s lower edge
to be advanced by one contracting the window.
• As the sending window contracts, the sender may open its window
to permit the sending of new frames subject to ensuring that the
number of outstanding unacknowledged frames must not exceed
the sending window size.
• An acknowledgement implicitly announces the receiver’s ability to
receive another frame.
Sliding window protocols
• Adv:
▪ Give the data link layer more freedom about the order
in which it may send and receive frames.
▪ Increases link utilization
A protocol using go back N
A protocol using go back N
• Sender (Assume a window size of n bits)
• The sender maintains a send window of Maxseq (or 2n-1).
• The sender is allowed to transmit up to a maximum of Maxseq
frames (not maxseq + 1 or 2n) without waiting for an
acknowledgement.
• A timer is started for each frame sent
• Since frames currently within the sender’s window may ultimately
be lost or damaged in transit , the sender must keep all these
frames in its memory for possible retransmission
A protocol using go back N
• Receiver:
• The receiver has a receive window of 1
• The receiver accepts frames in order.
• Valid frame:
• When an expected frame is received, it is passed to the network layer,
an acknowledgement is generated and the receive window is
advanced.
A protocol using go back N
• Sender:
• The sender discards acknowledged frames
• The lower edge of the send window is advanced appropriately.
• The sender may open its window to permit the sending of new
frames subject to ensuring that the number of outstanding
unacknowledged frames must not exceed the sending window
size.
• As each new packet is transmitted, it is given the next highest
sequence number, and the upper edge of the window is advanced
by 1.
A protocol using go back N
• Assumptions:
▪ Frames may arrive out of sequence/order
▪ Frames may be lost
▪ Frames may be damaged
▪ NACK or ACK may be lost
▪ NACK or ACK may be damaged
• How to sender and receiver respond to
▪ Out of sequence frame
▪ Lost frame, Lost Ack/Nack
▪ Damaged frame, Damaged Ack/Nack
▪ Valid frame, Valid Ack
A protocol using go back N
• The basic approach for dealing with an error (including an out of sequence error) in the
presence of a long stream of frames sent.
• Receiver:
▪ Damaged frame
▪ When a damaged frame is received it is simply discarded and no further action
is taken as a result of that frame.
▪ Out of sequence frame (implies Lost frame, )
▪ When the receiver detects an out-of sequence frame (due to lost frames(s)), it
is discards the frame. It may send a NAK for that frame.
▪ Frames following an error are discarded ( until the frame in error is
correctly received).
▪ This means that the receiver has a receive window of 1.
▪ The receiver informs the sender to start to retransmit frames from a specified
frame number. It does this by returning a special negative acknowledgment
frame ( NAK) known as reject.
A protocol using go back N
• The basic approach for dealing with an error (including an out of sequence
error) in the presence of a long stream of frames sent.
• Receiver:
▪ Out of sequence frame
• One way the receiver can deal with out of sequence frames is to send
a NAK frame informing the sender to go back and start retransmitting
from the frame whose number is included in the NAK frame (The one
following the last one acknowledged).
• Another way is take no further action as a result of that frame. The
sender will time out and retransmit all unacknowledged frames in
order starting with the lost one (or damaged one).
A protocol using go back N
• The basic approach for dealing with an error (including an out of sequence error) in the
presence of a long stream of frames sent.
• Sender:
• Valid NACK
• When a NAK frame arrives for frame N ,the sender retransmits all
unacknowledged frames (starting from N).
• Damaged ACK or NACK
• When a NACK or ACK frame is damaged, it is ignored.
• Ultimately the corresponding timer will expire and the frame will be
transmitted (and all subsequent frames).
• The sender may receive acknowledgement for subsequent frames before timer
expires. When an acknowledgement (ACK) frame arrives for frame n, frames
n-1, n-2 etc are acknowledged. Some previous acknowledgements may have
been lost
A protocol using go back N
• The basic approach for dealing with an error (including an out of sequence
error) in the presence of a long stream of frames sent.
• Sender:
• Lost Ack/Nack (Timer expires)
• When the timer expires before an ACK has been received, the sender
• Retransmits the frame (and all subsequent frames) or
• May explicitly request for an ACK (if no frames were sent after
the one whose timer has expired) indicating the next frame
expected.
A protocol using go back N