bcds.phison.sim
Class SimTask<V extends GraphIONode,E>

java.lang.Object
  extended by bcds.phison.sim.SimCore<V,E>
      extended by bcds.phison.sim.SimTask<V,E>
All Implemented Interfaces:
java.lang.Runnable

public class SimTask<V extends GraphIONode,E>
extends SimCore<V,E>
implements java.lang.Runnable

SimTask offers a simulation execution environment that is prepared based on parameters given in the SimParams object and, to a lesser extent, in the SimGlobals object, passed to the constructor.

The execution environment consists of the following:

Initialization is performed at the begining of the of run() method. One key structure initialized there is the traffic engineering database object, which is an instance of TED. The capacity each link is set according to the value obtained from the topology file, multiplied by the parametr opt.capmult. Link cost depends on what is provided in opt.costtype. Typically, the cost of each link will be value taken from the topology file. Note: this is an area where further generalization is needed, so that link costs can be set more flexibily..

This class processes events of type CONN_REQUEST and CONN_RELEASE besides the one handled by the parent class. See processEventOnCurrentTime(bcds.phison.sim.SimCore.EventEntry) for details on connection handling.

Simulation can terminate on any of the following conditions:

The event list is populated by processing modules; if no one inserts events into the system, the simulator simply terminates.

Processing modules are loaded dynamically. They are referenced as either unqualified or fully qualified class names. To resolve an unqualified name (that is, a class without its package name), the colon-separated list of prefixes given in opt.mod_prefixes is used. Likewise, routing algorithms are loaded dynamically; their prefix is in opt.ra_prefixes.

At the end of the simulation, modules are shut down, so that final statistics can be collected, summaries be printed, etc.

This class implements the Runnable interface so that the caller may spawn several instances in parallel. Processing modules usually write to System.out, and it is convenient that simple output to stdout remains as usual. However, different instances (threads) might want to have their stdout separated). When the parameter opt.rep_out_file is not null, this class assumes that System.out has been replaced with an instace of ThreadedPrintStream and redirects all output to the file named in opt.rep_out_file. That file is always overwritten.

The way to use this class is: instantiate the object passing the two required parameters; call the run method, or activated it as a thread.

Author:
Juan Segovia S.

Nested Class Summary
 
Nested classes/interfaces inherited from class bcds.phison.sim.SimCore
SimCore.EventEntry
 
Field Summary
static java.lang.String PHISON_RANDOM_SEED
          The key used as seed for opt.rnd_gen.
 
Constructor Summary
SimTask(SimGlobals<V,E> context, SimParams opt)
          Creates a new instance; the parameters are passed to the parent constructor.
 
Method Summary
 ConnectionInfo<V,E> createConnection(ConnectionInfo<V,E> rq)
          Returns a new connection between two nodes, of a given capacity, as indicated in the parameter rq.
 void run()
          Executes a simulation: prepares the required data, starts the simulator's core and process events until no event exists or a limit is reached, signaled with a LimitReachedException, which is catched (swallowed) here.
 
Methods inherited from class bcds.phison.sim.SimCore
advanceTime, callProcessingModules, ctx, enqueueCall, enqueueEvent, getLastBlockingReason, getSimStartTime, getSimStopTime, getTime, opt, processEnqueuedEventsPreviousTo, setLastBlockingReason, shutdownProcessingModules, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PHISON_RANDOM_SEED

public static final java.lang.String PHISON_RANDOM_SEED
The key used as seed for opt.rnd_gen. That object is assumed to be instantiated by the caller. Also, the caller is responsible for inserting this key into our environment.

See Also:
Constant Field Values
Constructor Detail

SimTask

public SimTask(SimGlobals<V,E> context,
               SimParams opt)
Creates a new instance; the parameters are passed to the parent constructor.

Method Detail

createConnection

public ConnectionInfo<V,E> createConnection(ConnectionInfo<V,E> rq)
Returns a new connection between two nodes, of a given capacity, as indicated in the parameter rq. This method is responsible for: The connection created MUST NOT be registered with the TED object in this method; that action is performed by the caller, for example by processEventOnCurrentTime(bcds.phison.sim.SimCore.EventEntry).

The parameter rq must be treated as input-only, that is, its state must not be changed. Note: This restriction might be lifted in the future; if each request was already enqueued with a new instance, this requirement should not be necessary.

Throws:
ConnBlockingException - with its error code set to one of the following reasons:
  • NO_WORKING_PATH: a working path could not be found, either because there is no capacity available, or the topology is not connected. There is no way to distinguish one case from the other.
  • NO_BACKUP_PATH: a suitable backup path could not be found. Depending on the algorithm, this might imply that a working path was not found either, but often that will not be the case (for example, when the routing algorithm uses a two-step approach). In any case, however, the working and backup paths in the returned object will be null.
  • PATH_TOO_LONG, a working path was found, but it is longer than the limit set in opt.pl_limit.
  • TOO_LOW_AVAILABILITY, there are paths to satisfy the connection request (both working and backup paths, if the routing algorithm provides protection), but the connection availability is too low. The limit is the value given in the minavail environment parameter of the routing algorithm. If that parameter does not exists, no lower limit is imposed. Please note that the environment parameter's name is unqualified.

run

public void run()
Executes a simulation: prepares the required data, starts the simulator's core and process events until no event exists or a limit is reached, signaled with a LimitReachedException, which is catched (swallowed) here.

If there is an error, the modules are not shut down. If requested so, the environment is always printed, even when the execution was interrupted by an error. Likewise, cleanup() is always called before returning.

Specified by:
run in interface java.lang.Runnable