I3BaseApp.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00025 #ifndef __I3BASEAPP_H__
00026 #define __I3BASEAPP_H__
00027 
00028 
00029 #include <omnetpp.h>
00030 #include <UDPAppBase.h>
00031 #include <INotifiable.h>
00032 
00033 
00034 #include "I3Trigger.h"
00035 #include "I3IdentifierStack.h"
00036 #include "I3Message.h"
00037 #include "I3IPAddress.h"
00038 #include "I3Identifier.h"
00039 
00041 class I3BaseApp : public UDPAppBase,
00042                   public INotifiable
00043 {
00044 public:
00045     struct I3CachedServer {
00046         I3IPAddress address;
00047 
00048         simtime_t lastReply;
00049         simtime_t roundTripTime;
00050 
00051         I3CachedServer();
00052         friend std::ostream& operator<<(std::ostream& os, const I3CachedServer& ip);
00053     };
00054 
00056     I3BaseApp();
00057 
00059     ~I3BaseApp();
00060 
00061 protected:
00062     enum I3MobilityStage {
00063         I3_MOBILITY_BEFORE_UPDATE,
00064         I3_MOBILITY_UPDATED
00065     };
00066 
00068     int numSent;
00069 
00070     int sentBytes;
00071 
00073     int numReceived;
00074 
00075     int receivedBytes;
00076 
00078     int numIsolations;
00079 
00081     IPvXAddress nodeIPAddress;
00082 
00084     std::set<I3Trigger> insertedTriggers;
00085 
00086     std::map<I3Identifier, I3CachedServer> samplingCache;
00087 
00088     std::map<I3Identifier, I3CachedServer> identifierCache;
00089 
00090     I3CachedServer gateway;
00091 
00092     cMessage *refreshTriggersTimer;
00093 
00094     int refreshTriggersTime;
00095 
00096     cMessage *refreshSamplesTimer;
00097 
00098     int refreshSamplesTime;
00099 
00100     cMessage *initializeTimer;
00101 
00102     cMessage *bootstrapTimer;
00103 
00105     int numInitStages() const;
00106 
00108     void initialize(int stage);
00109 
00113     virtual void initializeApp(int stage);
00114 
00116     void bootstrapI3();
00117 
00119     virtual void initializeI3();
00120 
00121 
00125     virtual void handleTimerEvent(cMessage* msg);
00126 
00130     virtual void handleUDPMessage(cMessage* msg);
00131 
00135     void handleMessage(cMessage *msg);
00136 
00142     virtual void deliver(I3Trigger &trigger, I3IdentifierStack &stack, cPacket *msg);
00143 
00147     void sendToI3(I3Message *msg);
00148 
00153     void sendThroughUDP(cMessage *msg, const I3IPAddress &ip);
00154 
00156     void refreshTriggers();
00157 
00159     void refreshSamples();
00160 
00161     I3Identifier retrieveClosestIdentifier();
00162 
00168     void sendPacket(const I3Identifier &id, cPacket *msg, bool useHint = false);
00169 
00175     void sendPacket(const I3IdentifierStack &stack, cPacket *msg, bool useHint = false);
00176 
00182     void insertTrigger(const I3Identifier &identifier, bool store = true);
00183 
00189     void insertTrigger(const I3Identifier &identifier, const I3IdentifierStack &stack, bool store = true);
00190 
00195     void insertTrigger(const I3Trigger &t, bool store = true);
00196 
00200     void removeTrigger(const I3Identifier &identifier);
00201 
00205     void removeTrigger(const I3Trigger &trigger);
00206 
00208     std::set<I3Trigger> &getInsertedTriggers();
00209 
00210 
00211     void receiveChangeNotification (int category, const cPolymorphic *details);
00212 
00213     virtual void doMobilityEvent(I3MobilityStage stage);
00214 
00215 private:
00216     bool mobilityInStages;
00217 
00218 
00219 };
00220 
00221 #endif
Generated on Wed May 26 16:21:14 2010 for OverSim by  doxygen 1.6.3