OverSim
Gia.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
24 #ifndef __GIA_H_
25 #define __GIA_H_
26 
27 
28 #include <vector>
29 
30 #include <omnetpp.h>
31 
32 #include <UDPAppBase.h>
33 #include <IPvXAddress.h>
34 
35 #include <GlobalNodeList.h>
36 #include <UnderlayConfigurator.h>
37 #include <OverlayKey.h>
38 #include <NodeHandle.h>
39 #include <CommonMessages_m.h>
40 #include <BaseOverlay.h>
41 
42 #include "GiaMessage_m.h"
43 #include "GiaKeyListModule.h"
44 #include "GiaKeyList.h"
45 #include "GiaNeighbors.h"
46 #include "GiaTokenFactory.h"
47 #include "GiaNode.h"
49 #include "GiaMessageBookkeeping.h"
50 
51 
61 class Gia : public BaseOverlay
62 {
63  public:
69  void initializeOverlay(int stage);
70 
74  void finishOverlay();
75 
80  virtual void changeState(int toStage);
81 
85  void updateTooltip();
86  //virtual void setBootstrapedIcon();
87 
88  // Gia
92  ~Gia();
93 
94  void handleTimerEvent(cMessage* msg);
95 
97 
98  // API for structured P2P overlays
99 
100  virtual void getRoute(const OverlayKey& key, CompType destComp,
101  CompType srcComp, cPacket* msg,
102  const std::vector<TransportAddress>& sourceRoute
104  RoutingType routingType = DEFAULT_ROUTING);
105 
106  void handleAppMessage(cMessage* msg);
107 
108  void sendToken(const GiaNode& dst);
109 
110  protected:
111  // parameters from OMNeT.ini
112  uint32_t maxNeighbors;
113  uint32_t minNeighbors;
117  double updateDelay;
118  uint32_t maxHopCount;
119  uint32_t messageTimeout;
120  uint32_t neighborTimeout;
121  uint32_t sendTokenTimeout;
122  uint32_t tokenWaitTime;
123  double keyListDelay;
128  unsigned int connectionDegree;
129  unsigned int receivedTokens;
130  unsigned int sentTokens;
131 
132  // node references
137  // statistics
138  uint32_t stat_joinCount;
140  uint32_t stat_joinREQ;
142  uint32_t stat_joinRSP;
144  uint32_t stat_joinACK;
146  uint32_t stat_joinDNY;
158  uint32_t stat_maxNeighbors;
165  // self-messages
166  cMessage* satisfaction_timer;
167  cMessage* update_timer;
170  cMessage* sendKeyList_timer;
171  cMessage* sendToken_timer;
173  // module references
178  // internal
183  // internal methodes
184 
185  void joinOverlay();
186 
193  bool acceptNode(const GiaNode& newNode, unsigned int degree);
194 
200  void addNeighbor(GiaNode& newNode, unsigned int degree);
201 
206  void removeNeighbor(const GiaNode& newNode);
207 
213 
218  void sendMessage_JOIN_REQ(const NodeHandle& dst);
219 
224  void sendMessage_JOIN_RSP(const NodeHandle& dst);
225 
230  void sendMessage_JOIN_ACK(const NodeHandle& dst);
231 
236  void sendMessage_JOIN_DNY(const NodeHandle& dst);
237 
242  void sendMessage_DISCONNECT(const NodeHandle& dst);
243 
248  void sendMessage_UPDATE(const NodeHandle& dst);
249 
254  void sendKeyListToNeighbor(const NodeHandle& dst);
255 
261  void updateNeighborList(GiaMessage* msg);
262 
268 
274  void forwardMessage(GiaIDMessage* msg, bool fromApplication);
275 
282  void processSearchMessage(SearchMessage* msg, bool fromApplication);
283 
289  void sendSearchResponseMessage(const GiaNode& srcNode, SearchMessage* msg);
290 
296 };
297 
298 #endif