OverSim
ReaSEUnderlayConfigurator Class Reference

Configurator module for the ReaSEUnderlay. More...

#include <ReaSEUnderlayConfigurator.h>

Inheritance diagram for ReaSEUnderlayConfigurator:
UnderlayConfigurator

Public Member Functions

TransportAddresscreateNode (NodeType type, bool initialize=false)
 Creates an overlay node.
void preKillNode (NodeType type, TransportAddress *addr=NULL)
 Notifies and schedules overlay nodes for removal.
void migrateNode (NodeType type, TransportAddress *addr=NULL)
 Migrates overlay nodes from one access net to another.
- Public Member Functions inherited from UnderlayConfigurator
 UnderlayConfigurator ()
virtual ~UnderlayConfigurator ()
bool isInInitPhase ()
 still in initialization phase?
bool isSimulationEndingSoon ()
 Is the simulation ending soon?
simtime_t getGracefulLeaveDelay ()
 Return the gracefulLeaveDelay.
bool isTransitionTimeFinished ()
void initFinished ()
ChurnGeneratorgetChurnGenerator (int typeID)
uint8_t getChurnGeneratorNum ()
int getOverlayTerminalCount ()

Protected Member Functions

void initializeUnderlay (int stage)
 Sets up backbone, assigns ip addresses, calculates routing tables, sets some parameters and adds the initial number of nodes to the network.
void handleTimerEvent (cMessage *msg)
 process timer messages
void finishUnderlay ()
 Saves statistics, prints simulation time.
void setDisplayString ()
 Updates the statistics display string.
- Protected Member Functions inherited from UnderlayConfigurator
int numInitStages () const
 OMNeT number of init stages.
virtual void initialize (int stage)
 OMNeT init methods.
void finish ()
 Cleans up configurator.
void handleMessage (cMessage *msg)
 Node mobility simulation.

Protected Attributes

std::vector< cModule * > accessNode
 stores accessRouter
std::deque< IPvXAddress > killList
 stores nodes scheduled to be killed
std::set< int > scheduledID
 stores nodeIds to prevent migration of prekilled nodes
int numCreated
 number of overall created overlay terminals
int numKilled
 number of overall killed overlay terminals
- Protected Attributes inherited from UnderlayConfigurator
int overlayTerminalCount
 current number of overlay terminals
int firstNodeId
 the Id of the overlayTerminal created first in the overlay
simtime_t gracefulLeaveDelay
 delay until scheduled node is removed from overlay
double gracefulLeaveProbability
 probability that node is notified befor removal
GlobalNodeListglobalNodeList
 pointer to GlobalNodeList
GlobalStatisticsglobalStatistics
 pointer to GlobalStatistics
std::vector< ChurnGenerator * > churnGenerator
 pointer to the ChurnGenerators
cMessage * endSimulationTimer
 timer to signal end of simulation
cMessage * endSimulationNotificationTimer
 timer to notify nodes that simulation ends soon
cMessage * endTransitionTimer
 timer to signal end of transition time
struct timeval initFinishedTime
 timestamp at end of init phase
struct timeval initStartTime
 timestamp at begin of init phase
simtime_t transitionTime
 time to wait before measuring after init phase is finished
simtime_t measurementTime
 duration of the simulation after init and transition phase

Private Attributes

int accessRouterNum
 number of access router
int overlayAccessRouterNum
 number of overlayAccessRouter
int overlayTerminalNum
 number of terminal in the overlay
ConnectReaSETerminalConnector

Additional Inherited Members

- Static Protected Attributes inherited from UnderlayConfigurator
static const int NUM_COLORS = 8
static const char * colorNames []

Detailed Description

Configurator module for the ReaSEUnderlay.

Author
Markus Mauch
Todo:
possibility to disable tier1-3 in overlay(access)routers

Definition at line 47 of file ReaSEUnderlayConfigurator.h.

Member Function Documentation

TransportAddress * ReaSEUnderlayConfigurator::createNode ( NodeType  type,
bool  initialize = false 
)
virtual

Creates an overlay node.

Parameters
typethe NodeType of the node to create
initializecreation during init phase?

Implements UnderlayConfigurator.

Definition at line 65 of file ReaSEUnderlayConfigurator.cc.

{
Enter_Method_Silent();
// derive overlay node from ned
std::string nameStr = "overlayTerminal";
if (churnGenerator.size() > 1) {
nameStr += "-" + convertToString<int32_t>(type.typeID);
}
cModuleType* moduleType = cModuleType::get(type.terminalType.c_str());
cModule* node = moduleType->create(nameStr.c_str(), accessNet.edge->Router->getParentModule(), //TODO: insert node in submodule
if (type.channelTypesTx.size() > 0) {
throw cRuntimeError("ReaSEUnderlayConfigurator::createNode(): Setting "
"channel types via the churn generator is not allowed "
"with the ReaSEUnderlay. Use **.accessNet.channelTypes instead!");
}
node->setGateSize("pppg", 1);
std::string displayString;
if ((type.typeID > 0) && (type.typeID <= NUM_COLORS)) {
((displayString += "i=device/wifilaptop_l,")
+= colorNames[type.typeID - 1])
+= ",40;i2=block/circle_s";
} else {
displayString = "i=device/wifilaptop_l;i2=block/circle_s";
}
node->finalizeParameters();
node->setDisplayString(displayString.c_str());
node->buildInside();
node->scheduleStart(simTime());
// create meta information
ReaSEInfo* info = new ReaSEInfo(type.typeID, node->getId(), type.context);
accessNet.terminal = node;
// add node to a randomly chosen access net
// add node to bootstrap oracle
globalNodeList->addPeer(IPAddressResolver().addressOf(node), info);
// if the node was not created during startup we have to
// finish the initialization process manually
if (!initialize) {
for (int i = MAX_STAGE_UNDERLAY + 1; i < NUM_STAGES_ALL; i++) {
node->callInitialize(i);
}
}
churnGenerator[type.typeID]->terminalCount++;
IPAddressResolver().addressOf(node));
// update display
return address;
}
void ReaSEUnderlayConfigurator::finishUnderlay ( )
protectedvirtual

Saves statistics, prints simulation time.

Reimplemented from UnderlayConfigurator.

Definition at line 298 of file ReaSEUnderlayConfigurator.cc.

{
// statistics
recordScalar("Terminals added", numCreated);
recordScalar("Terminals removed", numKilled);
if (!isInInitPhase()) {
struct timeval now, diff;
gettimeofday(&now, NULL);
timersub(&now, &initFinishedTime, &diff);
printf("Simulation time: %li.%06li\n", diff.tv_sec, diff.tv_usec);
}
}
void ReaSEUnderlayConfigurator::handleTimerEvent ( cMessage *  msg)
protectedvirtual

process timer messages

Parameters
msgthe received message

Reimplemented from UnderlayConfigurator.

Definition at line 257 of file ReaSEUnderlayConfigurator.cc.

{
Enter_Method_Silent();
// get next scheduled node from the kill list
IPvXAddress addr = killList.back();
killList.pop_back();
//AccessNet* accessNetModule = NULL;
int nodeID = -1;
ReaSEInfo* info = dynamic_cast<ReaSEInfo*>(globalNodeList->getPeerInfo(addr));
if (info != NULL) {
//accessNetModule = info->getAccessNetModule();
nodeID = info->getNodeID();
} else {
opp_error("IPv4UnderlayConfigurator: Trying to kill node with nonexistant TransportAddress!");
}
scheduledID.erase(nodeID);
cModule* node = TerminalConnector->removeOverlayNode(nodeID);
if (node == NULL)
opp_error("IPv4UnderlayConfigurator: Trying to remove node which is nonexistant in AccessNet!");
node->callFinish();
node->deleteModule();
delete msg;
}
void ReaSEUnderlayConfigurator::initializeUnderlay ( int  stage)
protectedvirtual

Sets up backbone, assigns ip addresses, calculates routing tables, sets some parameters and adds the initial number of nodes to the network.

Parameters
stagethe phase of the initialisation

Implements UnderlayConfigurator.

Definition at line 43 of file ReaSEUnderlayConfigurator.cc.

{
//backbone configuration
if (stage == MIN_STAGE_UNDERLAY) {
}
//access net configuration
else if (stage == MAX_STAGE_UNDERLAY) {
// fetch some parameters
// count the overlay clients
numKilled = 0;
// add access node modules to access node vector
TerminalConnector = (ConnectReaSE*)getParentModule()->getSubmodule("TerminalConnector");
}
}
void ReaSEUnderlayConfigurator::migrateNode ( NodeType  type,
TransportAddress addr = NULL 
)
virtual

Migrates overlay nodes from one access net to another.

Parameters
typethe NodeType of the node to migrate
addrNULL for random node

Implements UnderlayConfigurator.

Definition at line 203 of file ReaSEUnderlayConfigurator.cc.

{
Enter_Method_Silent();
// AccessNet* accessNetModule = NULL;
int nodeID = -1;
ReaSEInfo* info;
// If no address given, get random node
if (addr == NULL) {
info = dynamic_cast<ReaSEInfo*>(globalNodeList->getRandomPeerInfo(type.typeID));
} else {
// get node information
info = dynamic_cast<ReaSEInfo*>(globalNodeList->getPeerInfo(*addr));
}
if (info != NULL) {
//accessNetModule = info->getAccessNetModule();
nodeID = info->getNodeID();
} else {
opp_error("ReaSEUnderlayConfigurator: Trying to pre kill node with nonexistant TransportAddress!");
}
// do not migrate node that is already scheduled
if (scheduledID.count(nodeID))
return;
cModule* node = TerminalConnector->removeOverlayNode(nodeID);//intuniform(0, accessNetModule->size() - 1));
if (node == NULL)
opp_error("ReaSEUnderlayConfigurator: Trying to remove node which is not an overlay node in network!");
//remove node from bootstrap oracle
globalNodeList->killPeer(IPAddressResolver().addressOf(node));
node->bubble("I am migrating!");
// connect the node to another access net
AccessInfo newAccessModule;
// create meta information
ReaSEInfo* newinfo = new ReaSEInfo(type.typeID, node->getId(), type.context);
newAccessModule = TerminalConnector->migrateNode(node->getId());
newAccessModule.terminal = node;
// add node to a randomly chosen access net
info->setNodeID(TerminalConnector->addOverlayNode(&newAccessModule));
//add node to bootstrap oracle
globalNodeList->addPeer(IPAddressResolver().addressOf(node), newinfo);
// inform the notification board about the migration
NotificationBoard* nb = check_and_cast<NotificationBoard*>(node->getSubmodule("notificationBoard"));
nb->fireChangeNotification(NF_OVERLAY_TRANSPORTADDRESS_CHANGED);
}
void ReaSEUnderlayConfigurator::preKillNode ( NodeType  type,
TransportAddress addr = NULL 
)
virtual

Notifies and schedules overlay nodes for removal.

Parameters
typeNodeType of the node to remove
addrNULL for random node

Implements UnderlayConfigurator.

Definition at line 136 of file ReaSEUnderlayConfigurator.cc.

{
Enter_Method_Silent();
// AccessNet* accessNetModule = NULL;
int nodeID;
ReaSEInfo* info;
// If no address given, get random node
if (addr == NULL) {
if (addr == NULL) {
// all nodes are already prekilled
std::cout << "all nodes are already prekilled" << std::endl;
return;
}
}
// get node information
info = dynamic_cast<ReaSEInfo*>(globalNodeList->getPeerInfo(*addr));
if (info != NULL) {
//accessNetModule = info->getAccessNetModule();
nodeID = info->getNodeID();
} else {
opp_error("IPv4UnderlayConfigurator: Trying to pre kill node "
"with nonexistant TransportAddress!");
}
uint32_t effectiveType = info->getTypeID();
// do not kill node that is already scheduled
if (scheduledID.count(nodeID))
return;
//TODO: get overlay node
cModule* node = TerminalConnector->getOverlayNode(nodeID);
globalNodeList->removePeer(IPAddressResolver().addressOf(node));
//put node into the kill list and schedule a message for final removal of the node
killList.push_front(IPAddressResolver().addressOf(node));
scheduledID.insert(nodeID);
churnGenerator[effectiveType]->terminalCount--;
// update display
// inform the notification board about the removal
NotificationBoard* nb = check_and_cast<NotificationBoard*>(
node->getSubmodule("notificationBoard"));
nb->fireChangeNotification(NF_OVERLAY_NODE_LEAVE);
double random = uniform(0, 1);
if (random < gracefulLeaveProbability) {
nb->fireChangeNotification(NF_OVERLAY_NODE_GRACEFUL_LEAVE);
}
cMessage* msg = new cMessage();
scheduleAt(simTime() + gracefulLeaveDelay, msg);
}
void ReaSEUnderlayConfigurator::setDisplayString ( )
protectedvirtual

Updates the statistics display string.

Implements UnderlayConfigurator.

Definition at line 290 of file ReaSEUnderlayConfigurator.cc.

Referenced by createNode(), and preKillNode().

{
char buf[80];
sprintf(buf, "%i overlay terminals",
getDisplayString().setTagArg("t", 0, buf);
}

Member Data Documentation

std::vector<cModule*> ReaSEUnderlayConfigurator::accessNode
protected

stores accessRouter

Definition at line 108 of file ReaSEUnderlayConfigurator.h.

int ReaSEUnderlayConfigurator::accessRouterNum
private

number of access router

Definition at line 76 of file ReaSEUnderlayConfigurator.h.

std::deque<IPvXAddress> ReaSEUnderlayConfigurator::killList
protected

stores nodes scheduled to be killed

Definition at line 109 of file ReaSEUnderlayConfigurator.h.

Referenced by handleTimerEvent(), and preKillNode().

int ReaSEUnderlayConfigurator::numCreated
protected

number of overall created overlay terminals

Definition at line 113 of file ReaSEUnderlayConfigurator.h.

Referenced by createNode(), finishUnderlay(), and initializeUnderlay().

int ReaSEUnderlayConfigurator::numKilled
protected

number of overall killed overlay terminals

Definition at line 114 of file ReaSEUnderlayConfigurator.h.

Referenced by finishUnderlay(), initializeUnderlay(), and preKillNode().

int ReaSEUnderlayConfigurator::overlayAccessRouterNum
private

number of overlayAccessRouter

Definition at line 77 of file ReaSEUnderlayConfigurator.h.

int ReaSEUnderlayConfigurator::overlayTerminalNum
private

number of terminal in the overlay

Definition at line 78 of file ReaSEUnderlayConfigurator.h.

std::set<int> ReaSEUnderlayConfigurator::scheduledID
protected

stores nodeIds to prevent migration of prekilled nodes

Definition at line 110 of file ReaSEUnderlayConfigurator.h.

Referenced by handleTimerEvent(), migrateNode(), and preKillNode().

ConnectReaSE* ReaSEUnderlayConfigurator::TerminalConnector
private

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