UnderlayConfigurator Class Reference

#include <UnderlayConfigurator.h>

Inheritance diagram for UnderlayConfigurator:

IPv4UnderlayConfigurator SimpleNetConfigurator SingleHostConfigurator

List of all members.


Detailed Description

Base class for configurators of different underlay models.

Author:
Stephan Krause, Bernhard Heep

Public Member Functions

 UnderlayConfigurator ()
virtual ~UnderlayConfigurator ()
bool isInit ()
 still in initialization phase?
bool isSimulationEndingSoon ()
 Is the simulation ending soon?
bool getGracefulLeaveDelay ()
 Return the gracefulLeaveDelay.
bool isTransitionTimeFinished ()
virtual
TransportAddress
createNode (NodeType type, bool initialize=false)=0
 Creates an overlay node.
virtual void preKillNode (NodeType type, TransportAddress *addr=NULL)=0
 Notifies and schedules overlay nodes for removal.
virtual void migrateNode (NodeType type, TransportAddress *addr=NULL)=0
 Migrates overlay nodes from one access net to another.
void initFinished ()
ChurnGeneratorgetChurnGenerator (int typeID)

Protected Member Functions

int numInitStages () const
 OMNeT number of init stages.
virtual void initialize (int stage)
 OMNeT init methods.
virtual void initializeUnderlay (int stage)=0
 Init method for derived underlay configurators.
virtual void handleTimerEvent (cMessage *msg)
void finish ()
 Cleans up configurator.
virtual void finishUnderlay ()
 Cleans up concrete underlay configurator.
virtual void setDisplayString ()=0
 Sets display string.
void handleMessage (cMessage *msg)
 Node mobility simulation.

Protected Attributes

std::vector
< std::string > 
channelTypes
 possible access types
int overlayTerminalCount
 current number of overlay terminals
int firstNodeId
 the Id of the overlayTerminal created first in the overlay
double gracefulLeaveDelay
 delay until scheduled node is removed from overlay
double gracefulLeavePropability
 propability that node is notified befor removal
BootstrapOraclebootstrapOracle
 pointer to BootstrapOracle
GlobalStatisticsglobalStatistics
 pointer to GlobalStatistics
vector
< ChurnGenerator * > 
churnGenerator
 pointer to the ChurnGenerators
cMessage * endSimulationTimer
 timer to signal end of simulation
cMessage * endSimulationNotificationTimer
 timer to notify nodes that simulation ends soon
cMessage * endTransitionTimer
 timer to signal end of transition time
struct timeval initFinishedTime
 timestamp at end of init phase
struct timeval initStartTime
 timestamp at begin of init phase
double transitionTime
 time to wait before measuring after init phase is finished
double measurementTime
 duration of the simulation after init and transition phase

Private Member Functions

void consoleOut (const std::string &text)

Private Attributes

bool init
bool simulationEndingSoon
bool transitionTimeFinished
unsigned int initCounter

Constructor & Destructor Documentation

UnderlayConfigurator::UnderlayConfigurator (  ) 

00032 {
00033     endSimulationTimer = NULL;
00034     endSimulationNotificationTimer = NULL;
00035     endTransitionTimer = NULL;
00036     initFinishedTime.tv_sec = 0;
00037     initFinishedTime.tv_usec = 0;
00038 }

UnderlayConfigurator::~UnderlayConfigurator (  )  [virtual]

00041 {
00042     cancelAndDelete(endSimulationNotificationTimer);
00043     cancelAndDelete(endSimulationTimer);
00044     cancelAndDelete(endTransitionTimer);
00045 }


Member Function Documentation

bool UnderlayConfigurator::isInit (  )  [inline]

still in initialization phase?

00055 { return init; };

bool UnderlayConfigurator::isSimulationEndingSoon (  )  [inline]

Is the simulation ending soon?

00060 { return simulationEndingSoon; };

bool UnderlayConfigurator::getGracefulLeaveDelay (  )  [inline]

Return the gracefulLeaveDelay.

00065 { return gracefulLeaveDelay; };

bool UnderlayConfigurator::isTransitionTimeFinished (  )  [inline]

00068 { return transitionTimeFinished; };

virtual TransportAddress* UnderlayConfigurator::createNode ( NodeType  type,
bool  initialize = false 
) [pure virtual]

Creates an overlay node.

Parameters:
type NodeType of the node to create
initialize are we in init phase?

Implemented in IPv4UnderlayConfigurator, SimpleNetConfigurator, and SingleHostConfigurator.

virtual void UnderlayConfigurator::preKillNode ( NodeType  type,
TransportAddress addr = NULL 
) [pure virtual]

Notifies and schedules overlay nodes for removal.

Parameters:
type NodeType of the node to remove
addr NULL for random node

Implemented in IPv4UnderlayConfigurator, SimpleNetConfigurator, and SingleHostConfigurator.

virtual void UnderlayConfigurator::migrateNode ( NodeType  type,
TransportAddress addr = NULL 
) [pure virtual]

Migrates overlay nodes from one access net to another.

Parameters:
type NodeType of the node to migrate
addr NULL for random node

Implemented in IPv4UnderlayConfigurator, SimpleNetConfigurator, and SingleHostConfigurator.

void UnderlayConfigurator::initFinished (  ) 

00127 {
00128     Enter_Method_Silent();
00129 
00130     if (++initCounter == churnGenerator.size()) {
00131         init = false;
00132         gettimeofday(&initFinishedTime, NULL);
00133 
00134         scheduleAt(simulation.simTime() + transitionTime,
00135                 endTransitionTimer);
00136 
00137         if (measurementTime >= 0) {
00138             scheduleAt(simulation.simTime() + transitionTime + measurementTime,
00139                        endSimulationTimer);
00140             scheduleAt(simulation.simTime() + transitionTime + measurementTime
00141                     - gracefulLeaveDelay,
00142                     endSimulationNotificationTimer);
00143         }
00144         consoleOut("INIT phase finished");      
00145     }
00146 }

ChurnGenerator * UnderlayConfigurator::getChurnGenerator ( int  typeID  ) 

00210 {
00211     Enter_Method_Silent();
00212     
00213     return churnGenerator[typeID];
00214 }

int UnderlayConfigurator::numInitStages (  )  const [protected]

OMNeT number of init stages.

00048 {
00049     return MAX_STAGE_UNDERLAY + 1;
00050 }

void UnderlayConfigurator::initialize ( int  stage  )  [protected, virtual]

OMNeT init methods.

00053 {
00054     if (stage == MIN_STAGE_UNDERLAY) {
00055         gracefulLeaveDelay = par("gracefulLeaveDelay");
00056         gracefulLeavePropability = par("gracefulLeavePropability");
00057         channelTypes = cStringTokenizer(par("channelTypes"), " ").asVector();
00058 
00059         transitionTime = par("transitionTime");
00060         measurementTime = par("measurementTime");
00061 
00062         bootstrapOracle = BootstrapOracleAccess().get();
00063         globalStatistics =GlobalStatisticsAccess().get();
00064 
00065         endSimulationNotificationTimer =
00066             new cMessage("endSimulationNotificationTimer");
00067         endSimulationTimer = new cMessage("endSimulationTimer");
00068         endTransitionTimer = new cMessage("endTransitionTimer");
00069 
00070         gettimeofday(&initStartTime, NULL);      
00071         init = true;
00072         simulationEndingSoon = false;
00073         initCounter = 0;
00074 
00075         firstNodeId = -1;
00076         WATCH(firstNodeId);
00077         WATCH(overlayTerminalCount);
00078     }
00079 
00080     if (stage >= MIN_STAGE_UNDERLAY && stage <= MAX_STAGE_UNDERLAY) {
00081         initializeUnderlay(stage);
00082     }
00083 
00084     if (stage == MAX_STAGE_UNDERLAY) {
00085         // Create churn gernerators
00086         NodeType t;
00087         std::vector<std::string> churnGeneratorTypes = 
00088             cStringTokenizer(par("churnGeneratorTypes"), " ").asVector();
00089         std::vector<std::string> terminalTypes = 
00090             cStringTokenizer(par("terminalTypes"), " ").asVector();
00091 
00092         if (terminalTypes.size() != 1 
00093                 && churnGeneratorTypes.size() != terminalTypes.size())
00094         {
00095             opp_error("UnderlayConfigurator.initialize(): "
00096                       "terminalTypes size does not match churnGenerator size");
00097         }
00098 
00099         for( std::vector<std::string>::iterator it=churnGeneratorTypes.begin();
00100         it != churnGeneratorTypes.end(); ++it) {
00101 
00102             ChurnGenerator* gen = dynamic_cast<ChurnGenerator*> 
00103             (findModuleType(it->c_str())->create(it->c_str(),
00104                                                  parentModule()));
00105             // Name the generator
00106             char buf[80];
00107             sprintf(buf, "churnGenerator[%i]", t.typeID);
00108             gen->setName(buf);
00109 
00110             // Add it to the list of generators and initialize it
00111             churnGenerator.push_back(gen);
00112             t.typeID++;
00113             t.terminalType = (terminalTypes.size() == 1) ? 
00114                                                           terminalTypes[0] :
00115             terminalTypes[it - churnGeneratorTypes.begin()];
00116                                                           gen->setNodeType(t);
00117                                                           gen->buildInside();
00118                                                           gen->setDisplayString("i=block/cogwheel");
00119                                                           gen->callInitialize(stage);
00120                                                           gen->terminalCount = 0;
00121                                                           gen->initializeChurn();
00122         }
00123     }
00124 }

virtual void UnderlayConfigurator::initializeUnderlay ( int  stage  )  [protected, pure virtual]

Init method for derived underlay configurators.

Implemented in IPv4UnderlayConfigurator, SimpleNetConfigurator, and SingleHostConfigurator.

void UnderlayConfigurator::handleTimerEvent ( cMessage *  msg  )  [protected, virtual]

Reimplemented in IPv4UnderlayConfigurator, and SimpleNetConfigurator.

00164 {
00165     delete msg;
00166 }

void UnderlayConfigurator::finish (  )  [protected]

Cleans up configurator.

00169 {
00170     finishUnderlay();
00171 }

void UnderlayConfigurator::finishUnderlay (  )  [protected, virtual]

Cleans up concrete underlay configurator.

Reimplemented in IPv4UnderlayConfigurator, SimpleNetConfigurator, and SingleHostConfigurator.

00174 {
00175     //...
00176 }

virtual void UnderlayConfigurator::setDisplayString (  )  [protected, pure virtual]

Sets display string.

Implemented in IPv4UnderlayConfigurator, SimpleNetConfigurator, and SingleHostConfigurator.

void UnderlayConfigurator::handleMessage ( cMessage *  msg  )  [protected]

Node mobility simulation.

Parameters:
msg timer-message

Reimplemented in SingleHostConfigurator.

00149 {
00150     if (msg == endSimulationNotificationTimer) {
00151         simulationEndingSoon = true;
00152         //      bootstrapOracle->sendNotificationToAllPeers(NF_OVERLAY_NODE_LEAVE);
00153     } else if (msg == endSimulationTimer) {
00154         endSimulation();
00155     } else if (msg == endTransitionTimer) {
00156         consoleOut("transition time finished");
00157         globalStatistics->startMeasuring();
00158     } else {
00159         handleTimerEvent(msg);
00160     }
00161 }

void UnderlayConfigurator::consoleOut ( const std::string &  text  )  [private]

00179 {
00180     if (!ev.isGUI()) {
00181         struct timeval now, diff;
00182         gettimeofday(&now, NULL);
00183         timersub(&now, &initStartTime, &diff);
00184 
00185         std::stringstream ss;
00186         std::string line1(71, '*');
00187         std::string line2(71, '*');
00188 
00189         ss << "   " << text << "   ";
00190         line1.replace(35 - ss.str().size() / 2,
00191                       ss.str().size(),
00192                       ss.str());
00193         ss.str("");
00194 
00195         ss << "   (sim time: " << simTime()
00196            << ", real time: " << diff.tv_sec
00197            << "." << diff.tv_usec << ")   ";
00198         line2.replace(35 - ss.str().size() / 2,
00199                       ss.str().size(),
00200                       ss.str());
00201 
00202         std::cout << "\n" << line1 << "\n"
00203                   << line2 << "\n" << std::endl;
00204     } else {
00205         EV << "[UnderlayConfigurator::consoleOut()] " << text;
00206     }
00207 }


Member Data Documentation

std::vector<std::string> UnderlayConfigurator::channelTypes [protected]

possible access types

int UnderlayConfigurator::overlayTerminalCount [protected]

current number of overlay terminals

int UnderlayConfigurator::firstNodeId [protected]

the Id of the overlayTerminal created first in the overlay

double UnderlayConfigurator::gracefulLeaveDelay [protected]

delay until scheduled node is removed from overlay

double UnderlayConfigurator::gracefulLeavePropability [protected]

propability that node is notified befor removal

BootstrapOracle* UnderlayConfigurator::bootstrapOracle [protected]

pointer to BootstrapOracle

GlobalStatistics* UnderlayConfigurator::globalStatistics [protected]

pointer to GlobalStatistics

vector<ChurnGenerator*> UnderlayConfigurator::churnGenerator [protected]

pointer to the ChurnGenerators

cMessage* UnderlayConfigurator::endSimulationTimer [protected]

timer to signal end of simulation

cMessage* UnderlayConfigurator::endSimulationNotificationTimer [protected]

timer to notify nodes that simulation ends soon

cMessage* UnderlayConfigurator::endTransitionTimer [protected]

timer to signal end of transition time

struct timeval UnderlayConfigurator::initFinishedTime [read, protected]

timestamp at end of init phase

struct timeval UnderlayConfigurator::initStartTime [read, protected]

timestamp at begin of init phase

double UnderlayConfigurator::transitionTime [protected]

time to wait before measuring after init phase is finished

double UnderlayConfigurator::measurementTime [protected]

duration of the simulation after init and transition phase

bool UnderlayConfigurator::init [private]

bool UnderlayConfigurator::simulationEndingSoon [private]

bool UnderlayConfigurator::transitionTimeFinished [private]

unsigned int UnderlayConfigurator::initCounter [private]


The documentation for this class was generated from the following files:
Generated on Thu Apr 17 13:19:30 2008 for ITM OverSim by  doxygen 1.5.3