LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking > Linux - Wireless Networking
User Name
Password
Linux - Wireless Networking This forum is for the discussion of wireless networking in Linux.

Notices


Reply
  Search this Thread
Old 06-07-2012, 06:01 AM   #1
susanthomas
LQ Newbie
 
Registered: May 2012
Posts: 6

Rep: Reputation: Disabled
error 'variable can't be read' in nS2 wired cum wireles simulation


Sir
i was executing an example tcl file for wired cum wireless networking from www.isi.edu/nsnam/ns/tutorial/nsscript6.html.
But it shows the error' ns_(0)variable can't be read' at line number 114 .what could be the problem?

Coding is given below

set opt(chan) Channel/WirelessChannel ;# channel type
set opt(prop) Propagation/TwoRayGround ;# radio-propagation model
set opt(netif) Phy/WirelessPhy ;# network interface type
set opt(mac) Mac/802_11 ;# MAC type
set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type
set opt(ll) LL ;# link layer type
set opt(ant) Antenna/OmniAntenna ;# antenna model
set opt(ifqlen) 50 ;# max packet in ifq
set opt(adhocRouting) DSDV ;# routing protocol

set opt(cp) "" ;# connection pattern file
set opt(sc) "./scen/scen-3-test" ;# node movement file.

set opt(x) 670 ;# x coordinate of topology
set opt(y) 670 ;# y coordinate of topology
set opt(seed) 0.0 ;# seed for random number gen.
set opt(stop) 250 ;# time to stop simulation

set opt(ftp1-start) 100
set opt(ftp2-start) 150

set num_wired_nodes 2
set num_bs_nodes 1
# accpet input parameter
set opt(nn) [lindex $argv 0]
set outfile_ [lindex $argv 1]

# ================================================================
# check for boundary parameters and random seed
if { $opt(x) == 0 || $opt(y) == 0 } {
puts "No X-Y boundary values given for wireless topology\n"
}

if {$opt(seed) > 0} {
puts "Seeding Random number generator with $opt(seed)\n"
ns-random $opt(seed)
}
# create simulator instance
set ns_ [new Simulator]

# set up for hierarchical routing
$ns_ node-config -addressType hierarchical
AddrParams set domain_num_ 2 ;# number of domains
lappend cluster_num 2 1 ;# number of clusters in each domain
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 1 1 4 ;# number of nodes in each cluster
AddrParams set nodes_num_ $eilastlevel ;# of each domain

set tracefd [open $outfile_.tr w]
set namtrace [open $outfile_.nam w]
$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)
# Create topography object
set topo [new Topography]

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

# create God
create-god [expr $opt(nn) + $num_bs_nodes]

#create wired nodes
set temp {0.0.0 0.1.0} ;# hierarchical addresses for wired domain
for {set i 0} {$i < $num_wired_nodes} {incr i} {
set W($i) [$ns_ node [lindex $temp $i]]
}
# configure for base-station node
$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 $topo \
-wiredRouting ON \
-agentTrace OFF \
-routerTrace OFF \
-macTrace OFF

#create base-station node
set temp {1.0.0 1.0.1 1.0.2 1.0.3} ;# hier address to be used for wireless
;# domain
set BS(0) [$ns_ node [lindex $temp 0]]
$BS(0) random-motion 0 ;# disable random motion

#provide some co-ord (fixed) to base station node
$BS(0) set X_ 1.0
$BS(0) set Y_ 2.0
$BS(0) set Z_ 0.0
#configure for mobilenodes
$ns_ node-config -wiredRouting OFF

for {set j 0} {$j < $opt(nn)} {incr j} {
set node_($j) [ $ns_ node [lindex $temp \
[expr $j+1]] ]
$node_($j) base-station [AddrParams addr2id \
[$BS(0) node-addr]]
}

#create links between wired and BS nodes

$ns_ duplex-link $W(0) $W(1) 5Mb 2ms DropTail
$ns_ duplex-link $W(1) $BS(0) 5Mb 2ms DropTail

$ns_ duplex-link-op $W(0) $W(1) orient down
$ns_ duplex-link-op $W(1) $BS(0) orient left-down
# setup TCP connections
set tcp1 [new Agent/TCP]
$tcp1 set class_ 2
set sink1 [new Agent/TCPSink]
$ns_ attach-agent $node_(0) $tcp1
$ns_ attach-agent $W(0) $sink1
$ns_ connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ns_ at $opt(ftp1-start) "$ftp1 start"

set tcp2 [new Agent/TCP]
$tcp2 set class_ 2
set sink2 [new Agent/TCPSink]
$ns_ attach-agent $W(1) $tcp2
$ns_ attach-agent $node_(2) $sink2
$ns_ connect $tcp2 $sink2
set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp2
$ns_ at $opt(ftp2-start) "$ftp2 start"
# Tell all nodes when the simulation ends
for {set i } {$i < $opt(nn) } {incr i} {
$ns_ at $opt(stop).0 "$node_($i) reset";
}
$ns_ at $opt(stop).0 "$BS(0) reset";

$ns_ at $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $opt(stop).0001 "stop"
proc stop {} {
global ns_ tracefd namtrace
# $ns_ flush-trace
close $tracefd
close $namtrace
}

puts "Starting Simulation..."
$ns_ run
 
Old 06-07-2012, 07:22 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,513

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Please edit your post(s) to use code tags.
Write [/code] at code end, and [code] at code start.
Or use the # button in the Advanced Editor.
I.e. your code doesn't look like the code in the link.

Which example is it supposed to be ? There are three. With download links.
wireless1.tcl http://www.isi.edu/nsnam/ns/tutorial.../wireless1.tcl
wireless2.tcl http://www.isi.edu/nsnam/ns/tutorial.../wireless2.tcl
wireless3.tcl http://www.isi.edu/nsnam/ns/tutorial.../wireless3.tcl


The files are for the 13 year old ns2.1b5.

Be aware that the syntax may have changed.
Or that the files in ns-2.xx/tcl/lib/ are different from the ns2.1b5 ones.
I don't remember which of the above two things it is.

.

Last edited by knudfl; 06-07-2012 at 07:23 AM.
 
  


Reply



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
ns2 Wireless simulation Help md_imranullah Programming 1 06-13-2012 02:19 AM
ns2-how to use Diffserv in wireless-cum-wired networks robina Linux - Networking 0 03-03-2012 11:44 PM
Error on example simulation on ns2 using add-on for directional antenna Vixxx Linux - Software 5 02-03-2012 10:37 AM
wired connection is working but not wireles.how to config it ryzingsrinivas Linux - Wireless Networking 1 12-02-2010 08:01 AM
NS2 network simulation problem:Change queue parameters dynamically during simulation raeisy Linux - Networking 1 11-21-2010 11:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking > Linux - Wireless Networking

All times are GMT -5. The time now is 12:48 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