Leaky Bucket Program

April 13, 2017 | Author: Praveen Reddy | Category: N/A
Share Embed Donate


Short Description

Download Leaky Bucket Program...

Description

Networks Lab

2010-2011

Progarm8. Write a program for Congestion control using the leaky bucket algorithm #include int min(int x,int y) { if(x < y) { return x; } else return y; } int main() { int drop=0, mini, nsec, cap, count = 0; int i,inp[25],process; printf("Enter the Bucket Size:\n"); scanf("%d",&cap); printf("Enter the Processing Rate:\n"); scanf("%d",&process); printf("Enter The No. Of Seconds You Want To Stimulate:\n"); scanf("%d",&nsec);

Dept. of CS&E, BAE

1

Networks Lab

2010-2011

for(i=0;icap) { drop=count-cap; count=cap; } printf("%d",i+1); printf("\t0"); mini=min(count,process); printf("\t\t%d",mini); count=count-mini; printf("\t\t%d",count); printf("\t\t%d\n",drop); } }

Dept. of CS&E, BAE

3

Networks Lab

2010-2011

Execution and Output: $ cc 8.c $ ./a.out

Enter the Bucket Size: 5 Enter the Processing Rate: 2 Enter The No. Of Seconds You Want To Stimulate: 3 Enter the Size of the Packet Entering at 1 sec: 5 Enter the Size of the Packet Entering at 2 sec: 4 Enter the Size of the Packet Entering at 3 sec: 3 Second 1 2 3 4 5

Packet Received 5 4 3 0 0

Dept. of CS&E, BAE

Packet Sent 2 2 2 2 1

Packet Left 3 3 3 1 0

Packet Dropped 0 2 1 0 0

4

Networks Lab

Dept. of CS&E, BAE

2010-2011

5

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF