LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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


Closed Thread
  Search this Thread
Old 11-10-2016, 02:20 AM   #1
angelkot08
LQ Newbie
 
Registered: Nov 2016
Location: jakarta, indonesia
Posts: 3

Rep: Reputation: Disabled
Unhappy ns-allinone-2.35 error : "can't read "chan": no such variable"


hi friends...im a newbie in linux and ns2...im using ns-allinone-2.35 in ubuntu 14.04
currently im working in wireless sensor network...i got an error when i run the codes...i cant figure it out...i was trying to find the answer but i didnt get it...what does this error mean? because i didnt declare "chan"? i already did, such as set val(chan) Channel/WirelessChannel ; set chan_1 [new $val(chan)] ; channel $chan_1.
Or it's talking about "$ns node",
at "for {set i 0} {$i <22} {incr i} {
set n($i) [$ns node]
$n($i) color "blue"
$n($i) shape"circle"
}"
(file "coba2.tcl" line 64)?

this is the error
num_nodes is set 22
can't read "chan": no such variable
while executing
"$node add-interface $chan $propInstance_ $llType_ $macType_ $ifqType_ $ifqlen_ $phyType_ $antType_ $topoInstance_ $inerrProc_ $outerrProc_ $FECProc_"
(procedure "_o3" line 83)
(Simulator create-wireless-node line 83)
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 2)
invoked from within
"for {set i 0} {$i <22} {incr i} {
set n($i) [$ns node]
$n($i) color "blue"
$n($i) shape"circle"
}"
(file "coba2.tcl" line 64)


#simulation

#define options
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;#radio-propagation
set val(ant) Antenna/OmniAntenna ;# Antenna type
set val(ll) LL ;#Link layer type
set val(ifq) CMUPriQueue ;#Interface queue
set val(ifqlen) 50 ;# max packet in ifq
set val(netif) Phy/WirelessPhy ;#network interface
set val(mac) Mac/802_11 ;# MAC type
set val(nn) 22 ;#number of mobilenodes
set val(rp) DSR ;#routing protocol
set val(x) 4400
set val(y) 4400
set val(initialenergy) 1000 ;# Intial energy in Joules
set xdist 100
set ydist 100
set val(energymodel) EnergyModel ;#Energy set up

set ns [new Simulator]
#ns-random 0

#create tracefile
set f [open 1_out.tr w]
$ns trace-all $f

#create nam trace
set namtrace [open 1_out.nam w]
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

set f5 [open node5.tr w]

set topo [new Topography]
$topo load_flatgrid $val(x) $val(y) ; #set topology

create-god $val(nn)
set chan_1 [new $val(chan)]

#configure and create nodes

$ns node-config -adhocRouting $val(rp) \
llType $val(ll) \
macTtype $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 OFF \
channel $chan_1
$ns node-config -energyModel EnergyModel \
energyModel $val(energymodel) \
initialEnergy $val(initialenergy) \
idlePower 0.0 \
rxPower 1.0 \
txPower 2.0 \
sleepPower 0.000 \
transtionPower 0.2 \
transtionTime 0.00000005

for {set i 0} {$i <22} {incr i} {
set n($i) [$ns node]
$n($i) color "blue"
$n($i) shape"circle"
}

#set finish procedure
proc finish {} {
global ns f namtrace

global f5 namtrace


$ns flush-trace
close $namtrace
close $f
exec nam -r 5m 1_out.nam &
exit 0
}

proc record {} {

global sink5 f5

#Get An Instance of the simulator
set ns [Simulator instance]
#Set The Time After Which The Procedure Should Be Called Again
set time 0.05
set bw5 [$sink5 set bytes_]
#Get The current Time
set now [$ns now]
#Save Data to the files

puts $f5 "now [expr $bw5/$time*8/1000000]"
$sink5 set bytes_ 0

$ns at [expr $now + $time] "record"
}

set i 0
set y 100

for {set t 0} {$t < 5} {incr t} {

if {[expr $t % 2] == 0} {
puts "genap"
set x 100
for {ser b 0} {$b<6} {incr b}{
$n($i) set X_ $x
$n($i) set Y_ $y
$n($i) set Z_ 3000.0
set x [expr $x + 300]
set i [expr $i +1]
puts "$i $x $y"
}
} else {

puts "ganjil"
set x 100
for {set b 0} {$b<6} {incr b} {
$n($i) set X_ $x
$n($i) set Y_ $y
$n($i) set Z_ 3000.0
set x [expr $x + 1500]
set i [expr $i +1]
puts "$i $x $y"
}

}
set y [expr $y + 300]
}

for {set i 0} {$i < $val(nn) } {incr i} {
#$ns intial_node_pos $n($i) 30+i*100
$ns intial_node_pos $n($i) 10
}

#shutdown node
#command "node-down" and "node off" in ns2 is not working

$ns at 2.0 "$n(3) color red"
$ns at 2.0 "$n(3) shade triangle"
$ns at 2.0 "$n(3) setdest 4300.0 100.0 3000000000.0"
$ns at 4.0 "$n(11) color red"
$ns at 4.0 "$n(11) shade triangle"
$ns at 4.0 "$n(11) setdest 4300.0 700.0 3000000000.0"
$ns at 6.0 "$n(19) color red"
$ns at 6.0 "$n(19) shade triangle"
$ns at 6.0 "$n(19) setdest 4300.0 1300.0 3000000000.0"
$ns at 10.0 "$n(3) color red"
$ns at 10.0 "$n(3) shade triangle"
$ns at 10.0 "$n(3) setdest 4300.0 1300.0 3000000000.0"
$ns at 14.0 "$n(11) color red"
$ns at 14.0 "$n(11) shade triangle"
$ns at 14.0 "$n(11) setdest 4300.0 1300.0 3000000000.0"

#turn on mode
$ns at 6.0 "$n(3) color green"
$ns at 6.0 "$n(3) shade circle"
$ns at 6.0 "$n(3) setdest 1000.0 100.0 30000.0"
$ns at 10.0 "$n(11) color green"
$ns at 10.0 "$n(11) shade circle"
$ns at 10.0 "$n(11) setdest 1000.0 700.0 30000.0"
$ns at 14.0 "$n(11) color green"
$ns at 14.0 "$n(11) shade circle"
$ns at 14.0 "$n(11) setdest 1000.0 1300.0 30000.0"

#configure and set up a flow

set sink5 [new Agent/LossMonitor]
$ns attach-agent $n(5) $sink5
$ns attach-agent $n(9) $sink9

for {set i 0} {$i < 22} {incr i} {
set udp [expr $i] [new Agent/UDP]
}

$ns attach-agent $n(0) $udp0
$ns attach-agent $n(1) $udp1
$ns attach-agent $n(2) $udp2
$ns attach-agent $n(3) $udp3
$ns attach-agent $n(4) $udp4
$ns attach-agent $n(5) $udp5
$ns attach-agent $n(6) $udp6
$ns attach-agent $n(7) $udp7
$ns attach-agent $n(8) $udp8
$ns attach-agent $n(9) $udp9
$ns attach-agent $n(10) $udp10
$ns attach-agent $n(11) $udp11
$ns attach-agent $n(12) $udp12
$ns attach-agent $n(13) $udp13
$ns attach-agent $n(14) $udp14
$ns attach-agent $n(15) $udp15
$ns attach-agent $n(16) $udp16
$ns attach-agent $n(17) $udp17
$ns attach-agent $n(18) $udp18
$ns attach-agent $n(19) $udp19
$ns attach-agent $n(20) $udp20
$ns attach-agent $n(21) $udp21

proc attach-CBR-traffic { node sink size interval} {
#Get an instance of simulator
set ns [Simulator instance]
#create a cbr agent and attach it to the node
set cbr [new Agent/CBR]
$ns attach-agent $node $cbr
$cbr set packetSize_ $size
$cbr set interval_ $interval

#attach CBR source to sink;
$ns connect $cbr $sink
return $cbr
}

set cbr0 [attach-CBR-traffic $n(0) $sink5 1000 .050]

#simulation start
$ns at 0.0 "record"
$ns at 0.0 " $cbr0 start"
$ns at 20.0 " $cbr0 stop"
$ns at 20.0 "finish"
$ns run

can somebody help me please? i can't figure it out. thank you so much!
regards,

angel
Attached Files
File Type: txt aodv.txt (5.3 KB, 33 views)
 
Old 11-10-2016, 02:21 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,251

Rep: Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159Reputation: 4159
Not urgent at all - and don't multi-post.
Reported for closure.
 
Old 11-10-2016, 03:25 AM   #3
angelkot08
LQ Newbie
 
Registered: Nov 2016
Location: jakarta, indonesia
Posts: 3

Original Poster
Rep: Reputation: Disabled
hi syg00....im sorry about "the multi-post"

i dont understand what you mean...
btw i really need help to fix it...thank you...
 
Old 11-10-2016, 07:17 AM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,894
Blog Entries: 13

Rep: Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945
Per LQ rules, do not post the same discussion multiple times. Duplicate discussions can be frustrating for other members. Try and pick the most relevant forum for your post. This thread has been closed.
 
  


Closed Thread


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
"URGENT" can't read "chan": no such variable ns-allinone-2.35 angelkot08 Linux - Wireless Networking 1 11-10-2016 07:10 AM
[SOLVED] X: "loading extension glx" "no screens found" "fatal server error" (w/ nvidia driver) Geremia Slackware 7 12-29-2014 11:00 AM
Getting "Short read in buffer_copy" error with "dpkg" stalefries Linux - Software 6 03-24-2010 03:19 PM
how can i create a global variable called "dogpatch" with a value of "woof" earthdog Linux - Newbie 9 12-15-2009 01:03 AM
How to get the "data type" of an "unknown variable" in "C Language" ? Affair Programming 8 06-20-2009 12:30 PM

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

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