![](https://csdnimg.cn/release/download_crawler_static/86534183/bg1.jpg)
Tcl script to create the dynamic color and initial location to nodes
Description:
Number of nodes is fixed in the program. Nodes are configured with
specific parameters of a mobile wireless node. After creating the nam file
and trace file, we set up topography object. set node_ ($i) [$ns node] is used
to create the nodes. Initial location of the nodes is not fixed. X, Y coordinates
are randomly selected and assigned to every node. Here we set the initial size
for the every node by using initial_node_pos. AODV routing protocol is used
here. $val(stop) specifies the end time of the simulation. In this program
nodes are not given color. Their color will change dynamically based on
time.
File name: “wireless1.tcl”
#-------Event scheduler object creation--------#
set ns [new Simulator]
## Create a trace file and nam file..
set tracefd [open wireless1.tr w]
set namtrace [open wireless1.nam w]
## Trace the nam and trace details from the main simulation..
$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
## set up topography object..
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
评论0