Node placement in ns2 AODV (or) Random Distribution of nodes in ns2 (or) Create a 100 nodes in ns2 AODV
How to place Random Placement of Nodes in MANET:
Placement of nodes in the topography can be static or uniform or random. In static method, we use a list of predefined values for nodes placement. But, in Random Distribution, nodes are placed randomly within the topography. Using rand() function, we can implement the random distribution of nodes placement in ns2. We can create any number of nodes using this method.
Code:
> In tcl file,for { set j 0 } { $j < $val(nn) } { incr j } {
set node_($j) [$ns node]
$node_($j) set X_ [expr {rand()*1000}]
$node_($j) set Y_ [expr {rand()*500}]
$node_($j) set Z_ [expr {0.0}]
}
> The above code works for 1000 x 500 Topography.
Note :
rand() * 1000 gives values between 0 to 1000.
No comments:
Post a Comment