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.

Chapter 4<strong>The</strong> Class Simul<strong>at</strong>or<strong>The</strong> overall simul<strong>at</strong>or is described by a Tcl class Simul<strong>at</strong>or. It provides a set of interfaces for configuring a simul<strong>at</strong>ion<strong>and</strong> for choosing the type of event scheduler used to drive the simul<strong>at</strong>ion. A simul<strong>at</strong>ion script generally begi<strong>ns</strong> by cre<strong>at</strong>ing ani<strong>ns</strong>tance of this class <strong>and</strong> calling various methods to cre<strong>at</strong>e nodes, topologies, <strong>and</strong> configure other aspects of the simul<strong>at</strong>ion.A subclass of Simul<strong>at</strong>or called OldSim is used to support <strong>ns</strong> v1 backward comp<strong>at</strong>ibility.<strong>The</strong> procedures <strong>and</strong> functio<strong>ns</strong> described in this chapter can be found in ~<strong>ns</strong>/tcl/lib/<strong>ns</strong>-lib.tcl, ~<strong>ns</strong>/scheduler.{cc,h}, <strong>and</strong>,~<strong>ns</strong>/heap.h.4.1 Simul<strong>at</strong>or Initializ<strong>at</strong>ionWhen a new simul<strong>at</strong>ion object is cre<strong>at</strong>ed in tcl, the initializ<strong>at</strong>ion procedure performs the following oper<strong>at</strong>io<strong>ns</strong>:• initialize the packet form<strong>at</strong> (calls cre<strong>at</strong>e_packetform<strong>at</strong>)• cre<strong>at</strong>e a scheduler (defaults to a calendar scheduler)• cre<strong>at</strong>e a “null agent” (a discard sink used in various places)<strong>The</strong> packet form<strong>at</strong> initializ<strong>at</strong>ion sets up field offsets within packets used by the entire simul<strong>at</strong>ion. It is described in more detailin the following chapter on packets (Chapter 12). <strong>The</strong> scheduler ru<strong>ns</strong> the simul<strong>at</strong>ion in an event-driven manner <strong>and</strong> may bereplaced by altern<strong>at</strong>ive schedulers which provide somewh<strong>at</strong> different semantics (see the following section for more detail).<strong>The</strong> null agent is cre<strong>at</strong>ed with the following call:set nullAgent_ [new Agent/Null]This agent is generally useful as a sink for dropped packets or as a destin<strong>at</strong>ion for packets th<strong>at</strong> are not counted or recorded.4.2 Schedulers <strong>and</strong> Events<strong>The</strong> simul<strong>at</strong>or is an event-driven simul<strong>at</strong>or. <strong>The</strong>re are presently four schedulers available in the simul<strong>at</strong>or, each of which isimplemented using a different d<strong>at</strong>a structure: a simple linked-list, heap, calendar queue (default), <strong>and</strong> a special type called38

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

Saved successfully!

Ooh no, something went wrong!