0% found this document useful (0 votes)
6 views2 pages

Sliding Window Protocol

Uploaded by

Rakshith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Sliding Window Protocol

Uploaded by

Rakshith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Aim: -

Implement Sliding Window Protocol in a C program and execute the same and
display the result.

Theory:-
(i) Sliding Window Protocol :
Theory:

Program:

#include <stdio.h>
#include <stdlib.h>
#define RTT 5
int main()
{
int window_size,i,f,frames[50];
printf("Enter window size: ");
scanf("%d",&window_size);
printf("\nEnter number of frames to transmit: ");
scanf("%d",&f);
printf("\nEnter %d frames: ",f);
for(i=1;i<=f;i++)
scanf("%d",&frames[i]);
printf("\nAfter sending %d frames at each stage sender waits for ACK”,window_size);

printf("\nSending frames in the following manner.\n\n");


for(i=1;i<=f;i++)
{
if(i%window_size!=0)
{
printf(" %d",frames[i]);
}
else
{
printf(" %d\n",frames[i]);
printf("SENDER: waiting for ACK...\n\n");
sleep(RTT/2);
printf("RECEIVER: Frames Received, ACK Sent\n");
printf(" \n");
sleep(RTT/2);
printf("SENDER:ACK received, sending next frames\n");
}

}
if(f%window_size!=0)
{
printf("\nSENDER: waiting for ACK...\n");
sleep(RTT/2);
printf("\nRECEIVER:Frames Received, ACK Sent\n");
printf("\n");
sleep(RTT/2);
printf("SENDER:ACK received.");
}
return 0;
}

You might also like