PROGRAM-10
Write a program for congestion control using leaky bucket
algorithm.
import [Link].*;
class pg12
{
public static void main(String args[])
{
Scanner sc=new Scanner([Link]);
int i,size,nop,opr,temp=0; int[]
datarate=new int[100];
[Link]("enter the bucket size");
size=[Link]();
[Link]("enter the number of packets");
nop=[Link]();
[Link]("enter the dara rate");
for(i=0;i<nop;i++)
datarate[i]=[Link]();
[Link]("enter the output rate");
opr=[Link]();
for(i=0;i<nop;i++)
{
if(datarate[i]>size)
[Link]("bucket overflow");
else
{
temp=datarate[i];
while(temp>opr)
{
[Link]("packet transmission"+opr);
temp=temp-opr;
}
[Link]("packet transmission"+temp);
}
}
}
}
Output
$ gedit [Link]
$ javac [Link]
$ java Leakybucket
Enter the bucket size=
50
Enter the number of packets=
3
Enter the Data rate=
35 76 10
Enter output rate=
10