sample code for creating nodes in ns2 tcl file

 

$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) \
-channel $chan0 \
-topoInstance $topo \
-agentTrace OFF \
-routerTrace OFF \
-macTrace ON \
-movementTrace OFF

then configure the above lines for each node as follows

 

set node_(0) [$ns node]
set node_(1) [$ns node]
set node_(2) [$ns node]
set node_(3) [$ns node]
set node_(4) [$ns node]
set node_(5) [$ns node]
set node_(6) [$ns node]
set node_(7) [$ns node]
set node_(8) [$ns node]
set node_(9) [$ns node]
set node_(10) [$ns node]

Set X-axis and Y-axis position in tcl file

 

set X1(0) 800
set Y1(0) 604

set X1(1) 650
set Y1(1) 606

set X1(2) 926
set Y1(2) 602

set X1(3) 523
set Y1(3) 711

set X1(4) 416
set Y1(4) 846

set X1(5) 277
set Y1(5) 821

set X1(6) 196
set Y1(6) 684

set X1(7) 137
set Y1(7) 544

set X1(8) 433
set Y1(8) 425

set X1(9) 483
set Y1(9) 554

set X1(10) 644
set Y1(10) 407

Leave a Comment