Hello.I am a noob of NS2.I must be some simulations, but i must modify in
this tcl routing.I must usiing a statiic routing.How modify this tcl to work
static routing leaving the rest?thanks

set MESSAGE_PORT 42
set ACK_SIZE 12
set HEADER_SIZE 12
set PAYLOAD_UNIT 6
set DIFS 0.0;
set AckTimeout 0.02;
set BER 1e-6;

set val(Nsink) 2 ;# sink number
set val(L) 3  ;     # node number

set val(chan)           Channel/WirelessChannel    ;
set val(prop)           Propagation/TwoRayGround   ;
set val(netif)          Phy/WirelessPhy
set val(mac)            Mac/802_11
set val(ifq)            Queue/DropTail/PriQueue    ;
set val(ll)             LL                         ;
set val(ant)            Antenna/OmniAntenna        ;
set val(ifqlen)         50                         ;
set val(rp)             DumbAgent                  ;
set val(x)              10
set val(y)              10

Mac/802_11 set RTSThreshold_  1500

global defaultRNG
set the_seed [eval exec "/bin/date \"+%s\""]
puts stderr "Il seed è $the_seed"
$defaultRNG seed $the_seed


#read command line arguments
proc getCmdArgu {argc argv} {
        global val
        for {set i 0} {$i < $argc} {incr i} {
                set arg [lindex $argv $i]
                if {[string range $arg 0 0] != "-"} continue
                set name [string range $arg 1 end]
                set val($name) [lindex $argv [expr $i+1]]
        }
}
getCmdArgu $argc $argv

set N_tot [expr $val(Nsink) + $val(Nsink)*$val(L)]

source SimpleMSTP_agent.tcl

# Create scheduler
set ns [new Simulator]

set filename "scenario-$val(Nsink)x$val(L)"
set tracefd     [open "./$filename.tr" w]
$ns trace-all $tracefd
set namtrace     [open "./$filename.nam" w]
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

$ns puts-nam-traceall {# nam4wpan #}            ;# inform nam that this is a 
trace
file for wpan (special handling needed)

Mac/802_15_4 wpanNam namStatus on               ;# default = off (should be 
turned on
before other 'wpanNam' commands can work)
#Mac/802_15_4 wpanNam ColFlashClr gold          ;# default = gold
#Mac/802_15_4 wpanNam NodeFailClr grey          ;# default = grey

Mac/802_15_4 wpanCmd ack4data off

proc finish {} {
#       global ns namfile tracefile
#       $ns flush-trace
#       close $namfile

        global ns tracefd
        $ns flush-trace
        close $tracefd

#       exec nam prova_wireless.nam &
        exit 0
}

# For model 'TwoRayGround'
set dist(5m)  7.69113e-06
set dist(9m)  2.37381e-06
set dist(10m) 1.92278e-06
set dist(11m) 1.58908e-06
set dist(12m) 1.33527e-06
set dist(13m) 1.13774e-06
set dist(14m) 9.81011e-07
set dist(15m) 8.54570e-07
set dist(16m) 7.51087e-07
set dist(20m) 4.80696e-07
set dist(25m) 3.07645e-07
set dist(30m) 2.13643e-07
set dist(35m) 1.56962e-07
set dist(40m) 1.20174e-07
Phy/WirelessPhy set CSThresh_ $dist(15m)
Phy/WirelessPhy set RXThresh_ $dist(15m)

# set up topography object
set topo       [new Topography]
$topo load_flatgrid $val(x) $val(y)

# Create God
set god_ [create-god $N_tot]

set chan_1_ [new $val(chan)]

# configure node

$ns node-config -adhocRouting $val(rp) \
                -llType $val(ll) \
                -macType $val(mac) \
                -ifqType $val(ifq) \
                -ifqLen $val(ifqlen) \
                -antType $val(ant) \
                -propType $val(prop) \
                -phyType $val(netif) \
                -topoInstance $topo \
                -agentTrace ON \
                -routerTrace OFF \
                -macTrace ON \
                -movementTrace OFF \
                #-energyModel "EnergyModel" \
                #-initialEnergy 1 \
                #-rxPower 0.3 \
                #-txPower 0.3 \
                -channel $chan_1_ 

set u [new RandomVariable/Uniform]
$u set min_ 0
for {set i 0} {$i < $N_tot} {incr i} {
        set n($i) [$ns node]

        $n($i) random-motion 0          ;# disable random motion
        $u set max_ $val(x)
        $n($i) set X_ [$u value]
        $u set max_ $val(y)
        $n($i) set Y_ [$u value] 
}


for {set i 0} {$i < $N_tot} {incr i} {
        set agent($i) [new Agent/MessagePassing/SimpleMSTP]
        if [expr ($i%(1+$val(L))) != 0] {$agent($i) set type_ "Node"}

        $agent($i) set successor_ [expr ($i+1)%$N_tot]
        if {$i != 0} {
                $agent($i) set predecessor_ [expr $i-1]
        } else {
                $agent($i) set predecessor_ [expr $N_tot-1]
        }
        
        $n($i) attach  $agent($i) $MESSAGE_PORT
}



$ns at 0.1 "$agent(0) send-token"



$ns at 100 finish


$ns run



THANKS
-- 
View this message in context: 
http://old.nabble.com/static-routing-help%21%21%21-tp28247482p28247482.html
Sent from the ns-users mailing list archive at Nabble.com.


Reply via email to