divide the sensing fiels
i am working on ns2.35-ubuntu10.04,, i want to divide the sensor field in to 9 squares of equal size by using tcl script this is my first attempt but there is no result so please help me ,, the steps of division is delimited by the bold and red color.
# Define options
set val(chan) Channel/WirelessChannel ; # channel type
set val(prop) Propagation/TwoRayGround ; # radio-propagation model
set val(netif) Phy/WirelessPhy ; # network interface type
set val(mac) Mac/802_11 ; # MAC type
set val(ifq) Queue/DropTail/PriQueue ; # interface queue type
set val(ll) LL ; # link layer type
set val(ant) Antenna/OmniAntenna ; # antenna model
set val(ifqlen) 50 ; # max packet in ifq
set val(rp) AODV ; # routing protocol
set val(x) 900 ; # X dimension of topography
set val(y) 900 ; # Y dimension of topography
set val(stop) 10 ; # time of simulation end
set val(Y) 0;
set val(X) 0;
set val(nn) 30 ;
#Creating simulation:
set ns [new Simulator]
#Creating nam and trace file:
set tracefd [open k.tr w]
set namtrace [open k.nam w]
$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)
set god_ [create-god $val(nn)]
# configure the nodes
$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
#set $val(X) \[expr $val(x)/300\]
set $val(Y) \[expr $val(y)/300\]
for {set i 0} {$i<=$val(X)} {incr i}
{
for {set j 0} {$j<=$val(Y)} {incr i}
{
for {set b 0} {$b < $val(nn) } { incr b }
{
set node($b) \[$ns node\]
}
}
}
#stop procedure..
proc stop {} {
global ns tracefd namtrace
$ns flush-trace
close $tracefd
close $namtrace
exec nam k.nam &
}
$ns at $val(stop) "stop"
$ns run
|