LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   random deployment of node in NS2 (https://www.linuxquestions.org/questions/linux-newbie-8/random-deployment-of-node-in-ns2-4175427952/)

r0w225 09-19-2012 02:17 AM

random deployment of node in NS2
 
hi all
i would like to know how to randomly deploy some wireless sensors
nodes in ns2. have been trying and am getting this error /
Code:

num_nodes is set 120
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
INITIALIZE THE LIST xListHead
wrong # args: should be "set varName ?newValue?"
    while compiling
"set X_ axis [expr rand()*600]"
    ("for" body line 2)
    invoked from within
"for {set i 0} {$i < $val(nn)} { incr i } {
                set X_ axis [expr rand()*600]
                set Y_ axis [expr rand()*500]
$node_($i) set X_$X_ axis
$node_($i) set Y_..."

here is the portion of code that i addes to my scenario
for {set i 0} {$i < $val(nn)} { incr i } {
set X_ axis [expr rand()*600]
set Y_ axis [expr rand()*500]
$node_($i) set X_$X_ axis
$node_($i) set Y_$Y_ axis
$node_($i) set Z_$X_ 0.0
}
i believe it is something simple but i guess i need some coffee:) i cant see it. thanks

flower.Hercules 09-27-2012 06:53 AM

I don't think this is the biggest problem but I'd say you probably need a space in here:

Code:

X_$X_ axis
to look like this:

Code:

X_ $X_ axis
on each of them.

However, the error leads me to believe your syntax is wrong; specifically the addition of the "axis" after $X_ in the two lines after the for loop. Consider something like this instead:

Code:

for {set i 0} {$i < $val(nn) } { incr i } {
                set xx [expr rand()*600]
                set yy [expr rand()*500]
                $node_($i) set X_ $xx
                $node_($i) set Y_ $yy
                $node_($i) set Z_ 0.0
          }


r0w225 09-28-2012 06:13 AM

Quote:

Originally Posted by flower.Hercules (Post 4790665)
I don't think this is the biggest problem but I'd say you probably need a space in here:

Code:

X_$X_ axis
to look like this:

Code:

X_ $X_ axis
on each of them.

However, the error leads me to believe your syntax is wrong; specifically the addition of the "axis" after $X_ in the two lines after the for loop. Consider something like this instead:

Code:

for {set i 0} {$i < $val(nn) } { incr i } {
                set xx [expr rand()*600]
                set yy [expr rand()*500]
                $node_($i) set X_ $xx
                $node_($i) set Y_ $yy
                $node_($i) set Z_ 0.0
          }


Hi ! thanks for the contribution , i solved the problem, some days ago i just forget to close the thread, the syntax was not correct
but moreover i had to declare the variable X_ s a random variable to make it work! now its work fine thanks


All times are GMT -5. The time now is 06:56 AM.