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 (  ) 

00123                           {
00124     // destroy self timer messages
00125     cancelAndDelete(churnTimer);
00126     cancelAndDelete(mobilityTimer);
00127 }


Member Function Documentation

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

Implements ChurnGenerator.

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

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     // initialize simulation
00048     mobilityTimer = NULL;
00049     mobilityTimer = new cMessage("mobilityTimer");
00050     scheduleAt(simulation.simTime(), mobilityTimer);
00051     
00052     if ((double)(par("churnChangeInterval")) > 0) {
00053         churnTimer = new cMessage("churnTimer");
00054         scheduleAt(simulation.simTime() + churnChangeInterval, churnTimer);
00055     }
00056 }

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

Implements ChurnGenerator.

00117 {
00118     char buf[80];
00119     sprintf(buf, "random churn");
00120     displayString().setTagArg("t", 0, buf);
00121 }


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 Thu Apr 17 13:19:30 2008 for ITM OverSim by  doxygen 1.5.3