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 TransportAddresscreateNode (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 ()

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
bool keepFirstNode
 is the first node kept during simulation?
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
timeval initFinishedTime
 timestamp at end of init phase
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 }

UnderlayConfigurator::~UnderlayConfigurator (  )  [virtual]

00039 {
00040     cancelAndDelete(endSimulationNotificationTimer);
00041     cancelAndDelete(endSimulationTimer);
00042     cancelAndDelete(endTransitionTimer);
00043 }


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 (  ) 

00119 {
00120     Enter_Method_Silent();
00121 
00122     if(++initCounter = churnGenerator.size()) {
00123         init = false;
00124         gettimeofday(&initFinishedTime, NULL);
00125 
00126         scheduleAt(simulation.simTime() + transitionTime,
00127                    endTransitionTimer);
00128         
00129         if (measurementTime >= 0) {
00130             scheduleAt(simulation.simTime() + transitionTime + measurementTime,
00131                        endSimulationTimer);
00132             scheduleAt(simulation.simTime() + transitionTime + measurementTime
00133                        - gracefulLeaveDelay,
00134                        endSimulationNotificationTimer);
00135         }
00136         consoleOut("INIT phase finished");      
00137     }
00138 }

int UnderlayConfigurator::numInitStages (  )  const [protected]

OMNeT number of init stages.

00046 {
00047     return MAX_STAGE_UNDERLAY + 1;
00048 }

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

OMNeT init methods.

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

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.

00156 {
00157     delete msg;
00158 }

void UnderlayConfigurator::finish (  )  [protected]

Cleans up configurator.

00161 {
00162     finishUnderlay();
00163 }

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

Cleans up concrete underlay configurator.

Reimplemented in IPv4UnderlayConfigurator, SimpleNetConfigurator, and SingleHostConfigurator.

00166 {
00167     //...
00168 }

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.

00141 {
00142     if (msg == endSimulationNotificationTimer) {
00143         simulationEndingSoon = true;
00144 //      bootstrapOracle->sendNotificationToAllPeers(NF_OVERLAY_NODE_LEAVE);
00145     } else if (msg == endSimulationTimer) {
00146         endSimulation();
00147     } else if (msg == endTransitionTimer) {
00148         consoleOut("transition time finished");
00149         globalStatistics->startMeasuring();
00150     } else {
00151         handleTimerEvent(msg);
00152     }
00153 }

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

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


Member Data Documentation

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

possible access types

int UnderlayConfigurator::overlayTerminalCount [protected]

current number of overlay terminals

bool UnderlayConfigurator::keepFirstNode [protected]

is the first node kept during simulation?

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 [protected]

timestamp at end of init phase

struct timeval UnderlayConfigurator::initStartTime [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 Wed Sep 26 12:13:02 2007 for ITM OverSim by  doxygen 1.5.1