Random churn generating class. More...
#include <RandomChurn.h>
Public Member Functions | |
void | handleMessage (cMessage *msg) |
void | initializeChurn () |
~RandomChurn () | |
Protected Member Functions | |
void | updateDisplayString () |
Private Attributes | |
double | creationProbability |
probability of creating a new overlay terminal | |
double | migrationProbability |
probability of migrating an overlay terminal | |
double | removalProbability |
probability of removing an overlay terminal | |
double | initialMean |
mean of update interval during initalization phase | |
double | initialDeviation |
deviation of update interval during initalization phase | |
double | targetMean |
mean of update interval after initalization phase | |
double | targetOverlayTerminalNum |
number of created terminals after init phase | |
cMessage * | churnTimer |
message to change the churn rate | |
cMessage * | mobilityTimer |
message to schedule events | |
bool | churnIntervalChanged |
indicates if targetMean changed. | |
double | churnChangeInterval |
churn change interval | |
bool | initAddMoreTerminals |
true, if we're still adding more terminals in the init phase | |
GlobalStatistics * | globalStatistics |
Random churn generating class.
Definition at line 33 of file RandomChurn.h.
RandomChurn::~RandomChurn | ( | ) |
Definition at line 133 of file RandomChurn.cc.
{ // destroy self timer messages cancelAndDelete(churnTimer); cancelAndDelete(mobilityTimer); }
void RandomChurn::handleMessage | ( | cMessage * | msg | ) | [virtual] |
Implements ChurnGenerator.
Definition at line 66 of file RandomChurn.cc.
{ if (!msg->isSelfMessage()) { delete msg; return; } if (msg == churnTimer) { cancelEvent(churnTimer); scheduleAt(simTime() + churnChangeInterval, churnTimer); if (churnIntervalChanged) { targetMean = par("targetMobilityDelay"); churnIntervalChanged = false; } else { targetMean = par("targetMobilityDelay2"); churnIntervalChanged = true; } std::stringstream temp; temp << "Churn-rate changed to " << targetMean; bubble(temp.str().c_str()); } else if (msg == mobilityTimer) { if (initAddMoreTerminals) { // increase the number of nodes steadily during setup if (terminalCount < targetOverlayTerminalNum) { TransportAddress* ta = underlayConfigurator->createNode(type); delete ta; // Address not needed in this churn model } if (terminalCount >= targetOverlayTerminalNum) { initAddMoreTerminals = false; underlayConfigurator->initFinished(); } scheduleAt(simTime() + truncnormal(initialMean, initialDeviation), msg); } else { double random = uniform(0, 1); // modify the number of nodes according to user parameters if (random < creationProbability) { TransportAddress* ta = underlayConfigurator->createNode(type); delete ta; // Address not needed in this churn model } else if (creationProbability <= random && random < creationProbability + removalProbability && terminalCount > 1) { int oldTerminalCount = terminalCount; underlayConfigurator->preKillNode(type); assert ((oldTerminalCount - 1) == terminalCount); } else if (creationProbability + removalProbability <= random && random < creationProbability + removalProbability + migrationProbability && terminalCount > 1) { underlayConfigurator->migrateNode(type); } scheduleAt(simTime() + truncnormal(targetMean, targetMean / 3), msg); } } }
void RandomChurn::initializeChurn | ( | ) | [virtual] |
Implements ChurnGenerator.
Definition at line 35 of file RandomChurn.cc.
{ Enter_Method_Silent(); creationProbability = par("creationProbability"); migrationProbability = par("migrationProbability"); removalProbability = par("removalProbability"); initialMean = par("initPhaseCreationInterval"); initialDeviation = initialMean / 3; targetMean = par("targetMobilityDelay"); targetOverlayTerminalNum = par("targetOverlayTerminalNum"); WATCH(targetMean); churnTimer = NULL; churnIntervalChanged = false; churnChangeInterval = par("churnChangeInterval"); initAddMoreTerminals = true; globalStatistics = GlobalStatisticsAccess().get(); // initialize simulation mobilityTimer = NULL; mobilityTimer = new cMessage("mobilityTimer"); scheduleAt(simTime(), mobilityTimer); if (churnChangeInterval > 0) { churnTimer = new cMessage("churnTimer"); scheduleAt(simTime() + churnChangeInterval, churnTimer); } }
void RandomChurn::updateDisplayString | ( | ) | [protected, virtual] |
Implements ChurnGenerator.
Definition at line 126 of file RandomChurn.cc.
{ char buf[80]; sprintf(buf, "random churn"); getDisplayString().setTagArg("t", 0, buf); }
double RandomChurn::churnChangeInterval [private] |
churn change interval
Definition at line 54 of file RandomChurn.h.
Referenced by handleMessage(), and initializeChurn().
bool RandomChurn::churnIntervalChanged [private] |
indicates if targetMean changed.
Definition at line 53 of file RandomChurn.h.
Referenced by handleMessage(), and initializeChurn().
cMessage* RandomChurn::churnTimer [private] |
message to change the churn rate
Definition at line 51 of file RandomChurn.h.
Referenced by handleMessage(), initializeChurn(), and ~RandomChurn().
double RandomChurn::creationProbability [private] |
probability of creating a new overlay terminal
Definition at line 44 of file RandomChurn.h.
Referenced by handleMessage(), and initializeChurn().
GlobalStatistics* RandomChurn::globalStatistics [private] |
Definition at line 57 of file RandomChurn.h.
Referenced by initializeChurn().
bool RandomChurn::initAddMoreTerminals [private] |
true, if we're still adding more terminals in the init phase
Definition at line 55 of file RandomChurn.h.
Referenced by handleMessage(), and initializeChurn().
double RandomChurn::initialDeviation [private] |
deviation of update interval during initalization phase
Definition at line 48 of file RandomChurn.h.
Referenced by handleMessage(), and initializeChurn().
double RandomChurn::initialMean [private] |
mean of update interval during initalization phase
Definition at line 47 of file RandomChurn.h.
Referenced by handleMessage(), and initializeChurn().
double RandomChurn::migrationProbability [private] |
probability of migrating an overlay terminal
Definition at line 45 of file RandomChurn.h.
Referenced by handleMessage(), and initializeChurn().
cMessage* RandomChurn::mobilityTimer [private] |
message to schedule events
Definition at line 52 of file RandomChurn.h.
Referenced by handleMessage(), initializeChurn(), and ~RandomChurn().
double RandomChurn::removalProbability [private] |
probability of removing an overlay terminal
Definition at line 46 of file RandomChurn.h.
Referenced by handleMessage(), and initializeChurn().
double RandomChurn::targetMean [private] |
mean of update interval after initalization phase
Definition at line 49 of file RandomChurn.h.
Referenced by handleMessage(), and initializeChurn().
double RandomChurn::targetOverlayTerminalNum [private] |
number of created terminals after init phase
Reimplemented from ChurnGenerator.
Definition at line 50 of file RandomChurn.h.
Referenced by handleMessage(), and initializeChurn().