-
The Network Animator (NAM) Tool
- The Network Animator (nam) is a completely separate program that is distributed with the NS simulator
- This program is named nam and it shows the progression of the packets through the network.
- The nam program reads an input file (containing the packet transmission events) and draw the network events graphically.
-
Running NAM
- nam is a UNIX program and it is run as a command line.
- Example:
- nam.input is the file that contains network events
UNIX>> nam nam.input
- The key to making the animation input file is to tell NS to output network events into a file for nam to use. It's very simple...
-
Make NS output network event information for NAM
- Do the following:
- Create an output file
- Activate the NAM trace feature in NS before running the simulation (this will tell NS to write NAM events outputs to the output file)
- Close output file at the end of the simulation run Then you can run nam with the output file (as input file for nam)
- Here is an example of code in Tcl to achieve this:
# (1) Create the trace file set namfile [open out.nam w] # (2) Tell NS to write NAM network events to this trace file $ns namtrace-all $namfile # ################################################ # (3) Close output file at the end of the simulation run proc finish {} { global ns namfile $ns flush-trace ;# flush trace files close $namfile ;# close trace file exec nam out.nam & ;# OPTIONAL: run NAM from inside the NS simulation exit 0 }
- Example Program:
(Reno code with NAM)
- Prog file: click here
When it finishes, run: nam out.nam to see the packets flow.
- Do the following:
-
Making a better animation
- The output does not look very good...
- The nodes and links are placed very awkwardly
- All packets (from all flows) are colored black
- We can change some parameters in the animation from inside NS !
- The output does not look very good...
-
Placing Nodes to make NAM animations look good
- We can manipulate the placement of nodes through the
$ns duplex-link-op
(or $ns simplex-link-op)
method on an
existing link (to suggest a "direction"):
- left, right
- up, down
- left-up, left-down
- right-up, right-down
- Examples:
$ns duplex-link-op $n0 $n1 orient left
Make link n0-n1 orient to left
$ns duplex-link-op $n0 $n1 orient left-down
Make link n0-n1 orient to left-down $ns duplex-link-op $n0 $n1 orient left-up
Make link n0-n1 orient to left-up $ns duplex-link-op $n0 $n1 orient right
Make link n0-n1 orient to right $ns duplex-link-op $n0 $n1 orient right-down
Make link n0-n1 orient to right-down $ns duplex-link-op $n0 $n1 orient right-up
Make link n0-n1 orient to right-up -
NOTE: if things do not look good, you can press a "re-layout"
button in NAM to make NAM re-arrange the nodes....
- Example Program:
(Reno code with NAM - positioned nicely)
- Prog file: click here
When it finishes, run: nam out.nam to see a nicer network animation
- We can manipulate the placement of nodes through the
$ns duplex-link-op
(or $ns simplex-link-op)
method on an
existing link (to suggest a "direction"):
-
Coloring Packets from different sources
- Each TCP (or UDP) agent has a built-in flow id variable named fid_
- Each packet from a flow will have this given fid_ value.
- You can assign a value to the
fid_
of a TCP/UDP agent using the
set
command:
$tcp1 set fid_ 234
- You can "color" packets from a given TCP/UDP agent by
assigning a color to a certain flow id value.
For example, if you want packets that has
fid_ = 234
colored
blue, then use:
$ns color 234 blue
This set the color of the packets of flow 234 to blue. When NAM is run, these packets will be colored blue. - The different colors can highlight which packets are being dropped...
- Example Program:
(Reno code with NAM - positioned nicely)
- Prog file: click here
When it finishes, run: nam out.nam to see blue packets...
Saturday, 28 March 2015
Visualizing Network Activities in NS with Reno simulation
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment