OverSim
AccessNet.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 __ACCESSNET_H__
25 #define __ACCESSNET_H__
26 
27 #include <omnetpp.h>
28 
29 #include <InitStages.h>
30 #include <IPvXAddress.h>
31 
32 class IInterfaceTable;
33 class InterfaceEntry;
34 class IRoutingTable;
35 class RoutingTable6;
36 class IPRoute;
37 class IPv6Route;
38 
42 struct IPv6Words
43 {
44 public:
45  uint32 d0, d1, d2, d3;
46 
47  IPv6Words(IPvXAddress addr) {
48  const uint32* words = addr.words();
49  d0 = words[0];
50  d1 = words[1];
51  d2 = words[2];
52  d3 = words[3];
53  }
54 
56  d0 = 0;
57  d1 = 0;
58  d2 = 0;
59  d3 = 0;
60  }
61 };
62 
66 class NodeInfo
67 {
68 public:
69  IPvXAddress IPAddress;
70  cModule* module;
71  IInterfaceTable* interfaceTable;
72  IRoutingTable* routingTable;
73  RoutingTable6* routingTable6;
74  simtime_t createdAt;
75 
83  friend std::ostream& operator<<(std::ostream& os, NodeInfo& n);
84 };
85 
89 class TerminalInfo : public NodeInfo
90 {
91 public:
92  cModule* PPPInterface;
93  cModule* remotePPPInterface;
94  InterfaceEntry* interfaceEntry;
95  InterfaceEntry* remoteInterfaceEntry;
96  IInterfaceTable* remoteInterfaceTable;
97  IPRoute* remoteRoutingEntry;
98  IPRoute* routingEntry;
100  IPv6Route* ipv6routingEntry;
101 };
102 
106 class AccessNet : public cSimpleModule
107 {
108 public:
109 
115  virtual int size()
116  {
117  return overlayTerminal.size();
118  }
119 
125  virtual cModule* getAccessNode()
126  {
127  return router.module;
128  }
129 
138  virtual IPvXAddress addOverlayNode(cModule* overlayNode, bool migrate = false);
139 
143  int getRandomNodeId();
144 
148  virtual cModule* removeOverlayNode(int ID);
149 
156  virtual cModule* getOverlayNode(int ID);
157 
164  void selectChannel(const std::string& typeRx, const std::string &typeTx)
165  {
166  channelTypeRxStr = typeRx;
167  channelTypeTxStr = typeTx;
168  }
169 
170 protected:
171 
173  std::vector<TerminalInfo> overlayTerminal;
174  std::vector<IPvXAddress> returnedIPs;
175 
176  IPvXAddress getAssignedPrefix(IInterfaceTable* ift);
182  virtual int numInitStages() const
183  {
184  return MAX_STAGE_UNDERLAY + 1;
185  }
186 
190  virtual void initialize(int stage);
191 
197  virtual void handleMessage(cMessage* msg);
198 
202  virtual void updateDisplayString();
203 
204  uint32_t lastIP;
205  bool useIPv6;
206 
207  std::vector<std::string> channelTypesRx;
208  std::string channelTypeRxStr;
209  std::vector<std::string> channelTypesTx;
210  std::string channelTypeTxStr;
211 
212  // statistics
213  cOutVector lifetimeVector;
214 };
215 
223 cGate* firstUnusedGate(cModule* owner, const char* name, cGate::Type type = cGate::NONE);
224 
225 
226 
227 #endif