Gia.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 
00024 #ifndef __GIA_H_
00025 #define __GIA_H_
00026 
00027 
00028 #include <vector>
00029 
00030 #include <omnetpp.h>
00031 
00032 #include <UDPAppBase.h>
00033 #include <IPvXAddress.h>
00034 
00035 #include <GlobalNodeList.h>
00036 #include <UnderlayConfigurator.h>
00037 #include <OverlayKey.h>
00038 #include <NodeHandle.h>
00039 #include <CommonMessages_m.h>
00040 #include <BaseOverlay.h>
00041 
00042 #include "GiaMessage_m.h"
00043 #include "GiaKeyListModule.h"
00044 #include "GiaKeyList.h"
00045 #include "GiaNeighbors.h"
00046 #include "GiaTokenFactory.h"
00047 #include "GiaNode.h"
00048 #include "GiaNeighborCandidateList.h"
00049 #include "GiaMessageBookkeeping.h"
00050 
00051 
00061 class Gia : public BaseOverlay
00062 {
00063   public:
00069     void initializeOverlay(int stage);
00070 
00074     void finishOverlay();
00075 
00080     virtual void changeState(int toStage);
00081 
00085     void updateTooltip();
00086     //virtual void setBootstrapedIcon();
00087 
00088     // Gia
00092     ~Gia();
00093 
00094     void handleTimerEvent(cMessage* msg);
00095 
00096     void handleUDPMessage(BaseOverlayMessage* msg);
00097 
00098     // API for structured P2P overlays
00099 
00100     virtual void getRoute(const OverlayKey& key, CompType destComp,
00101                        CompType srcComp, cPacket* msg,
00102                        const std::vector<TransportAddress>& sourceRoute
00103                            = TransportAddress::UNSPECIFIED_NODES,
00104                        RoutingType routingType = DEFAULT_ROUTING);
00105 
00106     void handleAppMessage(cMessage* msg);
00107 
00108     void sendToken(const GiaNode& dst);
00109 
00110   protected:
00111     // parameters from OMNeT.ini
00112     uint32_t maxNeighbors; 
00113     uint32_t minNeighbors; 
00114     uint32_t maxTopAdaptionInterval; 
00115     uint32_t topAdaptionAggressiveness; 
00116     double maxLevelOfSatisfaction; 
00117     double updateDelay; 
00118     uint32_t maxHopCount; 
00119     uint32_t messageTimeout; 
00120     uint32_t neighborTimeout; 
00121     uint32_t sendTokenTimeout; 
00122     uint32_t tokenWaitTime; 
00123     double keyListDelay; 
00124     bool outputNodeDetails; 
00125     bool optimizeReversePath; 
00127     double levelOfSatisfaction; 
00128     unsigned int connectionDegree;
00129     unsigned int receivedTokens;
00130     unsigned int sentTokens;
00131 
00132     // node references
00133     GiaNode thisGiaNode; 
00134     NodeHandle bootstrapNode; 
00135     GiaMessageBookkeeping* msgBookkeepingList; 
00137     // statistics
00138     uint32_t stat_joinCount; 
00139     uint32_t stat_joinBytesSent; 
00140     uint32_t stat_joinREQ; 
00141     uint32_t stat_joinREQBytesSent;  
00142     uint32_t stat_joinRSP; 
00143     uint32_t stat_joinRSPBytesSent; 
00144     uint32_t stat_joinACK; 
00145     uint32_t stat_joinACKBytesSent; 
00146     uint32_t stat_joinDNY; 
00147     uint32_t stat_joinDNYBytesSent; 
00148     uint32_t stat_disconnectMessages; 
00149     uint32_t stat_disconnectMessagesBytesSent; 
00150     uint32_t stat_updateMessages; 
00151     uint32_t stat_updateMessagesBytesSent; 
00152     uint32_t stat_tokenMessages; 
00153     uint32_t stat_tokenMessagesBytesSent; 
00154     uint32_t stat_keyListMessages; 
00155     uint32_t stat_keyListMessagesBytesSent; 
00156     uint32_t stat_routeMessages; 
00157     uint32_t stat_routeMessagesBytesSent; 
00158     uint32_t stat_maxNeighbors; 
00159     uint32_t stat_addedNeighbors; 
00160     uint32_t stat_removedNeighbors; 
00161     uint32_t stat_numSatisfactionMessages; 
00162     double stat_sumLevelOfSatisfaction; 
00163     double stat_maxLevelOfSatisfaction; 
00165     // self-messages
00166     cMessage* satisfaction_timer; 
00167     cMessage* update_timer; 
00168     cMessage* timedoutMessages_timer; 
00169     cMessage* timedoutNeighbors_timer; 
00170     cMessage* sendKeyList_timer; 
00171     cMessage* sendToken_timer; 
00173     // module references
00174     GiaKeyListModule* keyListModule; 
00175     GiaNeighbors* neighbors; 
00176     GiaTokenFactory* tokenFactory; 
00178     // internal
00179     GiaNeighborCandidateList neighCand; 
00180     GiaNeighborCandidateList knownNodes; 
00181     GiaKeyList keyList; 
00183     // internal methodes
00184 
00185     void joinOverlay();
00186 
00193     bool acceptNode(const GiaNode& newNode, unsigned int degree);
00194 
00200     void addNeighbor(GiaNode& newNode, unsigned int degree);
00201 
00206     void removeNeighbor(const GiaNode& newNode);
00207 
00212     double calculateLevelOfSatisfaction();
00213 
00218     void sendMessage_JOIN_REQ(const NodeHandle& dst);
00219 
00224     void sendMessage_JOIN_RSP(const NodeHandle& dst);
00225 
00230     void sendMessage_JOIN_ACK(const NodeHandle& dst);
00231 
00236     void sendMessage_JOIN_DNY(const NodeHandle& dst);
00237 
00242     void sendMessage_DISCONNECT(const NodeHandle& dst);
00243 
00248     void sendMessage_UPDATE(const NodeHandle& dst);
00249 
00254     void sendKeyListToNeighbor(const NodeHandle& dst);
00255 
00261     void updateNeighborList(GiaMessage* msg);
00262 
00267     void forwardSearchResponseMessage(SearchResponseMessage* msg);
00268 
00274     void forwardMessage(GiaIDMessage* msg, bool fromApplication);
00275 
00282     void processSearchMessage(SearchMessage* msg, bool fromApplication);
00283 
00289     void sendSearchResponseMessage(const GiaNode& srcNode, SearchMessage* msg);
00290 
00295     void deliverSearchResult(SearchResponseMessage* msg);
00296 };
00297 
00298 #endif
Generated on Wed May 26 16:21:14 2010 for OverSim by  doxygen 1.6.3