I'm trying to orient the nodes in ns2 using angles. It's not working. What am I doing wrong?
set ns [new Simulator]
set nf [open out.nam w]
$ns namtrace-all $nf
set n 4
set router1 [$ns node]
set router2 [$ns node]
$ns duplex-link $router1 $router2 45Mb 75ms DropTail
set x_sndr 50
set x_rcvr 300
set offset 45
set angle [expr -1*$offset*$n/2]
$ns duplex-link-op $router1 $router2 orient right
for {set i 1} {$i <= $n} {incr i} {
set sndr($i) [$ns node]
set rcvr($i) [$ns node]
$ns duplex-link $router1 $sndr($i) 10Mb 10ms DropTail
$ns duplex-link $router2 $rcvr($i) 10Mb 10ms DropTail
set angle [expr $angle+$offset]
puts "$angle"
$ns duplex-link-op $router2 $rcvr($i) orient ($angle)
$ns duplex-link-op $sndr($i) $router1 orient (-1*$angle)
}
$ns duplex-link-op $router1 $router2 orient right
$ns
close $
exec nam out.
exit 0
In the for loop I'm setting duplex-link-op to orient in a particular way, using angles. No matter what values I put for angles, the orientation does not change.
Finally answering my own question,
The documentation of NS2/NAM is not proper and does not properly tell how to use angles as attributes to orient the links.
As shown on this page, it just says this
The may be one of the following: orient, color, queuePos,
label. Orient or the link orientation defines the angle between the
link and horizontal. The optional orientation values may be difined in
degrees or by text like right (0), right-up (45), right-down (-45),
left (180), left-up (135), left-down (-135), up (90), down (-90). The
queuePos or position of queue is defined as the angle of the queue
line with horizontal. Examples for each attribute are given as
following :
$ns duplex-link-op orient right ;# orientation is set as right. The order
;# in which links are created in nam
;# depends on calling order of this function. $ns duplex-link-op color "green" $ns duplex-link-op
queuePos 0.5 $ns duplex-link-op label "A"
But in reality you need to orient by appending the word deg to the angle value
Eg: $ns duplex-link-op orient 90
should be $ns duplex-link-op orient 90deg
So the code will be as follows:
set ns [new Simulator]
set nf [open out.nam w]
$ns namtrace-all $nf
set n 4
set router1 [$ns node]
set router2 [$ns node]
$ns duplex-link $router1 $router2 45Mb 75ms DropTail
set x_sndr 50
set x_rcvr 300
set offset 45
set angle [expr -1*$offset*$n/2]
$ns duplex-link-op $router1 $router2 orient right
for {set i 1} {$i <= $n} {incr i} {
set sndr($i) [$ns node]
set rcvr($i) [$ns node]
$ns duplex-link $router1 $sndr($i) 10Mb 10ms DropTail
$ns duplex-link $router2 $rcvr($i) 10Mb 10ms DropTail
set angle [expr $angle+$offset]
puts "$angle"
$ns duplex-link-op $router2 $rcvr($i) orient [expr $angle]deg
$ns duplex-link-op $sndr($i) $router1 orient [expr -1*$angle]deg
}
$ns duplex-link-op $router1 $router2 orient right
$ns
close $
exec nam out.
exit 0