Hi All, Our website moved to a new URL. Please bookmark the new link: https://ns2bloggers.blogspot.com/

Friday 23 May 2014

DATA ABOUT NEIGHBOR NODES

Here we developed a program to find the details of neighbor nodes especially current location and distance from a particular nodes.We think its helpful for you all.


proc neighbor {} {
set ns [Simulator instance]
global x1 x2 y1 y2 d n i j nn val
for {set i 0} {$i <$val(nn)} {incr i} {
puts "\n Neighbor list of node: $i"
   for {set j 0} {$j <$val(nn)} {incr j} {
if {$i != $j} {
set x1 [expr int([$n($i) set X_])]
set y1 [expr int([$n($i) set Y_])]
set x2 [expr int([$n($j) set X_])]
set y2 [expr int([$n($j) set Y_])]
set d [expr int(sqrt(pow(($x2-$x1),2)+pow(($y2-$y1),2)))]
puts "node: $j ==> position:- X: $x2 Y: $y2 Z= 0 \t distance: $d"
}
}
}
}
$ns at 10 "neighbor"



For script, Click here

SCREEN SHOT: 




No comments :

Post a Comment