Skip to content
Home » Sliding Window Protocols

Sliding Window Protocols

Sliding Window Protocols are Data Link Layer protocols used for flow control and error control.

They allow the sender to send one or more frames without waiting for an acknowledgement after every single frame.

The main sliding-window protocols are:

  1. Stop-and-Wait ARQ
  2. Go-Back-N ARQ
  3. Selective Repeat ARQ

ARQ = Automatic Repeat reQuest
If a frame is lost or damaged, the sender retransmits it.


1. Basic Idea of Sliding Window

Suppose the sender has frames:

F0  F1  F2  F3  F4  F5  F6  F7

A window represents the frames that the sender is currently allowed to send.

For example, with window size 4:

┌───────────────────────┐
│ F0  F1  F2  F3 │ F4 F5 F6 F7
└───────────────────────┘
       Window

After successful acknowledgement of F0:

     ┌───────────────────────┐
F0 F1│ F2  F3  F4  F5 │ F6 F7
     └───────────────────────┘

The window has slid forward.

Hence the name:

Sliding Window


2. Why Do We Need Sliding Window?

Suppose the sender sends one frame and waits for an ACK:

F0 → WAIT → ACK
F1 → WAIT → ACK
F2 → WAIT → ACK

This can waste a lot of time, especially when the network has a long delay.

Sliding window allows:

F0 → F1 → F2 → F3 → 
              ↓
        ACKs arrive later

So the communication link can remain busy.

Main purposes

  • Flow control — prevents receiver from being overwhelmed.
  • Error control — handles lost/damaged frames.
  • Better efficiency — allows multiple frames to be in transit.

3. Stop-and-Wait ARQ

Stop-and-Wait ARQ is the simplest form.

Although it is usually discussed separately from multi-frame sliding-window protocols, it can be viewed as having a window size of 1.

Working

Sender                         Receiver

   │──── Frame 0 ──────────────>│
   │                             │
   │<──────── ACK 0 ─────────────│
   │                             │
   │──── Frame 1 ──────────────>│
   │                             │
   │<──────── ACK 1 ─────────────│

The sender sends one frame and waits for its ACK.


What if the frame is lost?

Sender                         Receiver

   │──── Frame 0 ───────X       │
   │                             │
   │       No ACK                │
   │                             │
   │       TIMEOUT               │
   │                             │
   │──── Frame 0 ──────────────>│
   │                             │
   │<──────── ACK 0 ─────────────│

The sender retransmits the frame after timeout.


What if ACK is lost?

Sender                         Receiver

   │──── Frame 0 ──────────────>│
   │                             │
   │<──────── ACK 0 ───────X     │
   │                             │
   │       TIMEOUT               │
   │                             │
   │──── Frame 0 ──────────────>│

The receiver may receive a duplicate frame.

Therefore, sequence numbers are used to identify duplicates.

For example:

Frame 0
Frame 1
Frame 0
Frame 1
...

Advantages

  • Very simple
  • Easy to implement
  • Requires little memory
  • Reliable

Disadvantages

  • Slow
  • Poor utilization of high-speed/long-delay links
  • Only one frame can be outstanding

Memory

Stop-and-Wait = Send one → Wait for ACK → Send next


4. Go-Back-N ARQ

Go-Back-N allows the sender to transmit multiple frames before receiving ACKs.

Suppose the window size is 4:

┌───────────────────┐
│ F0 F1 F2 F3 │ F4 F5 F6
└───────────────────┘
     Window

The sender can send:

F0 → F1 → F2 → F3

without waiting after every frame.


Normal Transmission

Sender                         Receiver

F0 ──────────────────────────> ✓
F1 ──────────────────────────> ✓
F2 ──────────────────────────> ✓
F3 ──────────────────────────> ✓

ACKs are sent back.

The sender’s window then moves forward.


5. Error in Go-Back-N

Suppose F2 is damaged:

F0 ──────────────────────────> ✓
F1 ──────────────────────────> ✓
F2 ──────────────────────────> ✗
F3 ──────────────────────────> ?

The receiver expects F2.

In the basic Go-Back-N scheme, F3 and later out-of-order frames are not accepted for normal delivery.

The sender eventually retransmits:

F2 ──────────────────────────>
F3 ──────────────────────────>

Therefore:

Go-Back-N retransmits the erroneous/lost frame and the subsequent outstanding frames.


Why is it called Go-Back-N?

Suppose:

F0 ✓
F1 ✓
F2 ✗
F3 ✓
F4 ✓

The sender goes back to F2 and retransmits:

F2
F3
F4

So:

Go back to the damaged frame and retransmit from there.


6. Cumulative ACK in Go-Back-N

Go-Back-N commonly uses cumulative acknowledgements.

For example:

F0 ✓
F1 ✓
F2 ✓

An ACK can indicate that all frames up to a certain point have been received correctly.

This reduces acknowledgement overhead.


7. Advantages of Go-Back-N

  • Multiple frames can be transmitted.
  • Better efficiency than Stop-and-Wait.
  • Simple receiver.
  • Requires less receiver buffering than Selective Repeat.

Disadvantage

If one frame is lost, several correctly received frames may have to be retransmitted.

Memory

Go-Back-N = Error occurs → Go back → retransmit from that frame onward.


8. Selective Repeat ARQ

Selective Repeat is more efficient than Go-Back-N when errors occur.

The sender can send multiple frames:

F0 → F1 → F2 → F3

Suppose:

F0 ✓
F1 ✓
F2 ✗
F3 ✓

The receiver can buffer F3 even though F2 is missing.

The sender retransmits only F2:

F2 ──────────────────────────>

It does not retransmit F3.


9. Selective Repeat Example

Sender                         Receiver

F0 ──────────────────────────> ✓
F1 ──────────────────────────> ✓
F2 ──────────────────────────> ✗
F3 ──────────────────────────> ✓
                                │
                                │ Buffer F3
                                ↓

          Retransmit only F2

F2 ──────────────────────────> ✓

Now receiver can deliver:

F2 + buffered F3

This saves bandwidth.


10. Why is it called Selective Repeat?

Because the sender selectively selects only the missing or damaged frame for retransmission.

Only the problematic frame is repeated.


11. Advantages of Selective Repeat

  • Very efficient on noisy links.
  • Only damaged/lost frames are retransmitted.
  • Better bandwidth utilization.
  • Good for networks with high delay or high error rates.

Disadvantages

  • More complex.
  • Receiver needs more memory/buffering.
  • More sequence-number management is required.

Memory

Selective Repeat = Select only the damaged frame and repeat it.


12. Comparison of the Three

FeatureStop-and-Wait ARQGo-Back-N ARQSelective Repeat ARQ
Frames sent before ACK1MultipleMultiple
Window size1>1>1
Error controlYesYesYes
RetransmissionOne frameError frame + following outstanding framesOnly error/missing frame
Receiver bufferingVery lowLowHigher
EfficiencyLowMedium/HighHigh
ComplexityVery lowMediumHigh
ACK styleIndividualUsually cumulativeIndividual/selective
Best featureSimplicityBalanceEfficiency

13. Visual Comparison

Suppose F2 is lost:

Stop-and-Wait

F0 → ACK
F1 → ACK
F2 → LOST
     ↓
  TIMEOUT
     ↓
F2 → ACK

Only one frame is outstanding.


Go-Back-N

F0 → ✓
F1 → ✓
F2 → ✗
F3 → received out of order
F4 → received out of order

Retransmit:

F2 → F3 → F4

Selective Repeat

F0 → ✓
F1 → ✓
F2 → ✗
F3 → ✓
F4 → ✓

Retransmit:

F2 only

14. Sliding Window Concept

The most important idea is that the window moves forward as acknowledgements are received.

Example with window size 4:

Initially

┌───────────────┐
│ F0 F1 F2 F3 │ F4 F5 F6
└───────────────┘

After F0 and F1 are acknowledged:

      ┌───────────────┐
F0 F1 │ F2 F3 F4 F5 │ F6
      └───────────────┘

After F2 is acknowledged:

         ┌───────────────┐
F0 F1 F2 │ F3 F4 F5 F6 │
         └───────────────┘

The window slides toward the next frames.


15. Sender and Receiver Windows

There are two important concepts:

Sender Window

The range of frames that the sender is currently allowed to transmit.

Receiver Window

The range of frames that the receiver is currently prepared to accept.

Sender                         Receiver

Sender Window                  Receiver Window
┌───────────────┐              ┌───────────────┐
│ F0 F1 F2 F3   │              │ F0 F1 F2 F3   │
└───────────────┘              └───────────────┘

As ACKs arrive, the sender window moves forward.


16. Most Important Difference

Remember this example:

F0 ✓
F1 ✓
F2 ✗
F3 ✓
F4 ✓

Stop-and-Wait

Only one frame is sent at a time.

Go-Back-N

Retransmit:
F2 F3 F4

Selective Repeat

Retransmit:
F2

This is the most important exam difference.


⭐ Exam Summary

Stop-and-Wait ARQ

One frame → Wait for ACK → Next frame

  • Window size = 1
  • Simple
  • Reliable
  • Slow

Go-Back-N ARQ

Send many → Error → Go back and retransmit from the error

  • Multiple frames
  • Sliding window
  • Usually cumulative ACKs
  • Retransmits error frame and subsequent outstanding frames

Selective Repeat ARQ

Send many → Error → Retransmit only the error frame

  • Multiple frames
  • Receiver buffers out-of-order frames
  • Most efficient among the three for many noisy-link situations
  • More complex

Easy memory trick

S → G → S

Stop = one frame
Go-Back = many frames, repeat from error
Selective = many frames, repeat only error

Or simply:

Stop = 1, Go-Back = Many Again, Selective = Only Error Again.