00001 // 00002 // Copyright (C) 2010 Institut fuer Telematik, Karlsruher Institut fuer Technologie (KIT) 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 CONNECTREASE_H_ 00025 #define CONNECTREASE_H_ 00026 00027 #include <omnetpp.h> 00028 00029 #include <InitStages.h> 00030 00031 00032 class IInterfaceTable; 00033 class InterfaceEntry; 00034 class IRoutingTable; 00035 class IPRoute; 00036 00037 00038 00039 struct edgeRoutes 00040 { 00041 public: 00042 int countPPPInterfaces; 00043 IInterfaceTable* interfaceTable; 00044 IRoutingTable* routingTable; 00045 uint32 IPAddress; 00046 uint32 lastIP; 00047 cModule* Router; 00048 std::vector<uint32> IPAddresses; 00049 std::string channelTypeRxStr; 00050 std::string channelTypeTxStr; 00051 }; 00052 00053 struct autoSystem 00054 { 00055 public: 00056 //cModule* AS; 00057 std::vector<edgeRoutes> edgeRouter; 00058 uint32 edgeShift; 00059 }; 00060 00061 struct topologyProperty 00062 { 00063 public: 00064 cModule* pModule; 00065 const char* property; 00066 }; 00067 00068 struct edgePool 00069 { 00070 public: 00071 edgeRoutes* edge; 00072 uint32 indexAS; 00073 }; 00074 00075 00076 class terminalInfo 00077 { 00078 public: 00079 uint32 IPAddress; 00080 cModule* module; 00081 IInterfaceTable* interfaceTable; 00082 IRoutingTable* routingTable; 00083 cModule* PPPInterface; 00084 cModule* remotePPPInterface; 00085 InterfaceEntry* interfaceEntry; 00086 InterfaceEntry* remoteInterfaceEntry; 00087 IInterfaceTable* remoteInterfaceTable; 00088 IPRoute* routingEntry; 00089 IPRoute* remoteRoutingEntry; 00090 edgeRoutes* edgeRouter; 00091 int ASindex; // deleteable? 00092 simtime_t createdAt; 00093 00094 friend std::ostream& operator<<(std::ostream& os, terminalInfo& n); 00095 }; 00096 00097 class AccessInfo 00098 { 00099 public: 00100 edgeRoutes* edge; 00101 cModule* terminal; 00102 uint32 IPAddress; 00103 int ASindex; 00104 }; 00105 00106 class ConnectReaSE : public cSimpleModule 00107 { 00108 00109 public: 00115 virtual int addOverlayNode(AccessInfo* overlayNode, bool migrate = false); 00121 virtual AccessInfo getAccessNode(); 00125 virtual cModule* removeOverlayNode(int ID); 00132 virtual cModule* getOverlayNode(int ID); 00133 /* 00134 * migrates given node to a different edge router 00135 */ 00136 virtual AccessInfo migrateNode(int ID); 00137 00138 protected: 00144 virtual int numInitStages() const 00145 { 00146 return MAX_STAGE_UNDERLAY + 1; 00147 } 00148 00152 virtual void initialize(int stage); 00153 00159 virtual void handleMessage(cMessage* msg); 00160 00164 virtual void updateDisplayString(); 00165 00166 std::vector<std::string> channelTypesRx; 00167 00168 std::vector<std::string> channelTypesTx; 00169 00170 00171 std::vector<terminalInfo> overlayTerminal; 00172 00173 // statistics 00174 cOutVector lifetimeVector; 00175 00176 std::vector<autoSystem> AS_Pool; //<! list of autonomous systems of the topology 00177 std::vector<edgePool> globalEdgePool; //<! dedicated list of all connectable routers 00178 uint32 totalCountOfAS, nextPow, ASShift; 00179 double channelDiversity; //<! percentage that a channel delay can differ 00180 00181 private: 00189 cGate* firstUnusedGate(cModule* owner, const char* name, cGate::Type type = cGate::NONE); 00197 void setUpAS(cModule* currAS); 00204 static bool extractFromParentModule(cModule* currModule, void * properties); 00205 00206 }; 00207 00208 00209 #endif /* CONNECTREASE_H_ */