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 ...
X :layout lan-t time-n name-r rate-D delay-o orientation-O orientation46.2 Ns commands for creating and controlling nam animationsThis section describes different APIs in nsthat may be used to manipulate nam animations for objects like nodes, links, queuesand agents. The implementation of most of these APIs is contained in ns/tcl/lib/ns-namsupp.tcl. Demonstration of nam APIsmay be found in ns/tcl/ex/nam-example.tcl.46.2.1 NodeNodes are created from the ”n” trace event in trace file. Each node represents a host or a router. Nam terminates if thereare duplicate definitions of the same node. Attributes specific to node are color, shape, label, label-color, position of labeland adding/deleting mark on the node. Each node can have 3 shapes: circle (default), square, or hexagon. But once created,the shape of a node cannot be changed during the simulation. Different node may have different colors, and its color maybe changed during animation. The following OTcl procedures are used to set node attributes, they are methods of the classNode:$node color [color] ;# sets color of node$node shape [shape] ;# sets shape of node$node label [label] ;# sets label on node$node label-color [lcolor] ;# sets color of label$node label-at [ldirection] ;# sets position of label$node add-mark [name] [color] [shape] ;# adds a mark to node$node delete-mark [name] ;# deletes mark from node46.2.2 Link/QueueLinks are created between nodes to form a network topology. namlinks are internally simplex, but it is invisible to the users.The trace event ”l” creates two simplex links and other necessary setups, hence it looks to users identical to a duplex link.Link may have many colors and it can change its color during animation. Queues are constructed in nam between two nodes.Unlike link, nam queue is associated to a simplex link. The trace event “q” only creates a queue for a simplex link. In nam,queues are visualized as stacked packets. Packets are stacked along a line, and the angle between the line and the horizontalline can be specified in the trace event “q”. Commands to setup different animation attributes of a link are as follows:$ns duplex-link-op The may be one of the following: orient, color, queuePos, label. Orient or the link orientation defines the anglebetween 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 isdefined as the angle of the queue line with horizontal. Examples for each attribute are given as following :411
$ns duplex-link-op orient right$ns duplex-link-op color "green"$ns duplex-link-op queuePos 0.5$ns duplex-link-op label "A";# orientation is set as right. The order;# in which links are created in nam;# depends on calling order of this function.46.2.3 Agent and FeaturesAgents are used to separate protocol states from nodes. They are always associated with nodes. An agent has a name, whichis a unique identifier of the agent. It is shown as a square with its name inside, and a line link the square to its associatednode. The following are commands that support agent tracing:$ns add-agent-trace $ns delete-agent-trace $ns monitor-agent-trace Once the above command is used to create an agent in nam trace, the tracevar method of the nsagent can be used to createfeature traces of a given variable in the agent. For example, the following code segment creates traces of the variable C1_ inan SRM agent $srm(0):$ns attach-agent $n($i) $srm(0)$ns add-agent-trace $srm($i) srm(0)$ns monitor-agent-trace $srm(0) ;# turn nam monitor on from the start$srm(0) tracevar C1_46.2.4 Some Generic Commands$ns color defines color index for nam. Once specified, color-id can be used in place of the colorname in nam traces.$ns trace-annotate inserts an annotation in nam. Notice that if contains whitespaces, it must be quoted using the double quote. An example of this would be $ns at $time ”$ns trace-annotate”Event A happened”” This annotation appears in the nam window and is used to control playing of nam by events.$ns set-animation-rate causes nam to set the animation playout rate to the given timestep value.Time is in seconds, with optional prefixes (for example, 1 is 1 second, or 2ms is 0.002 seconds).412
- Page 361 and 362: Chapter 40Worm ModelIn this chapter
- Page 363 and 364: $w local-p 0.5Following are some co
- Page 365 and 366: (nsnode) clientcloudPackM ime(nsnod
- Page 367 and 368: HTTP responsesclients servers Delay
- Page 369 and 370: 41.5 Commands at a GlanceThe follow
- Page 371 and 372: • HTTP response size (bytes)• s
- Page 373 and 374: Chapter 42Session-level Packet Dist
- Page 375 and 376: 42.1.2 Inserting a Loss ModuleWhen
- Page 377 and 378: Delay and Loss Modules Each receive
- Page 379 and 380: Chapter 43Asim: approximate analyti
- Page 381 and 382: set n(1) [$ns node]set link(0:1) [$
- Page 383 and 384: Part VIIIEmulation382
- Page 385 and 386: When using the emulation mode, a sp
- Page 387 and 388: set intf [$pf1 open readonly]puts "
- Page 389 and 390: puts "install nets into taps..."$a0
- Page 391 and 392: Chapter 45Nam45.1 IntroductionNam i
- Page 393 and 394: • Button 6 (Chevron logo) - Close
- Page 395 and 396: Second, when dealing with randomly
- Page 397 and 398: dst_portaddr,seqno,flags,sname);A n
- Page 399 and 400: • up• down• right• left•
- Page 401 and 402: 46.1.7 Agent TracingAgent trace eve
- Page 403 and 404: v -t 1.0 -e node_tclscript 2 "Echo
- Page 405 and 406: If nam ever gets to the end of an e
- Page 407 and 408: l :link-t time-s source id-d des
- Page 409 and 410: E :D :P :a :session enqueue-t time
- Page 411: v :V :N :W :g :A :c :q :execute tcl
- Page 415 and 416: Chapter 47Educational use of NS and
- Page 417 and 418: Bibliography[1] C. Alaettinoğlu, A
$<strong>ns</strong> duplex-link-op orient right$<strong>ns</strong> duplex-link-op color "green"$<strong>ns</strong> duplex-link-op queuePos 0.5$<strong>ns</strong> duplex-link-op label "A";# orient<strong>at</strong>ion is set as right. <strong>The</strong> order;# in which links are cre<strong>at</strong>ed in nam;# depends on calling order of this function.46.2.3 Agent <strong>and</strong> Fe<strong>at</strong>uresAgents are used to separ<strong>at</strong>e protocol st<strong>at</strong>es from nodes. <strong>The</strong>y are always associ<strong>at</strong>ed with nodes. An agent has a name, whichis a unique identifier of the agent. It is shown as a square with its name i<strong>ns</strong>ide, <strong>and</strong> a line link the square to its associ<strong>at</strong>ednode. <strong>The</strong> following are comm<strong>and</strong>s th<strong>at</strong> support agent tracing:$<strong>ns</strong> add-agent-trace $<strong>ns</strong> delete-agent-trace $<strong>ns</strong> monitor-agent-trace Once the above comm<strong>and</strong> is used to cre<strong>at</strong>e an agent in nam trace, the tracevar method of the <strong>ns</strong>agent can be used to cre<strong>at</strong>efe<strong>at</strong>ure traces of a given variable in the agent. For example, the following code segment cre<strong>at</strong>es traces of the variable C1_ inan SRM agent $srm(0):$<strong>ns</strong> <strong>at</strong>tach-agent $n($i) $srm(0)$<strong>ns</strong> add-agent-trace $srm($i) srm(0)$<strong>ns</strong> monitor-agent-trace $srm(0) ;# turn nam monitor on from the start$srm(0) tracevar C1_46.2.4 Some Generic Comm<strong>and</strong>s$<strong>ns</strong> color defines color index for nam. Once specified, color-id can be used in place of the colorname in nam traces.$<strong>ns</strong> trace-annot<strong>at</strong>e i<strong>ns</strong>erts an annot<strong>at</strong>ion in nam. Notice th<strong>at</strong> if contai<strong>ns</strong> whitespaces, it must be quoted using the double quote. An example of this would be $<strong>ns</strong> <strong>at</strong> $time ”$<strong>ns</strong> trace-annot<strong>at</strong>e”Event A happened”” This annot<strong>at</strong>ion appears in the nam window <strong>and</strong> is used to control playing of nam by events.$<strong>ns</strong> set-anim<strong>at</strong>ion-r<strong>at</strong>e causes nam to set the anim<strong>at</strong>ion playout r<strong>at</strong>e to the given timestep value.Time is in seconds, with optional prefixes (for example, 1 is 1 second, or 2ms is 0.002 seconds).412