OverSim
SingleHostUnderlayConfigurator Class Reference

#include <SingleHostUnderlayConfigurator.h>

Inheritance diagram for SingleHostUnderlayConfigurator:
UnderlayConfigurator

Protected Member Functions

void initializeUnderlay (int stage)
 Init method for derived underlay configurators.
void finishUnderlay ()
 Cleans up concrete underlay configurator.
void setDisplayString ()
 Sets display string.
void handleTimerEvent (cMessage *msg)
TransportAddresscreateNode (NodeType type, bool initialize)
 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.
- 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.

Additional Inherited Members

- 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 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
- Static Protected Attributes inherited from UnderlayConfigurator
static const int NUM_COLORS = 8
static const char * colorNames []

Detailed Description

Definition at line 36 of file SingleHostUnderlayConfigurator.h.

Member Function Documentation

TransportAddress* SingleHostUnderlayConfigurator::createNode ( NodeType  type,
bool  initialize 
)
inlineprotectedvirtual

Creates an overlay node.

Parameters
typeNodeType of the node to create
initializeare we in init phase?

Implements UnderlayConfigurator.

Definition at line 46 of file SingleHostUnderlayConfigurator.h.

{error("createNode can't be used with singleHostUnderlay!"); return NULL;}
void SingleHostUnderlayConfigurator::finishUnderlay ( )
protectedvirtual

Cleans up concrete underlay configurator.

Reimplemented from UnderlayConfigurator.

Definition at line 157 of file SingleHostUnderlayConfigurator.cc.

{
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 SingleHostUnderlayConfigurator::handleTimerEvent ( cMessage *  msg)
protectedvirtual

Reimplemented from UnderlayConfigurator.

Definition at line 139 of file SingleHostUnderlayConfigurator.cc.

{
if (std::string(msg->getName()) != "init phase finished") {
throw cRuntimeError("unknown self-message received");
}
delete msg;
}
void SingleHostUnderlayConfigurator::initializeUnderlay ( int  stage)
protectedvirtual

Init method for derived underlay configurators.

Implements UnderlayConfigurator.

Definition at line 54 of file SingleHostUnderlayConfigurator.cc.

{
IPvXAddress addr;
if(stage != MAX_STAGE_UNDERLAY)
return;
// Set IP, Routes, etc
cModule* node = getParentModule()->getSubmodule("overlayTerminal", 0);
std::string nodeInterface = std::string(par("nodeInterface").stringValue());
std::string stunServer = std::string(par("stunServer").stringValue());
std::string nodeIP = std::string(par("nodeIP").stringValue());
if (!nodeInterface.size() && !stunServer.size() && !nodeIP.size()) {
throw cRuntimeError("SingleHostConfigurator::initializeUnderlay(): "
"Please specify at least one of "
"**.nodeInterface, **.nodeIP, or **.stunServer");
}
if (nodeInterface.size()) {
#ifndef _WIN32
SOCKET sock_fd;
struct ifreq req;
if ((sock_fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP)) !=
INVALID_SOCKET) {
snprintf(req.ifr_name, sizeof(req.ifr_name), "%s", nodeInterface.c_str());
if (!ioctl(sock_fd, SIOCGIFADDR, &req)) {
addr = IPAddress(inet_ntoa(((struct sockaddr_in *)
(&req.ifr_addr))->sin_addr));
} else {
throw cRuntimeError("SingleHostConfigurator::"
"initializeUnderlay(): "
"Invalid interface!");
}
close(sock_fd);
}
#else
throw cRuntimeError("SingleHostConfigurator::"
"initializeUnderlay(): "
"**.nodeInterface parameter not supported on WIN32 yet!");
#endif
} else if (nodeIP.size()) {
addr = IPAddress(nodeIP.c_str());
}
IPvXAddress gw = addr;
InterfaceEntry* ifEntry = IPAddressResolver().interfaceTableOf(node)->
getInterfaceByName("outDev");
IRoutingTable* rTable = check_and_cast<IRoutingTable*>(node->getSubmodule("routingTable", 0));
ifEntry->ipv4Data()->setIPAddress(addr.get4());
ifEntry->ipv4Data()->setNetmask(IPAddress::ALLONES_ADDRESS);
IPRoute* te = new IPRoute();
te->setHost(IPAddress::UNSPECIFIED_ADDRESS);
te->setNetmask(IPAddress::UNSPECIFIED_ADDRESS);
te->setGateway(gw.get4());
te->setInterface(ifEntry);
te->setType(IPRoute::REMOTE);
te->setSource(IPRoute::MANUAL);
rTable->addRoute(te);
//add node to bootstrap oracle
PeerInfo* info = new PeerInfo(0, node->getId(), NULL);
globalNodeList->addPeer(addr, info);
if (strlen(par("bootstrapIP")) > 0) {
PeerInfo* bootstrapInfo = new PeerInfo(0, -1, NULL);
globalNodeList->addPeer(IPAddress(par("bootstrapIP").stringValue()),
bootstrapInfo);
IPAddress(par("bootstrapIP").stringValue()), par("bootstrapPort")));
}
// update display
scheduleAt(simTime(), new cMessage("init phase finished"));
}
void SingleHostUnderlayConfigurator::migrateNode ( NodeType  type,
TransportAddress addr = NULL 
)
inlineprotectedvirtual

Migrates overlay nodes from one access net to another.

Parameters
typeNodeType of the node to migrate
addrNULL for random node

Implements UnderlayConfigurator.

Definition at line 48 of file SingleHostUnderlayConfigurator.h.

{error("migrateNode can't be used with singleHostUnderlay!");}
void SingleHostUnderlayConfigurator::preKillNode ( NodeType  type,
TransportAddress addr = NULL 
)
inlineprotectedvirtual

Notifies and schedules overlay nodes for removal.

Parameters
typeNodeType of the node to remove
addrNULL for random node

Implements UnderlayConfigurator.

Definition at line 47 of file SingleHostUnderlayConfigurator.h.

{error("preKillNode can't be used with singleHostUnderlay!");}
void SingleHostUnderlayConfigurator::setDisplayString ( )
protectedvirtual

Sets display string.

Implements UnderlayConfigurator.

Definition at line 149 of file SingleHostUnderlayConfigurator.cc.

Referenced by initializeUnderlay().

{
// updates the statistics display string
char buf[80];
sprintf(buf, "%i overlay terminals", overlayTerminalCount);
getDisplayString().setTagArg("t", 0, buf);
}

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