NS2 Notebook: Multi-channel Multi-interface Simulation in NS2 (2.29)

Back to Index


1. Modifications in tcl/lib/ns-lib.tcl

# New node structure
#
# Add APT to support multi-interface: user can specified multiple channels
# when config nod. Still need modifications in routing agents to make
# multi-interfaces really work. -chen xuan 07/21/00

......

Simulator instproc channel {val} {$self set channel_ $val}

# Multi-channel Multi-interface
Simulator instproc channel2 {val} {$self set channel2_ $val}
Simulator instproc channel3 {val} {$self set channel3_ $val}
Simulator instproc channel4 {val} {$self set channel4_ $val}
Simulator instproc channel5 {val} {$self set channel5_ $val}

 

Simulator instproc node-config args {

    ......


    # Multi-channel Multi-interface
    $self instvar addressType_ routingAgent_ propType_ macTrace_ \
    routerTrace_ agentTrace_ movementTrace_ channelType_ channel_ \
    channel2_ channel3_ channel4_ channel5_ \
    chan chan2 chan3 chan4 chan5 topoInstance_ propInstance_ mobileIP_ \
    rxPower_ txPower_ idlePower_ sleepPower_ transitionPower_ \
    transitionTime_ satNodeType_ eotTrace_

    ......

    # Add multi-interface support:
    # User can only specify either channelType_ (single_interface as
    # before) or channel_ (multi_interface)
    # If both variables are specified, error!


    if {[info exists channelType_] && [info exists channel_]} {
    error "Can't specify both channel and channelType, error!"
    } elseif {[info exists channelType_] && ![info exists satNodeType_]} {
    # Single channel, single interface
    warn "Please use -channel as shown in tcl/ex/wireless-mitf.tcl"
    if {![info exists chan]} {
    set chan [new $channelType_]
    }
    } elseif {[info exists channel_]} {
     # Multiple channel, multiple interfaces
     set chan $channel_
    
     # Multi-channel Multi-interface
     if {[info exists channel2_]} {
     set chan2 $channel2_
     }
     if {[info exists channel3_]} {
     set chan3 $channel3_
     }
     if {[info exists channel4_]} {
     set chan4 $channel4_
     }
     if {[info exists channel5_]} {
     set chan5 $channel5_
     }

     }

    ......

}

 

Simulator instproc create-wireless-node args {

    #Multi-channel Multi-interface

    $self instvar routingAgent_ wiredRouting_ propInstance_ llType_ \
    macType_ ifqType_ ifqlen_ phyType_ chan chan2 chan3 chan4 chan5 antType_ \
    energyModel_ initialEnergy_ txPower_ rxPower_ \
    idlePower_ sleepPower_ transitionPower_ transitionTime_ \
    topoInstance_ level1_ level2_ inerrProc_ outerrProc_ FECProc_

    # Add main node interface
    $node add-interface $chan $propInstance_ $llType_ $macType_ \
    $ifqType_ $ifqlen_ $phyType_ $antType_ $topoInstance_ \
    $inerrProc_ $outerrProc_ $FECProc_
    
    # Multi-channel Multi-interface

    $node add-interface $chan2 $propInstance_ $llType_ $macType_ \
    $ifqType_ $ifqlen_ $phyType_ $antType_ $topoInstance_\
    $inerrProc_ $outerrProc_ $FECProc_

    $node add-interface $chan3 $propInstance_ $llType_ $macType_ \
    $ifqType_ $ifqlen_ $phyType_ $antType_ $topoInstance_\
    $inerrProc_ $outerrProc_ $FECProc_

    $node add-interface $chan4 $propInstance_ $llType_ $macType_ \
    $ifqType_ $ifqlen_ $phyType_ $antType_ $topoInstance_\
    $inerrProc_ $outerrProc_ $FECProc_

    $node add-interface $chan5 $propInstance_ $llType_ $macType_ \
    $ifqType_ $ifqlen_ $phyType_ $antType_ $topoInstance_\
    $inerrProc_ $outerrProc_ $FECProc_

}

 

 
© Copyright 2008. All rights reserved. Powered by Free Site Templates