-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVormetricVAEClient.java
More file actions
183 lines (148 loc) · 4.68 KB
/
VormetricVAEClient.java
File metadata and controls
183 lines (148 loc) · 4.68 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import java.io.*;
import java.net.*;
import java.util.Random;
public class VormetricVAEClient {
static String application = "hr";
String inputdata = "app:machine:operation:value";
public static boolean isNumeric(String str) {
// StringBuffer specialchar = new StringBuffer();
for (char c : str.toCharArray()) {
if (!Character.isDigit(c)) {
System.out.println(c);
return false;
}
}
return true;
}
public static void main(String[] args) {
try {
Integer loopcnt = new Integer(1);
String ip = "192.168.159.134";
String algo = "CTR";
if (args.length == 3) {
if (isNumeric(args[1]))
{
ip = args[0];
loopcnt = new Integer(args[1]);
algo = args[2];
if (algo.equalsIgnoreCase("CTR") || algo.equalsIgnoreCase("CBC_PAD")|| algo.equalsIgnoreCase("CBC")|| algo.equalsIgnoreCase("FPE"))
System.out.println("Starting client with ip " + ip + " loopcnter " + loopcnt);
else
System.out.println("invalid algorithum valid values are CTR, CBC_PAD, CBC ");
}
else {
System.out.println("Loop counter must be numeric ");
System.exit(1);
}
} else {
System.out.println("format is program name ipaddress loopcnt algorithum ");
System.exit(1);
}
Socket s = new Socket(args.length == 0 ? "192.168.159.134" : args[0], 8181);
// Socket s = new Socket(args.length == 0 ? "192.168.159.134" : args[0], 8181);
DataOutputStream os = null;
DataInputStream is = null;
os = new DataOutputStream(s.getOutputStream());
is = new DataInputStream(s.getInputStream());
Random r = new Random();
int Low = 1000000;
int High = 3000000;
if (s != null && os != null && is != null) {
// "5471949763376677", "5545127221796024",
// The capital string before each colon has a special meaning to
// SMTP
// you may want to read the SMTP specification, RFC1822/3
StringBuffer sb = null;
String hostname = getHostName();
// StringBuffer randomestr = new StringBuffer();
int Result = 0;
for (int i = 0; i < loopcnt; i++) {
Result = r.nextInt(High-Low) + Low;
System.out.println("randome number " + Result);
sb = new StringBuffer();
sb.append(application);
sb.append(":");
sb.append(hostname);
sb.append(":");
sb.append(algo);
sb.append(":");
sb.append(String.valueOf(Result));
//randomestr.append(String.valueOf(Result));
sb.append(" \n");
os.writeBytes(sb.toString());
System.out.println(sb.toString());
// os.writeBytes("5471949763376677 \n");
/* sb = new StringBuffer();
sb.append(application);
sb.append(":");
sb.append(hostname);
sb.append(":");
sb.append("CBC_PAD");
sb.append(":");
sb.append("5545127221796024 \n");
os.writeBytes(sb.toString());
sb = new StringBuffer();
sb.append(application);
sb.append(":");
sb.append(hostname);
sb.append(":");
sb.append("CBC_PAD");
sb.append(":");
sb.append("7381572023856677 \n");
os.writeBytes(sb.toString());
sb = new StringBuffer();
// os.writeBytes("5545127221796024 \n");
// os.writeBytes("\n.\n");
// os.writeBytes("stop \n");
sb.append(application);
sb.append(":");
sb.append(hostname);
sb.append(":");
sb.append("CBC_PAD");
sb.append(":");
sb.append("0828428305336024 \n");
os.writeBytes(sb.toString());
*/
}
sb = new StringBuffer();
// os.writeBytes("5545127221796024 \n");
// os.writeBytes("\n.\n");
// os.writeBytes("stop \n");
sb.append(application);
sb.append(":");
hostname = getHostName();
sb.append(hostname);
sb.append(":");
sb.append("CBC_PAD");
sb.append(":");
sb.append("stop \n");
os.writeBytes(sb.toString());
}
OutputStream out = s.getOutputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
String responseLine;
while ((responseLine = is.readLine()) != null) {
System.out.println("Server: " + responseLine);
if (responseLine.indexOf("stop") != -1) {
break;
}
}
// String str = in.readLine();
// System.out.println("Socket message: " + str);
in.close();
os.close();
is.close();
s.close();
} catch (Exception e) {
}
}
public static String getHostName() throws UnknownHostException {
InetAddress iAddress = InetAddress.getLocalHost();
String hostName = iAddress.getHostName();
// To get the Canonical host name
String canonicalHostName = iAddress.getCanonicalHostName();
System.out.println("HostName:" + hostName);
System.out.println("Canonical Host Name:" + canonicalHostName);
return canonicalHostName;
}
}