src/internet-stack/wscript
author Florian Westphal <fw@strlen.de>
Wed Jul 15 18:46:14 2009 +0200 (2009-07-15)
changeset 4685 ae536d9e0d6d
parent 4667 5b92bfa1abee
permissions -rw-r--r--
nsc: move nsc glue code from nsc-tcp-l4-protocol to node/nsc-glue.cc.

known problems:
- sim_interface.h is duplicated
- nsc-glue.cc adds hooks in node.cc, "hijacks" incoming packets
- nsc-glue exports NSCs INetStack (instead of wrapping it completely)
- nsc-tcp-l4-protocol and nsc-tcp-socket-impl make calls into nsc-glue
- nsc-tcp-socket-impl should really be "nsc-socket-core" (or something
like that)

needs fixing on nsc side:
- no support for multiple interfaces yet (also not yet supported
on nsc side)
- nsc initialisation still tied to IP (Adding an Interface and assigning the
IP address is a single step; it should be separate)

maybe there is more.

There is a NSC_NEXT define in nsc-glue.h, its main purpose is to flag
the places where the NSC API needs to be adapted to support multiple
interfaces in nsc.
     1 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
     2 import os
     3 import sys
     4 
     5 import Options
     6 import Logs
     7 import Utils
     8 import Task
     9 
    10 # Required NSC version
    11 NSC_RELEASE_NAME = "nsc-0.5.0"
    12 
    13 
    14 def set_options(opt):
    15     opt.add_option('--with-nsc',
    16                    help=('Use Network Simulation Cradle, given by the indicated path,'
    17                          ' to allow the use of real-world network stacks'),
    18                    default='', dest='with_nsc')
    19 
    20 
    21 def configure(conf):
    22     conf.env['ENABLE_NSC'] = False
    23 
    24     # checks for flex and bison, which is needed to build NSCs globaliser
    25     # TODO: how to move these checks into the allinone scripts?
    26     #def check_nsc_buildutils():
    27     #    import flex
    28     #    import bison
    29     #    conf.check_tool('flex bison')
    30     #    conf.check(lib='fl', mandatory=True)
    31 
    32     # Check for the location of NSC
    33     if Options.options.with_nsc:
    34         if os.path.isdir(Options.options.with_nsc):
    35             conf.check_message("NSC location", '', True, ("%s (given)" % Options.options.with_nsc))
    36             conf.env['WITH_NSC'] = os.path.abspath(Options.options.with_nsc)
    37     else:
    38         nsc_dir = os.path.join('..', "nsc")
    39         if os.path.isdir(nsc_dir):
    40             conf.check_message("NSC location", '', True, ("%s (guessed)" % nsc_dir))
    41             conf.env['WITH_NSC'] = os.path.abspath(nsc_dir)
    42         del nsc_dir
    43     if not conf.env['WITH_NSC']:
    44         conf.check_message("NSC location", '', False)
    45         conf.report_optional_feature("nsc", "Network Simulation Cradle", False,
    46                                      "NSC not found (see option --with-nsc)")
    47 	return
    48     
    49     if sys.platform in ['linux2']:
    50         arch = os.uname()[4]
    51     else:
    52         arch = None
    53     ok = False
    54     if arch == 'x86_64' or arch == 'i686' or arch == 'i586' or arch == 'i486' or arch == 'i386':
    55         conf.env['NSC_ENABLED'] = 'yes'
    56         conf.env.append_value('CXXDEFINES', 'NETWORK_SIMULATION_CRADLE')
    57         conf.check(mandatory=True, lib='dl', define_name='HAVE_DL', uselib='DL')
    58         ok = True
    59     conf.check_message('NSC supported architecture', arch, ok)
    60     conf.report_optional_feature("nsc", "Network Simulation Cradle", ok,
    61                                  "architecture %r not supported" % arch)
    62 
    63     # append the NSC kernel dirs to the module path so that these dirs
    64     # will end up in the LD_LIBRARY_PATH, thus allowing the NSC NS-3
    65     # module to find the necessary NSC shared libraries.
    66     for nsc_module in ['linux-2.6.18', 'linux-2.6.26']:
    67         conf.env.append_value('NS3_MODULE_PATH',
    68                               os.path.abspath(os.path.join(conf.env['WITH_NSC'], nsc_module)))
    69 
    70 
    71 def build(bld):
    72     obj = bld.create_ns3_module('internet-stack', ['node'])
    73     obj.source = [
    74         'tcp-test.cc',
    75         'udp-test.cc',
    76         'ipv4-test.cc',
    77         'ipv4-l4-protocol.cc',
    78         'udp-header.cc',
    79         'tcp-header.cc',
    80         'ipv4-interface.cc',
    81         'ipv4-l3-protocol.cc',
    82         'ipv4-end-point.cc',
    83         'udp-l4-protocol.cc',
    84         'tcp-l4-protocol.cc',
    85         'arp-header.cc',
    86         'arp-cache.cc',
    87         'arp-l3-protocol.cc',
    88         'udp-socket-impl.cc',
    89         'tcp-socket-impl.cc',
    90         'ipv4-end-point-demux.cc',
    91         'udp-socket-factory-impl.cc',
    92         'tcp-socket-factory-impl.cc',
    93         'pending-data.cc',
    94         'sequence-number.cc',
    95         'rtt-estimator.cc',
    96         'ipv4-raw-socket-factory-impl.cc',
    97         'ipv4-raw-socket-impl.cc',
    98         'icmpv4.cc',
    99         'icmpv4-l4-protocol.cc',
   100         'loopback-net-device.cc',
   101         ]
   102 
   103     headers = bld.new_task_gen('ns3header')
   104     headers.module = 'internet-stack'
   105     headers.source = [
   106         'udp-header.h',
   107         'tcp-header.h',
   108         'sequence-number.h',
   109         'icmpv4.h',
   110         'ipv4-interface.h',
   111         'ipv4-l3-protocol.h',
   112         ]
   113 
   114     if bld.env['NSC_ENABLED']:
   115         obj.source.append ('nsc-tcp-socket-impl.cc')
   116         obj.source.append ('nsc-tcp-l4-protocol.cc')
   117         obj.source.append ('nsc-tcp-socket-factory-impl.cc')
   118         obj.uselib = 'DL'