OverSim
RandomChurn Class Reference

Random churn generating class. More...

#include <RandomChurn.h>

Inheritance diagram for RandomChurn:
ChurnGenerator

Public Member Functions

void handleMessage (cMessage *msg)
void initializeChurn ()
 ~RandomChurn ()
- Public Member Functions inherited from ChurnGenerator
virtual int numInitStages () const
virtual void initialize (int stage)
void setNodeType (const NodeType &t)
const NodeTypegetNodeType ()

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
GlobalStatisticsglobalStatistics

Additional Inherited Members

- Public Attributes inherited from ChurnGenerator
bool init
 still in initialization phase?
int terminalCount
 current number of overlay terminals
- Protected Attributes inherited from ChurnGenerator
UnderlayConfiguratorunderlayConfigurator
int targetOverlayTerminalNum
 final number of overlay terminals
NodeType type
 the nodeType this generator is responsible for

Detailed Description

Random churn generating class.

Definition at line 33 of file RandomChurn.h.

Constructor & Destructor Documentation

RandomChurn::~RandomChurn ( )

Definition at line 133 of file RandomChurn.cc.

{
// destroy self timer messages
cancelAndDelete(churnTimer);
cancelAndDelete(mobilityTimer);
}

Member Function Documentation

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);
targetMean = par("targetMobilityDelay");
}
else {
targetMean = par("targetMobilityDelay2");
}
std::stringstream temp;
temp << "Churn-rate changed to " << targetMean;
bubble(temp.str().c_str());
} else if (msg == mobilityTimer) {
// increase the number of nodes steadily during setup
delete ta; // Address not needed in this churn model
}
}
scheduleAt(simTime()
+ truncnormal(initialMean, initialDeviation), msg);
}
else {
double random = uniform(0, 1);
// modify the number of nodes according to user parameters
if (random < creationProbability) {
delete ta; // Address not needed in this churn model
} else if (creationProbability <= random &&
int oldTerminalCount = terminalCount;
assert ((oldTerminalCount - 1) == terminalCount);
} else if (creationProbability + removalProbability <= random &&
}
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");
targetMean = par("targetMobilityDelay");
targetOverlayTerminalNum = par("targetOverlayTerminalNum");
WATCH(targetMean);
churnTimer = NULL;
churnChangeInterval = par("churnChangeInterval");
// initialize simulation
mobilityTimer = NULL;
mobilityTimer = new cMessage("mobilityTimer");
scheduleAt(simTime(), mobilityTimer);
churnTimer = new cMessage("churnTimer");
scheduleAt(simTime() + churnChangeInterval, churnTimer);
}
}
void RandomChurn::updateDisplayString ( )
protectedvirtual

Implements ChurnGenerator.

Definition at line 126 of file RandomChurn.cc.

{
char buf[80];
sprintf(buf, "random churn");
getDisplayString().setTagArg("t", 0, buf);
}

Member Data Documentation

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

Definition at line 50 of file RandomChurn.h.

Referenced by handleMessage(), and initializeChurn().


The documentation for this class was generated from the following files: