Amazing technological breakthrough possible @S-Logix

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • +91- 81240 01111

Social List

How to create random dynamic topology in NS2?


The dynamic topology can be created using rand function in Tool Command Language (TCL) script with fixed number of nodes. The nodes can be deployed in the area of X & Y. Each node is assigned with a random location within X & Y using rand function. In dynamic topology, the neighbors of each node vary with the location of that particular node. The code segment in sample2.tcl file demonstrates the dynamic topology in wireless network with 2 nodes that are deployed in the area of 500m & 400m.

Sample Code

#Filename: sample2.tcl

#*******************Random Topology Creation*******************#
#Random Location for a two nodes

for {set i 0} {$i < 2} {incr i} {

$node_($i) set X_ [expr rand()*500]
$node_($i) set Y_ [expr rand()*400]
$node_($i) set Z_ 0



create random dynamic topology in NS2