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