LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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-24-2014, 10:23 AM   #1
Niraj Mishra
LQ Newbie
 
Registered: Oct 2014
Posts: 8

Rep: Reputation: Disabled
2 similar tcl files, but 1 is running properly while other shows error.please explain


#Example1.tcl#

set val(chan) Channel/WirelessChannel ;#Channel Type
set val(prop) Propagation/TwoRayGround ;# radio-propagationmodel
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) 10 ;# number of mobilenodes
set val(rp) ZRP ;# Routing protocol
set val(x) 1100
set val(y) 1100
Agent/ZRP set radius_ 2 ;# Setting ZRP radius=2


# Initialize Global Variables

set ns_ [new Simulator]

set tracefile [open scatternet10.tr w]

$ns_ trace-all $tracefile


set namtrace [open scatternet10.nam w]

$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)


#$ns_ use-newtrace


# set up topography object

set topo [new Topography]


$topo load_flatgrid $val(x) $val(y)


# Create God

create-god $val(nn)

# New API to config node:

# 1. Create channel (or multiple-channels);

# 2. Specify channel in node-config (instead of channelType);

# 3. Create nodes for simulations.


# Create channel #1 and #2

set chan_1_ [new $val(chan)]

set chan_2_ [new $val(chan)]


# configure node, please note the change below.

$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 ON \
-macTrace ON \
-movementTrace ON \
-channel $chan_1_


for {set i 0} {$i < $val(nn)} {incr i} {

set node_($i) [$ns_ node]

$node_($i) random-motion 0

$ns_ initial_node_pos $node_($i) 120

}

puts $tracefile "Nodes Defined"


$node_(0) set X_ 300.0

$node_(0) set Y_ 400.0

$node_(0) set Z_ 0.0

$ns_ initial_node_pos $node_(0) 200


$node_(1) set X_ 700.0

$node_(1) set Y_ 500.0

$node_(1) set Z_ 0.0

$ns_ initial_node_pos $node_(1) 200


$node_(2) set X_ 0.0

$node_(2) set Y_ 0.0

$node_(2) set Z_ 0.0

$ns_ initial_node_pos $node_(2) 0


$node_(3) set X_ 0.0

$node_(3) set Y_ 0.0

$node_(3) set Z_ 0.0

$ns_ initial_node_pos $node_(3) 0


$node_(4) set X_ 0.0

$node_(4) set Y_ 0.0

$node_(4) set Z_ 0.0

$ns_ initial_node_pos $node_(4) 0








$node_(7) set X_ 100.0

$node_(7) set Y_ 600.0

$node_(7) set Z_ 0.0

$ns_ initial_node_pos $node_(7) 100




$node_(5) set X_ 800.0

$node_(5) set Y_ 300.0

$node_(5) set Z_ 0.0

$ns_ initial_node_pos $node_(5) 100


$node_(6) set X_ 1000.0

$node_(6) set Y_ 500.0

$node_(6) set Z_ 0.0

$ns_ initial_node_pos $node_(6) 100


$node_(8) set X_ 600.0

$node_(8) set Y_ 900.0

$node_(8) set Z_ 0.0

$ns_ initial_node_pos $node_(8) 100


$node_(9) set X_ 1000.0

$node_(9) set Y_ 700.0

$node_(9) set Z_ 0.0

$ns_ initial_node_pos $node_(9) 100




puts $tracefile "Nodes' coordinates are Defined"


$ns_ at 1.0 "$node_(0) setdest 301.0 401.0 0.0"

$ns_ at 1.0 "$node_(1) setdest 700.0 500.0 0.0"



$ns_ at 1.0 "$node_(5) setdest 800.0 300.0 0.0"

$ns_ at 1.0 "$node_(6) setdest 900.0 500.0 0.0"

$ns_ at 1.0 "$node_(7) setdest 200.0 600.0 0.0"

$ns_ at 1.0 "$node_(8) setdest 600.0 700.0 0.0"

$ns_ at 1.0 "$node_(9) setdest 1000.0 700.0 0.0"


#$ns_ at 1.0 "$node_(2) setdest 0.0 0.0 0.0"

#$ns_ at 1.0 "$node_(3) setdest 0.0 0.0 0.0"

#$ns_ at 1.0 "$node_(4) setdest 0.0 0.0 0.0"

#$ns_ at 1.0 "$node_(12) setdest 0.0 0.0 0.0"

#$ns_ at 1.0 "$node_(13) setdest 0.0 0.0 0.0"

#$ns_ at 1.0 "$node_(14) setdest 0.0 0.0 0.0"

#$ns_ at 1.0 "$node_(16) setdest 0.0 0.0 0.0"

#$ns_ at 1.0 "$node_(17) setdest 0.0 0.0 0.0"

#$ns_ at 1.0 "$node_(18) setdest 0.0 0.0 0.0"

#$ns_ at 1.0 "$node_(19) setdest 0.0 0.0 0.0"


#Creating TCP agents


set tcp0 [new Agent/TCP]

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

set tcp1 [new Agent/TCP]

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




set tcp5 [new Agent/TCP]

$ns_ attach-agent $node_(5) $tcp5

set tcp6 [new Agent/TCP]

$ns_ attach-agent $node_(6) $tcp6

set tcp7 [new Agent/TCP]

$ns_ attach-agent $node_(7) $tcp7

set tcp8 [new Agent/TCP]

$ns_ attach-agent $node_(8) $tcp8

set tcp9 [new Agent/TCP]

$ns_ attach-agent $node_(9) $tcp9


#Creating NULL agents


set sink0 [new Agent/Null]

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

$ns_ connect $tcp0 $sink0


set sink1 [new Agent/Null]

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

$ns_ connect $tcp1 $sink1







set sink5 [new Agent/Null]

$ns_ attach-agent $node_(5) $sink5

$ns_ connect $tcp5 $sink5


set sink6 [new Agent/Null]

$ns_ attach-agent $node_(6) $sink6

$ns_ connect $tcp6 $sink6


set sink7 [new Agent/Null]

$ns_ attach-agent $node_(7) $sink7

$ns_ connect $tcp7 $sink7


set sink8 [new Agent/Null]

$ns_ attach-agent $node_(8) $sink8

$ns_ connect $tcp8 $sink8


set sink9 [new Agent/Null]

$ns_ attach-agent $node_(9) $sink9

$ns_ connect $tcp9 $sink9

# Creating CBR Agents


set cbr0 [new Agent/CBR]

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

$cbr0 set packetSize_ 100

$cbr0 set interval_ 0.05

$ns_ connect $cbr0 $sink0


set cbr1 [new Agent/CBR]

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

$cbr1 set packetSize_ 100

$cbr1 set interval_ 0.05

$cbr1 set rate_ 1mb

$ns_ connect $cbr1 $sink1








set cbr6 [new Agent/CBR]

$ns_ attach-agent $node_(6) $cbr6

$cbr6 set packetSize_ 100

$cbr6 set interval_ 0.05

$cbr6 set rate_ 1mb

$ns_ connect $cbr6 $sink6


set cbr7 [new Agent/CBR]

$ns_ attach-agent $node_(7) $cbr7

$cbr7 set packetSize_ 100

$cbr7 set interval_ 0.05

$cbr7 set rate_ 1mb

$ns_ connect $cbr7 $sink7


set cbr8 [new Agent/CBR]

$ns_ attach-agent $node_(8) $cbr8

$cbr8 set packetSize_ 100

$cbr8 set interval_ 0.05

$cbr8 set rate_ 1mb

$ns_ connect $cbr8 $sink8


set cbr9 [new Agent/CBR]

$ns_ attach-agent $node_(9) $cbr9

$cbr9 set packetSize_ 100

$cbr9 set interval_ 0.05

$cbr9 set rate_ 1mb

$ns_ connect $cbr9 $sink9


puts $tracefile "All Agents Created"


$ns_ at 1.1 "$cbr0 start"

$ns_ at 1.1 "$cbr1 start"





$ns_ at 1.1 "$cbr6 start"

$ns_ at 1.1 "$cbr7 start"

$ns_ at 1.1 "$cbr8 start"

$ns_ at 1.1 "$cbr9 start"

$ns_ at 5.0 "$cbr0 stop"

$ns_ at 5.0 "$cbr1 stop"





$ns_ at 5.0 "$cbr6 stop"

$ns_ at 5.0 "$cbr7 stop"

$ns_ at 5.0 "$cbr8 stop"

$ns_ at 5.0 "$cbr9 stop"


for {set i 0} {$i < $val(nn) } {incr i} {

$ns_ at 5.1 "$node_($i) reset";

}


$ns_ at 5.2 "stop"

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


proc stop {} {

global ns_ tracefile

$ns_ flush-trace

close $tracefile

}

puts "Starting Simulation..."

$ns_ run



#Result on execution#

num_nodes is set 10
INITIALIZE THE LIST xListHead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
Starting Simulation...
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 550.0
SORTING LISTS ...DONE!
NS EXITING...

#It runs properly and nam file is executed#












#Example2.tcl#


set opt(chan) Channel/WirelessChannel
set opt(prop) Propagation/TwoRayGround
set opt(netif) Phy/WirelessPhy
set opt(mac) Mac/NULL
#set opt(mac) Mac/802_11
set opt(ifq) Queue/DropTail/PriQueue
set opt(ll) LL
set opt(ant) Antenna/OmniAntenna
set opt(x) 1300 ;# X dimension of the topography
set opt(y) 1300 ;# Y dimension of the topography
set opt(ifqlen) 20 ;# max packet in ifq(effectless)
set opt(seed) 0.0
set opt(tr) pktdemo.tr ;# trace file
set opt(nam) pktdemo.nam ;# nam trace file
set opt(adhocRouting) ZRP
set opt(nn) 20 ;# how many nodes are simulated
set opt(stop) 10 ;# simulation time

set val(cp) "example.scen"
set val(trfile) "example.traffic"
# =====================================================================
# Other default settings
# for the ifq
Queue set limit_ 50




LL set mindelay_ 50us
LL set delay_ 25us
LL set bandwidth_ 0 ;# not used
LL set off_prune_ 0 ;# not used
LL set off_CtrMcast_ 0 ;# not used

Agent/Null set sport_ 0
Agent/Null set dport_ 0

Agent/CBR set sport_ 0
Agent/CBR set dport_ 0

Agent/TCPSink set sport_ 0
Agent/TCPSink set dport_ 0

Agent/TCP set sport_ 0
Agent/TCP set dport_ 0
Agent/TCP set packetSize_ 512

Queue/DropTail/PriQueue set Prefer_Routing_Protocols 1

# unity gain, omni-directional antennas
# set up the antennas to be centered in the node and 1.5 meters above it
Antenna/OmniAntenna set X_ 0
Antenna/OmniAntenna set Y_ 0
Antenna/OmniAntenna set Z_ 1.5
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0

# Initialize the SharedMedia interface with parameters to make
# it work like the 914MHz Lucent WaveLAN DSSS radio interface
Phy/WirelessPhy set CPThresh_ 10.0
Phy/WirelessPhy set CSThresh_ 1.559e-11
Phy/WirelessPhy set RXThresh_ 3.652e-10
Phy/WirelessPhy set Rb_ 2*1e6
Phy/WirelessPhy set Pt_ 0.2818
Phy/WirelessPhy set freq_ 914e+6
Phy/WirelessPhy set L_ 1.0



# ======================================================================
# Main Program
# ======================================================================


#
# Initialize Global Variables
#

# create simulator instance


set ns_ [new Simulator]

# set wireless channel, radio-model and topography objects

#set wchan [new $opt(chan)]
#set wprop [new $opt(prop)]
set wtopo [new Topography]

# create trace object for ns and nam

set tracefd [open $opt(tr) w]
set namtrace [open $opt(nam) w]

$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)

# define topology
$wtopo load_flatgrid $opt(x) $opt(y)

#$wprop topography $wtopo

#
# Create God
#
set god_ [create-god $opt(nn)]

#
# define how node should be created
#

#global node setting
# -ifqLen $opt(ifqlen) \
# -qlen $opt(ifqlen) \

$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-channelType $opt(chan) \
-topoInstance $wtopo \
-agentTrace ON\
-routerTrace ON \
-movementTrace OFF\
-macTrace OFF



#
# Create the specified number of nodes [$opt(nn)] and "attach" them
# to the channel.

for {set i 0} {$i < $opt(nn) } {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0 ;# disable random motion
}


#
# Define node movement model
#
puts "Loading connection pattern..."
#
# scen-670x670-50-600-20-0
#
source $val(cp)

#
# Define traffic model
#
puts "Loading traffic file"
source $val(trfile)


# Define node initial position in nam

for {set i 0} {$i < $opt(nn)} {incr i} {

# 20 defines the node size in nam, must adjust it according to your scenario
# The function must be called after mobility model is defined

$ns_ initial_node_pos $node_($i) 250
}


#
# Tell nodes when the simulation ends
#
for {set i 0} {$i < $opt(nn) } {incr i} {
$ns_ at $opt(stop).000000001 "$node_($i) reset";
}
# tell nam the simulation stop time
$ns_ at $opt(stop) "$ns_ nam-end-wireless $opt(stop)"

$ns_ at $opt(stop).000000001 "puts \"NS EXITING...\" ; $ns_ halt"


puts "Starting Simulation..."
$ns_ run


#Result on execution#

/NSnew/ns-allinone-2.35/ns-2.35/zrp$ ns235-zrp example.tcl
num_nodes is set 20
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
ns: Agent/ZRP set radius_: can't read "radius_": no such variable
(Object set line 1)
invoked from within
"Agent/ZRP set radius_"



# This has the error, unable to get what is the difference between the two file which becomes the reason for unsuccessful execution of Example1.tcl
 
Old 11-24-2014, 10:56 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,293

Rep: Reputation: 3164Reputation: 3164Reputation: 3164Reputation: 3164Reputation: 3164Reputation: 3164Reputation: 3164Reputation: 3164Reputation: 3164Reputation: 3164Reputation: 3164
Please read post #2 here, about "code tags"
http://www.linuxquestions.org/questi...0/#post5274238
 
  


Reply


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
getting error in NS 2.34 while running a tcl file Md Zishan Khan Linux - Newbie 11 02-11-2016 02:26 AM
error in running tcl file in NS2 mary1001 Linux - Newbie 4 11-09-2014 08:32 PM
Getting error while running fhmipv6.tcl in ns-2.33 masju Linux - Newbie 0 04-17-2012 07:48 AM
scheduler error in running tcl file humairaafzal73 Linux - Software 0 02-27-2012 10:17 AM
running of tcl error tootz Linux - Software 15 03-01-2011 12:08 AM


All times are GMT -5. The time now is 08:24 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration