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.
00126 { 00127 SessionMsg *smsg = check_and_cast<SessionMsg*>(msg); 00128 00129 if (smsg->getType() == PAYLOAD) { 00130 if (holdsSession) { 00131 //std::cout << "Got value " << smsg->getValue() << ", resending..." << endl; 00132 numExchanged++; 00133 actualValue = smsg->getValue(); 00134 sendPacket(serverIdentifier, msg); 00135 } else { 00136 numForeignPackets++; 00137 //std::cout << "Foreign packet at " << nodeIPAddress << endl; 00138 delete msg; 00139 } 00140 00141 } else if (smsg->getType() == CHANGE_SESSION) { 00142 00143 //cout << "Insert new trigger" << nodeIPAddress << endl; 00144 /* resume session */ 00145 insertTrigger(clientIdentifier, int(par("sessionMobilityType")) != DONT_REMOVE); // renew only if type != DONT_REMOVE 00146 holdsSession = true; 00147 00148 SessionMsg *newMsg = new SessionMsg(); 00149 newMsg->setType(PAYLOAD); 00150 newMsg->setValue(smsg->getValue()); 00151 sendPacket(serverIdentifier, newMsg); 00152 00153 if (int(par("sessionMobilityType")) == WAIT_CONFIRMATION) { 00154 // send confirmation 00155 SessionMsg *newMsg = new SessionMsg(); 00156 newMsg->setType(TRIGGER_CONFIRMATION); 00157 newMsg->setValue(0); 00158 newMsg->setSource(poolIdentifier); 00159 sendPacket(smsg->getSource(), newMsg); 00160 } 00161 delete smsg; 00162 00163 cMessage *msg = new cMessage(); 00164 msg->setKind(TYPE_CHANGE_SESSION); 00165 scheduleAt(simTime() + int(par("sessionTime")), msg); 00166 numSessions++; 00167 00168 getParentModule()->bubble("Got session!"); 00169 00170 } else if (smsg->getType() == TRIGGER_CONFIRMATION) { // only for WAIT_CONFIRMATION 00171 removeTrigger(clientIdentifier); 00172 getParentModule()->bubble("Got confirmation for erase."); 00173 delete smsg; 00174 00175 } else { 00176 // ?? 00177 delete smsg; 00178 } 00179 }
void I3SessionClient::finish | ( | ) |
Definition at line 181 of file I3Session.cc.
00181 { 00182 recordScalar("Client packets received", numExchanged); 00183 recordScalar("Client wrong received ", numForeignPackets); 00184 recordScalar("Client session changed ", numSessions); 00185 00186 }
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.
00188 { 00189 if (msg->getKind() == TYPE_CHANGE_SESSION) { 00190 myStats[STAT_CHANGE].collect(simTime()); 00191 switch (int(par("sessionMobilityType"))) { 00192 case DONT_REMOVE: 00193 case WAIT_CONFIRMATION: 00194 break; 00195 case REMOVE_AT_ONCE: 00196 removeTrigger(clientIdentifier); 00197 break; 00198 case WAIT_STATIC: 00199 cMessage *msg = new cMessage(); 00200 msg->setKind(TYPE_REMOVE_TRIGGER); 00201 scheduleAt(simTime() + int(par("sessionMobilityWait")), msg); 00202 break; 00203 } 00204 holdsSession = false; 00205 00206 /* cede session */ 00207 I3Identifier sessionId; 00208 00209 sessionId.createFromHash("Pool"); 00210 sessionId.createRandomSuffix(); 00211 00212 SessionMsg *newMsg = new SessionMsg(); 00213 newMsg->setType(CHANGE_SESSION); 00214 newMsg->setValue(actualValue); 00215 newMsg->setSource(poolIdentifier); 00216 sendPacket(sessionId, newMsg); 00217 00218 getParentModule()->bubble("Ceding session..."); 00219 delete msg; 00220 00221 } else if (msg->getKind() == TYPE_REMOVE_TRIGGER) { // for WAIT_STATIC only 00222 getParentModule()->bubble("Timer ticked for erase."); 00223 removeTrigger(clientIdentifier); 00224 //cout << "Delete old trigger " << nodeIPAddress << endl; 00225 delete msg; 00226 } 00227 }
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.
00109 { 00110 holdsSession = false; 00111 numForeignPackets = 0; 00112 numSessions = 0; 00113 numExchanged = 0; 00114 WATCH(numForeignPackets); 00115 clientIdentifier.createFromHash("Client"); 00116 serverIdentifier.createFromHash("Server"); 00117 }
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.
00119 { 00120 poolIdentifier.createFromHash("Pool"); 00121 poolIdentifier.createRandomSuffix(); 00122 insertTrigger(poolIdentifier); 00123 }
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().