LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-22-2011, 04:39 AM   #1
Marz22
LQ Newbie
 
Registered: Nov 2011
Posts: 10

Rep: Reputation: Disabled
NS-2 TCL error while simulation


I am stucked in a problem. i-e after running the ns on a my mrmc.tcl script file, i get the following error:

linux-p84p:/usr/local/src/ns-2.34/MRMC-Protocol # ns mrmc.tcl
Wireless Mesh Network in Chain Topologies - 4 Nodes, 3 Channels,
2 Interfaces
num_nodes is set 12

(_o3 cmd line 1)
invoked from within
"_o3 cmd change-numifs 3"
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 "_o3" line 2)
(SplitObject unknown line 2)
invoked from within
"$ns_ change-numifs $val(nc)"
(file "mrmc.tcl" line 74)


Any one have got the similar problem??
 
Old 11-22-2011, 04:41 AM   #2
Marz22
LQ Newbie
 
Registered: Nov 2011
Posts: 10

Original Poster
Rep: Reputation: Disabled
---------------------------------
mrmc.tcl
--------------------------------

# Description: Simulation script for multi-Channel multi-Interface Wireless Mesh Networks
# File: mrmc.tcl
#===============================================================================
#======================================
# MAC Layer Setup
#======================================
Mac/802_11 set dataRate_ 5.4e6 ;# rate for data frames in Mbps
#======================================
# Simulation Parameters Setup
#======================================
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(rp) AODV ;# routing protocol
set val(x) 1000 ;# X dimension of topography
set val(y) 1000 ;# Y dimension of topography
set val(stop) 70 ;# nam stop time
set val(nn) 4 ;# number of mobilenodes
set val(nc) 3 ;# number of channels
set val(ni) 2 ;# number of interfaces, <= number of channels
set pktsize 1000 ;# packet size in bytes
set pktrate 0.0014 ;# packet rate in seconds
set filename wireless_chain_n$val(nn)_c$val(nc)_i$val(ni)
puts "Wireless Mesh Network in Chain Topologies - $val(nn) Nodes, $val(nc) Channels,
$val(ni) Interfaces"
#======================================
# Initialization
#======================================
# Create a ns simulator
set ns_ [new Simulator]
# Setup topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
set god_ [create-god [expr $val(nn)*$val(nc)]]
# Open the NS trace file
set tracefd [open $filename.tr w]
$ns_ trace-all $tracefd
$ns_ use-newtrace
# Open the NAM trace file
set namfile [open $filename.nam w]
$ns_ namtrace-all $namfile
$ns_ namtrace-all-wireless $namfile $val(x) $val(y)
# Create wireless channels
for {set i 0} {$i < $val(nc)} {incr i} {
set chan($i) [new $val(chan)]
}
#======================================
# Mobile Node Parameter Setup
#======================================
$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)
#======================================
# Nodes Definition
#======================================
$ns_ change-numifs $val(nc)
for {set i 0} {$i < $val(nc)} {incr i} {
$ns_ add-channel $i $chan($i)
}
# Create nodes
for {set i 0} {$i < $val(nn)} {incr i} {
set n($i) [$ns_ node]
$god_ new_node $n($i)
}
# Set node positions in horizontal chain topology
set nodedist 250
for {set i 0} {$i < $val(nn)} {incr i} {
$n($i) set X_ [expr $i * $nodedist + 20]
$n($i) set Y_ 50
$n($i) set Z_ 0.0
$ns_ initial_node_pos $n($i) 40
$n($i) random-motion 0
}
#======================================
# Agents Definition
#======================================
set udp0 [new Agent/UDP]
$ns_ attach-agent $n(0) $udp0
set sink0 [new Agent/Null]
set last_node_id [expr $val(nn)-1]
$ns_ attach-agent $n($last_node_id) $sink0
$ns_ connect $udp0 $sink0
#======================================
# Applications Definition
#======================================
# Setup a CBR Application over UDP connection
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set packetSize_ $pktsize
$cbr0 set interval_ $pktrate
$ns_ at 1.0 "$cbr0 start"
$ns_ at 61.0 "$cbr0 stop"
#======================================
# Simulation Termination
#======================================
# Define a finish procedure
proc finish {} {
global ns_ tracefd filename pktsize last_node_id
global namfile
$ns_ flush-trace
close $tracefd
close $namfile
exec nam $filename.nam &
# Call throughput analyzer exec awk -f avgStats.awk src=0 dst=$last_node_id flow=0 pkt=$pktsize $filename.tr &
exit 0
}
for {set i 0} {$i < $val(nn) } { incr i } {
$ns_ at $val(stop) "\$n($i) reset"
}
$ns_ at $val(stop) "$ns_ nam-end-wireless $val(stop)"
$ns_ at $val(stop) "finish"
$ns_ at $val(stop) "puts \"done\" ; $ns_ halt"
$ns_ run

--------------

---------- Post added 11-22-11 at 04:41 AM ----------

some changes to ns-2.34/tcl/ns-lib.tcl

Added the below four procedure as per the document given in first post.

# MRMC: Procedure to change the number of interfaces
Simulator instproc change-numifs {newnumifs} {
$self instvar numifs_
set numifs_ $newnumifs
}
# MRMC: Procedure to add an interface on a node
Simulator instproc add-channel {indexch ch} {
$self instvar chan
set chan($indexch) $ch
}
# MRMC: Procedure to get the number of interfaces
Simulator instproc get-numifs { } {
$self instvar numifs_
if [info exists numifs_] {
return $numifs_
} else {
return ""
}
}
# Procedure to add multiple interfaces as an argument to node-config label
Simulator instproc ifNum {val} {
$self set numifs_ $val
}

I have defined the above procedures before creating node in ns-lib.tcl.

please help.
 
Old 11-22-2011, 04:49 AM   #3
Marz22
LQ Newbie
 
Registered: Nov 2011
Posts: 10

Original Poster
Rep: Reputation: Disabled
Further, note these changes to /tcl/lib/ns-lib.tcl: in procedure.. Simulator instproc create-wireless-node args {

------------------


XXX This should be moved into the node initialization procedure instead
# of standing here 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_ \
numifs_

.............

............

#################################################################
## Second Change Starts here
#################################################################

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

###################################################################
## Second Change Ends here
###################################################################

........
........
 
  


Reply

Tags
ns2


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error on example simulation on ns2 using add-on for directional antenna Vixxx Linux - Software 5 02-03-2012 11:37 AM
tcl code for ns2 simulation shanky Programming 2 08-10-2011 12:57 AM
NS2 network simulation problem:Change queue parameters dynamically during simulation raeisy Linux - Networking 1 11-21-2010 12:30 PM
i am getting this type of error when running simulation in omnet++ in base of mixim vst09 Linux - Wireless Networking 0 10-08-2010 01:59 AM
tcl.h error immortaltechnique Linux - Newbie 2 01-16-2007 09:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration