Future Vision BIE Future Vision BIE


ONE STOP FOR ALL STUDY MATERIALS & LAB PROGRAMS


E MENU Whatsapp Share Join Telegram, to get Instant Updates
× NOTE! Click on MENU to Browse between Subjects...

Advertisement

17CSL57
COMPUTER NETWORK LABORATORY
[As per Choice Based Credit System (CBCS) scheme]
(Effective from the academic year 2017-2018)
SEMESTER - V



This Page Provides Program & Output.
Program 12

Program 12
Write a program for congestion control using leaky bucket algorithm.




Advertisement

PRO12.java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import java.io.*; 
import java.util.*; 

class PRO12 { 
	private static int no_of_packet,bucket_capacity,array_size,current_bucket,over_flow,fixed_data_flow;
	private static int array[];
	public void LeakyBucket()
	{
		current_bucket=0;
		System.out.print("\nCurrent Bucket size :" +current_bucket );
		for(int i=0;i<array_size;i++)
		{
			int input=array[i];
			System.out.print("\n----------------------\nInput to bucket is " +input );
			over_flow=0;
			current_bucket=current_bucket+input;
			System.out.print("\nCurrent Bucket size :"+current_bucket);
			if(current_bucket<=fixed_data_flow)
				current_bucket=0;
			else
			{
				current_bucket=current_bucket-fixed_data_flow;
			}
				
			if(current_bucket<=bucket_capacity)
			{
				System.out.print("\nNO OverFLOW");
			}
			else
			{
				over_flow=(current_bucket-bucket_capacity);
				current_bucket=bucket_capacity;
				System.out.print("\nOver Flow Occured :"+over_flow);
			}
			System.out.print("\nAfter Processing Bucket size is :"+current_bucket);
			
		}
	}
	public static void main(String args[])
	{
		PRO12 pr = new PRO12();
		Scanner scan = new Scanner(System.in);
		System.out.print("Enter the Bucket Capacity : ");
		bucket_capacity = scan.nextInt();
		System.out.print("\nEnter the Bucket Fixed Data Flow : ");
		fixed_data_flow = scan.nextInt();
		System.out.print("\nEnter the Array Size : ");
		array_size=scan.nextInt();
		System.out.println("\nEnter the Input values of size : "+array_size);
		array = new int[array_size];
		for(int i=0;i<array_size;i++)
		{
			array[i]=scan.nextInt();
		}
		
		System.out.println("The Input for LeakyBucket is ");
		for(int i=0;i<array_size;i++)
		{
			System.out.print(array[i]+ " " );
		}
		
		pr.LeakyBucket();
		System.out.print("\n\nPROGRAM TERMINATING SUCCESSFULLY...\n");
		scan.close();
	}

}




Process to Execute the Program

Step 1: We need to have Java JDK installed, So That Java Programs can Run.
Step 2: Copy & Paste the Below Code of PRO12.java.
Step 3: or simple Download the Source Code.

Loading Image
Fig 12.1: Required Files .

Step 4: Open Command Prompt (cmd).
Step 5: Navigate to the PRO11.java File location.
Step 6: Use CD & DIR command on cmd to navigate.
Step 7: First Run the PRO11.java => javac PRO12.java
Step 8: => java PRO12

Loading Image
Fig 12.2: Demonstration of PRO12.java .

Step 9: Enter the Bucket Capacity
Step 10: Enter the Fixed Data Flow from Bucket
Step 11: Enter the Array size
Step 12: Enter the Input values for the Leaky Bucket
Step 13: Get the Output

× Note Please Share the website link with Your Friends and known Students...

-ADMIN

× Note Page Number is specified to navigate between Pages...
T = Text book
QB = Question Bank
AS = Amswer Script

-ADMIN