OverSim
I3HostMobility Class Reference
Inheritance diagram for I3HostMobility:
I3BaseApp

Private Member Functions

void initializeApp (int stage)
void initializeI3 ()
void handleTimerEvent (cMessage *msg)
void handleUDPMessage (cMessage *msg)
void deliver (I3Trigger &trigger, I3IdentifierStack &stack, cPacket *msg)
void doMobilityEvent (I3MobilityStage stage)
void discoverPartners ()
void finish ()

Private Attributes

bool checkedPartners
int numSentPackets
std::set< int > packets
std::vector< I3Identifierpartners
I3Identifier poolId
I3Identifier closestId

Additional Inherited Members

- Public Member Functions inherited from I3BaseApp
 I3BaseApp ()
 Constructor.
 ~I3BaseApp ()
 Destructor.
- Protected Types inherited from I3BaseApp
enum  I3MobilityStage { I3_MOBILITY_BEFORE_UPDATE, I3_MOBILITY_UPDATED }
- Protected Member Functions inherited from I3BaseApp
int numInitStages () const
 Returns number of init stages required.
void initialize (int stage)
 Basic initialization.
virtual void initializeApp (int stage)
 App initialization - should be overwritten by application.
void bootstrapI3 ()
 Internal I3 bootstrap - connects to I3, inserts sampling triggers and initializes timers.
virtual void initializeI3 ()
 Application I3 initialize - should be overwritten by application.
virtual void handleTimerEvent (cMessage *msg)
 Handles timers - should be overwritten by application.
virtual void handleUDPMessage (cMessage *msg)
 Handles messages incoming from UDP gate.
void handleMessage (cMessage *msg)
 Handles incoming messages.
virtual void deliver (I3Trigger &trigger, I3IdentifierStack &stack, cPacket *msg)
 Delivers packets coming from I3 - should be overwritten by application.
void sendToI3 (I3Message *msg)
 Sends a message to I3.
void sendThroughUDP (cMessage *msg, const I3IPAddress &ip)
 Sends a message through UDP.
void refreshTriggers ()
 Refreshes (reinserts) stored triggers.
void refreshSamples ()
 Refreshes sampling triggers and selects fastest server as gateway.
I3Identifier retrieveClosestIdentifier ()
void sendPacket (const I3Identifier &id, cPacket *msg, bool useHint=false)
 Routes a packet through I3, passing an identifier stack composed of a single identifier.
void sendPacket (const I3IdentifierStack &stack, cPacket *msg, bool useHint=false)
 Routes a packet through I3.
void insertTrigger (const I3Identifier &identifier, bool store=true)
 Inserts a trigger into I3, composed by the given identifier and an identifier stack containing only this node's IP address.
void insertTrigger (const I3Identifier &identifier, const I3IdentifierStack &stack, bool store=true)
 Inserts a trigger into I3 with the given identifier and identifier stack.
void insertTrigger (const I3Trigger &t, bool store=true)
 Inserts the given trigger into I3.
void removeTrigger (const I3Identifier &identifier)
 Removes all triggers from the list of inserted triggers whose identifiers equal the one given.
void removeTrigger (const I3Trigger &trigger)
 Removes a trigger from I3.
std::set< I3Trigger > & getInsertedTriggers ()
 Returns the list of inserted triggers.
void receiveChangeNotification (int category, const cPolymorphic *details)
virtual void doMobilityEvent (I3MobilityStage stage)
- Protected Attributes inherited from I3BaseApp
int numSent
 Number of sent messages.
int sentBytes
int numReceived
 Number of received messages.
int receivedBytes
int numIsolations
 Number of times this node has been isolated - i.e.
IPvXAddress nodeIPAddress
 Cached IP address of this node.
std::set< I3TriggerinsertedTriggers
 Stored I3 triggers sent from this node, to be refreshed automatically.
std::map< I3Identifier,
I3CachedServer
samplingCache
std::map< I3Identifier,
I3CachedServer
identifierCache
I3CachedServer gateway
cMessage * refreshTriggersTimer
int refreshTriggersTime
cMessage * refreshSamplesTimer
int refreshSamplesTime
cMessage * initializeTimer
cMessage * bootstrapTimer

Detailed Description

Definition at line 45 of file I3HostMobility.cc.

Member Function Documentation

void I3HostMobility::deliver ( I3Trigger trigger,
I3IdentifierStack stack,
cPacket *  msg 
)
private

Definition at line 102 of file I3HostMobility.cc.

{
MessageContent *mc = (MessageContent*)msg->getContextPointer();
switch (msg->getKind()) {
{
I3Identifier otherId = mc->source;
msg->setKind(MSG_REPLY_ID);
sendPacket(otherId, msg);
break;
}
partners.push_back(mc->source);
delete mc;
delete msg;
break;
case MSG_PING:
msg->setKind(MSG_REPLY);
sendPacket(mc->source, msg);
break;
case MSG_REPLY:
packets.erase(mc->id);
delete mc;
delete msg;
break;
default:
break;
}
}
void I3HostMobility::discoverPartners ( )
private

Definition at line 175 of file I3HostMobility.cc.

{
partners.clear();
for (int i = 0; i < NUM_PARTNERS; i++) {
cPacket *cmsg = new cPacket();
I3Identifier partner;
mc->id = -1;
cmsg->setContextPointer(mc);
cmsg->setKind(MSG_QUERY_ID);
partner.createFromHash("HostMobility");
partner.createRandomSuffix();
sendPacket(partner, cmsg);
}
}
void I3HostMobility::doMobilityEvent ( I3MobilityStage  stage)
private

Definition at line 195 of file I3HostMobility.cc.

{
if (stage == I3_MOBILITY_UPDATED) {
cMessage *msg = new cMessage();
msg->setKind(MSG_TIMER_RESET_ID);
scheduleAt(simTime() + 10, msg);
}
}
void I3HostMobility::finish ( )
private

Definition at line 73 of file I3HostMobility.cc.

{
recordScalar("Number of sent packets", numSentPackets);
recordScalar("Number of lost packets", packets.size());
}
void I3HostMobility::handleTimerEvent ( cMessage *  msg)
private

Definition at line 133 of file I3HostMobility.cc.

{
switch (msg->getKind()) {
case MSG_TIMER:
// partners.size() != NUM_PARTNERS in the unlikely event
// that not all id queries have returned
//if (partners.size() == 0) {
// opp_error("Wtf?!");
//}
for (unsigned int i = 0; i < partners.size(); i++) {
cPacket *cmsg = new cPacket();
mc->id = numSentPackets++;
cmsg->setContextPointer(mc);
cmsg->setKind(MSG_PING);
cmsg->setBitLength((32 + intrand(512)) * 8);
sendPacket(partners[i], cmsg, true);
}
scheduleAt(simTime() + truncnormal(0.5, 0.1), msg);
} else {
scheduleAt(simTime() + 10, msg);
}
break;
delete msg;
break;
checkedPartners = false;
scheduleAt(simTime() + 60, msg);
break;
default:
break;
}
}
void I3HostMobility::handleUDPMessage ( cMessage *  msg)
private

Definition at line 98 of file I3HostMobility.cc.

void I3HostMobility::initializeApp ( int  stage)
private

Definition at line 67 of file I3HostMobility.cc.

void I3HostMobility::initializeI3 ( )
private

Definition at line 78 of file I3HostMobility.cc.

{
checkedPartners = false;
poolId.createFromHash("HostMobility");
poolId.setName("HostMobility");
cMessage *msg = new cMessage();
msg->setKind(MSG_TIMER);
scheduleAt(simTime() + 5, msg);
cMessage *nmsg = new cMessage();
msg->setKind(MSG_TIMER_REDISCOVER);
scheduleAt(simTime() + 60, nmsg);
}

Member Data Documentation

bool I3HostMobility::checkedPartners
private

Definition at line 46 of file I3HostMobility.cc.

I3Identifier I3HostMobility::closestId
private

Definition at line 52 of file I3HostMobility.cc.

int I3HostMobility::numSentPackets
private

Definition at line 48 of file I3HostMobility.cc.

std::set<int> I3HostMobility::packets
private

Definition at line 49 of file I3HostMobility.cc.

std::vector<I3Identifier> I3HostMobility::partners
private

Definition at line 50 of file I3HostMobility.cc.

I3Identifier I3HostMobility::poolId
private

Definition at line 51 of file I3HostMobility.cc.


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