OverSim
I3SessionClient Class Reference
Inheritance diagram for I3SessionClient:
I3BaseApp I3SessionClientStarter

Public Member Functions

void initializeApp (int stage)
 App initialization - should be overwritten by application.
virtual void initializeI3 ()
 Application I3 initialize - should be overwritten by application.
void deliver (I3Trigger &trigger, I3IdentifierStack &stack, cPacket *msg)
 Delivers packets coming from I3 - should be overwritten by application.
void handleTimerEvent (cMessage *msg)
 Handles timers - should be overwritten by application.
void finish ()
- Public Member Functions inherited from I3BaseApp
 I3BaseApp ()
 Constructor.
 ~I3BaseApp ()
 Destructor.

Public Attributes

cStdDev myStats [NUM_STATS]
int numForeignPackets
int numSessions
int numExchanged
bool holdsSession
double actualValue
I3Identifier clientIdentifier
I3Identifier serverIdentifier
I3Identifier poolIdentifier

Additional Inherited Members

- 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.
void bootstrapI3 ()
 Internal I3 bootstrap - connects to I3, inserts sampling triggers and initializes timers.
virtual void handleUDPMessage (cMessage *msg)
 Handles messages incoming from UDP gate.
void handleMessage (cMessage *msg)
 Handles incoming messages.
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 84 of file I3Session.cc.

Member Function Documentation

void I3SessionClient::deliver ( I3Trigger trigger,
I3IdentifierStack stack,
cPacket *  msg 
)
virtual

Delivers packets coming from I3 - should be overwritten by application.

Parameters
triggerApplication trigger to which the packet was sent
stackIdentifier stack passed from I3
msgArriving message

Reimplemented from I3BaseApp.

Definition at line 125 of file I3Session.cc.

{
SessionMsg *smsg = check_and_cast<SessionMsg*>(msg);
if (smsg->getType() == PAYLOAD) {
if (holdsSession) {
//std::cout << "Got value " << smsg->getValue() << ", resending..." << endl;
actualValue = smsg->getValue();
} else {
//std::cout << "Foreign packet at " << nodeIPAddress << endl;
delete msg;
}
} else if (smsg->getType() == CHANGE_SESSION) {
//cout << "Insert new trigger" << nodeIPAddress << endl;
/* resume session */
insertTrigger(clientIdentifier, int(par("sessionMobilityType")) != DONT_REMOVE); // renew only if type != DONT_REMOVE
holdsSession = true;
SessionMsg *newMsg = new SessionMsg();
newMsg->setType(PAYLOAD);
newMsg->setValue(smsg->getValue());
if (int(par("sessionMobilityType")) == WAIT_CONFIRMATION) {
// send confirmation
SessionMsg *newMsg = new SessionMsg();
newMsg->setValue(0);
sendPacket(smsg->getSource(), newMsg);
}
delete smsg;
cMessage *msg = new cMessage();
msg->setKind(TYPE_CHANGE_SESSION);
scheduleAt(simTime() + int(par("sessionTime")), msg);
getParentModule()->bubble("Got session!");
} else if (smsg->getType() == TRIGGER_CONFIRMATION) { // only for WAIT_CONFIRMATION
getParentModule()->bubble("Got confirmation for erase.");
delete smsg;
} else {
// ??
delete smsg;
}
}
void I3SessionClient::finish ( )

Definition at line 181 of file I3Session.cc.

{
recordScalar("Client packets received", numExchanged);
recordScalar("Client wrong received ", numForeignPackets);
recordScalar("Client session changed ", numSessions);
}
void I3SessionClient::handleTimerEvent ( cMessage *  msg)
virtual

Handles timers - should be overwritten by application.

Parameters
msgTimer to be handled

Reimplemented from I3BaseApp.

Definition at line 188 of file I3Session.cc.

{
if (msg->getKind() == TYPE_CHANGE_SESSION) {
myStats[STAT_CHANGE].collect(simTime());
switch (int(par("sessionMobilityType"))) {
break;
break;
cMessage *msg = new cMessage();
msg->setKind(TYPE_REMOVE_TRIGGER);
scheduleAt(simTime() + int(par("sessionMobilityWait")), msg);
break;
}
holdsSession = false;
/* cede session */
I3Identifier sessionId;
sessionId.createFromHash("Pool");
sessionId.createRandomSuffix();
SessionMsg *newMsg = new SessionMsg();
sendPacket(sessionId, newMsg);
getParentModule()->bubble("Ceding session...");
delete msg;
} else if (msg->getKind() == TYPE_REMOVE_TRIGGER) { // for WAIT_STATIC only
getParentModule()->bubble("Timer ticked for erase.");
//cout << "Delete old trigger " << nodeIPAddress << endl;
delete msg;
}
}
void I3SessionClient::initializeApp ( int  stage)
virtual

App initialization - should be overwritten by application.

I3 related commands should go in initializeI3.

Parameters
stageInitialization stage passed from initialize()

Reimplemented from I3BaseApp.

Definition at line 108 of file I3Session.cc.

void I3SessionClient::initializeI3 ( )
virtual

Application I3 initialize - should be overwritten by application.

Reimplemented from I3BaseApp.

Reimplemented in I3SessionClientStarter.

Definition at line 119 of file I3Session.cc.

Referenced by I3SessionClientStarter::initializeI3().

Member Data Documentation

double I3SessionClient::actualValue

Definition at line 93 of file I3Session.cc.

I3Identifier I3SessionClient::clientIdentifier

Definition at line 94 of file I3Session.cc.

bool I3SessionClient::holdsSession

Definition at line 92 of file I3Session.cc.

cStdDev I3SessionClient::myStats[NUM_STATS]

Definition at line 87 of file I3Session.cc.

int I3SessionClient::numExchanged

Definition at line 91 of file I3Session.cc.

int I3SessionClient::numForeignPackets

Definition at line 89 of file I3Session.cc.

int I3SessionClient::numSessions

Definition at line 90 of file I3Session.cc.

I3Identifier I3SessionClient::poolIdentifier

Definition at line 96 of file I3Session.cc.

I3Identifier I3SessionClient::serverIdentifier

Definition at line 95 of file I3Session.cc.


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