yass.analysis
Class FullAnalyser

java.lang.Object
  extended by yass.analysis.Analyser
      extended by yass.analysis.FullAnalyser

public class FullAnalyser
extends Analyser

Analyses a provided simulation state to frequentYielding statistics focussing on energy consumption. TODO: This analyser should be modularised, being transformed into a set of complementary but orthogonal smaller analysers. Not diffcult to do, but nevertheless has not yet been done.


Field Summary
protected  long analysisStartTimeMillis
          Result of System.currentTimeMillis() at start of analysis; used to calculate how long has been spent during analysis
protected  Database db
          Simulation database
protected  double endTime
          Total elapsed simulated time
protected  PacketType generatedTypeToConsider
          Type of generated packet on which to filter analysis.
protected  java.util.Map<java.lang.Integer,Node> idNodeMap
          Mapping of node ID number to associated Node object
private static org.apache.log4j.Logger log
          The logger
protected  Node[] nodes
          Nodes participating in the simulated network
protected  java.lang.String nodeStateTable
          Name of database table to hold temporary data when analysing node states, specific to this instance
static java.lang.String nodeStateTablePrefix
          Name of database table to hold temporary data when analysing node states; prefix used for each instance
protected  boolean performCoverageAnalysis
          Flag indicating if optional packet coverage analysis is to be performed.
protected  boolean performDeliveryDistributionAnalysis
          Flag indicating if optional delivery distribution analysis is to be performed.
static int propagationAnalysisIncrements
          Number of steps to consider between 0% propagation and 100% propagation
protected  java.lang.String propagationTargetsTable
          Name of database table to hold temporary data when analysing message propagation targets, specific to this instance
static java.lang.String propagationTargetsTablePrefix
          Name of database table to hold temporary data when analysing message propagation targets; prefix used for each instance
protected  java.lang.String propagationTimesTable
          Name of database table to hold temporary data when analysing message propagation critical times, specific to this instance
static java.lang.String propagationTimesTablePrefix
          Name of database table to hold temporary data when analysing message propagation critical times; prefix used for each instance
protected  java.lang.String rmStateTable
          Name of database table to hold temporary data when analysing radio module states, specific to this instance
static java.lang.String rmStateTablePrefix
          Name of database table to hold temporary data when analysing radio module states; prefix used for each instance
protected  java.lang.String tableSuffix
          Instance-specific unique suffix appended to all shared tablename prefixes to guarantee that analyser instances never share temporary working data.
protected  java.text.NumberFormat twoDpNumberFormat
          Number formatter which rounds floats and doubles to two decimal places
 
Fields inherited from class yass.analysis.Analyser
analysisFinished, results, simulation, simulationState
 
Constructor Summary
FullAnalyser(Simulation state)
          Creates a new instance of FullAnalyser
FullAnalyser(Simulation state, PacketType generatedTypeToConsider, boolean performCoverageAnalysis, boolean performDeliveryDistributionAnalysis)
          Creates a new instance of FullAnalyser
 
Method Summary
 AnalysisResults analyse()
          Analyses the current simulation state
protected  void analyseDeliveryDistributions()
          Analyses distributions of metrics associated with packet delivery success and failure, from which investigators can derive an understanding of where failures in message delivery are concentrated.
protected  void analyseEnergy()
          Analyses the energy consumed by simulated network activity
protected  void analyseMessagePropagation()
          Analyses success of message propagation within the simulated network
protected  void analyseNetwork()
          Analyses the network and its participating nodes
protected  void analyseNetworkTraffic()
          Analyses traffic in the simulated network
protected  void analyseNetworkTrafficEnergy()
          Analyses energy expended on traffic in the simulated network
protected  void analyseNodeStates()
          Analyses the states adopted by nodes during simulation
protected  void analysePointToPointSuccess()
          Analyses success of point-to-point activity in the simulated network
protected  void analyseRadioModuleStates()
          Analyses the states adopted by radio modules during simulation
protected  java.lang.String analysisTimeSeconds()
           
protected  AnalysisException createException(java.lang.String message, java.lang.Exception e)
          Builds an AnalysisException to wrap the provided message and lower-level exception
protected  void createWorkingTables()
          Creates the set of temporary tables to hold working data required during analysis, which can be safely discarded when analysis completes.
protected  boolean dropWorkingTables()
          Drops the temporary analysis working tables from the simulation database if the backing Database object is configured to drop tables on shutdown.
private  void initialiseNumberFormatters()
           
protected  void logCumulativeTime(java.lang.String reason, long prev)
          Logs the number of seconds spent on analysis thus far
protected  void populateNodeMap()
          Populates the mapping of nodeId to node, and populates the node-bearing array, for all nodes supplied in the class constructor
protected  void populateNodeWorkingTables()
          Populates temporary working data tables with data used in later analysis of nodes participating in the simulated network
protected  void populatePropagationWorkingTables()
          Populates temporary working tables with data to be used in the later analysis of propagation of packets within the simulated network
protected  void populateRadioModuleWorkingTables()
          Populates temporary working data tables with data used in later analysis of radio modules participating in the simulated network
 
Methods inherited from class yass.analysis.Analyser
getResults, getSimulationId, getState, isAnalysisFinished
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propagationAnalysisIncrements

public static final int propagationAnalysisIncrements
Number of steps to consider between 0% propagation and 100% propagation

See Also:
Constant Field Values

rmStateTablePrefix

public static final java.lang.String rmStateTablePrefix
Name of database table to hold temporary data when analysing radio module states; prefix used for each instance

See Also:
Constant Field Values

nodeStateTablePrefix

public static final java.lang.String nodeStateTablePrefix
Name of database table to hold temporary data when analysing node states; prefix used for each instance

See Also:
Constant Field Values

propagationTargetsTablePrefix

public static final java.lang.String propagationTargetsTablePrefix
Name of database table to hold temporary data when analysing message propagation targets; prefix used for each instance

See Also:
Constant Field Values

propagationTimesTablePrefix

public static final java.lang.String propagationTimesTablePrefix
Name of database table to hold temporary data when analysing message propagation critical times; prefix used for each instance

See Also:
Constant Field Values

log

private static org.apache.log4j.Logger log
The logger


nodes

protected Node[] nodes
Nodes participating in the simulated network


db

protected Database db
Simulation database


endTime

protected double endTime
Total elapsed simulated time


idNodeMap

protected java.util.Map<java.lang.Integer,Node> idNodeMap
Mapping of node ID number to associated Node object


rmStateTable

protected java.lang.String rmStateTable
Name of database table to hold temporary data when analysing radio module states, specific to this instance


nodeStateTable

protected java.lang.String nodeStateTable
Name of database table to hold temporary data when analysing node states, specific to this instance


propagationTargetsTable

protected java.lang.String propagationTargetsTable
Name of database table to hold temporary data when analysing message propagation targets, specific to this instance


propagationTimesTable

protected java.lang.String propagationTimesTable
Name of database table to hold temporary data when analysing message propagation critical times, specific to this instance


tableSuffix

protected java.lang.String tableSuffix
Instance-specific unique suffix appended to all shared tablename prefixes to guarantee that analyser instances never share temporary working data.


performCoverageAnalysis

protected boolean performCoverageAnalysis
Flag indicating if optional packet coverage analysis is to be performed. This can be disabled for faster analysis if the results are not required.


performDeliveryDistributionAnalysis

protected boolean performDeliveryDistributionAnalysis
Flag indicating if optional delivery distribution analysis is to be performed. This can be disabled for faster analysis if the results are not required.


generatedTypeToConsider

protected PacketType generatedTypeToConsider
Type of generated packet on which to filter analysis. Generally used to apply analysis only to application packets, or only to network maintenance and routing packets. Set to PacketType.UNSPECIFIED to consider all types equally in analysis.


analysisStartTimeMillis

protected long analysisStartTimeMillis
Result of System.currentTimeMillis() at start of analysis; used to calculate how long has been spent during analysis


twoDpNumberFormat

protected java.text.NumberFormat twoDpNumberFormat
Number formatter which rounds floats and doubles to two decimal places

Constructor Detail

FullAnalyser

public FullAnalyser(Simulation state)
Creates a new instance of FullAnalyser

Parameters:
state - the simulation state to analyse

FullAnalyser

public FullAnalyser(Simulation state,
                    PacketType generatedTypeToConsider,
                    boolean performCoverageAnalysis,
                    boolean performDeliveryDistributionAnalysis)
Creates a new instance of FullAnalyser

Parameters:
generatedTypeToConsider - the type of packet to consider in analysis (or PacketType.UNSPECIFIED to consider all packet types equally)
state - the simulation state to analyse
performCoverageAnalysis - whether to perform optional packet coverage analysis, which can be disabled for faster analysis if the results are not required
performDeliveryDistributionAnalysis - whether to perform optional delivery distribution analysis, which can be disabled for faster analysis if the results are not required
Method Detail

initialiseNumberFormatters

private void initialiseNumberFormatters()

analyse

public AnalysisResults analyse()
                        throws AnalysisException
Analyses the current simulation state

Specified by:
analyse in class Analyser
Returns:
the analytical results
Throws:
AnalysisException - if analysis cannot be completed successfully

analysisTimeSeconds

protected java.lang.String analysisTimeSeconds()

logCumulativeTime

protected void logCumulativeTime(java.lang.String reason,
                                 long prev)
Logs the number of seconds spent on analysis thus far

Parameters:
prev - the previous number of millis before the current analytical phase of interest began.
reason - the reason for logging this time

populateNodeMap

protected void populateNodeMap()
Populates the mapping of nodeId to node, and populates the node-bearing array, for all nodes supplied in the class constructor


createException

protected AnalysisException createException(java.lang.String message,
                                            java.lang.Exception e)
Builds an AnalysisException to wrap the provided message and lower-level exception

Parameters:
message - the message describing the problem
e - the lower-level exception
Returns:
an AnalysisException wrapping the provided message and lower-level exception

analyseNetwork

protected void analyseNetwork()
Analyses the network and its participating nodes


analyseEnergy

protected void analyseEnergy()
                      throws java.sql.SQLException
Analyses the energy consumed by simulated network activity

Throws:
java.sql.SQLException - if the database is unusable

analyseNodeStates

protected void analyseNodeStates()
                          throws java.sql.SQLException
Analyses the states adopted by nodes during simulation

Throws:
java.sql.SQLException - if the simulation database cannot be used

analyseRadioModuleStates

protected void analyseRadioModuleStates()
                                 throws java.sql.SQLException
Analyses the states adopted by radio modules during simulation

Throws:
java.sql.SQLException - if the simulation database cannot be used

analyseNetworkTraffic

protected void analyseNetworkTraffic()
                              throws java.sql.SQLException
Analyses traffic in the simulated network

Throws:
java.sql.SQLException - if the simulation database cannot be used

analyseNetworkTrafficEnergy

protected void analyseNetworkTrafficEnergy()
Analyses energy expended on traffic in the simulated network


analysePointToPointSuccess

protected void analysePointToPointSuccess()
                                   throws java.sql.SQLException
Analyses success of point-to-point activity in the simulated network

Throws:
java.sql.SQLException - if the simulation database cannot be used

analyseDeliveryDistributions

protected void analyseDeliveryDistributions()
                                     throws java.sql.SQLException
Analyses distributions of metrics associated with packet delivery success and failure, from which investigators can derive an understanding of where failures in message delivery are concentrated.

Throws:
java.sql.SQLException - if the simulation database cannot be used

analyseMessagePropagation

protected void analyseMessagePropagation()
                                  throws java.sql.SQLException
Analyses success of message propagation within the simulated network

Throws:
java.sql.SQLException - if the simulation database cannot be used

createWorkingTables

protected void createWorkingTables()
                            throws java.sql.SQLException
Creates the set of temporary tables to hold working data required during analysis, which can be safely discarded when analysis completes. Primary-foreign key constraints are not enforced to maximise portability, and to improve performance when inserting large numbers of rows. Data integrity is of course important, but as the data is produced and consumed only by a single instance of this class there is a greatly reduced need to enforce this through database constraints; no other systems or subsystems rely on this temporary data, which will be discarded after the first and only use. Because it has been determined that these key relationships need not be enforced by database constraints, there is no need to expend database resources and therefore no need to rule out the use of DBMSs which do not support these constraints (e.g. early versions of MySQL). However, indexes are used. There is a consequent performance hit when inserting rows, as the DBMS will rebuild the indexes as it sees fit. These indexes can be safely removed if future analysis shows that the processing time saved through their use is outweighed by the processing time required for their maintenance, or if disk space is in short supply on the database server.

Throws:
java.sql.SQLException - if the tables and indexes cannot be created in the simulation database

dropWorkingTables

protected boolean dropWorkingTables()
                             throws java.sql.SQLException
Drops the temporary analysis working tables from the simulation database if the backing Database object is configured to drop tables on shutdown.

Returns:
true if attempts were made to delete working tables, otherwise false
Throws:
java.sql.SQLException - if the tables cannot be dropped from the simulation database

populatePropagationWorkingTables

protected void populatePropagationWorkingTables()
                                         throws java.sql.SQLException
Populates temporary working tables with data to be used in the later analysis of propagation of packets within the simulated network

Throws:
java.sql.SQLException - if the simulation database cannot be used

populateNodeWorkingTables

protected void populateNodeWorkingTables()
                                  throws java.sql.SQLException
Populates temporary working data tables with data used in later analysis of nodes participating in the simulated network

Throws:
java.sql.SQLException - if the simulation database cannot be used

populateRadioModuleWorkingTables

protected void populateRadioModuleWorkingTables()
                                         throws java.sql.SQLException
Populates temporary working data tables with data used in later analysis of radio modules participating in the simulated network

Throws:
java.sql.SQLException - if the simulation database cannot be used