RandomChurn Class Reference

#include <RandomChurn.h>

Inheritance diagram for RandomChurn:

ChurnGenerator List of all members.

Detailed Description

Random churn generating class.


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


Constructor & Destructor Documentation

RandomChurn::~RandomChurn (  ) 

00127                           {
00128     // destroy self timer messages
00129     cancelAndDelete(churnTimer);
00130     cancelAndDelete(mobilityTimer);
00131 }


Member Function Documentation

void RandomChurn::handleMessage ( cMessage *  msg  )  [virtual]

Implements ChurnGenerator.

00065 {
00066     if (!msg->isSelfMessage()) {
00067         delete msg;
00068         return;
00069     }
00070 
00071     if (msg == churnTimer) {
00072         cancelEvent(churnTimer);
00073         scheduleAt(simulation.simTime() + churnChangeInterval, churnTimer);
00074         if (churnIntervalChanged) {
00075             targetMean = par("targetMobilityDelay");
00076             churnIntervalChanged = false;
00077         }
00078         else {
00079             targetMean = par("targetMobilityDelay2");
00080             churnIntervalChanged = true;
00081         }
00082         std::stringstream temp;
00083         temp << "Churn-rate changed to " << targetMean;
00084         bubble(temp.str().c_str());
00085     } else if (msg == mobilityTimer) {
00086         if (initAddMoreTerminals) {
00087             // increase the number of nodes steadily during setup
00088             if (terminalCount < targetOverlayTerminalNum) {
00089                 underlayConfigurator->createNode(type);
00090             }
00091 
00092             if (terminalCount >= targetOverlayTerminalNum) {
00093                 initAddMoreTerminals = false;
00094                 underlayConfigurator->initFinished();
00095             }
00096             scheduleAt(simulation.simTime()
00097                     + truncnormal(initialMean, initialDeviation), msg);
00098         }
00099         else {
00100             double random = uniform(0, 1);
00101 
00102             // modify the number of nodes according to user parameters
00103             if (random < creationProbability) {
00104                 underlayConfigurator->createNode(type);
00105             } else if (creationProbability <= random &&
00106                     random < creationProbability + removalProbability &&
00107                     terminalCount > 1) {
00108                 underlayConfigurator->preKillNode(type);
00109             } else if (creationProbability + removalProbability <= random &&
00110                        random < creationProbability + removalProbability
00111                        + migrationProbability && terminalCount > 1) {
00112                 underlayConfigurator->migrateNode(type);
00113             }
00114             scheduleAt(simulation.simTime()
00115                        + truncnormal(targetMean, targetMean / 3), msg);
00116         }
00117     }
00118 }

void RandomChurn::initializeChurn (  )  [virtual]

Implements ChurnGenerator.

00029 {
00030     Enter_Method_Silent();
00031 
00032     creationProbability = par("creationProbability");
00033     migrationProbability = par("migrationProbability");
00034     removalProbability = par("removalProbability");
00035     initialMean = par("initialMobilityDelay");
00036     initialDeviation = initialMean / 3;
00037     targetMean = par("targetMobilityDelay");
00038     targetOverlayTerminalNum = par("targetOverlayTerminalNum");
00039     //targetDeviation = targetMean / 3;
00040     WATCH(targetMean);
00041 
00042     churnTimer = NULL;
00043     churnIntervalChanged = false;
00044     churnChangeInterval = (double)(par("churnChangeInterval"));
00045     initAddMoreTerminals = true;
00046 
00047     // add the overlay nodes
00048     //underlayConfigurator->firstNodeId = createRandomNode(true)->getModuleID();
00049     underlayConfigurator->createNode(type, true);
00050     for (int i = 1; i < initialOverlayTerminalNum; i++) {
00051         underlayConfigurator->createNode(type, true);
00052     }
00053 
00054     // initialize simulation
00055     mobilityTimer = NULL;
00056     mobilityTimer = new cMessage("mobilityTimer");
00057     scheduleAt(simulation.simTime(), mobilityTimer);
00058     if((double)(par("churnChangeInterval")) > 0) {
00059         churnTimer = new cMessage("churnTimer");
00060         scheduleAt(simulation.simTime() + churnChangeInterval, churnTimer);
00061     }
00062 }

void RandomChurn::updateDisplayString (  )  [protected, virtual]

Implements ChurnGenerator.

00121 {
00122     char buf[80];
00123     sprintf(buf, "random churn");
00124     displayString().setTagArg("t", 0, buf);
00125 }


Member Data Documentation

double RandomChurn::creationProbability [private]

probability of creating a new overlay terminal

double RandomChurn::migrationProbability [private]

probability of migrating an overlay terminal

double RandomChurn::removalProbability [private]

probability of removing an overlay terminal

double RandomChurn::initialMean [private]

mean of update interval during initalization phase

double RandomChurn::initialDeviation [private]

deviation of update interval during initalization phase

double RandomChurn::targetMean [private]

mean of update interval after initalization phase

double RandomChurn::targetOverlayTerminalNum [private]

number of created terminals after init phase

Reimplemented from ChurnGenerator.

cMessage* RandomChurn::churnTimer [private]

message to change the churn rate

cMessage* RandomChurn::mobilityTimer [private]

message to schedule events

bool RandomChurn::churnIntervalChanged [private]

indicates if targetMean changed.

double RandomChurn::churnChangeInterval [private]

churn change interval

bool RandomChurn::initAddMoreTerminals [private]

true, if we're still adding more terminals in the init phase


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