7 # Mercurial repository of the network simulation cradle |
7 # Mercurial repository of the network simulation cradle |
8 NSC_REPO = "https://secure.wand.net.nz/mercurial/nsc" |
8 NSC_REPO = "https://secure.wand.net.nz/mercurial/nsc" |
9 NSC_RELEASE_URL = "http://research.wand.net.nz/software/nsc" |
9 NSC_RELEASE_URL = "http://research.wand.net.nz/software/nsc" |
10 NSC_RELEASE_NAME = "nsc-0.5.0" |
10 NSC_RELEASE_NAME = "nsc-0.5.0" |
11 |
11 |
12 # directory that contains network simulation cradle source |
|
13 # note, this path is relative to the project root |
|
14 NSC_DIR = "nsc" |
|
15 |
|
16 |
12 |
17 def set_options(opt): |
13 def set_options(opt): |
18 opt.add_option('--enable-nsc', |
14 opt.add_option('--enable-nsc', |
19 help=('Enable Network Simulation Cradle to allow the use real-world network stacks'), |
15 help=('[deprecated option] Enable Network Simulation Cradle to allow the use real-world network stacks'), |
20 action="store_true", default=False, |
16 action="store_true", default=False, |
21 dest='enable_nsc') |
17 dest='enable_nsc') |
|
18 |
|
19 opt.add_option('--with-nsc', |
|
20 help=('Use Network Simulation Cradle, given by the indicated path,' |
|
21 ' to allow the use of real-world network stacks'), |
|
22 default='', dest='with_nsc') |
22 |
23 |
23 |
24 |
24 def nsc_fetch(): |
25 def nsc_fetch(): |
25 def nsc_clone(): |
26 def nsc_clone(): |
26 print "Retrieving nsc from " + NSC_REPO |
27 print "Retrieving nsc from " + NSC_REPO |
52 nsc_clone() |
53 nsc_clone() |
53 else: |
54 else: |
54 nsc_update() |
55 nsc_update() |
55 |
56 |
56 def configure(conf): |
57 def configure(conf): |
57 conf.env['ENABLE_NSC'] = False |
|
58 |
|
59 # checks for flex and bison, which is needed to build NSCs globaliser |
58 # checks for flex and bison, which is needed to build NSCs globaliser |
60 def check_nsc_buildutils(): |
59 def check_nsc_buildutils(): |
61 import flex |
60 import flex |
62 import bison |
61 import bison |
63 conf.check_tool('flex bison') |
62 conf.check_tool('flex bison') |
64 e = conf.create_library_configurator() |
63 e = conf.create_library_configurator() |
65 e.mandatory = True |
64 e.mandatory = True |
66 e.name = 'fl' |
65 e.name = 'fl' |
67 e.run() |
66 e.run() |
68 |
67 |
69 if not Params.g_options.enable_nsc: |
68 if not (Params.g_options.enable_nsc or Params.g_options.with_nsc): |
70 conf.report_optional_feature("nsc", "Network Simulation Cradle", False, |
69 conf.report_optional_feature("nsc", "Network Simulation Cradle", False, |
71 "--enable-nsc configure option not given") |
70 "--with/enable-nsc configure option not given") |
72 return |
71 return |
73 |
72 |
74 check_nsc_buildutils() |
73 check_nsc_buildutils() |
|
74 |
|
75 if Params.g_options.enable_nsc: |
|
76 Params.warning("--enable-nsc is a deprecated option; use --with-nsc instead") |
|
77 conf.env['WITH_NSC'] = 'nsc' |
|
78 |
|
79 if Params.g_options.with_nsc: |
|
80 if not os.path.isdir(Params.g_options.with_nsc): |
|
81 Params.fatal("--with-nsc nsc path %r does not exist" % Params.g_options.with_nsc) |
|
82 conf.env['WITH_NSC'] = Params.g_options.with_nsc |
75 |
83 |
76 arch = os.uname()[4] |
84 arch = os.uname()[4] |
77 ok = False |
85 ok = False |
78 if arch == 'x86_64' or arch == 'i686' or arch == 'i586' or arch == 'i486' or arch == 'i386': |
86 if arch == 'x86_64' or arch == 'i686' or arch == 'i586' or arch == 'i486' or arch == 'i386': |
79 conf.env['NSC_ENABLED'] = 'yes' |
87 conf.env['NSC_ENABLED'] = 'yes' |
82 e.mandatory = True |
90 e.mandatory = True |
83 e.name = 'dl' |
91 e.name = 'dl' |
84 e.define = 'HAVE_DL' |
92 e.define = 'HAVE_DL' |
85 e.uselib = 'DL' |
93 e.uselib = 'DL' |
86 e.run() |
94 e.run() |
87 conf.env['ENABLE_NSC'] = True |
|
88 ok = True |
95 ok = True |
89 conf.check_message('NSC supported architecture', arch, ok) |
96 conf.check_message('NSC supported architecture', arch, ok) |
90 conf.report_optional_feature("nsc", "Network Simulation Cradle", ok, |
97 conf.report_optional_feature("nsc", "Network Simulation Cradle", ok, |
91 "architecture %r not supported" % arch) |
98 "architecture %r not supported" % arch) |
92 nsc_fetch() |
99 if not Params.g_options.with_nsc: |
|
100 nsc_fetch() |
93 |
101 |
94 |
102 |
95 |
103 |
96 class NscBuildTask(Task.TaskBase): |
104 class NscBuildTask(Task.TaskBase): |
97 """task that builds nsc |
105 """task that builds nsc |
98 """ |
106 """ |
99 def __init__(self, builddir): |
107 def __init__(self, builddir, nsc_dir): |
100 self.prio = 1000 # build after the rest of ns-3 |
108 self.prio = 1000 # build after the rest of ns-3 |
101 self.builddir = builddir |
109 self.builddir = builddir |
|
110 self.nsc_dir = nsc_dir |
102 super(NscBuildTask, self).__init__() |
111 super(NscBuildTask, self).__init__() |
103 self.m_display = 'build-nsc\n' |
112 self.m_display = 'build-nsc\n' |
104 |
113 |
105 def run(self): |
114 def run(self): |
106 # XXX: Detect gcc major version(s) available to build supported stacks |
115 # XXX: Detect gcc major version(s) available to build supported stacks |
107 builddir = self.builddir |
116 builddir = self.builddir |
108 kernels = [['linux-2.6.18', 'linux2.6.18'], |
117 kernels = [['linux-2.6.18', 'linux2.6.18'], |
109 ['linux-2.6.26', 'linux2.6.26']] |
118 ['linux-2.6.26', 'linux2.6.26']] |
110 for dir, name in kernels: |
119 for dir, name in kernels: |
111 soname = 'lib' + name + '.so' |
120 soname = 'lib' + name + '.so' |
112 if not os.path.exists(os.path.join("..", NSC_DIR, dir, soname)): |
121 if not os.path.exists(os.path.join("..", self.nsc_dir, dir, soname)): |
113 if os.system('cd ../%s && python scons.py %s' % (NSC_DIR, dir)) != 0: |
122 if os.system('cd ../%s && python scons.py %s' % (self.nsc_dir, dir)) != 0: |
114 Params.fatal("Building NSC stack failed") |
123 Params.fatal("Building NSC stack failed") |
115 |
124 |
116 if not os.path.exists(builddir + '/' + soname): |
125 if not os.path.exists(builddir + '/' + soname): |
117 try: |
126 try: |
118 os.symlink('../../' + NSC_DIR + '/' + dir + '/' + soname, builddir + '/' + soname) |
127 os.symlink('../../' + self.nsc_dir + '/' + dir + '/' + soname, builddir + '/' + soname) |
119 except: |
128 except: |
120 Params.fatal("Error linking " + builddir + '/' + soname) |
129 Params.fatal("Error linking " + builddir + '/' + soname) |
121 |
130 |
122 |
131 |
123 def build(bld): |
132 def build(bld): |
167 'ipv4-static-routing.h', |
176 'ipv4-static-routing.h', |
168 'ipv4-global-routing.h', |
177 'ipv4-global-routing.h', |
169 'icmpv4.h', |
178 'icmpv4.h', |
170 ] |
179 ] |
171 |
180 |
172 if bld.env()['NSC_ENABLED']: |
181 if bld.env()['WITH_NSC']: |
173 obj.source.append ('nsc-tcp-socket-impl.cc') |
182 obj.source.append ('nsc-tcp-socket-impl.cc') |
174 obj.source.append ('nsc-tcp-l4-protocol.cc') |
183 obj.source.append ('nsc-tcp-l4-protocol.cc') |
175 obj.source.append ('nsc-tcp-socket-factory-impl.cc') |
184 obj.source.append ('nsc-tcp-socket-factory-impl.cc') |
176 obj.source.append ('nsc-sysctl.cc') |
185 obj.source.append ('nsc-sysctl.cc') |
177 obj.uselib = 'DL' |
186 obj.uselib = 'DL' |
178 builddir = os.path.abspath(os.path.join(bld.env()['NS3_BUILDDIR'], bld.env ().variant())) |
187 builddir = os.path.abspath(os.path.join(bld.env()['NS3_BUILDDIR'], bld.env ().variant())) |
179 NscBuildTask(builddir) |
188 NscBuildTask(builddir, bld.env()['WITH_NSC']) |