-
Notifications
You must be signed in to change notification settings - Fork 6
/
simulate.py
executable file
·58 lines (49 loc) · 1.75 KB
/
simulate.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
#!/usr/bin/env python
"""
This is the main file of the
simulator part of
Integrated MALware Simulator & Emulator
imalse
prou: `I'm sir`
"""
import sys
import argparse
# try:
# import experiments
# except ImportError as e:
# print 'error, ', e
# print 'You should use ns3 waf shell to run this code'
# sys.exit()
import experiments
from util import get_experiment_option
exper_options = get_experiment_option()
parser = argparse.ArgumentParser(description='imalse')
parser.add_argument('-e', '--experiment', default='TopoExperiment',
help='specify the experiment. Avaliable experiments are [%s]'%(" |").join(exper_options)
)
parser.add_argument('--mode', default='sim',
help="specify the mode, can be ['netns3' | 'sim'], default is 'sim'. "
)
parser.add_argument('--ehelp', action='store_true',
help="print the help of a experiment"
)
# Print Help when there is no argument
if len(sys.argv) == 1:
print '----------------Experment Selection Arguments------------------'
parser.print_help()
print '----------------Exeriment Options------------------------------'
for experiment in exper_options:
for mode in ['netns3','sim']:
print '+++++++++Experiment:[%s] Mode:[%s]+++++++++++++++++++++++'%(experiment, mode)
exper_class = experiments.experiment_factory(experiment, mode)
exper = exper_class()
exper.print_help()
sys.exit(1)
args, exper_args = parser.parse_known_args()
exper_class = experiments.experiment_factory(args.experiment, args.mode)
exper = exper_class()
if args.ehelp:
print '+++++++++Experiment:[%s] Mode:[%s]+++++++++++++++++++++++'%(args.experiment, args.mode)
exper.print_help()
sys.exit(1)
exper.main(exper_args)