0% found this document useful (0 votes)
25 views16 pages

Sliding Window Protocol

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 16

Sliding window

protocol
What is sliding window protocol?
• Sliding window protocols are mainely used in flow
control.
• Sliding window protocols are data link layer protocols
for reliable and sequential delivery of data frames.

• The sliding window is also used in Transmission


Control Protocol.(TCP).

• In this protocol, multiple frames can be sent by a


sender at a time before receiving an
acknowledgment from the receiver.
Sliding window
• Sliding window refers to an imaginary boxes that hold the frames on both sender
and receiver side.

• It provides the upper limit on the number of frames that can be transmitted before
requiring an acknowledgment.

• Frames may be acknowledged by receiver at any point even when window is not
full on receiver side.

• Frames may be transmitted by source even when window is not yet full on sender
side.
• The windows have a specific size in which the frames are numbered modulo- n,
which means they are numbered from 0 to n-l. For e.g. if n = 8, the frames are
numbered 0, 1,2,3,4,5,6, 7, 0, 1,2,3,4,5,6, 7, 0, 1, ….

• The size of window is n-1. For e.g. In this case it is 7. Therefore, a maximum of n-l
frames may be sent before an acknowledgment.
Sliding Window on Sender Side
• At the beginning of a transmission, the sender’s
window contains n-l frames.
• As the frames are sent by source, the left boundary of
the window moves inward, shrinking the size of
window.
• This means if window size is w, if 4 frames are sent by
source after the last acknowledgment, then the number
of frames left in window is w-4.
• When the receiver sends an ACK, the source’s window
expand i.e. (right boundary moves outward) to allow in
a number of new frames equal to the number of frames
acknowledged by that ACK.
• For example, Let the window size is 7 (see diagram (a)), if
frames 0 through 3 have been sent and no acknowledgment
has been received, then the sender’s window contains three
frames – 4,5,6.

• •Now, if an ACK numbered 3 is received by source, it


means three frames (0, 1, 2) have been received by receiver
and are undamaged.

• The sender’s window will now expand to include the next


three frames in its buffer. At this point the sender’s window
will contain six frames (4, 5, 6, 7, 0, 1). (See diagram (b)).
Sliding Window on Receiver Side
• At the beginning of transmission, the receiver’s
window contains n-1 spaces for frame but not the
frames.
• As the new frames come in, the size of window shrinks.
• Therefore the receiver window represents not the
number of frames received but the number of frames
that may still be received without an acknowledgment
(ACK) must be sent.
• Given a window of size w, if 3 frames are received
without an ACK being returned, the number of spaces
in a window is w-3.
• As soon as acknowledgment is sent, window expands
to include the number of frames equal to the number of
frames acknowledged.
• For example, let the size of receiver’s window is 7 as
shown in diagram. It means window contains spaces for
7 frames.
• With the arrival of the first frame, the receiving window
shrinks, moving the boundary from space 0 to 1.
• Now, window has shrunk by one, so the receiver may
accept six more frame before it is required to send an
ACK.
• As receiver sends an ACK, the window of the receiver
expands to include as many new placeholders as newly
acknowledged frames.
Example

• Suppose that we have sender window and


receiver window each of size 4. So the
sequence numbering of both the windows will
be 0,1,2,3,0,1,2 and so on.
• The following diagram shows the positions of
the windows after sending the frames and
receiving acknowledgments.
Types of Sliding Window Protocols
• The Sliding Window ARQ (Automatic Repeat
request) protocols are of two categories −
Go – Back – N ARQ

• Go – Back – N ARQ provides for sending


multiple frames before receiving the
acknowledgment for the first frame.
• The frames are sequentially numbered and a
finite number of frames are sent.
• If the acknowledgment of any frame is not
received within the time period, all frames
starting from that frame are retransmitted.
• we will explain with a help of example. Consider the
diagram given below.
• We have sender window size of 4.
• Now the sender has sent the packets 0, 1, 2 and 3.
• After acknowledging the packets 0 and 1, receiver is now
expecting packet 2 and sender window has also slided to
further transmit the packets 4 and 5.
• Now suppose the packet 2 is lost in the network, Receiver
will discard all the packets which sender has transmitted
after packet 2 as it is expecting sequence number of 2.
• On the sender side for every packet sent, there is a time out
timer which will expire for packet number 2.
• Now from the last transmitted packet 5 sender will go back
to the packet number 2 in the current window and transmit
all the packets till packet number 5.
• That’s why it is called Go Back N. Go back means sender
has to go back N places from the last transmitted packet in
the unacknowledged window and not from the point where
the packet is lost.
Selective Repeat ARQ
• This protocol also provides for sending multiple frames
before receiving the acknowledgment for the first
frame.

• If the receiver receives a corrupt frame, it does not


directly discard it. It sends a negative acknowledgment
to the sender. The sender sends that frame again as soon
as on the receiving negative acknowledgment.

• However, here only the erroneous or lost frames are


retransmitted, while the good frames are received and
buffered.
Why Selective Repeat Protocol?
• The go-back-n protocol works well if errors are
less, but if the line is poor it wastes a lot of
bandwidth on retransmitted frames.
• An alternative strategy, the selective repeat
protocol, is to allow the receiver to accept and
buffer the frames following a damaged or lost
one.
• Selective Repeat attempts to retransmit only those
packets that are actually lost (due to errors)

You might also like