Skip to main content

Sliding Window Protocol

What is Sliding Window Flow Control?

Sliding Window Flow Control is a mechanism that controls the flow of data between a sender and a receiver. It prevents the sender from overwhelming the receiver with too much data at once and ensures that data is transmitted efficiently.


Key Concepts

  1. Window Size:

    • The "window" represents the amount of data (in bytes or packets) that the sender can send before requiring an acknowledgment (ACK) from the receiver.
    • Both the sender and receiver agree on the window size beforehand.
  2. Acknowledgments (ACKs):

    • The receiver sends an acknowledgment to confirm the successful receipt of data.
    • The sender uses these acknowledgments to decide how much more data to send.
  3. Sliding Mechanism:

    • As the receiver acknowledges packets, the sender’s window "slides" forward, allowing it to send additional packets.

How It Works

  1. Initial Transmission:

    • The sender transmits packets up to the window size limit.
    • For example, if the window size is 4 packets, the sender sends packets 1, 2, 3, and 4.
  2. Waiting for Acknowledgments:

    • The sender waits for ACKs from the receiver.
    • If the receiver acknowledges packet 1, the window slides forward, allowing the sender to send packet 5.
  3. Retransmission:

    • If a packet is lost or corrupted, the receiver does not acknowledge it.
    • The sender retransmits the lost packet once it detects the missing acknowledgment.

Types of Sliding Window Protocols

  1. Go-Back-N (GBN):

    • If a packet is lost, the sender retransmits the lost packet and all subsequent packets in the window, even if some were already received correctly.
  2. Selective Repeat (SR):

    • The sender retransmits only the lost or corrupted packets.
    • This method is more efficient but requires the receiver to store out-of-order packets.

Advantages of Sliding Window Protocols

  • Efficiency: Sliding Window allows multiple packets to be in transit simultaneously, maximizing the use of available bandwidth.

  • Error Handling: Mechanisms like Go-Back-N and Selective Repeat ensure reliable communication.

  • Flow Control: Prevents the receiver's buffer from being overwhelmed by regulating the rate of data transfer.

Comments

Popular posts from this blog

CSL 332 Networking Lab KTU 2019 Scheme - Dr Binu V P

CSL 332 Networking Lab KTU BTech 2019 Scheme About Me Scheme Syllabus Experiments 1.Learn the Networking Commands and Network Configuration Files     Basic networking commands     More Networking commands     Network configuration Files     View the configuration and address of your network interface     Network Connectivity      View Active TCP connections     MAC address of another machine using ARP  2.  System calls in Network Programming 3.  Simple TCP/IP Client Server Program 4.  Simple UDP Client Server Program 5.Application Programs     Concurrent UDP Time Server     Checking Prime Numbers 6. Simulate ARQ Protocols  / sliding window protocols          Stop and Wait           Go-Back-N          Selective Repeat  7. Routing Protocols - Distance Vector and Link State   ...

Stop and Wait ARQ

Here's a simple C program that demonstrates the Stop-and-Wait ARQ protocol. This basic implementation simulates the sender transmitting packets one at a time and waiting for an acknowledgment from the receiver. If the acknowledgment is not received, the sender retransmits the packet. Key Points: The sender sends one packet at a time. If the receiver acknowledges it (ACK), the sender sends the next packet. If the acknowledgment is lost, the sender retransmits after a timeout. C Program: Stop-and-Wait ARQ Simulation #include <stdio.h> #include <stdlib.h> #include <time.h> #include <unistd.h>  // for sleep() #define TIMEOUT 3  // Timeout duration in seconds #define TOTAL_PACKETS 5  // Number of packets to send int simulate_acknowledgment() {     // Simulate a 70% chance of successful acknowledgment     return rand() % 10 < 7; } int main() {     srand(time(0));  // Seed for random number generation     i...

Go-Back-N ARQ

Here's a simple Go-Back-N ARQ implementation using C socket programming to simulate communication between a client (sender) and a server (receiver). Overview: Go-Back-N ARQ allows the sender to send multiple packets (window size) without waiting for individual ACKs. If a packet is lost or an ACK is not received, all packets starting from the lost packet are retransmitted. The server randomly simulates ACK loss or successful reception. Program Structure: Server : Simulates ACK reception with a chance of ACK loss, acknowledging packets up to the first lost packet. Client : Sends packets in a sliding window fashion, retransmitting the entire window if an ACK is lost. Server - Receiver #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <arpa/inet.h> #include <time.h> #define PORT 8080 #define BUFFER_SIZE 1024 #define LOSS_PROBABILITY 30  // 30% chance of ACK loss int main() {     int server_fd, new_soc...