0% found this document useful (0 votes)
2 views

Program 10

The document provides a Java program implementing the leaky bucket algorithm for congestion control. It prompts the user for bucket size, number of packets, data rates, and output rate, and checks for bucket overflow while simulating packet transmission. The program outputs the transmission details based on the specified rates and bucket size.

Uploaded by

Anisha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Program 10

The document provides a Java program implementing the leaky bucket algorithm for congestion control. It prompts the user for bucket size, number of packets, data rates, and output rate, and checks for bucket overflow while simulating packet transmission. The program outputs the transmission details based on the specified rates and bucket size.

Uploaded by

Anisha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PROGRAM-10

Write a program for congestion control using leaky bucket


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

You might also like