1. Home
cyber security

Learn Cyber Security Tutorial Concepts - From Beginner to Pro

Explore essential cyber security tutorials to safeguard your digital assets and protect data.

  • 28 Lessons
  • 5 Hours
right-top-arrow
12

Sliding Window Protocol

Updated on 27/08/2024475 Views

Ever wondered how modern-day networking works so flawlessly? There are a lot of protocols and workarounds being used simultaneously to ensure friction-free and efficient transfer of data. One such key protocol of computer networking is the sliding window protocol.

The sliding window protocol is a method that helps senders and recipients exchange and receive data efficiently in the data link. Data packets can be sent and received in a regulated way thanks to it, guaranteeing optimal packet delivery without any issues.

Based on my years of knowledge and all the experience I have gathered as an expert in this field, I have curated this detailed tutorial for you to take you through the nitty-gritty of this particular protocol.

Let’s take a look!

Working Principle of Sliding Window Protocol

In computer networks, the sliding window protocol is a technique that enables efficient and reliable data transfer between a sender and a recipient. Let me take you through the basic workings of this protocol. Then we will get into its different types in more detail.

Initialization of the Window

  • The number of packets (also known as window size) that can be on their way at any given time is represented by the window size. It is initialized by both the sender and the receiver.
  • There is a "sending window" maintained by the sender and a "receiving window" maintained by the recipient.

Transmission of Packets

  • First, the sender sends the receiver a collection of packets in order.
  • A serial number is then assigned to each packet, marking where it is in the data stream.

Acknowledgment of Reception

  • By responding with acknowledgment (ACK) messages to the sender, the recipient certifies that the packets have been received.
  • For packets delivered throughout its given sending window, the sender is waiting for acknowledgments or the ACK signal.

Sliding Window Operation

  • The sender's sending window moves forward, enabling it to send more packets as it receives acknowledgments(ACK).
  • The reception window of the receiver moves forward as well, displaying the expected range of serial numbers for incoming packets.

Handling and Detection of Errors

  • The sender understands a packet to be lost or corrupted and resends it if it does not get an acknowledgment (ACK) for it within the allotted timeout interval.
  • The recipient can utilize checksums and other error detection methods to find faults in packets they have received. If any packets are tampered with during transmission, it might request more transmissions.

Flow Control

  • The flow control sliding window protocol also helps with flow control by making sure that the sender doesn't send too many packets at once to the recipient.
  • To maximize data transfer, the transmitting window's size may be changed in real-time in response to network conditions.

Buffer Management

  • In order to store packets that are sent but not yet acknowledged (sender's buffer) or received out of order (receiver's buffer), both the sender and the recipient keep buffers. This is to keep track of errors.

Types of Sliding Window Protocol

There are two types of protocols for sliding windows in computer networks that can be differentiated by flow control in sliding window. Let me explain the types in detail. 

GBN (Go-Back-N) Protocol

While the Go-Back-N protocol is easy to set up, it can cause inefficiencies by redundantly resending multiple packets, especially in high-latency networks

In Go-Back-N, the sender continually transmits packets within a window of unacknowledged packets, up to a maximum window size. After filling the window, the sender awaits acknowledgments for the earliest sent packets. If an acknowledgment isn't received within a set buffering interval, the sender resends all unacknowledged packets from that point onward.

Let’s understand this with the help of the diagram above as an example of sliding window protocol (Go-Back-N).

Here, as you can see, the send sends the packets namely p1, p2, p3, p4. During the transmission, p2 gets lost. Then the receiver sends an acknowledgment letting the sender know that p2 was lost during transit and will discard every packet received after p2. The sender then resends all the packets again after p2. This process continues as long as the receiver sends an acknowledgment (ACK) letting the sender know it has received all the packets. 

SR (Selective-Repeat) Protocol

In Selective Repeat, the sender can send multiple packets simultaneously, keeping a window open for unacknowledged packets. If a specific packet isn't acknowledged within the timeout, only that packet is resent, unlike Go-Back-N where all unacknowledged packets are resent

Unlike Go-Back-N, the receiver saves network resources by buffering out-of-order packets until all missing ones arrive. Though more complex to implement, Selective Repeat is more efficient, particularly in networks with high packet loss and delays.

Now let us take a look into how SR protocol works with the help of this diagram.

As we can see, the first frame (frame0) is sent to the receiver. Then without waiting for acknowledgement from the receiver, the sender sends the frame1 and sets a timer. 

Similarly, the sender then sends frame2. When the receiver gets the acknowledgement(ACK0) for frame0, it closes the time for frame0 and sends frame3. When the receiver does not receive an acknowledgment for a frame (in this case, which is frame 2) and the set timer runs out, it sends that particular frame (here frame2) again.

Difference Between GBN (Go-Back-N) and SR (Selective-Repeat) protocol

There are two types of sliding window protocol as I mentioned earlier. Let me take you through the differences between the two types of sliding window protocol we use:

Key Points

GBN protocol

SR protocol

Strategy for Retransmission

Resends all unacknowledged packets from the last acknowledged one if a timeout occurs.

Only resends the specific unacknowledged packet if a timeout occurs, while keeping other unacknowledged packets untouched.

Buffering for Receivers

Does not buffer out-of-order packets at the receiver; they are discarded until the missing packets are received.

Buffers out-of-order packets at the receiver until all missing packets are received, conserving network resources.

Management of the Sender's Window

Uses a sliding window mechanism where the sender keeps sending packets within a window of unacknowledged packets, resending all unacknowledged packets upon timeout.

Also uses a sliding window mechanism but allows the sender to send multiple packets concurrently, maintaining a window for unacknowledged packets, and only resending the specific unacknowledged packet upon timeout.

Efficiency

Simple to implement but can lead to inefficiencies due to redundant retransmissions, especially in high-latency networks.

More complex to implement but more efficient, particularly in networks with prevalent packet loss and delays, due to selective retransmission and better resource usage.

Advantages of Using Sliding Window Protocol

Usage of the sliding window protocol brings a lot of advantages. In this section of the tutorial, I will discuss some of them.

Reliability

  • Safe data packet transmission between a sender and a recipient is one of the main purposes of the sliding window protocol.
  • By confirming the receipt of data packets and retransmitting any lost or corrupted packets, it attains reliability.

Efficiency

  • It restricts the amount of unacknowledged packets that can be sent at any given moment, making sure that the sender does not oversend the recipient with too many packets.
  • Through the usage of the sliding window protocol, many packets can be in transit simultaneously, maximizing the utilization of network bandwidth.


  • By allowing the sender to keep sending packets inside the window size without having to wait for acknowledgments for each individual packet, it reduces idle time.

Ordering of packets

  • Ensuring that packets are sent to the recipient in the right order is another purpose of the sliding window protocol.
  • Giving each packet a serial number and controlling the sliding window coordinating with the respective serial numbers, it keeps the order of packets intact.

Disadvantages of Sliding window protocol

The sliding window protocol has many drawbacks in addition to its many benefits for dependable and effective data transfer in computer networks. Here I will walk you through them one by one.

Complexity

  • Compared to simpler protocols, the sliding window protocol takes more overhead and complexity to implement.
  • Implementing the protocol becomes more complex when sequence numbers, acknowledgments, timeouts, and window sizes need to be managed.

Window size limitation 

  • A sliding window's size must be carefully selected taking into account network parameters like latency, bandwidth, and reliability.
  • Selecting the wrong window size can result in more retransmissions owing to packet loss or wasteful use of network resources.

Sequence number limitation

  • The amount of packets that can be transmitted before sequence number wrapping happens can be limited by sliding window protocols, which typically use finite sequence numbers to identify packets.
  • In order to prevent confusion in packet sequencing, sequence number wrapping must be handled correctly.

Retransmission of packets

  • In protocols such as Go-Back-N, the sender retransmits all consecutive packets in the window, even if the recipient receives them correctly, if any packet within the window is lost or damaged.
  • This might result in several packets being retransmitted needlessly, which can be inefficient, especially in networks with high packet loss rates.

Wrapping Up

In present computer networks, the sliding window protocol is essential for guaranteeing the accuracy and effectiveness of data transfer. Hopefully, this tutorial has provided valuable insight into the workings of this protocol

If you are looking to hone your knowledge and learn about different protocols and working of the modern computer networks, be sure to check out certification courses provided by upGrad. The certified courses are curated by industry-experienced professionals and are sure to give you valuable insights into more complex topics.

FAQs

  1. What is the sliding window protocol used for?

In computer networks, the sliding window protocol is mostly used for efficient data transfer.

  1. What is the sliding window technique?

The sliding window technique increases the effectiveness and dependability of data transfer via a network connection by enabling the controlled transmission and acknowledgement of numerous packets.

  1. What is the sliding window method in TCP?

The sliding window technique in TCP allows for reliable data transmission between a sender and a recipient as well as flow control. 

  1. What is the formula for sliding window protocol?

The functionality of the sliding window protocol is determined by a number of concepts and parameters rather than a single formula.

  1. What is the difference between a sliding window and a congestion window?

The sliding window and congestion window function at different levels of the networking stack and have distinct functions.

  1. What is the difference between a sliding window and Go-Back-N?

Go-Back-N is just a type of sliding window protocol.

  1. What is the sliding window congestion control?

It is a technique used in networking protocols, namely in TCP, to maintain reliability and maximize the amount of data transmission over a network connection.

  1. What is the advantage of sliding window flow control?

One of its advantages is that it allows the sender to send multiple packets without receiving any acknowledgment(ACK message) from the receiver.

  1. What is sliding window protocol efficiency?

It is measured by how well it uses network resources, achieves high speeds, reduces latency, and upholds dependable data transmission. 

  1. Is two pointers a sliding window?

Yes, a method known as "two pointers" can be categorized as a sliding window approach in many situations.

mukesh

mukesh

Working with upGrad as a Senior Engineering Manager with more than 10+ years of experience in Software Development and Product Management.

Get Free Career Counselling
form image
+91
*
By clicking, I accept theT&Cand
Privacy Policy
image
Join 10M+ Learners & Transform Your Career
Learn on a personalised AI-powered platform that offers best-in-class content, live sessions & mentorship from leading industry experts.
right-top-arrowleft-top-arrow

upGrad Learner Support

Talk to our experts. We’re available 24/7.

text

Indian Nationals

1800 210 2020

text

Foreign Nationals

+918045604032

Disclaimer

upGrad does not grant credit; credits are granted, accepted or transferred at the sole discretion of the relevant educational institution offering the diploma or degree. We advise you to enquire further regarding the suitability of this program for your academic, professional requirements and job prospects before enr...