[ns] ask for help
CHENG Yong
yongchengyl at 126.com
Wed Dec 5 02:56:41 PST 2007
Dear everyone,
did any one implement suceessful the extension of ns-2 for multi-channel
from Ramon Aguero at: http://personales.unican.es/aguerocr ,many thanks for Ramon Aguero for his Document.
there is a mistake when I do the test, the tcl script and the error are below. Please help me to find the error, thank you. I think the error's position is may in Listing 3.6 according to the error message.
thanks
########################## this is the test code start ##### ns-example.tcl
# Listing 6.1
set val(chan) Channel/WirelessChannel
set val(ni) 3
set val(nn) 2 ;# number of mobilenodes
# add by CHENG Yong 2007-12-04 start
set val(rp) AODV ;# routing protocol
set val(ll) LL
set val(mac) Mac/802_11
set val(ifq) Queue/DropTail/PriQueue
set val(ifqlen) 50 ;# max packet in ifq
set val(ant) Antenna/OmniAntenna
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
# Initialize Global Variables
set ns_ [new Simulator]
set tracefd [open mrmc.tr w]
$ns_ trace-all $tracefd#Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the NAM trace file
close $nf
#Execute NAM on the trace file
exec nam out.nam &
exit 0
}# set up topography
set topo [new Topography]
$topo load_flatgrid 1000 1000# add by CHENG Yong 2007-12-04 end# Listing 6.2
for {set i 0} {$i< $val(ni)} {incr i} {
set chan_($i) [new $val(chan)]
}
# Listing 6.3
create-god [expr $val(nn)*$val(ni)]
# Listing 6.4
$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) \
-channel $chan_(0) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON \
-ifNum $val(ni)# Listing 6.5
$ns_ change-numifs $val(ni)
# for {set i 0} {$i < $val(ni) } {incr i} {
# $ns_ add-channel $i $chan_($i)
# } for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0
}# Listing 6.6
$ns_ change-numifs 2
$ns_ add-channel 0 $chan_(0)
$ns_ add-channel 1 $chan_(2)
set node_(0) [$ns_ node]
$node_(0) random-motion 0$ns_ change-numifs 1
$ns_ add-channel 0 $chan_(2)
set node_(1) [$ns_ node]
$node_(1) random-motion 0$ns_ color 1 Blue
$ns_ color 2 Red#Create links between the nodes
$ns duplex-link $node_(0) $node_(1) 2Mb 10ms DropTail
#Setup a TCP connection
set tcp [new Agent/TCP]
$tcp set class_ 2
$ns_ attach-agent $node_(0) $tcp
$ns_ attach-agent $node_(1) $tcp#Setup a FTP over TCP connection
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP
#Schedule events for the FTP agents$ns_ at 0.1 "$ftp start"
$ns_ at 4.0 "$ftp stop"
#Call the finish procedure after 5 seconds of simulation time
$ns_ at 4.5 "finish"#Run the simulation
$ns_ run
########################## this is the test code end #####ns-example.tcl ########################## this is error for the test code start
$ ns ns-example.tcl
num_nodes is set 6
invalid command name "if{1}"
while executing
"if{[info exist numifs_]} {
for {set i 0}{ $i< $numifs_ } {incr i} {
$node add-interface $chan($i) $propInstance_ $llType_ $macType_ $ifqType_ $ifql
en..."
(procedure "_o3" line 70)
(Simulator create-wireless-node line 70)
invoked from within
"_o3 create-wireless-node"
("eval" body line 1)
invoked from within
"eval $self create-wireless-node $args"
(procedure "_o3" line 23)
(Simulator node line 23)
invoked from within
"$ns_ node"
("for" body line 2)
invoked from within
"for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0
}"
(file "ns-example.tcl" line 74)########################## this is error for the test code end
More information about the Ns-users
mailing list