#5, First Floor, 4th Street , Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 pro@slogix.in

Office Address

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

Social List

How to create Dynamic Wireless Network in ns2?

Description

The dynamic wireless network in ns2 can be modeled using rand function in Tool Command Language (TCL) script. The number of nodes in the network varies dynamically during the runtime. The dynamic wireless network allocates the dynamic location for each node. The sample3.tcl file shows the dynamic network with dynamic number of nodes specified during the execution that are deployed in the area of 500m  500m

Sample Code

#Filename: sample3.tcl

#***************Dynamic Wireless network **********************#

#******************Random Topology Creation********************#

#Run Time Argument

if {$argc != 1} {
error "\nCommand: ns sample3.tcl <no.of.nodes>\n\n "
}
set val(nn) [lindex $argv 0] ;# number of mobilenodes
#Random Location for nodes

for {set i 0} {$i < $val(nn)} {incr i} {

$node_($i) set X_ [expr rand()*$val(x)]
$node_($i) set Y_ [expr rand()*$val(y)]
$node_($i) set Z_ 0

}


Screenshots