LinuxQuestions.org
Help answer threads with 0 replies.
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 11-10-2016, 01:57 AM   #1
angelkot08
LQ Newbie
 
Registered: Nov 2016
Location: jakarta, indonesia
Posts: 3

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


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...


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
 
Old 11-10-2016, 07:10 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by angelkot08 View Post
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...
Code:
num_nodes is set 22
can't read "chan": no such variable
    while executing
can somebody help me please? i can't figure it out. thank you so much![/QUOTE]
You need to read the "Question Guidelines" and "How to ask a smart question' links in my posting signature. First, this is NOT URGENT for anyone here...we volunteer our time, so asking for/expecting 'urgent' help is fairly rude. Secondly, did you think about what you posted????

Your error says that your program cannot read the "chan" variable....it should be very obvious that either the initial definition of 'chan' isn't correct, or you're trying to read chan when you re-define it to 'chan_1' afterwards. Check the syntax at your initial definition.
 
  


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
[SOLVED] X: "loading extension glx" "no screens found" "fatal server error" (w/ nvidia driver) Geremia Slackware 7 12-29-2014 11:00 AM
[SOLVED] "net rpc" "failed to connect to ipc$ share on" or "unable to find a suitable server" larieu Linux - General 0 11-09-2014 12:45 AM
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
"Broken" envirnment variable (MANPATH) and "/etc/profile.d" question. ErV Slackware 3 03-20-2007 09:42 AM

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

All times are GMT -5. The time now is 01:19 AM.

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