The Wayback Machine - https://web.archive.org/web/20241005205235/https://www.geeksforgeeks.org/sliding-window-protocol-set-1/
Open In App

Sliding Window Protocol | Set 1 (Sender Side)

Last Updated : 25 Jul, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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 Protocol Selective 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.

Frequently Asked Question on Sliding Window Protocol – FAQs

What are the components of the SWP?

Sliding Window Protocol are Sender Window , Reciever Window , Acknowledgement.

What happens when a packet is lost ?

If the packet is lost then the sender retransmit the packet again then receiver sends acknowledgement for the retransmitted packet.

Is out of ordering of packet allowed in Sliding window Protocol?

Out of order packet is not allowed in Sliding Window Protocol.

What is Round Trip Time?

The amount of milliseconds (ms) required for a network request to travel from a starting point to a destination and back again is known as the round-trip time (RTT).



Previous Article
Next Article

Similar Reads

Difference between Stop and Wait protocol and Sliding Window protocol
Both the Stop and Wait protocol and the Sliding Window protocol are the techniques to the solution of flow control handling. The main difference between the Stop-and-wait protocol and the Sliding window protocol is that in the Stop-and-Wait Protocol, the sender sends one frame and waits for acknowledgment from the receiver whereas in the sliding wi
5 min read
Sliding Window Protocol | Set 3 (Selective Repeat)
Prerequisite : Sliding Window Protocol - Set 1 (Sender Side), Set 2 (Receiver Side) 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 t
3 min read
Sliding Window Protocol - Go Back N (GBN)
The Sliding Window Protocol is a method used in computer networks to manage the flow of data between two devices, ensuring that data is sent and received in the correct order. There are two types of sliding window protocol Go-Back-N (GBN), and Selective Repeat (SR). In Go-Back-N, the sender can send multiple data packets without waiting for an ackn
7 min read
Sliding Window protocols Summary With Questions
Prerequisites - Stop & Wait, Go Back N, Selective Repeat Summary of all the protocols - Before starting with the questions a quick recap for all the protocols. Stop and wait - Sender window size (Ws) = 1Receiver window size (Wr) = 1Sequence Number ≥ 1 + 1Uses independent acknowledgementDiscards out of order packetsPacket Loss ? Retransmit packe
4 min read
Hot Standby Router Protocol (HSRP) and Virtual Router Redundancy Protocol (VRRP)
Hot Standby Router Protocol (HSRP) is a CISCO proprietary protocol used to provide redundancy in a network. Only one router is the active router while others will be in standby state i.e the standby router will be responsible for forwarding the traffic when the active router fails. Virtual Router Redundancy Protocol (VRRP) is an open standard proto
3 min read
Cisco Discovery Protocol (CDP) and Link Layer Discovery Protocol (LLDP) in Data Link Layer
Layer 2 or the Datalink layer provides physical addressing and access to media. It defines how data is to be formatted for transmission and how access to the network is to be controlled. It also provides error detection, ensuring data on higher layers is formatted correctly for transmission. Cisco Discovery Protocol (CDP) and Link Layer Discovery P
2 min read
Difference between Border Gateway Protocol (BGP) and Routing Information Protocol (RIP)
When dealing with network routing, it's crucial to understand the various protocols that help direct traffic across complex networks. Two significant protocols in this space are the Border Gateway Protocol (BGP) and the Routing Information Protocol (RIP). Each serves different purposes and operates under different principles. This article explores
5 min read
Difference between File Transfer Protocol (FTP) and Secure File Transfer Protocol (SFTP)
Data transfer is the most common task in network and system communications, and they involve transfer of files using two means i.e the File Transfer Protocol (FTP) and the Secure File Transfer Protocol (SFTP). FTP is a commonly applied protocol that enables files to be transferred through a network from one computer to another, but FTP is unsecure
5 min read
Difference between Spanning Tree Protocol (STP) and Rapid Spanning Tree Protocol (RSTP)
Spanning Tree Protocol (STP) and Rapid Spanning Tree Protocol (RSTP), are designed to avoid network loops in Ethernet. It provide loop-free logical topology. They were both designed to provide network reliability and particularly avoid broadcast radiation, but the major differences are on the rate, functionality and versatility. In this article we
5 min read
Difference between Serial Line Internet Protocol (SLIP) and Point-to-Point Protocol (PPP)
SLIP and PPP, which are the widely used serial connection techniques, help to connect the distant devices of the network. The fullform of SLIP is Session Layer Internetworking Protocol. SLIP being a primitive protocol put into use during the early connections to the Internet, when there was not much overhead. PPP is slightly more complex as the pro
6 min read
Difference between Client side filter and Server side filters in Cyber Security
Filters are key components in web applications that validate user input and ensure it meets certain standards. These filters can be implemented on the client side (within the user's web browser) or the server side (on the web server). Understanding the differences between client-side and server-side filters is necessary to maintain data quality and
5 min read
Secure Electronic Transaction (SET) Protocol
Secure Electronic Transaction or SET is a security protocol designed to ensure the security and integrity of electronic transactions conducted using credit cards. Unlike a payment system, SET operates as a security protocol applied to those payments. It uses different encryption and hashing techniques to secure payments over the internet done throu
5 min read
MAC Protocol Used in Wireless Sensor Networks
Pre-requisites: Classification of MAC Protocols In Wireless Sensor Networks (WSNs), the Medium Access Control (MAC) protocol is a set of guidelines that dictate how each node should transmit data over the shared wireless medium. The primary objective of the MAC protocol is to minimize the occurrence of idle listening, over-hearing, and collisions o
6 min read
Hot Standby Router Protocol (HSRP)
Hot Standby Router Protocol (HSRP) is a CISCO proprietary protocol, which provides redundancy for a local subnet. In HSRP, two or more routers gives an illusion of a virtual router. HSRP allows you to configure two or more routers as standby routers and only a single router as an active router at a time. All the routers in a single HSRP group share
4 min read
What is DCCP (Datagram Congestion Control Protocol)?
Congestion in a network means deterioration of network or services which are caused due to overloading of network nodes, basically, this problem is primarily associated with large networks, in which a large amount of data and information is being transmitted. Congestion can be caused by several reasons: either the routers which are being used are n
6 min read
Introduction of Virtual Router Redundancy Protocol (VRRP) and its configuration
VRRP is an open standard protocol, which is used to provide redundancy in a network. It is a network layer protocol (protocol number-112). The number of routers (group members) in a group acts as a virtual logical router which will be the default gateway of all the local hosts. If one router goes down, one of the other group members can take place
4 min read
Dynamic Trunking Protocol (DTP)
Trunk ports are ports that are used to carry the traffic of more than one VLAN. The port which connects two different switches and the switches have more than one VLAN configured then that port should be made trunk. If all the VLANs are allowed then trunk ports will carry traffic of all the VLANs including native VLANs for which the traffic goes un
4 min read
VLAN Trunking Protocol (VTP)
To carry traffic of a VLAN, it must be first configured on the switch. Suppose, if the user wants to send a frame from source to destination and the shortest path between them contains 1000 switches. To process a frame of any VLAN, VLANs should be configured first so, have to configure the same VLANs on all the 1000 switches manually. It will not b
5 min read
Root Bridge Election in Spanning Tree Protocol
Redundant links are used to provide a backup path when one link goes down but a Redundant link can sometimes cause switching loops. The main purpose of Spanning Tree Protocol (STP) is to ensure that you do not create loops when you have redundant paths in your network. Spanning Tree Protocol (STP) - As IEEE STP is used to make a loop-free network b
4 min read
Features of Enhanced Interior Gateway Routing Protocol (EIGRP)
Enhanced Interior Gateway Routing Protocol (EIGRP) is a Cisco-proprietary Hybrid routing protocol that contains features of distance-vector and link-state routing protocols. It is a network layer protocol that works on protocol number 88. Some of its features are: Rapid convergence - EIGRP uses a DUAL algorithm to support rapid convergence. If a ro
4 min read
Open Shortest Path First (OSPF) Protocol fundamentals
Open shortest path first (OSPF) is a link-state routing protocol that is used to find the best path between the source and the destination router using its own shortest path first (SPF) algorithm. A link-state routing protocol is a protocol that uses the concept of triggered updates, i.e., if there is a change observed in the learned routing table
5 min read
Types of Spanning Tree Protocol (STP)
Prerequisite - Spanning Tree Protocol Spanning Tree Protocol (STP) is used to make a loop free network by monitoring the network to track all the links and shut down the least redundant ones. Root bridge is a switch in a single VLAN or whole topology (according to the type of STP standard used) which is responsible for distributing BPDUs and block
3 min read
Routing Information Protocol (RIP)
Routing Information Protocol (RIP) is a dynamic routing protocol that uses hop count as a routing metric to find the best path between the source and the destination network. It is a distance-vector routing protocol that has an AD value of 120 and works on the Network layer of the OSI model. RIP uses port number 520. Hop Count Hop count is the numb
6 min read
What is Anonymous FTP (File Transfer Protocol)?
AFTP (Anonymous File Transfer Protocol) is a network protocol used for transmitting files using TCP-based networks. Anonymous file transfer protocol lets a user move files anonymously from one computer to another. Anonymous FTP operates at layer 7; anonymous FTP permits anonymous external computer users without any designated password or user ID to
3 min read
Gateway Load Balancing Protocol (GLBP)
Gateway Load Balancing Protocol (GLBP) is one of First Hop Redundancy Protocol (FHRP) which provides redundancy like other First Hop Redundancy Protocol, also provides load Balancing. It is a Cisco proprietary protocol which can perform both functions. It provides load Balancing over multiple routers using single virtual IP address and multiple vir
5 min read
Challenge Handshake Authentication Protocol (CHAP)
Challenge Handshake Authentication Protocol (CHAP) is a Point-to-point protocol (PPP) authentication protocol developed by IETF (Internet Engineering Task Force). It is used at the initial startup of the link. Also, it performs periodic checkups to check if the router is still communicating with the same host. Features : It uses 3-way handshaking p
5 min read
RADIUS Protocol
If a single administrator wants to access 100 routers and the local database of the device is used for username and password (authentication) then the administrator has to make the same user account at different times. Also, if he wants to keep a different username and password for the devices then he has to manually change the authentication for t
4 min read
TACACS+ Protocol
If a single administrator wants to access 100 routers and the local database of the device is used for username and password (authentication) then the administrator has to make the same user account at different times. Also, if he wants to keep a different username and password for the devices then he has to manually change the authentication for t
3 min read
Password Authentication Protocol (PAP)
There are simply two methods to authenticate PPP links namely Password Authentication Protocol (PAP) and Challenge Handshake Authentication Protocol (CHAP). From these two authentication protocols, PAP is less secured as the password is sent in clear text and is performed only at the initial link establishment. Password Authentication Protocol (PAP
3 min read
Routing Information Protocol (RIP) V1 & V2
Routing Information Protocol (RIP) protocol are the intradomain (interior) routing protocol which is based on distance vector routing and it is used inside an autonomous system.Routers and network links are called node. The first column of routing table is destination address. The cost of metric in this protocol is hop count which is number of netw
4 min read