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 Attributes | |
cStdDev | myStats [NUM_STATS] |
int | numForeignPackets |
int | numSessions |
int | numExchanged |
bool | holdsSession |
double | actualValue |
I3Identifier | clientIdentifier |
I3Identifier | serverIdentifier |
I3Identifier | poolIdentifier |
Definition at line 84 of file I3Session.cc.
void I3SessionClient::deliver | ( | I3Trigger & | trigger, | |
I3IdentifierStack & | stack, | |||
cPacket * | msg | |||
) | [virtual] |
Delivers packets coming from I3 - should be overwritten by application.
trigger | Application trigger to which the packet was sent | |
stack | Identifier stack passed from I3 | |
msg | Arriving 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; numExchanged++; actualValue = smsg->getValue(); sendPacket(serverIdentifier, msg); } else { numForeignPackets++; //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()); sendPacket(serverIdentifier, newMsg); if (int(par("sessionMobilityType")) == WAIT_CONFIRMATION) { // send confirmation SessionMsg *newMsg = new SessionMsg(); newMsg->setType(TRIGGER_CONFIRMATION); newMsg->setValue(0); newMsg->setSource(poolIdentifier); sendPacket(smsg->getSource(), newMsg); } delete smsg; cMessage *msg = new cMessage(); msg->setKind(TYPE_CHANGE_SESSION); scheduleAt(simTime() + int(par("sessionTime")), msg); numSessions++; getParentModule()->bubble("Got session!"); } else if (smsg->getType() == TRIGGER_CONFIRMATION) { // only for WAIT_CONFIRMATION removeTrigger(clientIdentifier); 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.
msg | Timer 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"))) { case DONT_REMOVE: case WAIT_CONFIRMATION: break; case REMOVE_AT_ONCE: removeTrigger(clientIdentifier); break; case WAIT_STATIC: 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(); newMsg->setType(CHANGE_SESSION); newMsg->setValue(actualValue); newMsg->setSource(poolIdentifier); 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."); removeTrigger(clientIdentifier); //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.
stage | Initialization stage passed from initialize() |
Reimplemented from I3BaseApp.
Definition at line 108 of file I3Session.cc.
{ holdsSession = false; numForeignPackets = 0; numSessions = 0; numExchanged = 0; WATCH(numForeignPackets); clientIdentifier.createFromHash("Client"); serverIdentifier.createFromHash("Server"); }
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.
{ poolIdentifier.createFromHash("Pool"); poolIdentifier.createRandomSuffix(); insertTrigger(poolIdentifier); }
double I3SessionClient::actualValue |
Definition at line 93 of file I3Session.cc.
Referenced by deliver(), and handleTimerEvent().
Definition at line 94 of file I3Session.cc.
Referenced by deliver(), handleTimerEvent(), initializeApp(), and I3SessionClientStarter::initializeI3().
Definition at line 92 of file I3Session.cc.
Referenced by deliver(), handleTimerEvent(), initializeApp(), and I3SessionClientStarter::initializeI3().
cStdDev I3SessionClient::myStats[NUM_STATS] |
Definition at line 87 of file I3Session.cc.
Referenced by handleTimerEvent().
Definition at line 91 of file I3Session.cc.
Referenced by deliver(), finish(), and initializeApp().
Definition at line 89 of file I3Session.cc.
Referenced by deliver(), finish(), and initializeApp().
Definition at line 90 of file I3Session.cc.
Referenced by deliver(), finish(), and initializeApp().
Definition at line 96 of file I3Session.cc.
Referenced by deliver(), handleTimerEvent(), and initializeI3().
Definition at line 95 of file I3Session.cc.
Referenced by deliver(), initializeApp(), and I3SessionClientStarter::initializeI3().