00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef wiseroute_h
00027 #define wiseroute_h
00028
00029 #include <omnetpp.h>
00030
00031 #include <BaseNetwLayer.h>
00032 #include <BaseMobility.h>
00033 #include <fstream>
00034 #include "WiseRoutePkt_m.h"
00035 #include "MacPkt_m.h"
00036 #include "BaseMacLayer.h"
00037 #include "SimTracer.h"
00038 #include "NetwControlInfo.h"
00039 #include "NetwToMacControlInfo.h"
00040 #include "MacToNetwControlInfo.h"
00041
00042 #include <map>
00043 #include <list>
00044 #include <math.h>
00045
00046 using namespace std;
00047
00062 class WiseRoute : public BaseNetwLayer
00063 {
00064 public:
00066 virtual void initialize(int);
00067 virtual void finish();
00068
00069 ~WiseRoute();
00070
00071 protected:
00072 enum messagesTypes {
00073 UNKNOWN=0,
00074 DATA,
00075 ROUTE_FLOOD,
00076 SEND_ROUTE_FLOOD_TIMER
00077 };
00078
00079 typedef enum floodTypes {
00080 NOTAFLOOD,
00081 FORWARD,
00082 FORME,
00083 DUPLICATE
00084 } floodTypes;
00085
00086
00087 typedef struct tRouteTableEntry {
00088 int nextHop;
00089 double rssi;
00090 } tRouteTableEntry;
00091
00092 typedef map<int, tRouteTableEntry> tRouteTable;
00093 typedef multimap<int, unsigned long> tFloodTable;
00094
00095 tRouteTable routeTable;
00096 tFloodTable floodTable;
00097
00102 int headerLength;
00103
00104
00106
00107 int macaddress;
00108
00109 int sinkAddress;
00110
00111 bool useSimTracer;
00112
00114 double rssiThreshold;
00115
00119 double routeFloodsInterval;
00120
00122 unsigned long floodSeqNumber;
00123
00124 SimTracer *tracer;
00125 cMessage* routeFloodTimer;
00126
00127 long nbDataPacketsForwarded;
00128 long nbDataPacketsReceived;
00129 long nbDataPacketsSent;
00130 long nbDuplicatedFloodsReceived;
00131 long nbFloodsSent;
00132 long nbPureUnicastSent;
00133 long nbRouteFloodsSent;
00134 long nbRouteFloodsReceived;
00135 long nbUnicastFloodForwarded;
00136 long nbPureUnicastForwarded;
00137 long nbGetRouteFailures;
00138 long nbRoutesRecorded;
00139 long nbHops;
00140
00141 cOutVector receivedRSSI;
00142 cOutVector routeRSSI;
00143 cOutVector allReceivedRSSI;
00144 cOutVector allReceivedBER;
00145 cOutVector routeBER;
00146 cOutVector receivedBER;
00147 cOutVector nextHopSelectionForSink;
00148
00149 bool trace, stats, debug;
00150
00161
00163 virtual void handleUpperMsg(cMessage* msg);
00164
00166 virtual void handleLowerMsg(cMessage* msg);
00167
00169 virtual void handleSelfMsg(cMessage* msg);
00170
00172 virtual void handleLowerControl(cMessage* msg);
00173
00179 virtual void updateRouteTable(int origin, int lastHop, double rssi, double ber);
00180
00182 cMessage* decapsMsg(WiseRoutePkt *msg);
00183
00187 floodTypes updateFloodTable(bool isFlood, int srcAddr, int destAddr, unsigned long seqNum);
00188
00190 int getRoute(int destAddr, bool iAmOrigin = false);
00191 };
00192
00193 #endif