Introduction to Network Animator (nam) : Introduction to Network Animator (nam) V. Vasantha M.E.,
Senior Lecturer,
Dept. Of Information Technology,
National Engineering College,
K. R. Nagar, Kovilpatti.
nam : 2/14/2011 V. Vasantha, National Engineering College, Kovilpatti 2 nam Basic visualization
Topology layout
Animation control
Synchronous replay
Fine-tune layout
TCP/SRM visualization
Editor: generate ns simulation scripts
NAM window : 2/14/2011 V. Vasantha, National Engineering College, Kovilpatti 3 NAM window
nsnam Interface : 2/14/2011 V. Vasantha, National Engineering College, Kovilpatti 4 nsnam Interface Color
Node manipulation
Link manipulation
Topology layout
Protocol state
Miscellaneous
nam Interface: Color : 2/14/2011 V. Vasantha, National Engineering College, Kovilpatti 5 nam Interface: Color Color mapping
$ns color 40 red
$ns color 41 blue
$ns color 42 chocolate
Color flow id association
$tcp0 set fid_ 40 ;# red packets
$tcp1 set fid_ 41 ;# blue packets
nam Interface: Nodes : 2/14/2011 V. Vasantha, National Engineering College, Kovilpatti 6 nam Interface: Nodes Color
$node color red
Shape (can’t be changed after sim starts)
$node shape box ;# circle, box, hexagon
Marks (concentric “shapes”)
$ns at 1.0 “$n0 add-mark m0 blue box”
$ns at 2.0 “$n0 delete-mark m0”
Label (single string)
$ns at 1.1 “$n0 label \”web cache 0\””
nam Interfaces: Links : 2/14/2011 V. Vasantha, National Engineering College, Kovilpatti 7 nam Interfaces: Links Color
$ns duplex-link-op $n0 $n1 color "green"
Label
$ns duplex-link-op $n0 $n1 label "abced"
Dynamics (automatically handled)
$ns rtmodel Deterministic {2.0 0.9 0.1} $n0 $n1
Asymmetric links not allowed
nam Interface: Topo Layout : 2/14/2011 V. Vasantha, National Engineering College, Kovilpatti 8 nam Interface: Topo Layout “Manual” layout: specify everything
$ns duplex-link-op $n(0) $n(1) orient right
$ns duplex-link-op $n(1) $n(2) orient right
$ns duplex-link-op $n(2) $n(3) orient right
$ns duplex-link-op $n(3) $n(4) orient 60deg
If anything missing automatic layout
nam Interface: Protocol State : 2/14/2011 V. Vasantha, National Engineering College, Kovilpatti 9 nam Interface: Protocol State Monitor values of agent variables
$ns add-agent-trace $srm0 srm_agent0
$ns monitor-agent-trace $srm0
$srm0 tracevar C1_
$srm0 tracevar C2_
# … …
$ns delete-agent-trace $tcp1
nam Interface: Misc : 2/14/2011 V. Vasantha, National Engineering College, Kovilpatti 10 nam Interface: Misc Annotation
Add textual explaination to your sim
$ns at 3.5 "$ns trace-annotate \“packet drop\"“
Set animation rate
$ns at 0.0 "$ns set-animation-rate 0.1ms"
nam Interface: Misc – contd., : 2/14/2011 V. Vasantha, National Engineering College, Kovilpatti 11 nam Interface: Misc – contd., $no label “label name”
$n1 label “Receiver”
$ns at 1.2 "$n2 join-group $rcvr $group2; \
$n2 add-mark m0 red"
$ns at 1.25 "$n2 leave-group $rcvr $group2; \
$n2 delete-mark m0"
$ns at 1.3 "$n2 join-group $rcvr \ $group2; \
$n2 add-mark m1 red"
$ns at 1.35 "$n2 join-group $rcvr $group1; \
$n2 add-mark m2 blue"
Slide 12 : 2/14/2011 V. Vasantha, National Engineering College, Kovilpatti 12 Queries ???
Thank U !!!