OverSim
ParetoChurn Class Reference

Lifetime churn based on shifted pareto distribution. More...

#include <ParetoChurn.h>

Inheritance diagram for ParetoChurn:
ChurnGenerator

Classes

struct  node_stat

Public Member Functions

void handleMessage (cMessage *msg)
void initializeChurn ()
 ParetoChurn ()
 ~ParetoChurn ()
- 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 ()
void createNode (double lifetime, double meanLifetime, double meanDeadtime, bool initialize)
void deleteNode (TransportAddress &addr, double meanLifetime, double meanDeadtime)
double shiftedPareto (double a, double b, int rng=0)
 implements a shifted pareto funcion
double betaByMean (double mean, double alpha=3)
 returns a shifted pareto function's beta param by given mean and alpha
double individualMeanTime (double mean)
 returns the individual mean life/dead time of a node
double individualLifetime (double mean)
 returns a individual lifetime (or deadtime) based on a node's mean lifetime
double residualLifetime (double mean)
 returns the resiidual lifetime (or deadtime) based on a node's mean lifetime
void scheduleCreateNodeAt (double creationTime, double lifetime, double meanLifetime, double meanDeadtime)

Private Attributes

GlobalStatisticsglobalStatistics
double initialMean
 mean of update interval during initalization phase
double initialDeviation
 deviation of update interval during initalization phase
double lifetimeMean
 mean node lifetime
double deadtimeMean
 mean node deadtime
simtime_t lastCreatetime
simtime_t lastDeletetime
cMessage * initFinishedTimer
 timer to signal end of init phase

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

Lifetime churn based on shifted pareto distribution.

This class implements the curn model proposed in

Yao, Z.; Leonard, D.; Wang, X. & Loguinov, D. "Modeling Heterogeneous User Churn and Local Resilience of Unstructured P2P Networks" Proceedings of the 2006 14th IEEE International Conference on Network Protocols, 2006. ICNP '06. 2006, pp. 32–41

Definition at line 46 of file ParetoChurn.h.

Constructor & Destructor Documentation

ParetoChurn::ParetoChurn ( )
inline

Definition at line 51 of file ParetoChurn.h.

{ initFinishedTimer = NULL; };
ParetoChurn::~ParetoChurn ( )

Definition at line 247 of file ParetoChurn.cc.

{
// destroy self timer messages
cancelAndDelete(initFinishedTimer);
}

Member Function Documentation

double ParetoChurn::betaByMean ( double  mean,
double  alpha = 3 
)
protected

returns a shifted pareto function's beta param by given mean and alpha

Parameters
meanthe wanted mean
alphathe alph param of the shifted pareto (defaults to 3)
Returns
the beta parameter

Definition at line 209 of file ParetoChurn.cc.

Referenced by individualLifetime(), individualMeanTime(), and residualLifetime().

{
return 1/(mean*(alpha -1));
}
void ParetoChurn::createNode ( double  lifetime,
double  meanLifetime,
double  meanDeadtime,
bool  initialize 
)
protected

Definition at line 162 of file ParetoChurn.cc.

Referenced by handleMessage().

{
ParetoChurnMessage* churnMsg = new ParetoChurnMessage("DeleteNode");
churnMsg->setAddr(*ta);
delete ta;
churnMsg->setCreateNode(false);
churnMsg->setMeanLifetime(meanLifetime);
churnMsg->setMeanDeadtime(meanDeadtime);
scheduleAt(std::max(simTime(), simTime() + lifetime
RECORD_STATS(globalStatistics->recordOutVector("ParetoChurn: Session Time",
lifetime));
"Time between creates", SIMTIME_DBL(simTime() - lastCreatetime)));
lastCreatetime = simTime();
}
void ParetoChurn::deleteNode ( TransportAddress addr,
double  meanLifetime,
double  meanDeadtime 
)
protected

Definition at line 184 of file ParetoChurn.cc.

Referenced by handleMessage().

{
// Kill node
"Time between deletes", SIMTIME_DBL(simTime() - lastDeletetime)));
lastDeletetime = simTime();
scheduleCreateNodeAt(SIMTIME_DBL(simTime()+individualLifetime(meanDeadtime)),
individualLifetime(meanLifetime), meanLifetime,
meanDeadtime);
}
void ParetoChurn::handleMessage ( cMessage *  msg)
virtual

Implements ChurnGenerator.

Definition at line 132 of file ParetoChurn.cc.

{
if (!msg->isSelfMessage()) {
delete msg;
return;
}
// init phase finished
if (msg == initFinishedTimer) {
cancelEvent(initFinishedTimer);
return;
}
ParetoChurnMessage* churnMsg = check_and_cast<ParetoChurnMessage*>(msg);
if (churnMsg->getCreateNode() == true) {
createNode(churnMsg->getLifetime(), churnMsg->getMeanLifetime(),
churnMsg->getMeanDeadtime(), false);
} else {
deleteNode(churnMsg->getAddr(), churnMsg->getMeanLifetime(),
churnMsg->getMeanDeadtime());
}
delete msg;
}
double ParetoChurn::individualLifetime ( double  mean)
protected

returns a individual lifetime (or deadtime) based on a node's mean lifetime

Parameters
meanthe node's men lifetime
Returns
the lifetime

Definition at line 227 of file ParetoChurn.cc.

Referenced by deleteNode(), and initializeChurn().

{
return shiftedPareto(3, betaByMean(mean));
}
double ParetoChurn::individualMeanTime ( double  mean)
protected

returns the individual mean life/dead time of a node

Parameters
meanthe global mean life/dead time
Returns
the mean life/dead time of the node

Definition at line 221 of file ParetoChurn.cc.

Referenced by initializeChurn().

{
// return shiftedPareto(3, betaByMean(mean*exp(1)));
return shiftedPareto(3, betaByMean(mean));
}
void ParetoChurn::initializeChurn ( )
virtual

Implements ChurnGenerator.

Definition at line 44 of file ParetoChurn.cc.

{
Enter_Method_Silent();
initialMean = par("initPhaseCreationInterval");
lifetimeMean = par("lifetimeMean");
deadtimeMean = par("deadtimeMean");
WATCH(lifetimeMean);
WATCH(deadtimeMean);
double initFinishedTime = initialMean * targetOverlayTerminalNum;
// try to create a stable equilibrium of nodes in init phase
//
// check for each node if he is present in initial state
// and roll individual mean life+dead times
int liveNodes = 0;
double sum_l_i = 0;
std::deque<node_stat> node_stats;
for (int i = 0; liveNodes < (int)par("targetOverlayTerminalNum"); i++) {
double nodeLifetimeMean = individualMeanTime(lifetimeMean);
globalStatistics->recordOutVector("ParetoChurn: Node individual "
"mean lifetime", nodeLifetimeMean);
double nodeDeadtimeMean = individualMeanTime(deadtimeMean);
globalStatistics->recordOutVector("ParetoChurn: Node individual "
"mean deadtime", nodeDeadtimeMean);
sum_l_i += 1.0/(nodeLifetimeMean + nodeDeadtimeMean);
node_stat nodeStat;
nodeStat.l = nodeLifetimeMean;
nodeStat.d = nodeDeadtimeMean;
double nodeAvailability = nodeLifetimeMean/(nodeLifetimeMean
+ nodeDeadtimeMean);
globalStatistics->recordOutVector("Node availability", nodeAvailability);
nodeStat.alive = uniform(0, 1) < nodeAvailability;
if (nodeStat.alive) {
liveNodes++;
}
node_stats.push_back( nodeStat );
}
// compute "stretch" factor to reach the configured average lifetime
// this is neccessary as "individual" lifetime mean has to be bigger than
// "global" lifetime mean, as short-lived nodes will factor in more often
double mean_life = 0;
int numNodes = node_stats.size();
for( int i = 0; i < numNodes; ++i ){
node_stat& stat = node_stats[i];
mean_life += stat.l/( (stat.l + stat.d) * sum_l_i );
}
double stretch = lifetimeMean/mean_life;
liveNodes = 0;
// schedule creation for all (alive or dead) nodes
for( int i = 0; i < numNodes; ++i ){
node_stat& stat = node_stats.front();
stat.l *= stretch;
stat.d *= stretch;
if( stat.alive ){
double scheduleTime = truncnormal(initialMean*liveNodes, initialDeviation);
scheduleCreateNodeAt(scheduleTime, initFinishedTime - scheduleTime
+ residualLifetime(stat.l),
stat.l, stat.d);
liveNodes++;
} else {
scheduleCreateNodeAt(initFinishedTime
+ residualLifetime(stat.d),
stat.l, stat.d);
}
node_stats.pop_front();
}
initFinishedTimer = new cMessage("initFinishTimer");
scheduleAt(initFinishedTime, initFinishedTimer);
}
double ParetoChurn::residualLifetime ( double  mean)
protected

returns the resiidual lifetime (or deadtime) based on a node's mean lifetime

Parameters
meanthe node's men lifetime
Returns
the residual lifetime

Definition at line 235 of file ParetoChurn.cc.

Referenced by initializeChurn().

{
return shiftedPareto(2, betaByMean(mean));
}
void ParetoChurn::scheduleCreateNodeAt ( double  creationTime,
double  lifetime,
double  meanLifetime,
double  meanDeadtime 
)
protected

Definition at line 198 of file ParetoChurn.cc.

Referenced by deleteNode(), and initializeChurn().

{
ParetoChurnMessage* churnMsg = new ParetoChurnMessage("CreateNode");
churnMsg->setCreateNode(true);
churnMsg->setLifetime(lifetime);
churnMsg->setMeanLifetime(meanLifetime);
churnMsg->setMeanDeadtime(meanDeadtime);
scheduleAt(creationTime, churnMsg);
}
double ParetoChurn::shiftedPareto ( double  a,
double  b,
int  rng = 0 
)
protected

implements a shifted pareto funcion

Definition at line 214 of file ParetoChurn.cc.

Referenced by individualLifetime(), individualMeanTime(), and residualLifetime().

{
// What OMNET calles "pareto_shifted" in reality is a gerneralized pareto,
// not a shifted pareto...
return (pareto_shifted(a, b, 0, rng)/b - 1) / b;
}
void ParetoChurn::updateDisplayString ( )
protectedvirtual

Implements ChurnGenerator.

Definition at line 240 of file ParetoChurn.cc.

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

Member Data Documentation

double ParetoChurn::deadtimeMean
private

mean node deadtime

Definition at line 107 of file ParetoChurn.h.

Referenced by initializeChurn().

GlobalStatistics* ParetoChurn::globalStatistics
private

Definition at line 102 of file ParetoChurn.h.

Referenced by createNode(), deleteNode(), and initializeChurn().

cMessage* ParetoChurn::initFinishedTimer
private

timer to signal end of init phase

Definition at line 112 of file ParetoChurn.h.

Referenced by handleMessage(), initializeChurn(), ParetoChurn(), and ~ParetoChurn().

double ParetoChurn::initialDeviation
private

deviation of update interval during initalization phase

Definition at line 105 of file ParetoChurn.h.

Referenced by initializeChurn().

double ParetoChurn::initialMean
private

mean of update interval during initalization phase

Definition at line 104 of file ParetoChurn.h.

Referenced by initializeChurn().

simtime_t ParetoChurn::lastCreatetime
private

Definition at line 109 of file ParetoChurn.h.

Referenced by createNode(), and initializeChurn().

simtime_t ParetoChurn::lastDeletetime
private

Definition at line 110 of file ParetoChurn.h.

Referenced by deleteNode(), and initializeChurn().

double ParetoChurn::lifetimeMean
private

mean node lifetime

Definition at line 106 of file ParetoChurn.h.

Referenced by initializeChurn().


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