-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparser.py
More file actions
70 lines (61 loc) · 2.11 KB
/
parser.py
File metadata and controls
70 lines (61 loc) · 2.11 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
filenames = ["network_latency_nt_a.txt", "network_latency_nt_na.txt", "network_latency_t_a.txt",
"network_latency_t_na.txt", "secure_latency_nt_a.txt", "secure_latency_nt_na.txt",
"secure_latency_t_a.txt", "secure_latency_t_na.txt"
]
result_file_network = open("results_network.csv", "w")
result_file_network.write("info traffic attack Path_Length PIR latency throughput\n")
result_file_network.close()
result_file_network = open("results_network.csv", "a")
result_file_secure = open("results_secure.csv", "w")
result_file_secure.write("info traffic attack Path_Length PIR latency throughput WCL\n")
result_file_secure.close()
result_file_secure = open("results_secure.csv", "a")
for filename in filenames:
# print "-------------------------"*2
file = open(filename, "r")
Attack_Path_Length = None
PIR = None
latency = None
throughput = None
attack = True
traffic = True
info = None
WCL = None
if "secure" in filename:
info = "S"
if "network" in filename:
info = "N"
if "na" in filename:
attack = False
if "nt" in filename:
traffic = False
for line in file:
if "#"*92 in line:
if throughput != None:
if WCL != None:
result_file_secure.write(str(info)+" "+str(traffic)+" "+str(attack)+
" "+str(Attack_Path_Length)+" "+str(PIR)+
" "+str(float(latency)/10)+" "+str(throughput)+" "+str(WCL)+"\n")
else:
result_file_network.write(str(info)+" "+str(traffic)+" "+str(attack)+
" "+str(Attack_Path_Length)+" "+str(PIR)+
" "+str(float(latency)/10)+" "+str(throughput)+"\n")
Attack_Path_Length = None
PIR = None
latency = None
throughput = None
WCL = None
if "ATTACK_PATH_LENGTH:" in line:
Attack_Path_Length= int(line.split(" ")[-2])
if "PIR" in line:
PIR= float(line.split(" ")[-1])
if "average packet latency:" in line:
latency= float(line.split(" ")[-2])
if "throughput" in line:
throughput= float(line.split(" ")[-2])
if "Worst Case Latency on Router" in line:
WCL = float(line.split(" ")[-3])
else:
WCL = None
result_file_secure.close()
result_file_network.close()