OverSim
I3BaseApp.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 
25 #ifndef __I3BASEAPP_H__
26 #define __I3BASEAPP_H__
27 
28 
29 #include <omnetpp.h>
30 #include <UDPAppBase.h>
31 #include <INotifiable.h>
32 
33 
34 #include "I3Trigger.h"
35 #include "I3IdentifierStack.h"
36 #include "I3Message.h"
37 #include "I3IPAddress.h"
38 #include "I3Identifier.h"
39 
41 class I3BaseApp : public UDPAppBase,
42  public INotifiable
43 {
44 public:
45  struct I3CachedServer {
47 
48  simtime_t lastReply;
49  simtime_t roundTripTime;
50 
52  friend std::ostream& operator<<(std::ostream& os, const I3CachedServer& ip);
53  };
54 
56  I3BaseApp();
57 
59  ~I3BaseApp();
60 
61 protected:
65  };
66 
68  int numSent;
69 
70  int sentBytes;
71 
74 
76 
79 
81  IPvXAddress nodeIPAddress;
82 
84  std::set<I3Trigger> insertedTriggers;
85 
86  std::map<I3Identifier, I3CachedServer> samplingCache;
87 
88  std::map<I3Identifier, I3CachedServer> identifierCache;
89 
91 
93 
95 
97 
99 
100  cMessage *initializeTimer;
101 
102  cMessage *bootstrapTimer;
103 
105  int numInitStages() const;
106 
108  void initialize(int stage);
109 
113  virtual void initializeApp(int stage);
114 
116  void bootstrapI3();
117 
119  virtual void initializeI3();
120 
121 
125  virtual void handleTimerEvent(cMessage* msg);
126 
130  virtual void handleUDPMessage(cMessage* msg);
131 
135  void handleMessage(cMessage *msg);
136 
142  virtual void deliver(I3Trigger &trigger, I3IdentifierStack &stack, cPacket *msg);
143 
147  void sendToI3(I3Message *msg);
148 
153  void sendThroughUDP(cMessage *msg, const I3IPAddress &ip);
154 
156  void refreshTriggers();
157 
159  void refreshSamples();
160 
162 
168  void sendPacket(const I3Identifier &id, cPacket *msg, bool useHint = false);
169 
175  void sendPacket(const I3IdentifierStack &stack, cPacket *msg, bool useHint = false);
176 
182  void insertTrigger(const I3Identifier &identifier, bool store = true);
183 
189  void insertTrigger(const I3Identifier &identifier, const I3IdentifierStack &stack, bool store = true);
190 
195  void insertTrigger(const I3Trigger &t, bool store = true);
196 
200  void removeTrigger(const I3Identifier &identifier);
201 
205  void removeTrigger(const I3Trigger &trigger);
206 
208  std::set<I3Trigger> &getInsertedTriggers();
209 
210 
211  void receiveChangeNotification (int category, const cPolymorphic *details);
212 
213  virtual void doMobilityEvent(I3MobilityStage stage);
214 
215 private:
217 
218 
219 };
220 
221 #endif