#include<stdio.h>
#include<conio.h>
#include<string.h>
int sx[10],rx[20];
int n=0,k=0,nk=0,sls=0,j=0,l=0,count=1,i=0;
void main()
{
clrscr();
printf("\n*****SLIDING WINDOW FLOW CONTROL PROTOCOL******\n");
printf("\nEnter the no of data:\n ");
scanf("%d",&n);
printf("\nenter the data at one by one:\n");
for(i=0;i<n;i++)
{
scanf("%d",&sx[i]);
}
printf("\nEnter the slide size:\n ");
scanf("%d",&sls);
printf("\n****The frame size is calculated [framesize=slidesize-1]****");
nk=sls-1;
printf("\nThe frame size is: %d \n",nk);
printf("\n\tSENDER \t\tRECEIVER\n\t*******\t\t*********\n");
for(i=0;i<n;i++)
{
rx[i]=sx[i];
k++;
printf("\t");
for(j=i;j<nk;j++)
printf("%d",sx[j]);
printf("\t\t");
for(l=0;l<k;l++)
printf("%d",rx[l]);
printf("\t\n");
if(i==count)
{
getch();
printf("\n\t ACK%d is accered\n\n",count+1);
count+=2;
nk+=2;
}
getch();
}
printf("\n***The final zeros are consider as empty****");
getch();
}
#include<conio.h>
#include<string.h>
int sx[10],rx[20];
int n=0,k=0,nk=0,sls=0,j=0,l=0,count=1,i=0;
void main()
{
clrscr();
printf("\n*****SLIDING WINDOW FLOW CONTROL PROTOCOL******\n");
printf("\nEnter the no of data:\n ");
scanf("%d",&n);
printf("\nenter the data at one by one:\n");
for(i=0;i<n;i++)
{
scanf("%d",&sx[i]);
}
printf("\nEnter the slide size:\n ");
scanf("%d",&sls);
printf("\n****The frame size is calculated [framesize=slidesize-1]****");
nk=sls-1;
printf("\nThe frame size is: %d \n",nk);
printf("\n\tSENDER \t\tRECEIVER\n\t*******\t\t*********\n");
for(i=0;i<n;i++)
{
rx[i]=sx[i];
k++;
printf("\t");
for(j=i;j<nk;j++)
printf("%d",sx[j]);
printf("\t\t");
for(l=0;l<k;l++)
printf("%d",rx[l]);
printf("\t\n");
if(i==count)
{
getch();
printf("\n\t ACK%d is accered\n\n",count+1);
count+=2;
nk+=2;
}
getch();
}
printf("\n***The final zeros are consider as empty****");
getch();
}
No comments:
Post a Comment