I3BaseApp Class Reference

#include <I3BaseApp.h>

Inheritance diagram for I3BaseApp:

I3Anycast I3Composite I3HostMobility I3LatencyStretch I3Multicast I3SessionClient I3SessionServer I3Triggers I3TRTClient

List of all members.


Detailed Description

Basic template class for I3 applications.

Author:
Antonio Zea

Public Member Functions

 I3BaseApp ()
 Constructor.
 ~I3BaseApp ()
 Destructor.

Protected Types

enum  I3MobilityStage { I3_MOBILITY_BEFORE_UPDATE, I3_MOBILITY_UPDATED }

Protected Member Functions

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, cMessage *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, cMessage *msg, bool useHint=false)
 Routes a packet through I3, passing an identifier stack composed of a single identifier.
void sendPacket (const I3IdentifierStack &stack, cMessage *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, cPolymorphic *details)
virtual void doMobilityEvent (I3MobilityStage stage)

Protected Attributes

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

Private Attributes

bool mobilityInStages

Classes

struct  I3CachedServer

Member Enumeration Documentation

enum I3BaseApp::I3MobilityStage [protected]

Enumerator:
I3_MOBILITY_BEFORE_UPDATE 
I3_MOBILITY_UPDATED 
00060                          {
00061         I3_MOBILITY_BEFORE_UPDATE,
00062         I3_MOBILITY_UPDATED
00063     };


Constructor & Destructor Documentation

I3BaseApp::I3BaseApp (  ) 

Constructor.

00057 {
00058 }

I3BaseApp::~I3BaseApp (  ) 

Destructor.

00061 {
00062 }


Member Function Documentation

int I3BaseApp::numInitStages (  )  const [protected]

Returns number of init stages required.

00065 {
00066     return MAX_STAGE_APP + 1;
00067 }

void I3BaseApp::initialize ( int  stage  )  [protected]

Basic initialization.

00070 {
00071     if (stage != MIN_STAGE_APP) return;
00072 
00073     nodeIPAddress = IPAddressResolver().addressOf(parentModule()).get4();
00074 
00075     bindToPort(par("clientPort"));
00076     /*    NotificationBoardAccess().get()->subscribe(this, NF_HOSTPOSITION_BEFOREUPDATE);
00077         NotificationBoardAccess().get()->subscribe(this, NF_HOSTPOSITION_UPDATED);*/
00078 
00079     displayString().setTagArg("i", 0, "i3c");
00080     parentModule()->displayString().removeTag("i2");
00081 
00082     if (int(par("bootstrapTime")) >= int(par("initTime"))) {
00083         opp_error("Parameter bootstrapTime must be smaller than initTime");
00084     }
00085 
00086     bootstrapTimer = new cMessage();
00087     scheduleAt(simulation.simTime() + int(par("bootstrapTime")), bootstrapTimer);
00088 
00089     initializeTimer = new cMessage();
00090     scheduleAt(simulation.simTime() + int(par("initTime")), initializeTimer);
00091 
00092     numSent = 0;
00093     sentBytes = 0;
00094     numReceived = 0;
00095     receivedBytes = 0;
00096     numIsolations = 0;
00097     mobilityInStages = false;
00098 
00099     WATCH(nodeIPAddress);
00100     WATCH(numSent);
00101     WATCH(sentBytes);
00102     WATCH(numReceived);
00103     WATCH(receivedBytes);
00104     WATCH(numIsolations);
00105 
00106 
00107     WATCH_SET(insertedTriggers);
00108     WATCH(gateway);
00109     WATCH_MAP(samplingCache);
00110     WATCH_MAP(identifierCache);
00111 
00112     initializeApp(stage);
00113 }

void I3BaseApp::initializeApp ( int  stage  )  [protected, virtual]

App initialization - should be overwritten by application.

I3 related commands should go in initializeI3.

Parameters:
stage Initialization stage passed from initialize()

Reimplemented in I3Anycast, I3Composite, I3HostMobility, I3LatencyStretch, I3Multicast, I3SessionClient, and I3Triggers.

Referenced by initialize(), I3LatencyStretch::initializeApp(), and I3HostMobility::initializeApp().

00116 {
00117 }

void I3BaseApp::bootstrapI3 (  )  [protected]

Internal I3 bootstrap - connects to I3, inserts sampling triggers and initializes timers.

Referenced by handleMessage().

00120 {
00121     I3IPAddress myAddress(nodeIPAddress, par("clientPort"));
00122 
00123     // TODO: use BootstrapList instead of BootstrapOracle
00124     const NodeHandle handle = BootstrapOracleAccess().get()->getBootstrapNode();
00125     gateway.address = I3IPAddress(handle.ip, par("serverPort"));
00126 
00127     for (int i = 0; i < int(par("cacheSize")); i++) {
00128         I3Identifier id;
00129 
00130         id.createRandomKey();
00131 
00132         ostringstream os;
00133         os << myAddress << " sample" << i;
00134         id.setName(os.str());
00135 
00136         samplingCache[id] = I3CachedServer(); // placeholder
00137 
00138         insertTrigger(id, false);
00139     }
00140 
00141     refreshTriggersTimer = new cMessage();
00142     refreshTriggersTime = par("triggerRefreshTime");
00143     scheduleAt(simulation.simTime() + truncnormal(refreshTriggersTime, refreshTriggersTime / 10),
00144                refreshTriggersTimer);
00145 
00146     refreshSamplesTimer = new cMessage();
00147     refreshSamplesTime = par("sampleRefreshTime");
00148     scheduleAt(simulation.simTime() + truncnormal(refreshSamplesTime, refreshSamplesTime / 10),
00149                refreshSamplesTimer);
00150 }

void I3BaseApp::initializeI3 (  )  [protected, virtual]

Application I3 initialize - should be overwritten by application.

Reimplemented in I3Anycast, I3Composite, I3HostMobility, I3LatencyStretch, I3Multicast, I3SessionServer, I3SessionClient, I3SessionClientStarter, I3TRTClient, and I3Triggers.

Referenced by handleMessage().

00153 {
00154 
00155 }

void I3BaseApp::handleTimerEvent ( cMessage *  msg  )  [protected, virtual]

Handles timers - should be overwritten by application.

Parameters:
msg Timer to be handled

Reimplemented in I3Anycast, I3Composite, I3HostMobility, I3LatencyStretch, I3Multicast, I3SessionClient, I3TRTClient, and I3Triggers.

Referenced by handleMessage().

00192 {
00193     delete msg;
00194 }

void I3BaseApp::handleUDPMessage ( cMessage *  msg  )  [protected, virtual]

Handles messages incoming from UDP gate.

Parameters:
msg Message sent

Reimplemented in I3HostMobility, and I3LatencyStretch.

Referenced by handleMessage(), I3LatencyStretch::handleUDPMessage(), and I3HostMobility::handleUDPMessage().

00197 {
00198     I3Message *i3msg;
00199 
00200     i3msg = dynamic_cast<I3Message*>(msg);
00201     if (i3msg) {
00202         switch (i3msg->getType()) {
00203         case SEND_PACKET:
00204         {
00205             I3SendPacketMessage *smsg;
00206 
00207             smsg = check_and_cast<I3SendPacketMessage*>(msg);
00208             numReceived++;
00209             receivedBytes += smsg->byteLength();
00210 
00211             /* deliver to app */
00212             cMessage *newMessage = smsg->decapsulate();
00213             deliver(smsg->getMatchedTrigger(), smsg->getIdentifierStack(), newMessage);
00214 
00215             break;
00216         }
00217         case QUERY_REPLY:
00218         {
00219             I3QueryReplyMessage *pmsg;
00220             pmsg = check_and_cast<I3QueryReplyMessage*>(msg);
00221             I3Identifier &id = pmsg->getIdentifier();
00222 
00223             identifierCache[id].address = pmsg->getSource();
00224             identifierCache[id].lastReply = simulation.simTime();
00225             identifierCache[id].roundTripTime = simulation.simTime() - pmsg->getSendingTime();
00226 
00227             if (samplingCache.count(id) != 0) {
00228                 samplingCache[id] = identifierCache[id];
00229             }
00230             break;
00231         }
00232         default:
00233             /* shouldn't get here */
00234             break;
00235         }
00236     }
00237     delete msg;
00238 }

void I3BaseApp::handleMessage ( cMessage *  msg  )  [protected]

Handles incoming messages.

Parameters:
msg Incoming message
00158 {
00159     if (msg->isSelfMessage()) {
00160         if (msg == bootstrapTimer) {
00161             bootstrapI3();
00162             delete msg;
00163             bootstrapTimer = 0;
00164         } else if (msg == initializeTimer)  {
00165             initializeI3();
00166             delete msg;
00167             initializeTimer = 0;
00168         } else if (msg == refreshTriggersTimer) {
00169             refreshTriggers();
00170             scheduleAt(simulation.simTime() + truncnormal(refreshTriggersTime, refreshTriggersTime / 10),
00171                        refreshTriggersTimer);
00172         } else if (msg == refreshSamplesTimer) {
00173             refreshSamples();
00174             scheduleAt(simulation.simTime() + truncnormal(refreshSamplesTime, refreshSamplesTime / 10),
00175                        refreshSamplesTimer);
00176         } else {
00177             handleTimerEvent(msg);
00178         }
00179     } else if (msg->arrivedOn("from_udp")) {
00180         handleUDPMessage(msg);
00181     } else {
00182         delete msg;
00183     }
00184 }

void I3BaseApp::deliver ( I3Trigger trigger,
I3IdentifierStack stack,
cMessage *  msg 
) [protected, virtual]

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

Parameters:
trigger Application trigger to which the packet was sent
stack Identifier stack passed from I3
msg Arriving message

Reimplemented in I3Anycast, I3Composite, I3HostMobility, I3LatencyStretch, I3Multicast, I3SessionServer, I3SessionClient, and I3Triggers.

Referenced by handleUDPMessage().

00187 {
00188     delete msg;
00189 }

void I3BaseApp::sendToI3 ( I3Message *  msg  )  [protected]

Sends a message to I3.

Parameters:
msg Message to be sent
00241 {
00242     sendThroughUDP(msg, gateway.address);
00243 }

void I3BaseApp::sendThroughUDP ( cMessage *  msg,
const I3IPAddress ip 
) [protected]

Sends a message through UDP.

Parameters:
msg Message to be sent
ip IP of destination

Referenced by I3TRTClient::handleTimerEvent(), I3LatencyStretch::handleTimerEvent(), insertTrigger(), removeTrigger(), sendPacket(), and sendToI3().

00246 {
00247     msg->removeControlInfo();
00248     msg->setKind(UDP_C_DATA);
00249 
00250     UDPControlInfo* udpControlInfo = new UDPControlInfo();
00251     udpControlInfo->setSrcAddr(nodeIPAddress);
00252     udpControlInfo->setSrcPort(par("clientPort"));
00253 
00254     udpControlInfo->setDestAddr(add.ip);
00255     udpControlInfo->setDestPort(add.port);
00256 
00257     msg->setControlInfo(udpControlInfo);
00258     send(msg, "to_udp");
00259 }

void I3BaseApp::refreshTriggers (  )  [protected]

Refreshes (reinserts) stored triggers.

Referenced by handleMessage().

00262 {
00263     I3IPAddress myAddress(nodeIPAddress, par("clientPort"));
00264     map<I3Identifier, I3CachedServer>::iterator mit;
00265 
00266 
00267     // pick fastest I3 server as gateway
00268     gateway.roundTripTime = int(par("serverTimeout"));
00269     I3Identifier gatewayId;
00270     for (mit = samplingCache.begin(); mit != samplingCache.end(); mit++) {
00271         if (gateway.roundTripTime > mit->second.roundTripTime) {
00272             gatewayId = mit->first;
00273             gateway = mit->second;
00274         }
00275     }
00276 
00277     // check if gateway has timeout'ed
00278     if (simulation.simTime() - gateway.lastReply >= int(par("serverTimeout"))) {
00279         // We have a small problem here: if the fastest server has timeout,
00280         // that means the previous gateway had stopped responding some time before and no triggers were refreshed.
00281         // Since all servers have timeout'ed by now and we can't trust return times, pick a random server and hope that one is alive.
00282         int random = intrand(samplingCache.size()), i;
00283 
00284         EV << "Gateway timeout at " << nodeIPAddress
00285            << ", time " << simulation.simTime()
00286            << "; expired gateway is " << gateway << "(" << gatewayId << ") "
00287            << " with last reply at " << gateway.lastReply << endl;
00288 
00289         for (i = 0, mit = samplingCache.begin(); i < random; i++, mit++);
00290         gateway = mit->second;
00291         EV << "New gateway for " << nodeIPAddress << " is " << gateway << endl;
00292 
00293         if (gateway.roundTripTime > 2 * int(par("serverTimeout"))) {
00294             EV << "New gateway's (" << gateway << ") rtt for " <<
00295             nodeIPAddress << " too high... marking as isolated!" << endl;
00296             numIsolations++;
00297             const NodeHandle handle = BootstrapOracleAccess().get()->getBootstrapNode();
00298             gateway.address = I3IPAddress(handle.ip, par("serverPort"));
00299         }
00300     }
00301 
00302     /* ping gateway */
00303     insertTrigger(gatewayId, false);
00304 //    cout << "Client " << nodeIPAddress << " pings " << gatewayId << endl;
00305 
00306     /* reinsert stored triggers */
00307     set<I3Trigger>::iterator it;
00308     for (it = insertedTriggers.begin(); it != insertedTriggers.end(); it++) {
00309         insertTrigger(*it, false);
00310     }
00311 
00312     /* now that we are refreshing stuff, might as well erase old identifier cache entries */
00313     for (mit = identifierCache.begin(); mit != identifierCache.end(); mit++) {
00314         if (mit->second.lastReply - simulation.simTime() > int(par("idStoreTime"))) {
00315             identifierCache.erase(mit);
00316         }
00317     }
00318 
00319 }

void I3BaseApp::refreshSamples (  )  [protected]

Refreshes sampling triggers and selects fastest server as gateway.

Referenced by handleMessage().

00321                                {
00322     map<I3Identifier, I3CachedServer>::iterator mit;
00323 
00324     EV << "Refresh samples!" << endl;
00325     /* reinsert sample triggers */
00326     for (mit = samplingCache.begin(); mit != samplingCache.end(); mit++) {
00327         insertTrigger(mit->first, false);
00328     }
00329 }

I3Identifier I3BaseApp::retrieveClosestIdentifier (  )  [protected]

Referenced by I3HostMobility::handleTimerEvent(), I3LatencyStretch::initializeI3(), and I3HostMobility::initializeI3().

00332 {
00333     simtime_t time;
00334     I3Identifier id;
00335     map<I3Identifier, I3CachedServer>::iterator mit;
00336     I3IPAddress myAddress(nodeIPAddress, par("clientPort"));
00337 
00338     time = DBL_MAX;
00339     for (mit = samplingCache.begin(); mit != samplingCache.end(); mit++) {
00340         if (time > mit->second.roundTripTime) {
00341             time = mit->second.roundTripTime;
00342             id = mit->first;
00343         }
00344     }
00345     samplingCache.erase(id);
00346 
00347     I3Identifier rid;
00348     rid.createRandomKey();
00349 
00350     ostringstream os;
00351     os << myAddress << " sample";
00352     rid.setName(os.str());
00353 
00354     samplingCache[rid] = I3CachedServer(); // placeholder
00355     insertTrigger(rid, false);
00356 
00357     return id;
00358 }

void I3BaseApp::sendPacket ( const I3Identifier id,
cMessage *  msg,
bool  useHint = false 
) [protected]

Routes a packet through I3, passing an identifier stack composed of a single identifier.

Parameters:
id Destination identifier
msg Message to be sent
useHint Use address in server cache if existant

Referenced by I3Composite::createMessage(), I3Triggers::deliver(), I3SessionClient::deliver(), I3SessionServer::deliver(), I3LatencyStretch::deliver(), I3HostMobility::deliver(), I3Composite::deliver(), I3Anycast::deliver(), I3HostMobility::discoverPartners(), I3Triggers::handleTimerEvent(), I3SessionClient::handleTimerEvent(), I3Multicast::handleTimerEvent(), I3LatencyStretch::handleTimerEvent(), I3HostMobility::handleTimerEvent(), I3Anycast::handleTimerEvent(), and I3SessionClientStarter::initializeI3().

00361 {
00362     I3IdentifierStack stack;
00363 
00364     stack.push(id);
00365     sendPacket(stack, msg, useHint);
00366 }

void I3BaseApp::sendPacket ( const I3IdentifierStack stack,
cMessage *  msg,
bool  useHint = false 
) [protected]

Routes a packet through I3.

Parameters:
stack Destination identifier stack
msg Message to be sent
useHint Use address in server cache if existant
00369 {
00370     I3SendPacketMessage *smsg;
00371 
00372     smsg = new I3SendPacketMessage();
00373     smsg->setLength(SEND_PACKET_L(smsg));
00374     smsg->encapsulate(msg);
00375     smsg->setIdentifierStack(stack);
00376 
00377     smsg->setSendReply(useHint);
00378     if (useHint) {
00379         I3IPAddress add(nodeIPAddress, par("clientPort"));
00380         smsg->setSource(add);
00381     }
00382 
00383     numSent++;
00384     sentBytes += smsg->byteLength();
00385 
00386     I3SubIdentifier subid = stack.peek(); // first check where the packet should go
00387     if (subid.getType() == I3SubIdentifier::IPAddress) { // if it's an IP address
00388         smsg->getIdentifierStack().pop(); // pop it
00389         sendThroughUDP(smsg, subid.getIPAddress()); // and send directly to host
00390     } else { // else if it's an identifier
00391         // check if we have the I3 server cached
00392         I3IPAddress address = (useHint && identifierCache.count(subid.getIdentifier()) != 0) ?
00393                               identifierCache[subid.getIdentifier()].address :
00394                               gateway.address;
00395         sendThroughUDP(smsg, address); // send it directly
00396     }
00397 }

void I3BaseApp::insertTrigger ( const I3Identifier identifier,
bool  store = true 
) [protected]

Inserts a trigger into I3, composed by the given identifier and an identifier stack containing only this node's IP address.

Parameters:
identifier Trigger's identifier
store Sets whether to store the trigger for auto-refresh

Referenced by bootstrapI3(), I3Triggers::deliver(), I3SessionClient::deliver(), I3HostMobility::handleTimerEvent(), I3Triggers::initializeI3(), I3SessionClientStarter::initializeI3(), I3SessionClient::initializeI3(), I3SessionServer::initializeI3(), I3Multicast::initializeI3(), I3LatencyStretch::initializeI3(), I3HostMobility::initializeI3(), I3Composite::initializeI3(), I3Anycast::initializeI3(), insertTrigger(), refreshSamples(), refreshTriggers(), and retrieveClosestIdentifier().

00400 {
00401     I3Trigger trigger;
00402     I3IPAddress add(nodeIPAddress, par("clientPort"));;
00403 
00404     trigger.getIdentifierStack().push(add);
00405     trigger.setIdentifier(identifier);
00406     insertTrigger(trigger, store);
00407 }

void I3BaseApp::insertTrigger ( const I3Identifier identifier,
const I3IdentifierStack stack,
bool  store = true 
) [protected]

Inserts a trigger into I3 with the given identifier and identifier stack.

Parameters:
identifier Trigger's identifier
stack Trigger's identifier stack
store Sets whether to store the trigger for auto-refresh
00410 {
00411     I3Trigger trigger;
00412 
00413     trigger.setIdentifier(identifier);
00414     trigger.getIdentifierStack() = stack;
00415     insertTrigger(trigger, store);
00416 }

void I3BaseApp::insertTrigger ( const I3Trigger t,
bool  store = true 
) [protected]

Inserts the given trigger into I3.

Parameters:
t Trigger to be inserted
store Sets whether to store the trigger for auto-refresh
00418                                                             {
00419 
00420     if (store) {
00421         if (insertedTriggers.count(t) != 0) return;
00422         insertedTriggers.insert(t);
00423     }
00424 
00425     I3InsertTriggerMessage *msg = new I3InsertTriggerMessage();
00426     I3IPAddress myAddress(nodeIPAddress, par("clientPort"));
00427 
00428     msg->setTrigger(t);
00429     msg->setSendReply(true);
00430     msg->setSource(myAddress);
00431     msg->setLength(INSERT_TRIGGER_L(msg));
00432 
00433     sendThroughUDP(msg, gateway.address);
00434 }

void I3BaseApp::removeTrigger ( const I3Identifier identifier  )  [protected]

Removes all triggers from the list of inserted triggers whose identifiers equal the one given.

Parameters:
identifier Identifier to be compared against

Referenced by I3SessionClient::deliver(), and I3SessionClient::handleTimerEvent().

00437 {
00438     I3Trigger dummy;
00439     dummy.setIdentifier(identifier);
00440 
00441     set<I3Trigger>::iterator it = insertedTriggers.lower_bound(dummy);
00442     if (it == insertedTriggers.end()) return; /* no matches */
00443 
00444     for (; it != insertedTriggers.end() && it->getIdentifier() == identifier; it++) {
00445         removeTrigger(*it);
00446     }
00447 }

void I3BaseApp::removeTrigger ( const I3Trigger trigger  )  [protected]

Removes a trigger from I3.

Parameters:
trigger Trigger to be removed
00450 {
00451     I3RemoveTriggerMessage *msg = new I3RemoveTriggerMessage();
00452     msg->setTrigger(t);
00453     msg->setLength(REMOVE_TRIGGER_L(msg));
00454     sendThroughUDP(msg, gateway.address);
00455 
00456     insertedTriggers.erase(t);
00457 }

set< I3Trigger > & I3BaseApp::getInsertedTriggers (  )  [protected]

Returns the list of inserted triggers.

00460 {
00461     return insertedTriggers;
00462 }

void I3BaseApp::receiveChangeNotification ( int  category,
cPolymorphic *  details 
) [protected]

00465 {
00466     Enter_Method_Silent();
00467 
00468     /* Mobility is happening (the only event we are subscribed to). We have two things to do:
00469     * 1) Insert triggers with new IP
00470     * 2) Delete triggers with old IP
00471     * If it's one staged mobility, we just get told the IP after it's changed, and we need to make sure
00472     * step 1 and 2 are done. If it's two staged mobility, we need to make sure we do step 1 first and then
00473     * step 2. */
00474 
00475 //     if (!mobilityInStages) { /* if the flag isn't set, mobility isn't done in stages or this is stage 1 */
00476 //         if (category == NF_HOSTPOSITION_BEFOREUPDATE) {
00477 //             mobilityInStages = true; /* set the flag so we don't land here in stage 2 again */
00478 //         }
00479 //         /* do part 1! */
00480 //         cMessage *msg = check_and_cast<cMessage*>(details);
00481 //         IPvXAddress *ipAddr = (IPvXAddress*)msg->contextPointer();
00482 //
00483 //         ostringstream os;
00484 //         os << "Mobility first stage - actual IP is " << nodeIPAddress << ", future IP is " << *ipAddr << endl;
00485 //         parentModule()->bubble(os.str().c_str());
00486 //
00487 //         std::cout << "In advance from " << nodeIPAddress << " to " << *ipAddr << endl;
00488 //         I3IPAddress oldAddress(nodeIPAddress, par("clientPort"));
00489 //         I3IPAddress newAddress(*ipAddr, par("clientPort"));
00490 //
00491 //         delete ipAddr;
00492 //         delete msg;
00493 //
00494 //         for (set<I3Trigger>::iterator it = insertedTriggers.begin(); it != insertedTriggers.end(); it++) {
00495 //             I3Trigger trigger(*it); /* create copy */
00496 //             trigger.getIdentifierStack().replaceAddress(oldAddress, newAddress); /* replace old address with new */
00497 //             insertTrigger(trigger, false); /* insert trigger in I3, but don't store it in our list yet - that's done in part 2 */
00498 //         }
00499 //
00500 //         doMobilityEvent(I3_MOBILITY_BEFORE_UPDATE);
00501 //     }
00502 //     if (category == NF_HOSTPOSITION_UPDATED) { /* part 2: both for 1-stage and stage 2 of 2-stage mobility */
00503 //         I3IPAddress oldAddress(nodeIPAddress, par("clientPort"));
00504 //         nodeIPAddress = IPAddressResolver().addressOf(parentModule()).get4();
00505 //         I3IPAddress newAddress(nodeIPAddress, par("clientPort"));
00506 //
00507 //         cout << "After from " << oldAddress << " to " << newAddress << endl;
00508 //
00509 //         ostringstream os;
00510 //         os << "Mobility second stage - setting IP as " << newAddress << endl;
00511 //         parentModule()->bubble(os.str().c_str());
00512 //
00513 //         set<I3Trigger> newSet; /* list of new triggers (that we already inserted in I3 in stage 1) */
00514 //
00515 //         for (set<I3Trigger>::iterator it = insertedTriggers.begin(); it != insertedTriggers.end(); it++) {
00516 //             I3Trigger trigger(*it); /* create copy */
00517 //
00518 //             trigger.getIdentifierStack().replaceAddress(oldAddress, newAddress); /* replace old address with new */
00519 //             newSet.insert(trigger); /* insert in new list */
00520 //
00521 //             removeTrigger(*it);  /* remove trigger from I3 and out list */
00522 //
00523 //         }
00524 //         insertedTriggers = newSet; /* replace old list with updated one */
00525 //
00526 //         mobilityInStages = false; /* reset variable */
00527 //         refreshTriggers(); /* to get new trigger round-trip times, new cache list */
00528 //      refreshSamples();
00529 //
00530 //         doMobilityEvent(I3_MOBILITY_UPDATED);
00531 //     }
00532 }

void I3BaseApp::doMobilityEvent ( I3MobilityStage  stage  )  [protected, virtual]

Reimplemented in I3HostMobility.

00535 {
00536 }


Member Data Documentation

int I3BaseApp::numSent [protected]

Number of sent messages.

Referenced by initialize(), and sendPacket().

int I3BaseApp::sentBytes [protected]

Referenced by initialize(), and sendPacket().

int I3BaseApp::numReceived [protected]

Number of received messages.

Referenced by handleUDPMessage(), and initialize().

int I3BaseApp::receivedBytes [protected]

Referenced by handleUDPMessage(), and initialize().

int I3BaseApp::numIsolations [protected]

Number of times this node has been isolated - i.e.

without any I3 servers known

Referenced by initialize(), and refreshTriggers().

IPvXAddress I3BaseApp::nodeIPAddress [protected]

std::set<I3Trigger> I3BaseApp::insertedTriggers [protected]

Stored I3 triggers sent from this node, to be refreshed automatically.

Referenced by getInsertedTriggers(), initialize(), insertTrigger(), refreshTriggers(), and removeTrigger().

cMessage* I3BaseApp::refreshTriggersTimer [protected]

Referenced by bootstrapI3(), and handleMessage().

Referenced by bootstrapI3(), and handleMessage().

cMessage* I3BaseApp::refreshSamplesTimer [protected]

Referenced by bootstrapI3(), and handleMessage().

Referenced by bootstrapI3(), and handleMessage().

cMessage* I3BaseApp::initializeTimer [protected]

Referenced by handleMessage(), and initialize().

cMessage* I3BaseApp::bootstrapTimer [protected]

Referenced by handleMessage(), and initialize().

Referenced by initialize().


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

Generated on Fri Sep 19 13:05:07 2008 for ITM OverSim by  doxygen 1.5.5