Exp 5
Exp 5
Sliding window protocols are data link layer protocols for reliable and sequential delivery of data frames. The sliding
window is also used in Transmission Control Protocol. In this protocol, multiple frames can be sent by a sender at a
time before receiving an acknowledgment from the receiver. The term sliding window refers to the imaginary boxes to
hold frames. The sliding window method is also known as windowing. The Sliding Window ARQ (Automatic Repeat
Request) protocols are of two categories:
1. Go – Back – N ARQ: Go – Back – N ARQ provides for sending multiple frames before receiving the
acknowledgment for the first frame. It uses the concept of sliding window, and so is also called sliding window
protocol. The frames are sequentially numbered and a finite number of frames are sent. If the acknowledgment of a
frame is not received within the time period, all frames starting from that frame are retransmitted.
2. Selective Repeat ARQ: This protocol also provides for sending multiple frames before receiving the
acknowledgment for the first frame. However, here only the erroneous or lost frames are retransmitted, while the good
frames are received and buffered
Algorithm:
Program:
include <bits/stdc++.h>
using namespace std;
int reciever(int temp1)
{
int i;
for (i = 1; i < 100; i++)
rand();
i = rand() % temp1;
return i;
}
int nack(int templ)
{
int i;
for (i = 1; i < 100; i++)
rand();
i = rand() % templ;
return i;
}
int simulate(int winsize)
{
int temp1, i;
for (i = 1; i < 50; i++)
temp1 = rand();
if (temp1 == 0)
temp1 = simulate(winsize);
i = temp1 % winsize;
if (i == 0)
return winsize;
else
return temp1 % winsize;
}
int main()
{
int temp1, temp2, temp3, temp4, temp5, i, winsize = 8,noframes, moreframes;
char c;
temp4 = 0, temp1 = 0, temp2 = 0, temp3 = 0, temp5 = 0;
Conclusion
The Sliding Window protocol was discussed and implemented, and the outputs were verified.