Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App

Sliding Window Protocol | Set 1 (Sender Side)

Last Updated : 25 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Reliable data transmission is critical in computer networking, particularly across long distances or in networks that have high latency. The Sliding Window Protocol is a critical component in obtaining this reliability. It is part of the OSI model's Data Link Layer and is used in several protocols, including TCP. Sliding Window protocol handles efficiency issues by sending more than one packet at a time with a larger sequence number. The idea is the same as pipelining in architecture. In this article, we will discuss about Sliding Window Protocol.

What is Sliding Window Protocol?

The Sliding Window Protocol is a key computer networking technique for controlling the flow of data between two devices. It guarantees that data is sent consistently and effectively, allowing many packets to be sent before requiring an acknowledgment for the first, maximizing the use of available bandwidth.

Terminologies Related to Sliding Window Protocol

Transmission Delay (Tt) - Time to transmit the packet from the host to the outgoing link. If B is the Bandwidth of the link and D is the Data Size to transmit

    Tt = D/B  

Propagation Delay (Tp) - It is the time taken by the first bit transferred by the host onto the outgoing link to reach the destination. It depends on the distance d and the wave propagation speed s (depends on the characteristics of the medium).

   Tp = d/s  

Efficiency - It is defined as the ratio of total useful time to the total cycle time of a packet. For stop and wait protocol,

Total time(TT) = Tt(data) + Tp(data) + 
Tt(acknowledgement) + Tp(acknowledgement)
= Tt(data) + Tp(data) + Tp(acknowledgement)
= Tt + 2*Tp

Since acknowledgements are very less in size, their transmission delay can be neglected.

Efficiency = Useful Time / Total Cycle Time 
= Tt/(Tt + 2*Tp) (For Stop and Wait)
= 1/(1+2a) [ Using a = Tp/Tt ]

Effective Bandwidth(EB) or Throughput - Number of bits sent per second.

EB = Data Size(D) / Total Cycle time(Tt + 2*Tp)
Multiplying and dividing by Bandwidth (B),
= (1/(1+2a)) * B [ Using a = Tp/Tt ]
= Efficiency * Bandwidth

Capacity of link - If a channel is Full Duplex, then bits can be transferred in both the directions and without any collisions. Number of bits a channel/Link can hold at maximum is its capacity.

 Capacity = Bandwidth(B) * Propagation(Tp)

For Full Duplex channels,
Capacity = 2*Bandwidth(B) * Propagation(Tp)

Concept of Pipelining

In Stop and Wait protocol, only 1 packet is transmitted onto the link and then sender waits for acknowledgement from the receiver. The problem in this setup is that efficiency is very less as we are not filling the channel with more packets after 1st packet has been put onto the link. Within the total cycle time of Tt + 2*Tp units, we will now calculate the maximum number of packets that sender can transmit on the link before getting an acknowledgement.

 In Tt units ----> 1 packet is Transmitted.
In 1 units ----> 1/Tt packet can be Transmitted.
In Tt + 2*Tp units -----> (Tt + 2*Tp)/Tt
packets can be Transmitted
------> 1 + 2a [Using a = Tp/Tt]

Maximum packets That can be Transmitted in total cycle time = 1+2*a Let me explain now with the help of an example. Consider Tt = 1ms, Tp = 1.5ms. In the picture given below, after sender has transmitted packet 0, it will immediately transmit packets 1, 2, 3. Acknowledgement for 0 will arrive after 2*1.5 = 3ms. In Stop and Wait, in time 1 + 2*1.5 = 4ms, we were transferring one packet only. Here we keep a window of packets that we have transmitted but not yet acknowledged. Sliding Window Protocol After we have received the Ack for packet 0, window slides and the next packet can be assigned sequence number 0. We reuse the sequence numbers which we have acknowledged so that header size can be kept minimum as shown in the diagram given below. Sliding Window Protocol

Minimum Number of Bits For Sender Window (Very Important For GATE)

As we have seen above,

 Maximum window size = 1 + 2*a    where a = Tp/Tt

Minimum sequence numbers required = 1 + 2*a.

All the packets in the current window will be given a sequence number. Number of bits required to represent the sender window = ceil(log2(1+2*a)). But sometimes number of bits in the protocol headers is pre-defined. Size of sequence number field in header will also determine the maximum number of packets that we can send in total cycle time. If N is the size of sequence number field in the header in bits, then we can have 2N sequence numbers. Window Size ws = min(1+2*a, 2N) If you want to calculate minimum bits required to represent sequence numbers/sender window, it will be ceil(log2(ws)). In this article, we have discussed sending window only. For receiving window, there are 2 protocols namely Go Back N and Selective Repeat which are used to implement pipelining practically. We will be discussing receiving window in set 2.

Types of Sliding Window Protocol

There are two types of Sliding Window Protocol which include Go-Back-N ARQ and Selective Repeat ARQ:

1. Go-Back-N ARQ

Go-Back-N ARQ allows sending more than one frame before getting the first frame's acknowledgment. It is also known as sliding window protocol since it makes use of the sliding window notion. There is a limit to the amount of frames that can be sent, and they are numbered consecutively. All frames beginning with that frame are retransmitted if the acknowledgment is not received in a timely manner. For more detail visit the page Go-Back-N ARQ.

2. Selective Repeat ARQ

Additionally, this protocol allows additional frames to be sent before the first frame's acknowledgment is received. But in this case, the excellent frames are received and buffered, and only the incorrect or lost frames are retransmitted. Check the detailed explanation of Selective Repeat ARQ.

Advantages of Sliding Window Protocol

  • Efficiency: The sliding window protocol is an efficient method of transmitting data across a network because it allows multiple packets to be transmitted at the same time. This increases the overall throughput of the network.
  • Reliable: The protocol ensures reliable delivery of data, by requiring the receiver to acknowledge receipt of each packet before the next packet can be transmitted. This helps to avoid data loss or corruption during transmission.
  • Flexibility: The sliding window protocol is a flexible technique that can be used with different types of network protocols and topologies, including wireless networks, Ethernet, and IP networks.
  • Congestion Control: The sliding window protocol can also help control network congestion by adjusting the size of the window based on the network conditions.

Disadvantages of Sliding Window Protocol

  • Complexity: The sliding window protocol can be complex to implement and can require a lot of memory and processing power to operate efficiently.
  • Delay: The protocol can introduce a delay in the transmission of data, as each packet must be acknowledged before the next packet can be transmitted. This delay can increase the overall latency of the network.
  • Limited Bandwidth Utilization: The sliding window protocol may not be able to utilize the full available bandwidth of the network, particularly in high-speed networks, due to the overhead of the protocol.
  • Window Size Limitations: The maximum size of the sliding window can be limited by the size of the receiver's buffer or the available network resources, which can affect the overall performance of the protocol.

Difference between the Go-Back-N ARQ and Selective Repeat ARQ

Go-Back-N ProtocolSelective Repeat Protocol
In Go-Back-N Protocol, if the sent frame are find suspected then all the frames are re-transmitted from the lost packet to the last packet transmitted.In selective Repeat protocol, only those frames are re-transmitted which are found suspected.
Sender window size of Go-Back-N Protocol is N.Sender window size of selective Repeat protocol is also N.
Receiver window size of Go-Back-N Protocol is 1.Receiver window size of selective Repeat protocol is N.
Go-Back-N Protocol is less complex.Selective Repeat protocol is more complex.
In Go-Back-N Protocol, neither sender nor at receiver need sorting.In selective Repeat protocol, receiver side needs sorting to sort the frames.
In Go-Back-N Protocol, type of Acknowledgement is cumulative.In selective Repeat protocol, type of Acknowledgement is individual.
In Go-Back-N Protocol, Out-of-Order packets are NOT Accepted (discarded) and the entire window is re-transmitted.In selective Repeat protocol, Out-of-Order packets are Accepted.
In Go-Back-N Protocol, if Receives  a corrupt packet, then also, the entire window is re-transmitted.In selective Repeat protocol, if Receives  a corrupt packet, it immediately sends a negative acknowledgement and hence only the selective packet is retransmitted.

Efficiency of Go-Back-N Protocol is

N/(1+2*a)

Efficiency of selective Repeat protocol is also

N/(1+2*a)

Conclusion

The Sliding Window Protocol is a crucial technique for assuring reliable and efficient data delivery in computer networks. Allowing many packets to be delivered before demanding acknowledgments and maximizes bandwidth use and minimizes delays. This protocol, which is implemented in forms such as Go-Back-N ARQ and Selective Repeat ARQ, maintains a balance between efficiency and reliability, despite the increased complexity and potential transmission latency.


K

kartik
Improve
Article Tags :
  • Computer Networks
  • Data Link Layer

Similar Reads

    TCP/IP Model
    The TCP/IP model (Transmission Control Protocol/Internet Protocol) is a four-layer networking framework that enables reliable communication between devices over interconnected networks. It provides a standardized set of protocols for transmitting data across interconnected networks, ensuring efficie
    7 min read
    Multiple Access Protocols in Computer Network
    Multiple Access Protocols are methods used in computer networks to control how data is transmitted when multiple devices are trying to communicate over the same network. These protocols ensure that data packets are sent and received efficiently, without collisions or interference. They help manage t
    9 min read
    Framing in Data Link Layer
    Frames are the units of digital transmission, particularly in computer networks and telecommunications. Frames are comparable to the packets of energy called photons in the case of light energy. Frame is continuously used in Time Division Multiplexing process. Framing is a point-to-point connection
    6 min read
    What is Ethernet?
    A LAN is a data communication network connecting various terminals or computers within a building or limited geographical area. The connection between the devices could be wired or wireless. Although Ethernet has been largely replaced by wireless networks, wired networking still uses Ethernet more f
    9 min read
    Ethernet Frame Format
    The basic frame format which is required for all MAC implementation is defined in IEEE 802.3 standard. Though several optional formats are being used to extend the protocol's basic capability. Ethernet frame starts with the Preamble and SFD, both work at the physical layer. The ethernet header conta
    8 min read
    Token Ring Frame Format
    In a Token Ring network, frames have a specific format to ensure reliable and orderly communication among nodes. The Token Ring uses a token-passing protocol for access control, and each frame follows a standardized structure as defined in IEEE 802.5.Structure of a Token Ring FrameToken Ring is a ne
    4 min read
    Difference between Byte stuffing and Bit stuffing
    In Data Communication Bit and Byte both techniques ensure that special control information which is being correctly transmitted without any mistake. Framing, which is the division of a stream of bits from the network layer into manageable units (called frames). Each frame consists of the sender's ad
    9 min read
    Hamming Code in Computer Network
    Hamming code is an error-correcting code used to ensure data accuracy during transmission or storage. Hamming code detects and corrects the errors that can occur when the data is moved or stored from the sender to the receiver. This simple and effective method helps improve the reliability of commun
    10 min read
    Back-off Algorithm for CSMA/CD
    Prerequisite - Basics of CSMA/ CD, Collision Detection in CSMA/CD Back-off algorithm is a collision resolution mechanism which is used in random access MAC protocols (CSMA/CD). This algorithm is generally used in Ethernet to schedule re-transmissions after collisions. If a collision takes place betw
    7 min read
    Collision Detection in CSMA/CD
    CSMA/CD (Carrier Sense Multiple Access/ Collision Detection) is a media access control method that was widely used in Early Ethernet technology/LANs when there used to be shared Bus Topology and each node ( Computers) was connected by Coaxial Cables. Nowadays Ethernet is Full Duplex and Topology is
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences