The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ... The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

nmlab.korea.ac.kr
from nmlab.korea.ac.kr More from this publisher
12.07.2015 Views

This event is very generic, in that it may execute several different procedures at a given time, as long as it is in one line(no more than 256 characters). There may be white spaces in the string which are passed as arguments to the tcl procedure.Unlike other events, the order of flags and the tcl procedure call is important.Here are some examples of this event in use:Setting playback speedNormally the user chooses a playback rate via the rate slider in the animation window. A trace file may set the playback ratevia the set_rate_ext command:v -t -e set_rate_ext For example:v -t 2.5 -e set_rate_ext 20ms 1For compatibility with earlier versions of nam, the set_rate command is also supported. Instead of specifying the stepsize directly, you use 10 × log 10 . For example:v -t 2.5 -16.9897000433602 1In order to have more readable files, set_rate_ext is preferred.AnnotationThis procedure is used for displaying text annotation at specfic times:v -t -e sim_annotation For example:v -t 4 -e sim_annotation 4 3 node 0 added one markThis line calls a special tcl function sim_annotation in nam, which inserts the given string node 0 added onemark into nam’s annotation pane. Look at Animator instproc sim_annotation in tcl/annotation.tcl for the implementationdetails.Node Exec ButtonIn nam releases, version 1.0a10 and later there is support for running external userdefinable scripts or programs from nam byclicking on a node button.v -t 1.0 -e node_tclscript This line when read in a tracefile will add an extra button to node objects that will execute a tcl script when clicked.For example:401

v -t 1.0 -e node_tclscript 2 "Echo Hello" {puts [exec echo hello]}The above line adds a button to node 2’s info window with the label "Echo Hello" and when this button is pressed the shellcommand "echo hello" will be run and it’s output will be returned to nam and then output to the terminal via the tcl procedureputs.The functions that implement the different nam trace formats described above may be found in the following files: ns/trace.cc,ns/trace.h, ns/tcl/lib/ns-namsupp.tcl.46.1.10 Using Streams for Realtime ApplicationsIn addtion to reading from files nam can also read from a stream such as STDIN. Here is a little tutorial on how to send a namtrace stream to nam to make it operate with real-time data. First some background on how nam works internally. Basically, itthinks it is reading from a nam tracefile. The file has a format to it. Each line is a nam event. The first character on the linedefines the type of event and is followed by several flags to set options on that event. Each event is terminated by a newlinecharacter. A nam tracefile has 2 sections, static configuration events and animation events. All events with -t * in them areconfiguration events and should be sent to nam in one burst. Lines beginning with a # are comment lines. Currently commentsshould only be place in the animation section of the file after the first animation event.First of all you need to pipe your data to nam’s stdin and add the ’-’ flag to the nam command.For example:% cat wireless.nam | nam -nam will read the information from stdinFollowing is a short wireless animation example. The first part of the script has line with -t * which tells nam that these areinitial configuration information.V -t * -v 1.0a5 -a 0W -t * -x 600 -y 600The first 2 lines are used in the nam initialization. They need to be the first 2 lines sent to nam from your program. V is theminimum nam version needed to correctly run this script. W means this is script contains wireless nodes which will be withinthe canvas size of width x and height y.n -t * -s 0 -x 0.0 -y 0.0 -z 20 -v circle -c black -wn -t * -s 1 -x 0.0 -y 200.0 -z 20 -v box -c black -wNext is the network layout information. The first line n creates a wireless (-w) circular (-v circle) node with id 0 (-s 0) atposition 0.0,0.0 (-x 0.0 -y 0.0). It’s size (-z) is 20 and it’s color (-c) is black. The second is a wireless square (-v box) nodewith id 1 (-s 1) at 0.0,200.0. Each node has to have a unique id number given by the -s flag.A -t * -n 1 -p 0 -o 0xffffffff -c 31 -a 1A -t * -h 1 -m 2147483647 -s 0402

This event is very generic, in th<strong>at</strong> it may execute several different procedures <strong>at</strong> a given time, as long as it is in one line(no more than 256 characters). <strong>The</strong>re may be white spaces in the string which are passed as arguments to the tcl procedure.Unlike other events, the order of flags <strong>and</strong> the tcl procedure call is important.Here are some examples of this event in use:Setting playback speedNormally the user chooses a playback r<strong>at</strong>e via the r<strong>at</strong>e slider in the anim<strong>at</strong>ion window. A trace file may set the playback r<strong>at</strong>evia the set_r<strong>at</strong>e_ext comm<strong>and</strong>:v -t -e set_r<strong>at</strong>e_ext For example:v -t 2.5 -e set_r<strong>at</strong>e_ext 20ms 1For comp<strong>at</strong>ibility with earlier versio<strong>ns</strong> of nam, the set_r<strong>at</strong>e comm<strong>and</strong> is also supported. I<strong>ns</strong>tead of specifying the stepsize directly, you use 10 × log 10 . For example:v -t 2.5 -16.9897000433602 1In order to have more readable files, set_r<strong>at</strong>e_ext is preferred.Annot<strong>at</strong>ionThis procedure is used for displaying text annot<strong>at</strong>ion <strong>at</strong> specfic times:v -t -e sim_annot<strong>at</strong>ion For example:v -t 4 -e sim_annot<strong>at</strong>ion 4 3 node 0 added one markThis line calls a special tcl function sim_annot<strong>at</strong>ion in nam, which i<strong>ns</strong>erts the given string node 0 added onemark into nam’s annot<strong>at</strong>ion pane. Look <strong>at</strong> Anim<strong>at</strong>or i<strong>ns</strong>tproc sim_annot<strong>at</strong>ion in tcl/annot<strong>at</strong>ion.tcl for the implement<strong>at</strong>iondetails.Node Exec ButtonIn nam releases, version 1.0a10 <strong>and</strong> l<strong>at</strong>er there is support for running external userdefinable scripts or programs from nam byclicking on a node button.v -t 1.0 -e node_tclscript This line when read in a tracefile will add an extra button to node objects th<strong>at</strong> will execute a tcl script when clicked.For example:401

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!