2007-05-07 12:01:51 +01:00
|
|
|
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
2008-08-29 23:10:00 +02:00
|
|
|
import os
|
2009-03-01 12:11:00 +00:00
|
|
|
import sys
|
2008-08-29 23:10:00 +02:00
|
|
|
|
2008-12-29 13:28:54 +00:00
|
|
|
import Options
|
|
|
|
|
import Logs
|
|
|
|
|
import Utils
|
|
|
|
|
import Task
|
|
|
|
|
|
2009-01-12 11:25:51 +00:00
|
|
|
# Required NSC version
|
|
|
|
|
NSC_RELEASE_NAME = "nsc-0.5.0"
|
|
|
|
|
|
|
|
|
|
|
2008-09-05 19:55:21 +01:00
|
|
|
def set_options(opt):
|
2008-12-07 19:02:55 +00:00
|
|
|
opt.add_option('--with-nsc',
|
|
|
|
|
help=('Use Network Simulation Cradle, given by the indicated path,'
|
|
|
|
|
' to allow the use of real-world network stacks'),
|
|
|
|
|
default='', dest='with_nsc')
|
2008-09-05 19:55:21 +01:00
|
|
|
|
|
|
|
|
|
2008-08-29 23:10:00 +02:00
|
|
|
def configure(conf):
|
2008-09-17 20:04:26 -07:00
|
|
|
conf.env['ENABLE_NSC'] = False
|
|
|
|
|
|
2008-08-29 23:10:00 +02:00
|
|
|
# checks for flex and bison, which is needed to build NSCs globaliser
|
2009-01-11 23:26:34 +00:00
|
|
|
# TODO: how to move these checks into the allinone scripts?
|
|
|
|
|
#def check_nsc_buildutils():
|
|
|
|
|
# import flex
|
|
|
|
|
# import bison
|
|
|
|
|
# conf.check_tool('flex bison')
|
|
|
|
|
# conf.check(lib='fl', mandatory=True)
|
2008-08-29 23:10:00 +02:00
|
|
|
|
2009-01-24 15:38:20 +00:00
|
|
|
# Check for the location of NSC
|
|
|
|
|
if Options.options.with_nsc:
|
|
|
|
|
if os.path.isdir(Options.options.with_nsc):
|
|
|
|
|
conf.check_message("NSC location", '', True, ("%s (given)" % Options.options.with_nsc))
|
|
|
|
|
conf.env['WITH_NSC'] = os.path.abspath(Options.options.with_nsc)
|
|
|
|
|
else:
|
|
|
|
|
nsc_dir = os.path.join('..', "nsc")
|
|
|
|
|
if os.path.isdir(nsc_dir):
|
|
|
|
|
conf.check_message("NSC location", '', True, ("%s (guessed)" % nsc_dir))
|
|
|
|
|
conf.env['WITH_NSC'] = os.path.abspath(nsc_dir)
|
|
|
|
|
del nsc_dir
|
|
|
|
|
if not conf.env['WITH_NSC']:
|
|
|
|
|
conf.check_message("NSC location", '', False)
|
2008-09-05 18:16:29 +01:00
|
|
|
conf.report_optional_feature("nsc", "Network Simulation Cradle", False,
|
2009-01-24 15:38:20 +00:00
|
|
|
"NSC not found (see option --with-nsc)")
|
2008-08-29 23:10:00 +02:00
|
|
|
return
|
2009-03-01 12:11:00 +00:00
|
|
|
|
|
|
|
|
if sys.platform in ['linux2']:
|
|
|
|
|
arch = os.uname()[4]
|
|
|
|
|
else:
|
|
|
|
|
arch = None
|
2008-08-29 23:10:00 +02:00
|
|
|
ok = False
|
|
|
|
|
if arch == 'x86_64' or arch == 'i686' or arch == 'i586' or arch == 'i486' or arch == 'i386':
|
|
|
|
|
conf.env['NSC_ENABLED'] = 'yes'
|
2008-09-09 17:09:37 -07:00
|
|
|
conf.env.append_value('CXXDEFINES', 'NETWORK_SIMULATION_CRADLE')
|
2008-12-29 14:19:25 +00:00
|
|
|
conf.check(mandatory=True, lib='dl', define_name='HAVE_DL', uselib='DL')
|
2008-08-29 23:10:00 +02:00
|
|
|
ok = True
|
|
|
|
|
conf.check_message('NSC supported architecture', arch, ok)
|
2008-09-05 18:16:29 +01:00
|
|
|
conf.report_optional_feature("nsc", "Network Simulation Cradle", ok,
|
|
|
|
|
"architecture %r not supported" % arch)
|
2007-05-07 12:01:51 +01:00
|
|
|
|
2009-01-10 00:46:24 +00:00
|
|
|
# append the NSC kernel dirs to the module path so that these dirs
|
|
|
|
|
# will end up in the LD_LIBRARY_PATH, thus allowing the NSC NS-3
|
|
|
|
|
# module to find the necessary NSC shared libraries.
|
|
|
|
|
for nsc_module in ['linux-2.6.18', 'linux-2.6.26']:
|
|
|
|
|
conf.env.append_value('NS3_MODULE_PATH',
|
|
|
|
|
os.path.abspath(os.path.join(conf.env['WITH_NSC'], nsc_module)))
|
|
|
|
|
|
2007-05-07 12:01:51 +01:00
|
|
|
|
2008-09-05 19:55:21 +01:00
|
|
|
|
2007-05-07 12:01:51 +01:00
|
|
|
def build(bld):
|
2008-06-09 15:40:22 -07:00
|
|
|
obj = bld.create_ns3_module('internet-stack', ['node'])
|
2007-05-07 12:01:51 +01:00
|
|
|
obj.source = [
|
2009-05-28 21:37:25 -07:00
|
|
|
'tcp-test.cc',
|
|
|
|
|
'udp-test.cc',
|
2009-06-21 22:29:08 -07:00
|
|
|
'ipv4-test.cc',
|
2007-05-07 12:01:51 +01:00
|
|
|
'ipv4-l4-protocol.cc',
|
|
|
|
|
'udp-header.cc',
|
2008-01-25 13:57:38 -05:00
|
|
|
'tcp-header.cc',
|
2007-05-07 12:01:51 +01:00
|
|
|
'ipv4-interface.cc',
|
2007-06-12 14:05:01 +01:00
|
|
|
'ipv4-l3-protocol.cc',
|
2007-05-07 12:01:51 +01:00
|
|
|
'ipv4-end-point.cc',
|
2007-06-12 14:05:01 +01:00
|
|
|
'udp-l4-protocol.cc',
|
2008-01-25 13:57:38 -05:00
|
|
|
'tcp-l4-protocol.cc',
|
2007-05-07 12:01:51 +01:00
|
|
|
'arp-header.cc',
|
|
|
|
|
'arp-cache.cc',
|
2007-06-12 14:05:01 +01:00
|
|
|
'arp-l3-protocol.cc',
|
2008-05-20 10:30:40 -07:00
|
|
|
'udp-socket-impl.cc',
|
2008-05-20 11:52:25 -07:00
|
|
|
'tcp-socket-impl.cc',
|
2007-05-07 12:01:51 +01:00
|
|
|
'ipv4-end-point-demux.cc',
|
2008-05-17 22:02:09 -07:00
|
|
|
'udp-socket-factory-impl.cc',
|
2008-05-20 12:27:30 -07:00
|
|
|
'tcp-socket-factory-impl.cc',
|
2008-01-25 13:57:38 -05:00
|
|
|
'pending-data.cc',
|
|
|
|
|
'sequence-number.cc',
|
|
|
|
|
'rtt-estimator.cc',
|
2008-10-29 11:18:39 -07:00
|
|
|
'ipv4-raw-socket-factory-impl.cc',
|
|
|
|
|
'ipv4-raw-socket-impl.cc',
|
|
|
|
|
'icmpv4.cc',
|
|
|
|
|
'icmpv4-l4-protocol.cc',
|
2009-05-28 21:37:25 -07:00
|
|
|
'loopback-net-device.cc',
|
2009-09-09 12:19:22 +04:00
|
|
|
'ipv6-interface.cc',
|
|
|
|
|
'ndisc-cache.cc',
|
|
|
|
|
'icmpv6-header.cc',
|
|
|
|
|
'ipv6-l3-protocol.cc',
|
|
|
|
|
'ipv6-end-point.cc',
|
|
|
|
|
'ipv6-end-point-demux.cc',
|
|
|
|
|
'ipv6-l4-protocol.cc',
|
|
|
|
|
'ipv6-raw-socket-factory-impl.cc',
|
|
|
|
|
'ipv6-raw-socket-impl.cc',
|
|
|
|
|
'ipv6-autoconfigured-prefix.cc',
|
|
|
|
|
'icmpv6-l4-protocol.cc',
|
|
|
|
|
'ipv6-test.cc'
|
2007-05-07 12:01:51 +01:00
|
|
|
]
|
|
|
|
|
|
2008-12-29 13:28:54 +00:00
|
|
|
headers = bld.new_task_gen('ns3header')
|
2008-06-09 15:40:22 -07:00
|
|
|
headers.module = 'internet-stack'
|
2007-05-07 12:01:51 +01:00
|
|
|
headers.source = [
|
2007-08-08 11:20:35 +02:00
|
|
|
'udp-header.h',
|
2008-01-25 13:57:38 -05:00
|
|
|
'tcp-header.h',
|
2008-02-09 18:37:58 +00:00
|
|
|
'sequence-number.h',
|
2008-10-29 11:18:39 -07:00
|
|
|
'icmpv4.h',
|
2009-09-09 12:19:22 +04:00
|
|
|
'icmpv6-header.h',
|
2009-08-18 15:07:25 +04:00
|
|
|
# used by routing
|
|
|
|
|
'ipv4-interface.h',
|
|
|
|
|
'ipv4-l3-protocol.h',
|
2009-09-09 12:19:22 +04:00
|
|
|
'arp-l3-protocol.h',
|
|
|
|
|
'udp-l4-protocol.h',
|
|
|
|
|
'tcp-l4-protocol.h',
|
|
|
|
|
'icmpv4-l4-protocol.h',
|
|
|
|
|
'ipv4-l4-protocol.h',
|
2009-08-18 15:07:25 +04:00
|
|
|
'arp-cache.h',
|
2009-09-09 12:19:22 +04:00
|
|
|
]
|
|
|
|
|
|
2008-08-29 23:10:00 +02:00
|
|
|
|
2009-03-01 12:11:00 +00:00
|
|
|
if bld.env['NSC_ENABLED']:
|
2008-09-08 09:22:45 -07:00
|
|
|
obj.source.append ('nsc-tcp-socket-impl.cc')
|
|
|
|
|
obj.source.append ('nsc-tcp-l4-protocol.cc')
|
|
|
|
|
obj.source.append ('nsc-tcp-socket-factory-impl.cc')
|
|
|
|
|
obj.source.append ('nsc-sysctl.cc')
|
|
|
|
|
obj.uselib = 'DL'
|