Mannasim Framework Classes Manual
Mannasim Framework Classes Manual
10 de fevereiro de 2006
1 Mannasim classes
This document provides a description of the principal classes that constitutes Mannasim. Each
class description will be provided with a class summary and an enumeration of its fundamental
methods and fields.
The classes are detailed acording to the following structure:
FILES
Presents the files where the class is defined and implemented.
EXTENDS
If the class inherits some features from other ones, these classes are specified in this subsection.
METHODS
Here the class essential methods are listed and explained. Note that the explanation concerns
the class functionality not how it actually implements it.
Field
Here the class essential fields are listed and explained.
• Sensor Node
• DataGenerator
• TemperatureDataGenerator
• TemperatureAppData
• Processing
• SensedData
• OnDemandData
• OnDemandParameter
• SensorBaseApp
• CommonNodeApp
1
• ClusterHeadApp
EXTENDS
NS-2 MobileNode class.
DESCRIPTION
This class represents a wireless sensor node. It extends NS-2 MobileNode class adding specific
sensor nodes characteristics as power consumption for sensing and processing activities, instruc-
tions executed per seconds by its microcontrole, states of sensor parts (processor, transceptor,
sensing devices). The SensorNode class was the first step taken in the implementation of the
simulator and also can be used as an initial approach for the development of different sensor
node types.
METHODS
• void SensorNode::selfTest() – performs a sensor node self test verifying its proper func-
tioning. IMPORTANT: this method isn’t implemented yet.
• void SensorNode::sleep() – turns the sensor node off when necessary. Stop all of its
applications.
• void SensorNode::wakeUp() – wakes the sensor node up after a sleepy period. Start all
of its applications.
FIELDS
• AppList apps – the list of WSN applications witch the sensor node is associated to. The
AppList type is simple an STL1 list of AppData objects (see NS-2 documentation for further
details).
• int instructionsPerSecond – the number of instructions the nodes processor can execute
in a second. This field has its value defined in TCL simulation script.
1
C++ Standard Template Library
2
• double processingPower – the energy consumption of the sensor node in processing ac-
tivities. This field has its value expressed in watts (joules/second) and is defined in TCL
simulation script.
• double sensingPower – the energy consumption of the sensor node in sensing activities.
This field has its value expressed in watts (joules/second) and is defined in TCL simulation
script.
• int sensorUseState – the sensor state. Indicates whether the node’s sensing activity is
in use or not.
• int processorUseState – the processor state. Indicates whether the node’s processing
activity is in use or not.
• int transceptorUseState – the transceptor state. Indicates whether the node’s dissemi-
nation activity is in use or not.
EXTENDS
NS-2 EnergyModel class.
DESCRIPTION
This class represents sensor nodes power supply. It extends NS-2 EnergyModel class. The Bat-
tery class can be used to implement all different kinds of existing battery models. The class
contains methods to turn sensor node on and off, put it into sleep and wake it up. Also contains
methods to decrease energy when a sensing, processing or disseminating job is performend by
the sensor node.
METHODS
• void Battery::DecrSensingEnergy(double sensing time, double sensing power) –
computes the energy spent by a sensing task and reduce energy stock by this amount.
• void Battery::DecrProcessingEnergy(int number instructions, double instructions per seco
double processing power) – computes the energy spent by a processing task and reduce
energy stock by this amount. .
• void Battery::setNodeOn() – turns sensor node on.
• void Battery::setNodeOff() – turns sensor node off.
• void Battery::sleep() – puts node battery in sleep mode.
• void Battery::wakeUp() – wakes up the sleepy node battery.
FIELDS
All fields are inherited from NS-2 EnergyModel. (see NS-2 documentation for futher details).
3
1.3 DataGenerator Class
FILES
dataGenerator.h and dataGenerator.cc
EXTENDS
NS-2 TclObject class.
DESCRIPTION
This class simulates the sensing task of a wireless sensor node. With methods to adjusts sensing
interval, generate and collect synthetic data, the DataGenerator class also works as a base class
for futher specialized sensed information like for example temperature, light, magnetic fields etc.
The data created by this class is encapsulated as an AppData object (see NS-2 documentation
for further details).
Within DataGenerator files, SensingTime class is also defined. This timer class in conjunc-
tion with the defined sensing interval acts in periodic sensing.
METHODS
• void DataGenerator::start() – schedules the first sensing activity if the network has
periodic sensing.
• void DataGenerator::stop() – stops the sensing activity and drops all scheduled sensing
events.
FIELDS
• AppDataType type – the identity of the data generator in terms of application data type.
• SensorAppList app – the list of sensor applications associated with the data generator.
The SensorAppList type is simple an STL list of SensorBaseApp (see Section 1.10) objects.
4
• int sensing type – the way the sensor node, and consequently the DataGenerator class, is
oriented to gather data. Possible values are PROGRAMMED, CONTINUOUS, ON DEMAND
and EVENT DRIVEN representing respectively periodic, continuous, on demand and event
driven data sensing.
EXTENDS
DataGenerator class.
DESCRIPTION
This class simulates temperature sensing task of a wireless sensor node. TemperatureDataGe-
nerator extends DataGenerator adding characteristics proper for temperature data. Synthetic
temperature generation is based in Gaussian Distribution so average and standard deviations
are fields of this class.
METHODS
FIELDS
• double avg measure – average measure for synthetic temperature data generation.
• double std deviation – standard deviation measure for synthetic temperature data ge-
neration.
5
1.5 TemperatureAppData Class
FILES
temperatureAppData.h and temperatureAppData.cc
EXTENDS
NS-2 AppData class.
DESCRIPTION
This class encapsulates raw data generated by TemperatureDataGenerator class. Objects of this
class are sent to the processing module.
METHODS
FIELDS
• int priority – temperature data priority (Usefull for temperature data deliver).
6
1.6 Processing Class
FILES
processing.h and processing.cc
EXTENDS
NS-2 TclObject class.
DESCRIPTION
This class provides a foundation for all kinds of data processing over sensed data in a sensor
node. Every sensed data goes through processing before dissemination. Specialized data pro-
cessing should inherit from Processing class.
METHODS
FIELDS
2
In an on demand WSN the outsider observer make requests to the network about data of its interest
7
• SensedData* info – processed data buffer, data stored here is ready for dissemination.
For more details about SensedData data type see Section 1.7).
• SensorNode* sensor node – sensor node where the processing task takes place. Used for
energy contability proposes.
EXTENDS
NS-2 AppData class.
DESCRIPTION
This class represents sensed data after processing. Data contained in SensedData is ready for
dissemination so the class provides networking information such as source node identification,
message type, message priority among others. SensedData class acts as dissemination message
for processed data witch is stored in a data buffer.
METHODS
• int & SensedData::eventType() – returns a reference to sensed data event type. This
method is designed to be used in a event driven application.
FIELDS
• int node id – source node identification for sensed data dissemination purposes.
8
• int msgType – type of the message to be disseminated to the network.
• int eventType – type of the event that caused sensed data processing.
• AppDataList infoRepository – sensed data buffer. Storages all data processed by the
sensor node.
EXTENDS
SensedData class.
DESCRIPTION
This class represents request messages from an outsider of the WSN. Requests are interes-
ting for on demand applications where dissemination only occurs when someone requests data.
OnDemandData uses inherited infoRepository field from SensedData to storage OnDemand-
Parameter queries (see Section 1.9).
METHODS
• int & OnDemandData::requestType() – returns a reference for the request type field.
FIELDS
• int request type – message request type for a on demand WSN. Possible values include
REAL, BUFFER and AVERAGE.
EXTENDS
NS-2 AppData class.
DESCRIPTION
This class represents queries sent within OnDemandData request messages. In on demand
applications, requests follows this line:
9
“Disseminate sensor node data if it’s greater than X”.
An OnDemandParameter object carries the X value and also the kind of operation to be realized
for request validation.
METHODS
FIELDS
EXTENDS
NS-2 Application class.
DESCRIPTION
This class is the base for WSN applications, specialized node applications like a common node ap-
plication and a cluster head application should extends SensorBaseApp class. With instances of
DataGenerator, Processing and SensorNode classes, SensorBaseApp class congregates the WSN
tasks tripod: sensing, processing and disseminating with special attention to the disseminating
task.
Within SensorBaseApp files, DisseminatingTimer class is also defined. This timer class in
conjunction with the defined disseminating interval acts in periodic disseminating.
METHODS
• virtual void disseminateData() – disseminates sensed data into the network after its
processing. This method is virtual so it must be overloaded.
• virtual void disseminateData(AppData* data) – disseminates sensed data into the
network after its processing. In this method disseminating data is passed as parameter
and as the method is virtual it must be overloaded.
10
• virtual void recvSensedData(AppData* data ) – receives data gathered by the node’s
sensors, process it and disseminate the results. This method is virtual so it must be
overloaded.
• void SensorBaseApp::stop() – drops all scheduled events, stopping also all sensing tasks.
FIELDS
• DataGenList gen – list of data generator objects (or one of its extensions). DataGenList
type is simple a STL list data structure of data generator objects.
• Processing* processing – processing module of the sensor node. Gets raw data from a
data generator object and returns processed data.
• int disseminating type – the way the sensor node, and consequently the SensorBaseApp
class, is oriented to disseminate data.. Possible values are PROGRAMMED, CONTINU-
OUS, ON DEMAND and EVENT DRIVEN representing respectively periodic, continuous,
on demand and event driven dissemination.
EXTENDS
SensorBaseApp class.
11
DESCRIPTION
This class specializes SensorBaseApp class providing implementations to its pure virtual methods.
The CommonNodeApp class represents a general purpose node application.
METHODS
• inline bool CommonNodeApp::isDead() – informs whether or not the sensor node ran
out of energy.
FIELDS
All fields are inherited from SensorBaseApp class.
EXTENDS
SensorBaseApp class.
DESCRIPTION
This class specializes SensorBaseApp class providing implementations to its pure virtual methods.
The ClusterHeadApp class simulates the behavior of a Cluster Head in a hierarchical WSN. So
in other to accomplish its objectives a sort of fields and methods dealing with the list of nodes
under the cluster supervision is provided.
METHODS
12
• void ClusterHeadApp::process data(int size, AppData* data) – process on demand
requests from outsider observer. This method overload NS-2 Process::process data()
and is invoked in Agent::recv().
• void ClusterHeadApp::insert child(int id) – insert node identification into the clus-
ter head children list.
• bool ClusterHeadApp::search child(int id) – search the cluster head children list for
a node whose identification is the method parameter.
FIELDS
• IdList child list – the cluster head children list. Storages identification number of all
nodes under the cluster head responsability.
13