error "error when calling class $cls: $args" $..."

View: New views
4 Messages — Rating Filter:   Alert me  

error "error when calling class $cls: $args" $..."

by Neelambari :: Rate this Message:

| View Threaded | Show Only this Message

Hi all,
As part of my major project I am developing
a multicast routing protocol in Multichannel Wireless Mesh
Network..Now I am simulating the protocol using NS 2.
(ns-allinone-2.33).For multi channel support in NS2 I modified it
using "Adding Multiple Interface Support in NS-2" by Prof.Ramon
Aguero.Now i developed the code for a mesh router which can have
multiple wireless interfaces.The Agent  code is now implemented only
to send hello message which informs its neighbors about its presence.
For this part I went through AODV implementation in NS2. Now I am able
to compile the code but while executing a TCL program I am getting
error as below. The TCL code is also listed. I was trying to solve it
by searching in google but i couldn't find anything helpful in this
regard.Please  help me to overcome this problem.
With Regards
Ajish



TCL CODE
=====================================================================================
#==========================================================================
#--------------------------Define 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)         50                         ;# max packet in ifq

set val(nn)             2                          ;# number of mobilenodes
set val(ni)             2                          ;# number of interfaces

#set val(rp)             DSDV                       ;# routing protocol
set val(rp)             LMP                       ;# routing protocol
#set val(ni)             2                         ;# number of interfaces

#==============================================================================
#---------------------------Main Program---------------------------------------
#==============================================================================
set ns_         [new Simulator]

set tracefd     [open LMP.tr w]

$ns_ trace-all $tracefd

#==============================================================================
#----------------------------Set The Topology----------------------------------
#==============================================================================


set topo [new Topography]


$topo load_flatgrid 500 500

#==============================================================================
#----------------------------Create GOD----------------------------------------
#==============================================================================
for {set i 0} {$i < $val(ni) } {incr i} {
       set chan_($i) [new $val(chan)]
}
#set chan_(0) [new $val(chan)]


#set chan_(1) [new $val(chan)]
create-god [expr $val(nn)*$val(ni)]

#==============================================================================
#--------------------------------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) \

                        -channel $chan_(0) \

                        -topoInstance $topo \

                        -agentTrace ON \

                        -routerTrace ON \

                        -macTrace OFF \

                        -movementTrace OFF \
                        -ifNum $val(ni)
                        #-channel $chan_1_


for {set i 0} {$i < $val(ni) } {incr i} {
       $ns_ add-channel $i $chan_($i)
}
for {set i 0} {$i < $val(nn) } {incr i} {
#       puts "Its not working......"
       set node_($i) [$ns_ node]
#       puts "Its not working......hihi"
       $node_($i) random-motion 0
#       puts "Its not working......"
}

#for {set i 0} {$i < $val(nn) } {incr i} {
#               puts "hello"

#               set node_($i) [$ns_ node]

#               $node_($i) random-motion 0              ;# disable random motion

#       }

#==================================================================================
#----------------------------Placing Nodes in the
Grid-----------------------------
#==================================================================================
$node_(0) set X_ 5.0

$node_(0) set Y_ 2.0

$node_(0) set Z_ 0.0



$node_(1) set X_ 390.0

$node_(1) set Y_ 385.0

$node_(1) set Z_ 0.0

#=================================================================================
#--------------------------------Create and attach
Agent--------------------------
#=================================================================================
set lmpsrc [new Agent/LMPMeshRouter]

set lmpsink [new Agent/LMPMeshRouter]

$ns_ attach-agent $node_(0) $lmpsrc

$ns_ attach-agent $node_(1) $lmpsink

$ns_ connect $lmpsrc $lmpsink

set ftp [new Application/FTP]

$ftp attach-agent $lmpsrc

$ns_ at 10.0 "$lmpsrc start"
$ns_ at 100.0 "stop"

$ns_ at 100.01 "puts \"NS EXITING...\" ; $ns_ halt"

proc stop {} {

   global ns_ tracefd

   $ns_ flush-trace

   close $tracefd

}



puts "Starting Simulation..."

$ns_ run


===================================================================================
===================================================================================
Error
===================================================================================
num_nodes is set 4
AJISH.................
helloooooooooooo
add-channel working fine.....
helloooooooooooo
add-channel working fine.....

   (_o15 cmd line 1)
   invoked from within
"_o15 cmd addr"
   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 "_o15" line 2)
   (SplitObject unknown line 2)
   invoked from within
"_o15 addr"
   ("eval" body line 1)
   invoked from within
"eval $node addr $args"
   ("default" arm line 2)
   invoked from within
"switch -exact $routingAgent_ {
Protoname {
set ragent [$self create-protoname-agent $node]
}
LMPMeshRouter {
set ragent [$self create-lmpmrrouter-agen..."
   (procedure "_o3" line 14)
   (Simulator create-wireless-node line 14)
   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 3)
   invoked from within
"for {set i 0} {$i < $val(nn) } {incr i} {
#       puts "Its not working......"
       set node_($i) [$ns_ node]
#       puts "Its not working......hihi"
       $node_($i) ran..."
   (file "LMP.tcl" line 76)
===================================================================================
The create-wireless-node args procedure in ns-lib.tcl
===================================================================================
Simulator instproc create-wireless-node args {
       $self instvar routingAgent_ wiredRouting_ propInstance_ llType_ \
           macType_ ifqType_ ifqlen_ phyType_ chan antType_ \
           energyModel_ initialEnergy_ txPower_ rxPower_ \
           idlePower_ sleepPower_ sleepTime_ transitionPower_ transitionTime_ \
           topoInstance_ level1_ level2_ inerrProc_ outerrProc_ FECProc_
rtAgentFunction_ numifs_

       Simulator set IMEPFlag_ OFF

       # create node instance
       set node [eval $self create-node-instance $args]

       # basestation address setting
       if { [info exist wiredRouting_] && $wiredRouting_ == "ON" } {
               $node base-station [AddrParams addr2id [$node node-addr]]
       }
       if {$rtAgentFunction_ != ""} {
               set ragent [$self $rtAgentFunction_ $node]
       } else {
               switch -exact $routingAgent_ {
                   Protoname {
                          set ragent [$self create-protoname-agent $node]
                   }
                   LMPMeshRouter {
                         set ragent [$self create-lmpmrrouter-agent $node]
                   }
                   DSDV {
                           set ragent [$self create-dsdv-agent $node]
                   }
                   DSR {
                           $self at 0.0 "$node start-dsr"
                   }
                   AODV {
                           set ragent [$self create-aodv-agent $node]
                   }
                   TORA {
                           Simulator set IMEPFlag_ ON
                           set ragent [$self create-tora-agent $node]
                   }
                   DIFFUSION/RATE {
                           eval $node addr $args
                           set ragent [$self create-diffusion-rate-agent $node]
                   }
                   DIFFUSION/PROB {
                           eval $node addr $args
                           set ragent [$self create-diffusion-probability-agent $node]
                   }
                   Directed_Diffusion {
                           eval $node addr $args
                           set ragent [$self create-core-diffusion-rtg-agent $node]
                   }
                   FLOODING {
                           eval $node addr $args
                           set ragent [$self create-flooding-agent $node]
                   }
                   OMNIMCAST {
                           eval $node addr $args
                           set ragent [$self create-omnimcast-agent $node]
                   }
                   DumbAgent {
                           set ragent [$self create-dumb-agent $node]
                   }
                   ManualRtg {
                           set ragent [$self create-manual-rtg-agent $node]
                   }
                   default {
                           eval $node addr $args
                           puts "Wrong node routing agent!"
                           exit
                   }
               }
       }

       # errProc_ and FECProc_ are an option unlike other
       # parameters for node interface
       if ![info exist inerrProc_] {
               set inerrProc_ ""
       }
       if ![info exist outerrProc_] {
               set outerrProc_ ""
       }
       if ![info exist FECProc_] {
               set FECProc_ ""
       }



       # Add node interface
       if { [info exist numifs_] } {
               for { set i 0 } { $i < $numifs_ } { incr i } {
                       #puts "Add-Interface....One....."
                       # Add one interface per channel
                       $node add-interface $chan($i) $propInstance_ $llType_ $macType_ \
                       $ifqType_ $ifqlen_ $phyType_ $antType_ $topoInstance_ \
                       $inerrProc_ $outerrProc_ $FECProc_
                       #puts "Add-Interface....One One....."
               }
       } else {
               #puts "Add-Interface....One.....Two"
               $node add-interface $chan $propInstance_ $llType_ $macType_ \
               $ifqType_ $ifqlen_ $phyType_ $antType_ $topoInstance_ \
               $inerrProc_ $outerrProc_ $FECProc_
               #puts "Add-Interface....One.....Three"
       }


       # Attach agent
       if {$routingAgent_ != "DSR"} {
               $node attach $ragent [Node set rtagent_port_]
       }
       if {$routingAgent_ == "DIFFUSION/RATE" ||
           $routingAgent_ == "DIFFUSION/PROB" ||
           $routingAgent_ == "FLOODING" ||
           $routingAgent_ == "OMNIMCAST" ||
           $routingAgent_ == "Directed_Diffusion" } {
               $ragent port-dmux [$node demux]
               $node instvar ll_
               $ragent add-ll $ll_(0)
       }
       if { $routingAgent_ == "DumbAgent" } {
               $ragent port-dmux [$node demux]
       }


       # Bind routing agent and mip agent if existing basestation
       # address setting
       if { [info exist wiredRouting_] && $wiredRouting_ == "ON" } {
               if { $routingAgent_ != "DSR" } {
                       $node mip-call $ragent
               }
       }
       #
       # This Trace Target is used to log changes in direction
       # and velocity for the mobile node.
       #
       set tracefd [$self get-ns-traceall]
       if {$tracefd != "" } {
               $node nodetrace $tracefd
               $node agenttrace $tracefd
       }
       set namtracefd [$self get-nam-traceall]
       if {$namtracefd != "" } {
               $node namattach $namtracefd
       }
       if [info exists energyModel_] {
               if  [info exists level1_] {
                       set l1 $level1_
               } else {
                       set l1 0.5
               }
               if  [info exists level2_] {
                       set l2 $level2_
               } else {
                       set l2 0.2
               }
               $node addenergymodel [new $energyModel_ $node \
                               $initialEnergy_ $l1 $l2]
       }
       if [info exists txPower_] {
               $node setPt $txPower_
       }
       if [info exists rxPower_] {
               $node setPr $rxPower_
       }
       if [info exists idlePower_] {
               $node setPidle $idlePower_
       }
#
       if [info exists sleepPower_] {
               $node setPsleep $sleepPower_
       }
       if [info exists sleepTime_] {
               $node setTSleep $sleepTime_
       }
       if [info exists transitionPower_] {
               $node setPtransition $transitionPower_
       }
       if [info exists transitionTime_] {
               $node setTtransition $transitionTime_
       }
#
       $node topography $topoInstance_

       return $node
}
===================================================================================

Re: error "error when calling class $cls: $args" $..."

by Neelambari :: Rate this Message:

| View Threaded | Show Only this Message

finally i got the mistake which i made....In my TCL code I specified the name of the routing protocol wrongly as LMP instead of LMPMeshRouter which is specified in the create-wireless-node args procedure in ns-lib.tcl .When I changed that it is working
Neelambari wrote:
Hi all,
As part of my major project I am developing
a multicast routing protocol in Multichannel Wireless Mesh
Network..Now I am simulating the protocol using NS 2.
(ns-allinone-2.33).For multi channel support in NS2 I modified it
using "Adding Multiple Interface Support in NS-2" by Prof.Ramon
Aguero.Now i developed the code for a mesh router which can have
multiple wireless interfaces.The Agent  code is now implemented only
to send hello message which informs its neighbors about its presence.
For this part I went through AODV implementation in NS2. Now I am able
to compile the code but while executing a TCL program I am getting
error as below. The TCL code is also listed. I was trying to solve it
by searching in google but i couldn't find anything helpful in this
regard.Please  help me to overcome this problem.
With Regards
Ajish



TCL CODE
=====================================================================================
#==========================================================================
#--------------------------Define 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)         50                         ;# max packet in ifq

set val(nn)             2                          ;# number of mobilenodes
set val(ni)             2                          ;# number of interfaces

#set val(rp)             DSDV                       ;# routing protocol
set val(rp)             LMP                       ;# routing protocol
#set val(ni)             2                         ;# number of interfaces

#==============================================================================
#---------------------------Main Program---------------------------------------
#==============================================================================
set ns_         [new Simulator]

set tracefd     [open LMP.tr w]

$ns_ trace-all $tracefd

#==============================================================================
#----------------------------Set The Topology----------------------------------
#==============================================================================


set topo [new Topography]


$topo load_flatgrid 500 500

#==============================================================================
#----------------------------Create GOD----------------------------------------
#==============================================================================
for {set i 0} {$i < $val(ni) } {incr i} {
       set chan_($i) [new $val(chan)]
}
#set chan_(0) [new $val(chan)]


#set chan_(1) [new $val(chan)]
create-god [expr $val(nn)*$val(ni)]

#==============================================================================
#--------------------------------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) \

                        -channel $chan_(0) \

                        -topoInstance $topo \

                        -agentTrace ON \

                        -routerTrace ON \

                        -macTrace OFF \

                        -movementTrace OFF \
                        -ifNum $val(ni)
                        #-channel $chan_1_


for {set i 0} {$i < $val(ni) } {incr i} {
       $ns_ add-channel $i $chan_($i)
}
for {set i 0} {$i < $val(nn) } {incr i} {
#       puts "Its not working......"
       set node_($i) [$ns_ node]
#       puts "Its not working......hihi"
       $node_($i) random-motion 0
#       puts "Its not working......"
}

#for {set i 0} {$i < $val(nn) } {incr i} {
#               puts "hello"

#               set node_($i) [$ns_ node]

#               $node_($i) random-motion 0              ;# disable random motion

#       }

#==================================================================================
#----------------------------Placing Nodes in the
Grid-----------------------------
#==================================================================================
$node_(0) set X_ 5.0

$node_(0) set Y_ 2.0

$node_(0) set Z_ 0.0



$node_(1) set X_ 390.0

$node_(1) set Y_ 385.0

$node_(1) set Z_ 0.0

#=================================================================================
#--------------------------------Create and attach
Agent--------------------------
#=================================================================================
set lmpsrc [new Agent/LMPMeshRouter]

set lmpsink [new Agent/LMPMeshRouter]

$ns_ attach-agent $node_(0) $lmpsrc

$ns_ attach-agent $node_(1) $lmpsink

$ns_ connect $lmpsrc $lmpsink

set ftp [new Application/FTP]

$ftp attach-agent $lmpsrc

$ns_ at 10.0 "$lmpsrc start"
$ns_ at 100.0 "stop"

$ns_ at 100.01 "puts \"NS EXITING...\" ; $ns_ halt"

proc stop {} {

   global ns_ tracefd

   $ns_ flush-trace

   close $tracefd

}



puts "Starting Simulation..."

$ns_ run


===================================================================================
===================================================================================
Error
===================================================================================
num_nodes is set 4
AJISH.................
helloooooooooooo
add-channel working fine.....
helloooooooooooo
add-channel working fine.....

   (_o15 cmd line 1)
   invoked from within
"_o15 cmd addr"
   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 "_o15" line 2)
   (SplitObject unknown line 2)
   invoked from within
"_o15 addr"
   ("eval" body line 1)
   invoked from within
"eval $node addr $args"
   ("default" arm line 2)
   invoked from within
"switch -exact $routingAgent_ {
Protoname {
set ragent [$self create-protoname-agent $node]
}
LMPMeshRouter {
set ragent [$self create-lmpmrrouter-agen..."
   (procedure "_o3" line 14)
   (Simulator create-wireless-node line 14)
   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 3)
   invoked from within
"for {set i 0} {$i < $val(nn) } {incr i} {
#       puts "Its not working......"
       set node_($i) [$ns_ node]
#       puts "Its not working......hihi"
       $node_($i) ran..."
   (file "LMP.tcl" line 76)
===================================================================================
The create-wireless-node args procedure in ns-lib.tcl
===================================================================================
Simulator instproc create-wireless-node args {
       $self instvar routingAgent_ wiredRouting_ propInstance_ llType_ \
           macType_ ifqType_ ifqlen_ phyType_ chan antType_ \
           energyModel_ initialEnergy_ txPower_ rxPower_ \
           idlePower_ sleepPower_ sleepTime_ transitionPower_ transitionTime_ \
           topoInstance_ level1_ level2_ inerrProc_ outerrProc_ FECProc_
rtAgentFunction_ numifs_

       Simulator set IMEPFlag_ OFF

       # create node instance
       set node [eval $self create-node-instance $args]

       # basestation address setting
       if { [info exist wiredRouting_] && $wiredRouting_ == "ON" } {
               $node base-station [AddrParams addr2id [$node node-addr]]
       }
       if {$rtAgentFunction_ != ""} {
               set ragent [$self $rtAgentFunction_ $node]
       } else {
               switch -exact $routingAgent_ {
                   Protoname {
                          set ragent [$self create-protoname-agent $node]
                   }
                   LMPMeshRouter {
                         set ragent [$self create-lmpmrrouter-agent $node]
                   }
                   DSDV {
                           set ragent [$self create-dsdv-agent $node]
                   }
                   DSR {
                           $self at 0.0 "$node start-dsr"
                   }
                   AODV {
                           set ragent [$self create-aodv-agent $node]
                   }
                   TORA {
                           Simulator set IMEPFlag_ ON
                           set ragent [$self create-tora-agent $node]
                   }
                   DIFFUSION/RATE {
                           eval $node addr $args
                           set ragent [$self create-diffusion-rate-agent $node]
                   }
                   DIFFUSION/PROB {
                           eval $node addr $args
                           set ragent [$self create-diffusion-probability-agent $node]
                   }
                   Directed_Diffusion {
                           eval $node addr $args
                           set ragent [$self create-core-diffusion-rtg-agent $node]
                   }
                   FLOODING {
                           eval $node addr $args
                           set ragent [$self create-flooding-agent $node]
                   }
                   OMNIMCAST {
                           eval $node addr $args
                           set ragent [$self create-omnimcast-agent $node]
                   }
                   DumbAgent {
                           set ragent [$self create-dumb-agent $node]
                   }
                   ManualRtg {
                           set ragent [$self create-manual-rtg-agent $node]
                   }
                   default {
                           eval $node addr $args
                           puts "Wrong node routing agent!"
                           exit
                   }
               }
       }

       # errProc_ and FECProc_ are an option unlike other
       # parameters for node interface
       if ![info exist inerrProc_] {
               set inerrProc_ ""
       }
       if ![info exist outerrProc_] {
               set outerrProc_ ""
       }
       if ![info exist FECProc_] {
               set FECProc_ ""
       }



       # Add node interface
       if { [info exist numifs_] } {
               for { set i 0 } { $i < $numifs_ } { incr i } {
                       #puts "Add-Interface....One....."
                       # Add one interface per channel
                       $node add-interface $chan($i) $propInstance_ $llType_ $macType_ \
                       $ifqType_ $ifqlen_ $phyType_ $antType_ $topoInstance_ \
                       $inerrProc_ $outerrProc_ $FECProc_
                       #puts "Add-Interface....One One....."
               }
       } else {
               #puts "Add-Interface....One.....Two"
               $node add-interface $chan $propInstance_ $llType_ $macType_ \
               $ifqType_ $ifqlen_ $phyType_ $antType_ $topoInstance_ \
               $inerrProc_ $outerrProc_ $FECProc_
               #puts "Add-Interface....One.....Three"
       }


       # Attach agent
       if {$routingAgent_ != "DSR"} {
               $node attach $ragent [Node set rtagent_port_]
       }
       if {$routingAgent_ == "DIFFUSION/RATE" ||
           $routingAgent_ == "DIFFUSION/PROB" ||
           $routingAgent_ == "FLOODING" ||
           $routingAgent_ == "OMNIMCAST" ||
           $routingAgent_ == "Directed_Diffusion" } {
               $ragent port-dmux [$node demux]
               $node instvar ll_
               $ragent add-ll $ll_(0)
       }
       if { $routingAgent_ == "DumbAgent" } {
               $ragent port-dmux [$node demux]
       }


       # Bind routing agent and mip agent if existing basestation
       # address setting
       if { [info exist wiredRouting_] && $wiredRouting_ == "ON" } {
               if { $routingAgent_ != "DSR" } {
                       $node mip-call $ragent
               }
       }
       #
       # This Trace Target is used to log changes in direction
       # and velocity for the mobile node.
       #
       set tracefd [$self get-ns-traceall]
       if {$tracefd != "" } {
               $node nodetrace $tracefd
               $node agenttrace $tracefd
       }
       set namtracefd [$self get-nam-traceall]
       if {$namtracefd != "" } {
               $node namattach $namtracefd
       }
       if [info exists energyModel_] {
               if  [info exists level1_] {
                       set l1 $level1_
               } else {
                       set l1 0.5
               }
               if  [info exists level2_] {
                       set l2 $level2_
               } else {
                       set l2 0.2
               }
               $node addenergymodel [new $energyModel_ $node \
                               $initialEnergy_ $l1 $l2]
       }
       if [info exists txPower_] {
               $node setPt $txPower_
       }
       if [info exists rxPower_] {
               $node setPr $rxPower_
       }
       if [info exists idlePower_] {
               $node setPidle $idlePower_
       }
#
       if [info exists sleepPower_] {
               $node setPsleep $sleepPower_
       }
       if [info exists sleepTime_] {
               $node setTSleep $sleepTime_
       }
       if [info exists transitionPower_] {
               $node setPtransition $transitionPower_
       }
       if [info exists transitionTime_] {
               $node setTtransition $transitionTime_
       }
#
       $node topography $topoInstance_

       return $node
}
===================================================================================

Re: error "error when calling class $cls: $args" $..."

by qnbee :: Rate this Message:

| View Threaded | Show Only this Message

hello,

can u pls send me the complete coding for the same.

my id is potter1238@gmail.com

thanks in advance

Re: error "error when calling class $cls: $args" $..."

by Bhupi1988 :: Rate this Message:

| View Threaded | Show Only this Message

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