Re: error "error when calling class $cls: $args" $..."
I got this error when I am running my code in ns2.34
if you need the code then I will send it to you
With Regards
Bhupendra
and my tcl script is given below
# Options
set val(chan) Channel/WirelessChannel ;#Channel Type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 500 ;# max packet in ifq
set val(nn) 5 ;# number of mobilenodes
#set val(rp) DSDV ;# routing protocol
set val(rp) AODV ;# routing protocol
#set val(rp) DSR ;# routing protocol
set val(x) 2000 ;
set val(y) 500 ;
set val(energymodel) EnergyModel ;# Energy Model
set val(initialenergy) initialenergy ;# value
# Initialize Global Variables
set ns_ [new Simulator]
set tracefd [open cc.tr w]
$ns_ trace-all $tracefd
set namtrace [open cc.nam w]
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
# Create God
create-god $val(nn)
# Create channel #1,#2,#3,#4,#5
set chan_1_ [new $val(chan)]
#set chan_2_ [new $val(chan)]
#set chan_3_ [new $val(chan)]
#set chan_4_ [new $val(chan)]
#set chan_5_ [new $val(chan)]
# Create node(0) "attached" to channel #1
# configure node, please note the change below.
# configure the nodes
proc create_node_(0) {} {
$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 [new $val(chan)] \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF \
-channel $chan_1_\
-energyModel$val(energymodel)\
-txPower 0.4 \
-rxPower 0.4 \
-idlePower 0.0 \
-sensePower 0.0175\
-sleepPower .30 \
-initail energy 9
}
proc create_node_(1) {} {
$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 [new $val(chan)] \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF \
-energyModel $val(energymodel) \
-txPower 0.5 \
-rxPower 0.5 \
-idlePower 0.0 \
-sensePower 0.0175\
-sleepPower .30 \
-channel $chan_1_\
-initial energy 5
}
proc create_node_(2) {} {
$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 [new $val(chan)] \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF \
-energyModel $val(energymodel) \
-txPower 0.6 \
-rxPower 0.6 \
-idlePower 0.0 \
-sensePower 0.0175\
-sleepPower .30 \
-channel $chan_1_\
-initial energy 6
}
proc create_node_(3) {} {
$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 [new $val(chan)] \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF \
-energyModel $val(energymodel) \
-txPower 0.7 \
-rxPower 0.7 \
-idlePower 0.0 \
-sensePower 0.0175\
-sleepPower .30 \
-channel $chan_1_\
-initial energy 7
}
proc create_node_(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 [new $val(chan)] \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF \
-energyModel $val(energymodel) \
-txPower 0.8 \
-rxPower 0.8 \
-idlePower 0.0 \
-sensePower 0.0175\
-sleepPower .30 \
-channel $chan_1_\
-initial energy 8
}
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0
}
set node_(0) [$ns_ node]
set node_(1) [$ns_ node]
set node_(2) [$ns_ node]
set node_(3) [$ns_ node]
set node_(4) [$ns_ node]
# node_(1) can also be created with the same configuration, or with a different
# channel specified.
# Uncomment below two lines will create node_(1) with a different channel.
# $ns_ node-config \
# -channel $chan_2_
$ns_ at 0.0 "$node_(0) label Sinknode"
$ns_ at 0.0 "$node_(1) label Sensornode"
$ns_ at 0.0 "$node_(2) label Sensornode"
$ns_ at 0.0 "$node_(3) label Sensornode"
$ns_ at 0.0 "$node_(4) label Sensornode"
$node_(0) random-motion 0
$node_(1) random-motion 0
$node_(2) random-motion 0
$node_(3) random-motion 0
$node_(4) random-motion 0
for {set i 0} {$i < $val(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 30
}
#
# Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes
#
$node_(0) set X_ 250.0
$node_(0) set Y_ 250.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 350.0
$node_(1) set Y_ 350.0
$node_(1) set Z_ 0.0
$node_(2) set X_ 150.0
$node_(2) set Y_ 150.0
$node_(2) set Z_ 0.0
$node_(3) set X_ 350.0
$node_(3) set Y_ 150.0
$node_(3) set Z_ 0.0
$node_(4) set X_ 150.0
$node_(4) set Y_ 350.0
$node_(4) set Z_ 0.0
# Now produce some simple node movements
# Node_(1) starts to move towards node_(0)
#
$ns_ at 0.0 "$node_(0) setdest 1800.0 300.0 0.0"
$ns_ at 0.0 "$node_(1) setdest 1800.0 330.0 0.0"
$ns_ at 0.0 "$node_(2) setdest 1800.0 330.0 0.0"
$ns_ at 0.0 "$node_(3) setdest 1800.0 330.0 0.0"
$ns_ at 0.0 "$node_(4) setdest 1800.0 370.0 0.0"
# Node_(1) then starts to move away from node_(0)
#$ns_ at 30.0 "$node_(1) setdest 10.0 300.0 30.0"
# Setup traffic flow between nodes
# TCP connections between node_(0) and node_(1)
set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(0) $tcp
$ns_ attach-agent $node_(4) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ at .10 "$ftp start"
set tcp1 [new Agent/TCP]
$tcp1 set class_ 2
set sink1 [new Agent/TCPSink]
$ns_ attach-agent $node_(0) $tcp1
$ns_ attach-agent $node_(2) $sink1
$ns_ connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ns_ at .10 "$ftp1 start"
set tcp2 [new Agent/TCP]
$tcp set class_ 2
set sink2 [new Agent/TCPSink]
$ns_ attach-agent $node_(0) $tcp2
$ns_ attach-agent $node_(3) $sink2
$ns_ connect $tcp2 $sink2
set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp2
$ns_ at .10 "$ftp2 start"
set tcp3 [new Agent/TCP]
$tcp set class_ 2
set sink3 [new Agent/TCPSink]
$ns_ attach-agent $node_(0) $tcp3
$ns_ attach-agent $node_(1) $sink3
$ns_ connect $tcp3 $sink3
set ftp3 [new Application/FTP]
$ftp3 attach-agent $tcp3
$ns_ at .10 "$ftp3 start"
#
# Tell nodes when the simulation ends
#
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at 10.0 "$node_($i) reset";
}
#$ns_ at 10.0 "finish file"
$ns_ at 10.0 "stop"
$ns_ at 10.0 "finish file"
$ns_ at 10.01 "puts \"NS EXITING...\" ; $ns_ halt"
proc stop {} {
global ns_ tracefd namtrace
$ns_ flush-trace
close $tracefd
close $namtrace
puts "running nam..."
exec nam cc.nam &
exit 0
}
puts "Starting Simulation..."
$ns_ run
num_nodes is set 5
(_o13 cmd line 1)
invoked from within
"_o13 cmd random-motion 0"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o13" line 2)
(SplitObject unknown line 2)
invoked from within
"$node_($i) random-motion 0"
("for" body line 3)
invoked from within
"for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0
}"
(file "cc.tcl" line 170)
Please tell how can i remove this error I am very need this replay me as soon as possible