forked from cawka/ndnSIM-ddos-interest-flooding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wscript
132 lines (110 loc) · 5.13 KB
/
wscript
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
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
VERSION='0.1'
APPNAME='template'
from waflib import Build, Logs, Options, TaskGen
import subprocess
def options(opt):
opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
opt.add_option('--logging',action='store_true',default=True,dest='logging',help='''enable logging in simulation scripts''')
opt.add_option('--run',
help=('Run a locally built program; argument can be a program name,'
' or a command starting with the program name.'),
type="string", default='', dest='run')
opt.add_option('--visualize',
help=('Modify --run arguments to enable the visualizer'),
action="store_true", default=False, dest='visualize')
opt.add_option('--mpi',
help=('Run in MPI mode'),
type="string", default="", dest="mpi")
opt.add_option('--time',
help=('Enable time for the executed command'),
action="store_true", default=False, dest='time')
opt.load("compiler_c compiler_cxx boost ns3")
def configure(conf):
conf.load("compiler_cxx boost ns3")
try:
conf.check(features='cxx cxxprogram', cxxflags="-std=c++11")
conf.env.CXX11_CMD = "-std=c++11"
except:
try:
conf.check(features='cxx cxxprogram', cxxflags="-std=c++0x")
conf.env.CXX11_CMD = "-std=c++0x"
except:
try:
version = conf.cmd_and_log(conf.env.CXX + ["--version"]).split("\n")[0]
except:
pass
else:
conf.msg("Compiler version:", version, color="RED")
print "Bad compiler. Require GCC >= 4.4 or recent version of Clang."
raise
conf.check_boost(lib='system iostreams')
boost_version = conf.env.BOOST_VERSION.split('_')
if int(boost_version[0]) < 1 or int(boost_version[1]) < 48:
Logs.error ("ndnSIM requires at least boost version 1.48")
Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)")
exit (1)
try:
conf.check_ns3_modules("ndnSIM core network internet point-to-point topology-read applications mobility")
conf.check_ns3_modules("visualizer", mandatory = False)
except:
Logs.error ("NS-3 or one of the required NS-3 modules not found")
Logs.error ("NS-3 needs to be compiled and installed somewhere. You may need also to set PKG_CONFIG_PATH variable in order for configure find installed NS-3.")
Logs.error ("For example:")
Logs.error (" PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH ./waf configure")
conf.fatal ("")
if conf.options.debug:
conf.define ('NS3_LOG_ENABLE', 1)
conf.define ('NS3_ASSERT_ENABLE', 1)
conf.define ('_DEBUG', 1)
conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
else:
conf.env.append_value('CXXFLAGS', ['-O3', '-g'])
if conf.env["CXX"] == ["clang++"]:
conf.env.append_value('CXXFLAGS', ['-fcolor-diagnostics'])
if conf.env.DEST_BINFMT == 'elf':
# All ELF platforms are impacted but only the gcc compiler has a flag to fix it.
if 'gcc' in (conf.env.CXX_NAME, conf.env.CC_NAME):
conf.env.append_value ('SHLIB_MARKER', '-Wl,--no-as-needed')
if conf.options.logging:
conf.define ('NS3_LOG_ENABLE', 1)
conf.define ('NS3_ASSERT_ENABLE', 1)
def build (bld):
deps = 'BOOST BOOST_IOSTREAMS' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'ndnSIM', 'topology-read', 'applications', 'mobility', 'visualizer']]).upper ()
common = bld.objects (
target = "extensions",
features = ["cxx"],
source = bld.path.ant_glob(['extensions/**/*.cc']),
use = deps,
cxxflags = [bld.env.CXX11_CMD],
includes = "extensions",
)
for scenario in bld.path.ant_glob (['scenarios/*.cc']):
name = str(scenario)[:-len(".cc")]
app = bld.program (
target = name,
features = ['cxx'],
source = [scenario],
use = deps + " extensions",
cxxflags = [bld.env.CXX11_CMD],
includes = "extensions",
)
def shutdown (ctx):
if Options.options.run:
visualize=Options.options.visualize
mpi = Options.options.mpi
if mpi and visualize:
Logs.error ("You cannot specify --mpi and --visualize options at the same time!!!")
return
argv = Options.options.run.split (' ');
argv[0] = "build/%s" % argv[0]
if visualize:
argv.append ("--SimulatorImplementationType=ns3::VisualSimulatorImpl")
if mpi:
argv.append ("--SimulatorImplementationType=ns3::DistributedSimulatorImpl")
argv.append ("--mpi=1")
argv = ["openmpirun", "-np", mpi] + argv
Logs.error (argv)
if Options.options.time:
argv = ["time"] + argv
return subprocess.call (argv)