#include <UnderlayConfigurator.h>
Public Member Functions | |
UnderlayConfigurator () | |
virtual | ~UnderlayConfigurator () |
bool | isInInitPhase () |
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 () |
ChurnGenerator * | getChurnGenerator (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 | gracefulLeaveProbability |
probability that node is notified befor removal | |
BootstrapOracle * | bootstrapOracle |
pointer to BootstrapOracle | |
GlobalStatistics * | globalStatistics |
pointer to GlobalStatistics | |
std::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 | |
Static Protected Attributes | |
static const uint | NUM_COLORS = 8 |
static const char * | colorNames [] |
Private Member Functions | |
void | consoleOut (const std::string &text) |
Private Attributes | |
bool | init |
bool | simulationEndingSoon |
bool | transitionTimeFinished |
unsigned int | initCounter |
UnderlayConfigurator::UnderlayConfigurator | ( | ) |
00036 { 00037 endSimulationTimer = NULL; 00038 endSimulationNotificationTimer = NULL; 00039 endTransitionTimer = NULL; 00040 initFinishedTime.tv_sec = 0; 00041 initFinishedTime.tv_usec = 0; 00042 }
UnderlayConfigurator::~UnderlayConfigurator | ( | ) | [virtual] |
00045 { 00046 cancelAndDelete(endSimulationNotificationTimer); 00047 cancelAndDelete(endSimulationTimer); 00048 cancelAndDelete(endTransitionTimer); 00049 }
bool UnderlayConfigurator::isInInitPhase | ( | ) | [inline] |
still in initialization phase?
Referenced by SingleHostConfigurator::finishUnderlay(), SimpleNetConfigurator::finishUnderlay(), IPv4UnderlayConfigurator::finishUnderlay(), KBRTestApp::handleTimerEvent(), GIASearchApp::handleTimerEvent(), and DHTTestApp::handleTimerEvent().
00051 { return init; };
bool UnderlayConfigurator::isSimulationEndingSoon | ( | ) | [inline] |
Is the simulation ending soon?
Referenced by KBRTestApp::handleTimerEvent(), and DHTTestApp::handleTimerEvent().
00056 { return simulationEndingSoon; };
bool UnderlayConfigurator::getGracefulLeaveDelay | ( | ) | [inline] |
Return the gracefulLeaveDelay.
Referenced by ParetoChurn::createNode(), and LifetimeChurn::createNode().
00061 { return gracefulLeaveDelay; };
bool UnderlayConfigurator::isTransitionTimeFinished | ( | ) | [inline] |
virtual TransportAddress* UnderlayConfigurator::createNode | ( | NodeType | type, | |
bool | initialize = false | |||
) | [pure virtual] |
Creates an overlay node.
type | NodeType of the node to create | |
initialize | are we in init phase? |
Implemented in IPv4UnderlayConfigurator, SimpleNetConfigurator, and SingleHostConfigurator.
Referenced by TraceChurn::createNode(), ParetoChurn::createNode(), LifetimeChurn::createNode(), RandomChurn::handleMessage(), and NoChurn::handleMessage().
virtual void UnderlayConfigurator::preKillNode | ( | NodeType | type, | |
TransportAddress * | addr = NULL | |||
) | [pure virtual] |
Notifies and schedules overlay nodes for removal.
type | NodeType of the node to remove | |
addr | NULL for random node |
Implemented in IPv4UnderlayConfigurator, SimpleNetConfigurator, and SingleHostConfigurator.
Referenced by TraceChurn::deleteNode(), ParetoChurn::deleteNode(), LifetimeChurn::deleteNode(), and RandomChurn::handleMessage().
virtual void UnderlayConfigurator::migrateNode | ( | NodeType | type, | |
TransportAddress * | addr = NULL | |||
) | [pure virtual] |
Migrates overlay nodes from one access net to another.
type | NodeType of the node to migrate | |
addr | NULL for random node |
Implemented in IPv4UnderlayConfigurator, SimpleNetConfigurator, and SingleHostConfigurator.
Referenced by RandomChurn::handleMessage().
void UnderlayConfigurator::initFinished | ( | ) |
Referenced by RandomChurn::handleMessage(), ParetoChurn::handleMessage(), NoChurn::handleMessage(), LifetimeChurn::handleMessage(), and TraceChurn::initializeChurn().
00136 { 00137 Enter_Method_Silent(); 00138 00139 if (++initCounter == churnGenerator.size()) { 00140 init = false; 00141 gettimeofday(&initFinishedTime, NULL); 00142 00143 scheduleAt(simulation.simTime() + transitionTime, 00144 endTransitionTimer); 00145 00146 if (measurementTime >= 0) { 00147 scheduleAt(simulation.simTime() + transitionTime + measurementTime, 00148 endSimulationTimer); 00149 00150 if ((transitionTime + measurementTime) < gracefulLeaveDelay) { 00151 throw new cRuntimeError("UnderlayConfigurator::initFinished():" 00152 " gracefulLeaveDelay must be bigger " 00153 "than transitionTime + measurementTime!"); 00154 } 00155 00156 scheduleAt(simulation.simTime() + transitionTime + measurementTime 00157 - gracefulLeaveDelay, 00158 endSimulationNotificationTimer); 00159 } 00160 consoleOut("INIT phase finished"); 00161 } 00162 }
ChurnGenerator * UnderlayConfigurator::getChurnGenerator | ( | int | typeID | ) |
Referenced by GlobalTraceManager::createNode(), GlobalTraceManager::deleteNode(), and GlobalTraceManager::getAppGateById().
00226 { 00227 Enter_Method_Silent(); 00228 00229 return churnGenerator[typeID]; 00230 }
int UnderlayConfigurator::numInitStages | ( | ) | const [protected] |
void UnderlayConfigurator::initialize | ( | int | stage | ) | [protected, virtual] |
OMNeT init methods.
00057 { 00058 if (stage == MIN_STAGE_UNDERLAY) { 00059 gracefulLeaveDelay = par("gracefulLeaveDelay"); 00060 gracefulLeaveProbability = par("gracefulLeaveProbability"); 00061 channelTypes = cStringTokenizer(par("channelTypes"), " ").asVector(); 00062 00063 transitionTime = par("transitionTime"); 00064 measurementTime = par("measurementTime"); 00065 00066 bootstrapOracle = BootstrapOracleAccess().get(); 00067 globalStatistics =GlobalStatisticsAccess().get(); 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 generators 00090 NodeType t; 00091 std::vector<std::string> churnGeneratorTypes = 00092 cStringTokenizer(par("churnGeneratorTypes"), " ").asVector(); 00093 std::vector<std::string> terminalTypes = 00094 cStringTokenizer(par("terminalTypes"), " ").asVector(); 00095 00096 if (terminalTypes.size() != 1 00097 && churnGeneratorTypes.size() != terminalTypes.size()) 00098 { 00099 opp_error("UnderlayConfigurator.initialize(): " 00100 "terminalTypes size does not match churnGenerator size"); 00101 } 00102 00103 for (std::vector<std::string>::iterator it = 00104 churnGeneratorTypes.begin(); it != churnGeneratorTypes.end(); ++it) { 00105 00106 cModuleType* genType = findModuleType(it->c_str()); 00107 00108 if (genType == NULL) { 00109 throw new cRuntimeError((std::string("UnderlayConfigurator::" 00110 "initialize(): invalid churn generator: ") + *it).c_str()); 00111 } 00112 00113 ChurnGenerator* gen = check_and_cast<ChurnGenerator*> 00114 (genType->create(it->c_str(),parentModule())); 00115 00116 // Name the generator 00117 char buf[80]; 00118 sprintf(buf, "churnGenerator[%i]", t.typeID); 00119 gen->setName(buf); 00120 00121 // Add it to the list of generators and initialize it 00122 churnGenerator.push_back(gen); 00123 t.typeID++; 00124 t.terminalType = (terminalTypes.size() == 1) ? 00125 terminalTypes[0] : 00126 terminalTypes[it - churnGeneratorTypes.begin()]; 00127 00128 gen->setNodeType(t); 00129 gen->buildInside(); 00130 gen->setDisplayString("i=block/cogwheel"); 00131 } 00132 } 00133 }
virtual void UnderlayConfigurator::initializeUnderlay | ( | int | stage | ) | [protected, pure virtual] |
Init method for derived underlay configurators.
Implemented in IPv4UnderlayConfigurator, SimpleNetConfigurator, and SingleHostConfigurator.
Referenced by initialize().
void UnderlayConfigurator::handleTimerEvent | ( | cMessage * | msg | ) | [protected, virtual] |
Reimplemented in IPv4UnderlayConfigurator, and SimpleNetConfigurator.
Referenced by handleMessage().
void UnderlayConfigurator::finish | ( | ) | [protected] |
void UnderlayConfigurator::finishUnderlay | ( | ) | [protected, virtual] |
Cleans up concrete underlay configurator.
Reimplemented in IPv4UnderlayConfigurator, SimpleNetConfigurator, and SingleHostConfigurator.
Referenced by finish().
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.
msg | timer-message |
Reimplemented in SingleHostConfigurator.
00165 { 00166 if (msg == endSimulationNotificationTimer) { 00167 simulationEndingSoon = true; 00168 // bootstrapOracle->sendNotificationToAllPeers(NF_OVERLAY_NODE_LEAVE); 00169 } else if (msg == endSimulationTimer) { 00170 endSimulation(); 00171 } else if (msg == endTransitionTimer) { 00172 consoleOut("transition time finished"); 00173 globalStatistics->startMeasuring(); 00174 } else { 00175 handleTimerEvent(msg); 00176 } 00177 }
void UnderlayConfigurator::consoleOut | ( | const std::string & | text | ) | [private] |
Referenced by handleMessage(), and initFinished().
00195 { 00196 if (!ev.isGUI()) { 00197 struct timeval now, diff; 00198 gettimeofday(&now, NULL); 00199 timersub(&now, &initStartTime, &diff); 00200 00201 std::stringstream ss; 00202 std::string line1(71, '*'); 00203 std::string line2(71, '*'); 00204 00205 ss << " " << text << " "; 00206 line1.replace(35 - ss.str().size() / 2, 00207 ss.str().size(), 00208 ss.str()); 00209 ss.str(""); 00210 00211 ss << " (sim time: " << simTime() 00212 << ", real time: " << diff.tv_sec 00213 << "." << diff.tv_usec << ") "; 00214 line2.replace(35 - ss.str().size() / 2, 00215 ss.str().size(), 00216 ss.str()); 00217 00218 std::cout << "\n" << line1 << "\n" 00219 << line2 << "\n" << std::endl; 00220 } else { 00221 EV << "[UnderlayConfigurator::consoleOut()] " << text; 00222 } 00223 }
std::vector<std::string> UnderlayConfigurator::channelTypes [protected] |
possible access types
Referenced by initialize(), IPv4UnderlayConfigurator::initializeUnderlay(), and SimpleNetConfigurator::migrateNode().
int UnderlayConfigurator::overlayTerminalCount [protected] |
current number of overlay terminals
Referenced by SimpleNetConfigurator::createNode(), IPv4UnderlayConfigurator::createNode(), initialize(), SingleHostConfigurator::initializeUnderlay(), SimpleNetConfigurator::initializeUnderlay(), IPv4UnderlayConfigurator::initializeUnderlay(), SimpleNetConfigurator::preKillNode(), IPv4UnderlayConfigurator::preKillNode(), SingleHostConfigurator::setDisplayString(), SimpleNetConfigurator::setDisplayString(), and IPv4UnderlayConfigurator::setDisplayString().
int UnderlayConfigurator::firstNodeId [protected] |
double UnderlayConfigurator::gracefulLeaveDelay [protected] |
delay until scheduled node is removed from overlay
Referenced by getGracefulLeaveDelay(), initFinished(), initialize(), SimpleNetConfigurator::preKillNode(), and IPv4UnderlayConfigurator::preKillNode().
double UnderlayConfigurator::gracefulLeaveProbability [protected] |
probability that node is notified befor removal
Referenced by initialize(), SimpleNetConfigurator::preKillNode(), and IPv4UnderlayConfigurator::preKillNode().
BootstrapOracle* UnderlayConfigurator::bootstrapOracle [protected] |
pointer to BootstrapOracle
Referenced by SimpleNetConfigurator::createNode(), IPv4UnderlayConfigurator::createNode(), SimpleNetConfigurator::handleTimerEvent(), IPv4UnderlayConfigurator::handleTimerEvent(), initialize(), SingleHostConfigurator::initializeUnderlay(), IPv4UnderlayConfigurator::initializeUnderlay(), SimpleNetConfigurator::migrateNode(), IPv4UnderlayConfigurator::migrateNode(), SimpleNetConfigurator::preKillNode(), and IPv4UnderlayConfigurator::preKillNode().
GlobalStatistics* UnderlayConfigurator::globalStatistics [protected] |
std::vector<ChurnGenerator*> UnderlayConfigurator::churnGenerator [protected] |
pointer to the ChurnGenerators
Referenced by SimpleNetConfigurator::createNode(), IPv4UnderlayConfigurator::createNode(), getChurnGenerator(), initFinished(), initialize(), SimpleNetConfigurator::preKillNode(), and IPv4UnderlayConfigurator::preKillNode().
cMessage* UnderlayConfigurator::endSimulationTimer [protected] |
timer to signal end of simulation
Referenced by handleMessage(), initFinished(), initialize(), UnderlayConfigurator(), and ~UnderlayConfigurator().
cMessage* UnderlayConfigurator::endSimulationNotificationTimer [protected] |
timer to notify nodes that simulation ends soon
Referenced by handleMessage(), initFinished(), initialize(), UnderlayConfigurator(), and ~UnderlayConfigurator().
cMessage* UnderlayConfigurator::endTransitionTimer [protected] |
timer to signal end of transition time
Referenced by handleMessage(), initFinished(), initialize(), UnderlayConfigurator(), and ~UnderlayConfigurator().
struct timeval UnderlayConfigurator::initFinishedTime [read, protected] |
timestamp at end of init phase
Referenced by SingleHostConfigurator::finishUnderlay(), SimpleNetConfigurator::finishUnderlay(), IPv4UnderlayConfigurator::finishUnderlay(), initFinished(), and UnderlayConfigurator().
struct timeval UnderlayConfigurator::initStartTime [read, protected] |
double UnderlayConfigurator::transitionTime [protected] |
time to wait before measuring after init phase is finished
Referenced by initFinished(), and initialize().
double UnderlayConfigurator::measurementTime [protected] |
duration of the simulation after init and transition phase
Referenced by initFinished(), and initialize().
const uint UnderlayConfigurator::NUM_COLORS = 8 [static, protected] |
Referenced by SimpleNetConfigurator::createNode(), and IPv4UnderlayConfigurator::createNode().
const char * UnderlayConfigurator::colorNames [static, protected] |
Initial value:
{ "red", "green", "yellow", "brown", "grey", "violet", "pink", "orange"}
Referenced by SimpleNetConfigurator::createNode(), and IPv4UnderlayConfigurator::createNode().
bool UnderlayConfigurator::init [private] |
Referenced by initFinished(), initialize(), and isInInitPhase().
bool UnderlayConfigurator::simulationEndingSoon [private] |
Referenced by handleMessage(), initialize(), and isSimulationEndingSoon().
bool UnderlayConfigurator::transitionTimeFinished [private] |
Referenced by isTransitionTimeFinished().
unsigned int UnderlayConfigurator::initCounter [private] |
Referenced by initFinished(), and initialize().