-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
executable file
·73 lines (61 loc) · 2.68 KB
/
run.py
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
#!/usr/bin/python3.5
import os
import sys
import time
#sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
#from Cd.Cd import Cd
from Utils.Cd import Cd
#PCAP_FILE = "../../Pcap/wireshark-wiki_http.pcap"
#SIMULATION_NAME = "wombat"
def main(args):
pcap = args[0]
sym_name = args[1]
# input arguments
pcap_file = os.path.dirname(os.path.abspath(__file__)) + '/' + pcap
# making sure the program is being executed in the source location, so it can be executed from anyware
cd = Cd(os.path.dirname(os.path.abspath(__file__)))
plots_dir = 'plots/' + sym_name
# run simulations
run_simulations(pcap_file, sym_name, plots_dir, cd)
# plot data
#plot_data(pcap_file, sym_name, plots_dir)
def dataprocessor_help():
print('./run.py <pcap_file> <simulation_name>')
print('\tEg.: ./run.py ../pcaps/wireshark-wiki_http.pcap wombat')
def print_header(title):
print('')
print('###############################################################################')
print('# ' + title)
print('###############################################################################')
def run_simulations(pcap_file, sym_name, plots_dir, cd):
print_header("Simulations for:" + sym_name + " using pcap:" + pcap_file)
# clean sim dir or create if it does not exist
cd.cd('./dataProcessor/')
os.system('mkdir -p figures')
os.system('mkdir -p data')
os.system('rm -rf data/*')
# filter inter-pacekt times
os.system('./pcap-filter.sh --time-delta ' + pcap_file + ' ' + sym_name)
# execute dataProcessor prototype
os.system('./dataProcessor.m ' + sym_name + ' |tee data/dataProcessorStdOut.log')
# calc cost function of each simulation
os.system('./calcCostFunction.py data/')
# generate AIC/BIC csv and calculate its relative difference
os.system('./aicBicRelativeDiff.py data/')
# back to working directory
cd.back()
# creating plots dir, clean if already exist
os.system('rm -rf ' + plots_dir)
os.system('mkdir -p ' + plots_dir)
os.system('mv dataProcessor/data/* ' + plots_dir)
str_about = 'Simulation:' + sym_name + " using pcap:" + pcap_file
str_date = '@ ' + str(time.localtime().tm_mday) + '/' + str(time.localtime().tm_mon) + '/' + str(
time.localtime().tm_year) + '-' + str(time.localtime().tm_hour) + ':' + str(
time.localtime().tm_min) + ':' + str(time.localtime().tm_sec)
os.system('echo \"' + str_about + '\" >>' + plots_dir + '/about.log')
os.system('echo \"' + str_date + '\" >>' + plots_dir + '/about.log')
if __name__ == "__main__":
if (len(sys.argv) == 1) or (len(sys.argv) == 2):
dataprocessor_help()
else:
main(sys.argv[1:])