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
00027
00028
00029
00030
00037 #ifndef _MRCL_AODV_
00038 #define _MRCL_AODV_
00039
00040 #include <routing-module.h>
00041 #include "aodv-rt-table.h"
00042 #include <hop-count-metric.h>
00043 #include <priqueue.h>
00044
00045
00046 #define BCAST_ID_SAVE 6
00047
00048 #define AODV_GOT_MY_REQUEST_VERBOSITY 10
00049 #define AODV_GOT_MY_REQUEST "MyREQ"
00050 #define AODV_DISCARD_REQUEST_VERBOSITY 10
00051 #define AODV_DISCARD_REQUEST "REQ"
00052 #define AODV_RECEIVED_REQUEST_VERBOSITY 10
00053 #define AODV_RECEIVED_REQUEST "RREQ"
00054 #define AODV_RECEIVED_REQUEST_RESOLVED "RQRV"
00055 #define AODV_DROP_RTR_TTL_VERBOSITY 10
00056 #define AODV_DROP_RTR_TTL "TTL"
00057 #define AODV_REPLY_FOR_ME_VERBOSITY 20
00058 #define AODV_REPLY_FOR_ME "MyREP"
00059 #define AODV_SUPPRESS_REPLY_VERBOSITY 10
00060 #define AODV_SUPPRESS_REPLY "SREP"
00061 #define AODV_DROP_RTR_NO_ROUTE_VERBOSITY 10
00062 #define DROP_RTR_NO_ROUTE "NRTE"
00063 #define AODV_RECV_ERROR_VERBOSITY 20
00064 #define AODV_RECV_ERROR "RERR"
00065 #define AODV_RECV_HELLO_VERBOSITY 20
00066 #define AODV_RECV_HELLO "RHELLO"
00067 #define AODV_DROP_RTR_NO_ROUTE "NRTE" // no route
00068 #define AODV_DROP_RTR_NO_ROUTE_VEROSITY 10
00069 #define DROP_RTR_MAC_CALLBACK "CBK" // MAC callback (from cmu-trace.h, ns2 standard distribution)
00070 #define DROP_RTR_MAC_CALLBACK_VERBOSITY 10
00071
00072 #define REV_ROUTE_LIFE 6 // 5 seconds
00073 #define ARP_DELAY 0.01 // fixed delay to keep arp happy
00074 #define HELLO_INTERVAL 1 // 1000 ms
00075 #define ALLOWED_HELLO_LOSS 3 // packets
00076 #define ACTIVE_ROUTE_TIMEOUT 10 // 50 seconds
00077 #define MY_ROUTE_TIMEOUT 10 // 100 seconds
00078
00079
00080
00081 #define NETWORK_DIAMETER 30 // 30 hops
00082
00083 #define RREQ_RETRIES 3
00084
00085 #define MAX_RREQ_TIMEOUT 10.0 //sec
00086
00087
00088
00089 #define TTL_START 5
00090 #define TTL_THRESHOLD 7
00091 #define TTL_INCREMENT 2
00092
00093
00094 #define NODE_TRAVERSAL_TIME 0.03 // 30 ms
00095
00096 class AodvModule;
00097
00098
00099
00100
00101 class MrclBroadcastTimer : public Handler {
00102 public:
00103 MrclBroadcastTimer(AodvModule* a) : module(a) {}
00104 void handle(Event*);
00105 private:
00106 AodvModule *module;
00107 Event intr;
00108 };
00109
00110 class MrclHelloTimer : public Handler {
00111 public:
00112 MrclHelloTimer(AodvModule* a) : module(a) {}
00113 void handle(Event*);
00114 private:
00115 AodvModule *module;
00116 Event intr;
00117 };
00118
00119 class MrclNeighborTimer : public Handler {
00120 public:
00121 MrclNeighborTimer(AodvModule* a) : module(a) {}
00122 void handle(Event*);
00123 private:
00124 AodvModule *module;
00125 Event intr;
00126 };
00127
00128 class MrclRouteCacheTimer : public Handler {
00129 public:
00130 MrclRouteCacheTimer(AodvModule* a) : module(a) {}
00131 void handle(Event*);
00132 private:
00133 AodvModule *module;
00134 Event intr;
00135 };
00136
00137 class MrclLocalRepairTimer : public Handler {
00138 public:
00139 MrclLocalRepairTimer(AodvModule* a) : module(a) {}
00140 void handle(Event*);
00141 private:
00142 AodvModule *module;
00143 Event intr;
00144 };
00145
00146
00147
00148 class AodvModule : public MrclRouting
00149 {
00150 friend class MrclBroadcastTimer;
00151 friend class MrclHelloTimer;
00152 friend class MrclNeighborTimer;
00153 friend class MrclRouteCacheTimer;
00154 friend class MrclLocalRepairTimer;
00155
00156 public:
00157 AodvModule();
00158 virtual ~AodvModule();
00159 virtual int command(int argc, const char *const *argv);
00160
00161 void rt_ll_failed(Packet *p);
00162 void handle_link_failure(char* id);
00163 void local_rt_repair(Aodv_rt_entry *rt, Packet *p);
00164
00165
00166 protected:
00167 virtual int controlPacket(Packet *p);
00168 virtual void forward(Packet *p);
00169 virtual void resolve(Packet *p);
00170 virtual void forward(Packet *p, Aodv_rt_entry *re, double delay = 0.0);
00171
00172 virtual char *getNextHop(Packet *p);
00173 virtual int canIReach(char *a, Metric ***m);
00174
00175 virtual void recvAodv(Packet *p);
00176 virtual void recvRequest(Packet *p);
00177 virtual void recvReply(Packet *p);
00178 virtual void recvError(Packet *p);
00179 virtual void recvHello(Packet *p);
00180
00181 virtual void sendHello();
00182
00183
00184
00185
00186 virtual void sendReply(char *dst, int hop_count, char *rp_dst, int rpseq, int lifetime, double timestamp);
00187 virtual void sendRequest(char *dst);
00188 virtual void sendError(Packet *p, int jitter = 1);
00189 int id_lookup(char *addr, int bid);
00190 void id_insert(char *addr, int bid);
00191
00192 void id_delete(AddrList *a);
00193 void id_purge(void);
00194 void rt_update(Aodv_rt_entry *rt, int seqnum, int metric, char *nexthop, double expire_time);
00195 void rt_down(Aodv_rt_entry *rt);
00196 void rt_purge();
00197 Aodv_rt_entry* rtable_lookup(char *addr) {return (rtable_.rt_lookup(addr));};
00198
00199
00200 void nb_insert(char *id);
00201 AddrList *nb_lookup(char *id);
00202 void nb_delete(char *id);
00203 void nb_delete(AddrList *a);
00204 void nb_purge();
00205
00206 double perHopTime(Aodv_rt_entry *rt);
00207
00208 double minHelloInterval() {return (helloInterval_ * minHelloIntervalRatio_);};
00209 double maxHelloInterval() {return (helloInterval_ * maxHelloIntervalRatio_);};
00210 double routeCacheFrequency() {return (routeCacheFrequency_);};
00211
00212 int debug(){return (debug_);};
00213
00214 HopCountMetric **m_;
00215 AddrList *ncache_;
00216 AddrList *bcache_;
00217 RoutingQueue rqueue_;
00218 Aodv_rtable rtable_;
00219 PriQueue* ifqueue_;
00220
00221 MrclAddress *broadcastAddr_;
00222 int seqno_;
00223 int RREQ_GRAT_RREP;
00224 int bid_;
00225
00226 int AODV_LINK_LAYER_DETECTION;
00227
00228
00229
00230 int AODV_LOCAL_REPAIR;
00231
00232 int AODV_MIRACLE_ROUTING;
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245 MrclBroadcastTimer btimer;
00246 MrclHelloTimer htimer;
00247 MrclNeighborTimer ntimer;
00248 MrclRouteCacheTimer rtimer;
00249 MrclLocalRepairTimer lrtimer;
00250
00251
00252 double minHelloIntervalRatio_;
00253 double maxHelloIntervalRatio_;
00254 double helloInterval_;
00255 double routeCacheFrequency_;
00256
00257 int debugout;
00258 };
00259
00260
00261 #endif
00262