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.

<strong>The</strong> A event line has to do with setting up hierarchical addressing in nam. It is necessary in wireless nam because packets aretre<strong>at</strong>ed as broadcast to every node.Now we are done with the configur<strong>at</strong>ion part of the nam file. Next are the anim<strong>at</strong>ion events. In order for nam to oper<strong>at</strong>e in aclose to real-time mode it needs to co<strong>ns</strong>tantly receive upd<strong>at</strong>es. As it is playing it will keeps reading lines from the nam trace<strong>and</strong> playing them back. <strong>The</strong> sequence of events must be in chronological order. For example the following lines change thecolor of node 1 from black to green back to black <strong>and</strong> then to black again.n -t 0.0 -s 1 -S COLOR -c green -o blackn -t 0.01 -s 1 -S COLOR -c black -o greenn -t 0.02 -s 1 -S COLOR -c black -o blackNotice th<strong>at</strong> the "-t " flags are always increasing. You cannot issue one event <strong>at</strong> -t 0.2 <strong>and</strong> then another l<strong>at</strong>er on <strong>at</strong> -t0.1. Nam has an internal counter of time <strong>and</strong> it executes an event once it’s time counter passes th<strong>at</strong> event time. It will executeevents in chronological order but only if they are given to it in chronological order. So the following WILL NOT work.n -t 0.0 -s 1 -S COLOR -c black -o blackn -t 0.02 -s 1 -S COLOR -c green -o blackn -t 0.01 -s 1 -S COLOR -c black -o greenSince nam has its own internal represent<strong>at</strong>ion of time which is different than current real world time you have to try <strong>and</strong>synchronize them. <strong>The</strong>re is no explicit <strong>and</strong> totally accur<strong>at</strong>e way to do this but you can have a rough synchroniz<strong>at</strong>ion of timeby having you applic<strong>at</strong>ion periodically send nam events even if nothing has happened. We have cre<strong>at</strong>ed a dummy or "no-op"event (T) for this purpose.T -t 0.5As described above, you MUST feed events to nam in non-decreasing timestamp order. Successive events <strong>at</strong> the same timeare OK. Before anim<strong>at</strong>ing to a given time, nam needs to know th<strong>at</strong> it’s got all the events for th<strong>at</strong> time, <strong>and</strong> so it actually hasto read an event AFTER th<strong>at</strong> time. <strong>The</strong>refore if you’re driving nam from an external process in real-time it will refuse toanim<strong>at</strong>e time t until it sees an event <strong>at</strong> time t+i (for any i > 0). To make nam play out events smoothly, you may therefore needto gener<strong>at</strong>e dummy events with intermedi<strong>at</strong>e timestamps (so th<strong>at</strong> nam knows it can advance). Events of type "T" are dummyevents, so this stream would produce jerky anim<strong>at</strong><strong>at</strong>ion:n -t 1.0 -s 1 -S COLOR -c green -o blackn -t 2.0 -s 1 -S COLOR -c black -o greenn -t 3.0 -s 1 -S COLOR -c black -o blackwhile this would be anim<strong>at</strong><strong>at</strong>ed much smoother:T -t 0.0T -t 0.5n -t 1.0 -s 1 -S COLOR -c green -o blackT -t 1.5n -t 2.0 -s 1 -S COLOR -c black -o greenT -t 2.5n -t 3.0 -s 1 -S COLOR -c black -o blackT -t 3.5T -t 4.0...403

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

Saved successfully!

Ooh no, something went wrong!