Вы находитесь на странице: 1из 51

11.

1
Flow control coordinates the amount of data that can be sent
before receiving an acknowledgment and is one of the most important
duties of the data link layer.

Flow control refers to a set of procedures used to restrict the amount
of data that the sender can send before waiting for acknowledgment.

For reliable and efficient data communication a great deal of
coordination is necessary between at least two machines

Both sender and receiver have limited speed
Both sender and receiver have limited memory

It is necessary to satisfy the following requirements:
A fast sender should not overwhelm a slow receiver, which must
perform a certain amount of processing before passing the data on
to the higher-level software.
If error occur during transmission, it is necessary to devise
mechanism to correct it .
Error Control
Error control includes both error detection
and error correction.
It allows the receiver to inform the sender if a
frame is lost or damaged during transmission
and coordinates the retransmission of those
frames by the sender.
Error control in the data link layer is based
on automatic repeat request (ARQ).
Whenever an error is detected, specified
frames are retransmitted.
Error and Flow Control Mechanisms
Assuming channel is error
free
Not realistic
No need for error control
Simplest Protocol -Noiseless channel
Assume that the receiver can immediately handle any frame it receives
with a processing time that is small enough to be negligible.
The data link layer of the receiver immediately:
Removes the header
Hands the data packet to its network layer
Network layer also accept the packet immediately.
In other words, the receiver can never be overwhelmed with incoming
frames.
Simplest Protocol - Noiseless channel
The data link layer at the sender site gets data from its network layer,
makes a frame out of the data, and sends it.
The data link layer at the receiver site receives a frame from its
physical layer, extracts data from the frame, and delivers the data to
its network layer.
The data link layers of the sender and receiver provide transmission
services for their network layers.
If data frames arrive at the receiver site faster than
they can be processed, the frames must be stored until
their use.
Normally, the receiver does not have enough storage
space, especially if it is receiving data from many
sources.
This may result in either the discarding of frames or
denial of service.
We need a mechanism to tell the sender to slow down
Achieved by employing the feedback from the receiver
to the sender
Stop and Wait Protocol
Noiseless channel
Still noiseless channel
Receiver has limited buffer
Requires flow control
Sender sends one frame at a time and wait for an
acknowledgment
Stop and Wait Protocol
Noiseless channel
ACK number always defines the
number of the next expected frame
For identification, both data frames
and acknowledgements (ACK)
frames are numbered alternatively
0 and 1
Sender starts a timer when it sends
a frame. If an ACK is not received
within a allocated time period, the
sender assumes that the frame was
lost or damaged and resends it
Receiver send only positive ACK if
the frame is intact.
Stop and Wait Protocol
Noiseless channel
Noisy Channel
Realistic
Error can and will happen
Require error control
Mechanisms:
Stop-and-Wait ARQ
Go-Back-N ARQ
Selective Repeat ARQ
Sender keeps a copy of the last frame until it
receives an acknowledgement.
For identification, both data frames and
acknowledgements (ACK) frames are
numbered alternatively 0 and 1.
Sender has a control variable (S) that holds
the number of the recently sent frame. (0 or
1)
Receiver has a control variable that holds the
number of the next frame expected (0 or 1).
Sender starts a timer when it sends a frame.
If an ACK is not received within a allocated
time period, the sender assumes that the
frame was lost or damaged and resends it
Receiver send only positive ACK if the frame
is intact.
ACK number always defines the number of
the next expected frame
Stop-and-Wait ARQ Protocol
Normal Operation
When a receiver
receives a damaged
frame, it discards it.
The receiver remains
silent about a lost
frame and keeps its
value of R.
After the timer at the
sender expires,
another copy of
frame 1 is sent.
Lost or Damaged frame
Stop-and-Wait ARQ Protocol
If the sender receives a
damaged ACK, it discards
it.
When the timer of the
sender expires, the
sender retransmits
frame 1.
Receiver has already
received frame 1 and
expecting to receive
frame 0 (R=0). Therefore
it discards the second
copy of frame 1.
Lost Acknowledgement
Stop-and-Wait ARQ Protocol
The ACK can be delayed
at the receiver or due to
some problem
It is received after the
timer for frame 0 has
expired.
Sender retransmitted a
copy of frame 0.
However, R =1 means
receiver expects to see
frame 1. Receiver
discards the duplicate
frame 0.
Sender receives 2 ACKs,
it discards the second
ACK.


Delayed ACK frame
Stop-and-Wait ARQ Protocol
Piggybacking
A method to combine a
data frame with ACK.
Station A and B both
have data to send.
Instead of sending
separately, station A
sends a data frame that
includes an ACK.
Station B does the same
thing.
Piggybacking saves
bandwidth.
Stop and wait mechanism is unidirectional
Bidirectional transmission is possible if two parties have two
separate channels for Full duplex transmission or share the same
channel for half duplex transmission.
Link utilization Simple stop and wait
Time taken to transmit one complete frame is t
f
is given by

=


=


The time taken by the sender to send a frame and getting
processed by the receive =


The time taken by the receiver to send ACK and getting
processed by the sender =


Where:


= time to transmit frame


= propagation time

= processing time at station

= time to transmit ack


Total time T=


Link utilization Simple stop and wait
Assume

and

relatively small

T

+2



Link Utilization U for n frames is ratio of time to transmit
data n

and the total time to send the data and get the
response (

+2

)

=

+2

)
=

+2

=
1
1 +2


Where
a = propagation delay =


Link utilization Simple stop and wait
1. If a<1, t
p
< t
f

frame is longer enough such that the leading bits of frame reach the
receiver before the entire frame is transmitted, link is inefficiently utilized.
2. If a>1, t
p
> t
f

Which implies that the sender has transmitted the entire frame and leading
bits of frame that have not still arrived at the receiver, link is underutilized.

Let the probability of a frame in error be p
The number of frames sent in one second is:
=
1

+2


Hence the number of frames which have errors in them sent
per second is:
=

+2


Therefore the number of packets transmitted per second that
don't have errors in them:
=
1

+ 2


The case where there is no flow control or errors, the network
capacity is:
=
1


Link utilization Stop and Wait ARQ
The case where there is no flow control or errors, the
network capacity is:
=
1


Since the number of packets transmitted per second with
no errors must be equal to the number of packets
received correctly

The utilisation U of the link is:

=


=
1

+2

+



Link utilization Stop and Wait ARQ
Disadvantage of Stop-and-Wait ARQ
At any point in time, there is only one frame
that is sent and waiting to be acknowledged
This reduces the efficiency of the link
This is not a good use of transmission medium
To improve efficiency, multiple frames can be
sent at a time
Sliding Window Protocol
Efficiency can be greatly improved by allowing multiple
frames to be in transit at the same time
Efficiency can also be improved by making use of the
full-duplex line
To keep track of the frames, sender station sends
sequentially numbered frames.
If the header of the frame allows k bits for sequence
number, the sequence numbers range from 0 to 2
k
1.
For k = 3, sequence numbers are: 0, 1, 2, 3, 4, 5, 6,7
We can repeat the sequence number.
Sequence numbers are:
0, 1, 2, 3, 4, 5, 6,7, 0, 1, 2, 3, 4, 5, 6,7, 0, 1,
Sliding Window Protocol
The size of the senders window is at most 2
k
1
The sender is provided with a buffer equal to the
window size.
Receiver also maintains a window of size 2
k
1
The receiver acknowledges a frame by sending an
ACK frame that includes the sequence number of
the next frame expected
This scheme can be used to acknowledge multiple
frames
It could receive frames 2, 3, 4 but withhold ACK
until frame 4 has arrived
i.e. By returning an ACK with sequence number 5,
it acknowledges frames 2, 3, 4 in one go.
Sender and receiver Window
Sliding Window Protocol
Ambiguity Problem :
For n-bit sequence number, maximum window size is N = 2
k
1 not
N = 2
k
with N = 2
k
confusion may occur
Consider n = 3, if N = 8 what may happen:
Suppose that sender transmits frame 0 and gets
an ACK1
It then transmits frames 1,2,3,4,5,6,7,0 (this is
allowed, as they are within the sending window of size 8) and gets
another ACK1

-- This could mean that all eight frames were received correctly
-- It could also mean that all eight frames were lost, and receiver is
repeating its previous ACK1.

With N = 7, this confusing situation is avoided.
Go-Back-N ARQ
We can send up to W frames before worrying
about ACKs.
We keep a copy of these frames until the
ACKs arrive.
This procedure requires additional features to
be added to Stop-and-Wait ARQ.
It is a special case of the general sliding
window protocol with the transmit window
size of N and receive window size of 1.
Acknowledgement
Receiver sends positive ACK if a frame arrived safe and in order.
If the frames are damaged/out of order, receiver is silent and
discard all subsequent frames until it receives the one it is
expecting.
The silence of the receiver causes the timer of the
unacknowledged frame to expire.
Then the sender resends all frames, beginning with the one with
the expired timer.
For example, suppose the sender has sent frame 6, but the timer
for frame 3 expires (i.e. frame 3 has not been acknowledged),
then the sender goes back and sends frames 3, 4, 5, 6 again. Thus
it is called Go-Back-N-ARQ
The receiver does not have to acknowledge each frame received,
it can send one cumulative ACK for several frames.

Go-Back-N ARQ, normal operation
The sender keeps track of the outstanding frames and
updates the variables and windows as the ACKs arrive.
Go-Back-N ARQ, lost frame
Frame 2 is lost
When the
receiver receives
frame 3, it
discards frame 3
as it is expecting
frame 2
(according to
window).
After the timer
for frame 2
expires at the
sender site, the
sender sends
frame 2 and 3.
(go back to 2)
Go-Back-N ARQ.
Go-Back-N ARQ, damaged/lost/delayed ACK
If an ACK is damaged/lost, we can have two situations:
If the next ACK arrives before the expiration of any timer,
there is no need for retransmission of frames because
ACKs are cumulative in this protocol.
If ACK1, ACK2, and ACk3 are lost, ACK4 covers them if it
arrives before the timer expires.
If ACK4 arrives after time-out, the last frame and all the
frames after that are resent.
Receiver never resends an ACK.
A delayed ACK also triggers the resending of frames
Go-Back-N ARQ.
Go-Back-N ARQ, sender window size
Size of the sender window must be less than 2
m
. Size of the
receiver is always 1. If m = 2, window size = 2
m
1 = 3.
Fig compares a window size of 3 and 4.
Accepts as
the 1
st

frame in
the next
cycle-an
error
Selective Repeat ARQ, sender and receiver windows
Go-Back-N ARQ simplifies the process at the receiver site. Receiver only keeps
track of only one variable, and there is no need to buffer out-of-order frames,
they are simply discarded.
However, Go-Back-N ARQ protocol is inefficient for noisy link. It is bandwidth
inefficient and slows down the transmission.
In Selective Repeat ARQ, only the damaged frame is resent. More bandwidth
efficient but more complex processing at receiver.
It defines a negative ACK (NAK) to report the sequence number of a damaged
frame before the timer expires.
Selective Repeat ARQ, lost frame
Frames 0 and 1 are
accepted when
received because
they are in the range
specified by the
receiver window.
Same for frame 3.
Receiver sends a
NAK2 to show that
frame 2 has not been
received and then
sender resends only
frame 2 and it is
accepted as it is in the
range of the window.
Selective Repeat ARQ, sender window size
Size of the sender and receiver windows must be at most one-half of 2
m
. If m =
2, window size should be 2
m
/2 = 2.
Figure compares a window size of 2 with a window size of 3. Window size is 3
and all ACKs are lost, sender sends duplicate of frame 0, window of the receiver
expect to receive frame 0 (part of the window), so accepts frame 0, as the 1
st

frame of the next cycle an error.
Go Back N vs. Selective Repeat
Conceptually, the main difference between the "Go Back N"
and "Selective Repeat" protocols is the size of the receiver
window. (Go back N can be thought of as having a receiver
window of size 1).

Implementation-wise, selective repeat requires more memory
at the receiver and is more complex to implement.

Selective repeat does result in higher efficiencies than go back
N; how significant these gains are depend on the error
probability, frame sizes, and the round-trip time.
Sliding Window Protocol Efficiency
High Level Data Link Control
(HDLC)
A Bit Oriented Protocol for communication over point to point
and multipoint links.

The most important data link control protocol is HDLC (ISO
3009, ISO 4335). Not only is HDLC widely used, but it is the
basis for many other important data link control protocols,
which use the same or similar formats and the same
mechanisms as employed in HDLC.


Basic Characteristics
Primary station: Responsible for controlling the operation of the
link. Frames issued by the primary are called commands.
Secondary station: Operates under the control of the primary
station. Frames issued by a secondary are called responses. The
primary maintains a separate logical link with each secondary
station on the line.
Combined station: Combines the features of primary and
secondary. A combined station may issue both commands and
responses.
The two link configurations are
Unbalanced configuration: Consists of one primary and one or
more secondary stations and supports both full-duplex and half-
duplex transmission.
Balanced configuration: Consists of two combined stations
and supports both full-duplex and half-duplex transmission.
HDLC Transfer Modes
Normal response mode (NRM): Used with an unbalanced
configuration. The primary may initiate data transfer to a
secondary, but a secondary may only transmit data in response
to a command from the primary.

Asynchronous balanced mode (ABM): Used with a balanced
configuration. Either combined station may initiate transmission
without receiving permission from the other combined station.

Asynchronous response mode (ARM): Used with an
unbalanced configuration.
The secondary may initiate transmission without explicit
permission of the primary. The primary still retains responsibility
for the line, including initialization, error recovery, and logical
disconnection.
NRM
ABM
45
HDLC Frames
Information frame (I-frame)


Transport user data from the network layer. In addition they can
also include flow and error control information piggybacked on
data.
Supervisory frame (S-frame)


Used for flow and error control whenever piggybacking is
impossible or inappropriate, such as when a station does not
have data to send.
Unnumbered frame (U-frame) : link management.
Information frames : (I-frames) carry the data
to be transmitted for the user.
Additionally, flow and error control data, using
the ARQ mechanism, are piggybacked on an
information frame.
Supervisory frames (S-frames) provide the
ARQ mechanism when piggybacking is not used.
Unnumbered frames (U-frames) provide
supplemental link control functions.

HDLC Frame Structure
Flag Fields and Bit Stuffing
Delimit frame at both ends with 01111110 sequence
receiver hunts for flag sequence to synchronize bit
stuffing used to avoid confusion with data containing
flag sequence 01111110
0 inserted after every sequence of five 1s
if receiver detects five 1s it checks next bit
if next bit is 0, it is deleted (was stuffed bit)
if next bit is 1 and seventh bit is 0, accept as flag
if sixth and seventh bits 1, sender is indicating abort
Address Field
The address field identifies the secondary station that
transmitted or is to receive the frame.
usually 8 bits long
may be extended to multiples of 7 bits
Left bit indicates if it is the last octet (1) or not (0)
all ones address 11111111 is broadcast
50
Control Field Format
N(S) Frame sequence number
N(R) Ack sequence number
P/F
Poll (primary secondary)=1
Final (secondary primary)=0
code meaning
00 RR(Receive Ready)
01 REJ(Reject)
10 RNR(Receive Not Ready)
11 SREJ(Selective REJ)
S-Frame
Information & FCS Fields
Information Field
in information and some unnumbered frames
must contain integral number of octets
variable length
Frame Check Sequence Field (FCS)
used for error detection
either 16 bit CRC or 32 bit CRC (for reliability)

Вам также может понравиться