• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/aodv/aodv_rqueue.h

00001 /*
00002 Copyright (c) 1997, 1998 Carnegie Mellon University.  All Rights
00003 Reserved. 
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007 
00008 1. Redistributions of source code must retain the above copyright notice,
00009 this list of conditions and the following disclaimer.
00010 2. Redistributions in binary form must reproduce the above copyright notice,
00011 this list of conditions and the following disclaimer in the documentation
00012 and/or other materials provided with the distribution.
00013 3. The name of the author may not be used to endorse or promote products
00014 derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00017 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00018 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00019 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00020 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00021 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00022 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00023 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00024 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00025 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 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. 
00028 
00029 */
00030 
00031 
00032 #ifndef __aodv_rqueue_h__
00033 #define __aodv_rqueue_h_
00034 
00035 //#include <packet.h>
00036 #include <ip.h>
00037 #include <agent.h>
00038 
00039 /*
00040  * The maximum number of packets that we allow a routing protocol to buffer.
00041  */
00042 #define AODV_RTQ_MAX_LEN     64      // packets
00043 
00044 /*
00045  *  The maximum period of time that a routing protocol is allowed to buffer
00046  *  a packet for.
00047  */
00048 #define AODV_RTQ_TIMEOUT     30 // seconds
00049 
00050 class aodv_rqueue : public Connector {
00051  public:
00052         aodv_rqueue();
00053 
00054         void            recv(Packet *, Handler*) { abort(); }
00055 
00056         void            enque(Packet *p);
00057 
00058         inline int      command(int argc, const char * const* argv) 
00059           { return Connector::command(argc, argv); }
00060 
00061         /*
00062          *  Returns a packet from the head of the queue.
00063          */
00064         Packet*         deque(void);
00065 
00066         /*
00067          * Returns a packet for destination "D".
00068          */
00069         Packet*         deque(nsaddr_t dst);
00070   /*
00071    * Finds whether a packet with destination dst exists in the queue
00072    */
00073         char            find(nsaddr_t dst);
00074 
00075  private:
00076         Packet*         remove_head();
00077         void            purge(void);
00078         void            findPacketWithDst(nsaddr_t dst, Packet*& p, Packet*& prev);
00079         bool            findAgedPacket(Packet*& p, Packet*& prev); 
00080         void            verifyQueue(void);
00081 
00082         Packet          *head_;
00083         Packet          *tail_;
00084 
00085         int             len_;
00086 
00087         int             limit_;
00088         double          timeout_;
00089 
00090 };
00091 
00092 #endif /* __aodv_rqueue_h__ */

Generated on Tue Aug 10 2010 16:16:06 for ns-2.33 by  doxygen 1.7.1