12.07.2015 Views

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 ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

v -t 1.0 -e node_tclscript 2 "Echo Hello" {puts [exec echo hello]}<strong>The</strong> above line adds a button to node 2’s info window with the label "Echo Hello" <strong>and</strong> when this button is pressed the shellcomm<strong>and</strong> "echo hello" will be run <strong>and</strong> it’s output will be returned to nam <strong>and</strong> then output to the terminal via the tcl procedureputs.<strong>The</strong> functio<strong>ns</strong> th<strong>at</strong> implement the different nam trace form<strong>at</strong>s described above may be found in the following files: <strong>ns</strong>/trace.cc,<strong>ns</strong>/trace.h, <strong>ns</strong>/tcl/lib/<strong>ns</strong>-namsupp.tcl.46.1.10 Using Streams for Realtime Applic<strong>at</strong>io<strong>ns</strong>In 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 oper<strong>at</strong>e with real-time d<strong>at</strong>a. First some background on how nam works internally. Basically, itthinks it is reading from a nam tracefile. <strong>The</strong> file has a form<strong>at</strong> to it. Each line is a nam event. <strong>The</strong> first character on the linedefines the type of event <strong>and</strong> is followed by several flags to set optio<strong>ns</strong> on th<strong>at</strong> event. Each event is termin<strong>at</strong>ed by a newlinecharacter. A nam tracefile has 2 sectio<strong>ns</strong>, st<strong>at</strong>ic configur<strong>at</strong>ion events <strong>and</strong> anim<strong>at</strong>ion events. All events with -t * in them areconfigur<strong>at</strong>ion events <strong>and</strong> should be sent to nam in one burst. Lines beginning with a # are comment lines. Currently commentsshould only be place in the anim<strong>at</strong>ion section of the file after the first anim<strong>at</strong>ion event.First of all you need to pipe your d<strong>at</strong>a to nam’s stdin <strong>and</strong> add the ’-’ flag to the nam comm<strong>and</strong>.For example:% c<strong>at</strong> wireless.nam | nam -nam will read the inform<strong>at</strong>ion from stdinFollowing is a short wireless anim<strong>at</strong>ion example. <strong>The</strong> first part of the script has line with -t * which tells nam th<strong>at</strong> these areinitial configur<strong>at</strong>ion inform<strong>at</strong>ion.V -t * -v 1.0a5 -a 0W -t * -x 600 -y 600<strong>The</strong> first 2 lines are used in the nam initializ<strong>at</strong>ion. <strong>The</strong>y 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 mea<strong>ns</strong> this is script contai<strong>ns</strong> wireless nodes which will be withinthe canvas size of width x <strong>and</strong> 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 inform<strong>at</strong>ion. <strong>The</strong> first line n cre<strong>at</strong>es a wireless (-w) circular (-v circle) node with id 0 (-s 0) <strong>at</strong>position 0.0,0.0 (-x 0.0 -y 0.0). It’s size (-z) is 20 <strong>and</strong> it’s color (-c) is black. <strong>The</strong> second is a wireless square (-v box) nodewith id 1 (-s 1) <strong>at</strong> 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

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

Saved successfully!

Ooh no, something went wrong!