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

bool isInit ()
 still in initialization phase?
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 gracefullLeaveDelay
 delay until scheduled node is removed from overlay
double gracefullLeavePropability
 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 * 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 transitionTimeFinished
unsigned int initCounter


Member Function Documentation

bool UnderlayConfigurator::isInit (  )  [inline]

still in initialization phase?

00052 { return init; };

bool UnderlayConfigurator::isTransitionTimeFinished (  )  [inline]

00054 { return transitionTimeFinished; };

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

Creates an overlay node.

Parameters:
initialize 

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:
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:
addr NULL for random node

Implemented in IPv4UnderlayConfigurator, SimpleNetConfigurator, and SingleHostConfigurator.

void UnderlayConfigurator::initFinished (  ) 

00102 {
00103     Enter_Method_Silent();
00104 
00105     if(++initCounter = churnGenerator.size()) {
00106         init = false;
00107         gettimeofday(&initFinishedTime, NULL);
00108 
00109         scheduleAt(simulation.simTime() + transitionTime,
00110                    endTransitionTimer);
00111         
00112         //transitionTimeFinished = true;        
00113 
00114         if (measurementTime >= 0) {
00115             scheduleAt(simulation.simTime() + transitionTime + measurementTime,
00116                        endSimulationTimer);
00117         }
00118         consoleOut("INIT phase finished");      
00119     }
00120 }

int UnderlayConfigurator::numInitStages (  )  const [protected]

OMNeT number of init stages.

00033 {
00034     return MAX_STAGE_UNDERLAY + 1;
00035 }

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

OMNeT init methods.

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

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.

00136 {
00137     delete msg;
00138 }

void UnderlayConfigurator::finish (  )  [protected]

Cleans up configurator.

00141 {
00142     cancelAndDelete(endSimulationTimer);
00143     cancelAndDelete(endTransitionTimer);
00144 
00145     finishUnderlay();
00146 }

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

Cleans up concrete underlay configurator.

Reimplemented in IPv4UnderlayConfigurator, SimpleNetConfigurator, and SingleHostConfigurator.

00149 {
00150     //...
00151 }

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.

00123 {
00124     if(msg == endSimulationTimer) {
00125         endSimulation();
00126     } else if(msg == endTransitionTimer) {
00127         consoleOut("transition time finished");
00128         //transitionTimeFinished = true;
00129         globalStatistics->startMeasuring();
00130     } else {
00131         handleTimerEvent(msg);
00132     }
00133 }

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

00154 {
00155     if(!ev.isGUI()) {
00156         struct timeval now, diff;
00157         gettimeofday(&now, NULL);
00158         timersub(&now, &initStartTime, &diff);
00159 
00160         std::stringstream ss;
00161         std::string line1(71, '*');
00162         std::string line2(71, '*');
00163 
00164         ss << "   " << text << "   ";
00165         line1.replace(35 - ss.str().size() / 2,
00166                       ss.str().size(),
00167                       ss.str());
00168         ss.str("");
00169 
00170         ss << "   (sim time: " << simTime()
00171                 << ", real time: " << diff.tv_sec
00172                 << "." << diff.tv_usec << ")   ";
00173         line2.replace(35 - ss.str().size() / 2,
00174                       ss.str().size(),
00175                       ss.str());
00176 
00177         std::cout << "\n" << line1 << "\n"
00178                   << line2 << "\n" << std::endl;
00179     } else {
00180         EV << "(UnderlayConfigurator) " << text;
00181     }
00182     
00183 }


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

delay until scheduled node is removed from overlay

double UnderlayConfigurator::gracefullLeavePropability [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::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::transitionTimeFinished [private]

unsigned int UnderlayConfigurator::initCounter [private]


The documentation for this class was generated from the following files:
Generated on Tue Jul 24 16:51:19 2007 for ITM OverSim by  doxygen 1.5.1