Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

aodv_rtable.h

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 1997, 1998 Carnegie Mellon University.  All Rights
00003 Reserved. 
00004 
00005 Permission to use, copy, modify, and distribute this
00006 software and its documentation is hereby granted (including for
00007 commercial or for-profit use), provided that both the copyright notice and this permission notice appear in all copies of the software, derivative works, or modified versions, and any portions thereof, and that both notices appear in supporting documentation, and that credit is given to Carnegie Mellon University in all publications reporting on direct or indirect use of this code or its derivatives.
00008 
00009 ALL CODE, SOFTWARE, PROTOCOLS, AND ARCHITECTURES DEVELOPED BY THE CMU
00010 MONARCH PROJECT ARE EXPERIMENTAL AND ARE KNOWN TO HAVE BUGS, SOME OF
00011 WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON PROVIDES THIS
00012 SOFTWARE OR OTHER INTELLECTUAL PROPERTY IN ITS ``AS IS'' CONDITION,
00013 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00014 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00015 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
00016 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00017 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00018 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
00019 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00020 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
00021 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE OR
00022 INTELLECTUAL PROPERTY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00023 DAMAGE.
00024 
00025 Carnegie Mellon encourages (but does not require) users of this
00026 software or intellectual property to return any improvements or
00027 extensions that they make, and to grant Carnegie Mellon the rights to redistribute these changes without encumbrance.
00028 
00029 The AODV code developed by the CMU/MONARCH group was optimized and tuned by Samir Das and Mahesh Marina, University of Cincinnati. The work was partially done in Sun Microsystems.
00030 */
00031 
00032 
00033 #ifndef __aodv_rtable_h__
00034 #define __aodv_rtable_h__
00035 
00036 #include <assert.h>
00037 #include <sys/types.h>
00038 #include <config.h>
00039 #include <lib/bsd-list.h>
00040 #include <scheduler.h>
00041 
00042 #define CURRENT_TIME    Scheduler::instance().clock()
00043 #define INFINITY2        0xff
00044 
00045 /*
00046    AODV Neighbor Cache Entry
00047 */
00048 class AODV_Neighbor {
00049         friend class AODV;
00050         friend class aodv_rt_entry;
00051  public:
00052         AODV_Neighbor(u_int32_t a) { nb_addr = a; }
00053 
00054  protected:
00055         LIST_ENTRY(AODV_Neighbor) nb_link;
00056         nsaddr_t        nb_addr;
00057         double          nb_expire;      // ALLOWED_HELLO_LOSS * HELLO_INTERVAL
00058 };
00059 
00060 LIST_HEAD(aodv_ncache, AODV_Neighbor);
00061 
00062 /*
00063    AODV Precursor list data structure
00064 */
00065 class AODV_Precursor {
00066         friend class AODV;
00067         friend class aodv_rt_entry;
00068  public:
00069         AODV_Precursor(u_int32_t a) { pc_addr = a; }
00070 
00071  protected:
00072         LIST_ENTRY(AODV_Precursor) pc_link;
00073         nsaddr_t        pc_addr;        // precursor address
00074 };
00075 
00076 LIST_HEAD(aodv_precursors, AODV_Precursor);
00077 
00078 
00079 /*
00080   Route Table Entry
00081 */
00082 
00083 class aodv_rt_entry {
00084         friend class aodv_rtable;
00085         friend class AODV;
00086         friend class LocalRepairTimer;
00087  public:
00088         aodv_rt_entry();
00089         ~aodv_rt_entry();
00090 
00091         void            nb_insert(nsaddr_t id);
00092         AODV_Neighbor*  nb_lookup(nsaddr_t id);
00093 
00094         void            pc_insert(nsaddr_t id);
00095         AODV_Precursor* pc_lookup(nsaddr_t id);
00096         void            pc_delete(nsaddr_t id);
00097         void            pc_delete(void);
00098         bool            pc_empty(void);
00099 
00100         double          rt_req_timeout;         // when I can send another req
00101         u_int8_t        rt_req_cnt;             // number of route requests
00102         
00103  protected:
00104         LIST_ENTRY(aodv_rt_entry) rt_link;
00105 
00106         nsaddr_t        rt_dst;
00107         u_int32_t       rt_seqno;
00108         /* u_int8_t     rt_interface; */
00109         u_int16_t       rt_hops;                // hop count
00110         int             rt_last_hop_count;      // last valid hop count
00111         nsaddr_t        rt_nexthop;             // next hop IP address
00112         /* list of precursors */ 
00113         aodv_precursors rt_pclist;
00114         double          rt_expire;              // when entry expires
00115         u_int8_t        rt_flags;
00116 
00117 #define RTF_DOWN 0
00118 #define RTF_UP 1
00119 #define RTF_IN_REPAIR 2
00120 
00121         /*
00122          *  Must receive 4 errors within 3 seconds in order to mark
00123          *  the route down.
00124         u_int8_t        rt_errors;      // error count
00125         double          rt_error_time;
00126 #define MAX_RT_ERROR            4       // errors
00127 #define MAX_RT_ERROR_TIME       3       // seconds
00128          */
00129 
00130 #define MAX_HISTORY     3
00131         double          rt_disc_latency[MAX_HISTORY];
00132         char            hist_indx;
00133         int             rt_req_last_ttl;        // last ttl value used
00134         // last few route discovery latencies
00135         // double               rt_length [MAX_HISTORY];
00136         // last few route lengths
00137 
00138         /*
00139          * a list of neighbors that are using this route.
00140          */
00141         aodv_ncache          rt_nblist;
00142 };
00143 
00144 
00145 /*
00146   The Routing Table
00147 */
00148 
00149 class aodv_rtable {
00150  public:
00151         aodv_rtable() { LIST_INIT(&rthead); }
00152 
00153         aodv_rt_entry*       head() { return rthead.lh_first; }
00154 
00155         aodv_rt_entry*       rt_add(nsaddr_t id);
00156         void                 rt_delete(nsaddr_t id);
00157         aodv_rt_entry*       rt_lookup(nsaddr_t id);
00158 
00159  private:
00160         LIST_HEAD(aodv_rthead, aodv_rt_entry) rthead;
00161 };
00162 
00163 #endif /* _aodv__rtable_h__ */

Generated on Tue Apr 20 12:14:10 2004 for NS2.26SourcesOriginal by doxygen 1.3.3