-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjava3
More file actions
45 lines (45 loc) · 912 Bytes
/
Copy pathjava3
File metadata and controls
45 lines (45 loc) · 912 Bytes
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
import java.net.*;
import java.io.*;
class Main
{
static int bkt;
static void bktinput(int a,int b)
{
if(a>bkt)
{
System.out.println("bkt overflow and packet rejected");
}
else
{
while(a>b)
{
System.out.println("bytes outputtede is"+b);
a-=b;
}
if(a>0)
{
System.out.println("remaining byte :"+a);
System.out.println("last byte send:"+a);
System.out.println("bytes send succesfully");
}
}
}
public static void main(String[] args)
{
int op,pktSize,i,N;
Scanner s = new Scanner(System.in);
System.out.println("enter the bkt size");
bkt=s.nextInt();
System.out.println("enter the output rate");
op = s.nextInt();
Random randomGenerator= new Random();
System.out.println("number of packet to be generated");
N=s.nextInt();
for(i=0;i<N;i++)
{
pktSize=randomGenerator.nextInt(100);
System.out.println("packet no"+" "+i+"and packet size:"+pktSize);
}
bktinput(pktSize,op);
}
}