SLIDING WINDOW PROTOCOL
AIM:
To write a C program to simulate sliding window protocol
ALGORITHM:
- Start the program.
- Get the frame size from the user
- To create the frame based on the user request.
- To send frames to server from the client side.
- If your frames reach the server it will send ACK signal to client otherwise it will send NACK signal to client.
- Stop the program
PROGRAM:
#include<stdio.h>
int main()
{
int i,sq,ws,buf=20,ls=0,rcv[20],count,ack,ch;
do
{
count=0;
printf(“\n Enter window size:”);
scanf(“%d”,&ws);
if(buf>0)
{
for(sq=ls;count<ws;sq++)
{
rcv[sq]=sq;
printf(” Enter the data in number:”);
printf(“\n %d \n”,rcv[sq]);
count++;
buf–;
ls++;
}
}
else
{
printf(“\n buffer is full!”);
break;
}
ack=ls;
printf(“\n ACK NO=%d”,ack);
printf(“\n enter to quit or enter any no:”);
scanf(“%d”,&ch);
}
while(ch!=1);
}
OUTPUT:
Enter window size:5
Enter the data in number:0
Enter the data in number:1
Enter the data in number:2
Enter the data in number:3
Enter the data in number:4
ACK NO=5
Enter to quit or enter any nymber:2
Enter window size:10
Enter the data in number:5
Enter the data in number:6
Enter the data in number:7
Enter the data in number:8
Enter the data in number:9
Enter the data in number:10
Enter the data in number:11
Enter the data in number:12
Enter the data in number:13
Enter the data in number:14
ACK NO=15
Enter to quit
RESULT:
Thus the simulation of sliding window protocol has been executed and verified successfully