pamvotis.core
Class Simulator

java.lang.Object
  extended by pamvotis.core.Simulator

public class Simulator
extends java.lang.Object

This is the basic class of Pamvotis that does all the work. It contains useful methods that the user can call in order to configure a simulation, run a simulation splitted in time intervals and collect results for each time interval or globally, for all the simulation.

Author:
Dimitris El. Vassis

Constructor Summary
Simulator()
          Creates a new simulation instance.
 
Method Summary
 void addNode(int id, int rate, int coverage, int xPosition, int yPosition, int ac)
          Adds a new node to the system.
 boolean appendNewSource(int node, Source newSource)
          Appends a new source to a specific node
 void changeNodeParams(int node, int coverage, int xPosition, int yPosition)
          Changes the parameters of a node.
 void confParams()
          Configures system and node parameters according to the "config/NtConf.xml" configuration file.
 float getDelay(int node)
          Get the total delay of a node for the last simulation interval.
 float getJitter(int node)
          Get the jitter of a node for the last simulation interval.
 float getMDelay(int node)
          Get the media access delay of a node for the last simulation interval.
 MobileNode getNode(int nodeId)
          Finds a node whose Id is 'nodeId', or null if the node with the specified ID does not exist.
 int getProgress()
           
 float getQDelay(int node)
          Get the queuing delay of a node for the last simulation interval.
 float getQLength(int node)
          Get the average packet buffer length of a node for the last simulation interval.
 float getRatts(int node)
          Get the average number of retransmission attempts of a node for the last simulation interval.
 float getSysThrBps()
          Get the throughput of the system for the last simulation interval.
 float getSysThrPkts()
          Get the throughput of the system for the last simulation interval.
 float getSysUtil()
          Get the utilization of the system for the last simulation interval.
 float getThrBps(int node)
          Get the throughput of a node for the last simulation interval.
 float getThrPkts(int node)
          Get the throughput of a node for the last simulation interval.
 long getTime()
           
 float getUtil(int node)
          Get the utilization of a node for the last simulation interval.
 void printHeaders()
          Prints the headers of the files which contain the statistic results Each statistic is printed only if the user asks it (depending on the containing characteristic two-character sets of the reslts string.
 void printMeanValues()
          Prints the mean statistic results to text file.
 void removeAllNodes()
          Removes all nodes from the system
 boolean removeAllSources(int node)
          Removes all sources from the specified node.
 boolean removeNode(int nodeId)
          Removes a node with a specific ID
 void removeSource(int node, int sourceId)
          Removes a source from a given node
 void simulate(long startTime, long endTime)
          Simulates a specific time interval.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Simulator

public Simulator()
Creates a new simulation instance. When a new instance is created, the parameters of the 802.11 standard family are read.

See Also:
SpecParams.ReadParameters()
Method Detail

getNode

public MobileNode getNode(int nodeId)
                   throws ElementDoesNotExistException
Finds a node whose Id is 'nodeId', or null if the node with the specified ID does not exist.

Parameters:
nodeId - The ID of the node.
Returns:
The node whose ID is 'nodeId'
Throws:
ElementDoesNotExistException

simulate

public void simulate(long startTime,
                     long endTime)
Simulates a specific time interval. First, this interval is simulated and then results are collected. These results refer to this interval only. Be careful on how to call the simulate function. e.g. For simulating from 0 to 10sec: simulate(1,10000). For simulating from 10sec to 20sec: simulate(10001,20000)

Parameters:
startTime - The start time of the simulation interval in miliseconds.
endTime - The end time of the simulation interval in miliseconds.

printHeaders

public void printHeaders()
Prints the headers of the files which contain the statistic results Each statistic is printed only if the user asks it (depending on the containing characteristic two-character sets of the reslts string. Called from the interface.


printMeanValues

public void printMeanValues()
Prints the mean statistic results to text file. These mean results concern the whole simulation and all the times the simulate() method was called.


getProgress

public int getProgress()
Returns:
The % progress of the simulation

getTime

public long getTime()
Returns:
The simulation time in seconds

getThrBps

public float getThrBps(int node)
                throws ElementDoesNotExistException
Get the throughput of a node for the last simulation interval.

Parameters:
node - The node for which we ask for the throughput
Returns:
The throughput of the node in Kb/s
Throws:
ElementDoesNotExistException

getSysThrBps

public float getSysThrBps()
Get the throughput of the system for the last simulation interval.

Returns:
The throughput of the system in Kb/s

getThrPkts

public float getThrPkts(int node)
                 throws ElementDoesNotExistException
Get the throughput of a node for the last simulation interval.

Parameters:
node - The node for which we ask for the throughput
Returns:
The throughput of the node in packets/s
Throws:
ElementDoesNotExistException

getSysThrPkts

public float getSysThrPkts()
Get the throughput of the system for the last simulation interval.

Returns:
The throughput of the system in packets/s

getUtil

public float getUtil(int node)
              throws ElementDoesNotExistException
Get the utilization of a node for the last simulation interval.

Parameters:
node - The node for which we ask for the utilization
Returns:
The utilization of the node in a percentage value
Throws:
ElementDoesNotExistException

getSysUtil

public float getSysUtil()
Get the utilization of the system for the last simulation interval.

Returns:
The utilization of the system in a percentage value

getMDelay

public float getMDelay(int node)
                throws ElementDoesNotExistException
Get the media access delay of a node for the last simulation interval. The media access delay is defined as the delay from the time a packet is picked up for transmission, until the ACK from the receiving node arrives to the sending node.

Parameters:
node - The node for which we ask for the media access delay
Returns:
The media access delay of the node in miliseconds.
Throws:
ElementDoesNotExistException

getQDelay

public float getQDelay(int node)
                throws ElementDoesNotExistException
Get the queuing delay of a node for the last simulation interval. The queuing delay is defined as the delay from the time a packet is generated, until the packet is picked up from the transmitter for transmission.

Parameters:
node - The node for which we ask for the queuing delay
Returns:
The queuing delay of the node in miliseconds.
Throws:
ElementDoesNotExistException

getDelay

public float getDelay(int node)
               throws ElementDoesNotExistException
Get the total delay of a node for the last simulation interval. The total delay is defined as the sum of the media access delay and the queuing delay.

Parameters:
node - The node for which we ask for the total delay
Returns:
The total delay of the node in miliseconds.
Throws:
ElementDoesNotExistException

getJitter

public float getJitter(int node)
                throws ElementDoesNotExistException
Get the jitter of a node for the last simulation interval.

Parameters:
node - The node for which we ask for the jitter.
Returns:
The jitter of the node in miliseconds.
Throws:
ElementDoesNotExistException

getQLength

public float getQLength(int node)
                 throws ElementDoesNotExistException
Get the average packet buffer length of a node for the last simulation interval.

Parameters:
node - The node for which we ask for the buffer length.
Returns:
The buffer length of the node in packets.
Throws:
ElementDoesNotExistException

getRatts

public float getRatts(int node)
               throws ElementDoesNotExistException
Get the average number of retransmission attempts of a node for the last simulation interval.

Parameters:
node - The node for which we ask for the average number of retransmission attempts.
Returns:
The average number of retransmission attempts (pure value).
Throws:
ElementDoesNotExistException

changeNodeParams

public void changeNodeParams(int node,
                             int coverage,
                             int xPosition,
                             int yPosition)
Changes the parameters of a node. Can be called anywhere on the simulation. This method is useful if a mobility or signal strength pattern was implemented, currently not supported in Pamvotis.

Parameters:
node - The node for which we want to change the parameters.
coverage - The node's coverage in meters.
xPosition - The node's x-axis coordinate in meters.
yPosition - The node's y-axis coordinate in meters.

confParams

public void confParams()
Configures system and node parameters according to the "config/NtConf.xml" configuration file. If this method is used externally, pay attention on where to store the xml file.


addNode

public void addNode(int id,
                    int rate,
                    int coverage,
                    int xPosition,
                    int yPosition,
                    int ac)
             throws ElementExistsException
Adds a new node to the system. Pay attention: The user is responsible for assigning correct node IDs. If a dublicate ID exists in the system the simulator is not responsible of identifying it, and unexpected results will occur.

Parameters:
id - The ID of the new node.
rate - The data rate of the node.
coverage - The coverage of the node.
xPosition - The x-axis coordinate.
yPosition - The y-axis coordinate
ac - The 802.11 EDCA access category.
Throws:
ElementExistsException

removeNode

public boolean removeNode(int nodeId)
                   throws ElementDoesNotExistException
Removes a node with a specific ID

Parameters:
nodeId - The ID of the node to be removed.
Returns:
True if the node removed successfully or false in other case.
Throws:
ElementDoesNotExistException

removeAllNodes

public void removeAllNodes()
Removes all nodes from the system


appendNewSource

public boolean appendNewSource(int node,
                               Source newSource)
                        throws ElementExistsException,
                               ElementDoesNotExistException
Appends a new source to a specific node

Parameters:
node - The node id, which is the element number of the vector that stores the nodes.
newSource - A source instance
Returns:
False if the node is not available.
Throws:
ElementExistsException
ElementDoesNotExistException
See Also:
Source, removeSource(int, int), removeAllSources(int)

removeAllSources

public boolean removeAllSources(int node)
                         throws ElementDoesNotExistException
Removes all sources from the specified node.

Parameters:
node - The node id, which is the element number of the vector that stores the nodes.
Returns:
False if the id does not correspond to an existing node
Throws:
ElementDoesNotExistException
See Also:
removeSource(int, int), appendNewSource(int, pamvotis.sources.Source), MobileNode

removeSource

public void removeSource(int node,
                         int sourceId)
                  throws ElementDoesNotExistException
Removes a source from a given node

Parameters:
node - The node id from which the source will be removed
sourceId - The unique id of the session to be terminated
Throws:
ElementDoesNotExistException
See Also:
Source, appendNewSource(int, pamvotis.sources.Source), removeAllSources(int), MobileNode