Skip to content

Commit 0dda35e

Browse files
sliding window proctol in c++
1 parent cca22c4 commit 0dda35e

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include<stdio.h>
2+
3+
int main()
4+
{
5+
int w,i,f,frames[50];
6+
7+
printf("Enter window size: ");
8+
scanf("%d",&w);
9+
10+
printf("\nEnter number of frames to transmit: ");
11+
scanf("%d",&f);
12+
13+
printf("\nEnter %d frames: ",f);
14+
15+
for(i=1;i<=f;i++)
16+
scanf("%d",&frames[i]);
17+
18+
printf("\nWith sliding window protocol the frames will be sent in the following manner (assuming no corruption of frames)\n\n");
19+
printf("After sending %d frames at each stage sender waits for acknowledgement sent by the receiver\n\n",w);
20+
21+
for(i=1;i<=f;i++)
22+
{
23+
if(i%w==0)
24+
{
25+
printf("%d\n",frames[i]);
26+
printf("Acknowledgement of above frames sent is received by sender\n\n");
27+
}
28+
else
29+
printf("%d ",frames[i]);
30+
}
31+
32+
if(f%w!=0)
33+
printf("\nAcknowledgement of above frames sent is received by sender\n");
34+
35+
return 0;
36+
}

0 commit comments

Comments
 (0)