A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
aodv-rqueue.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 IITP RAS
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Based on
19  * NS-2 AODV model developed by the CMU/MONARCH group and optimized and
20  * tuned by Samir Das and Mahesh Marina, University of Cincinnati;
21  *
22  * AODV-UU implementation by Erik Nordström of Uppsala University
23  * http://core.it.uu.se/core/index.php/AODV-UU
24  *
25  * Authors: Elena Buchatskaia <borovkovaes@iitp.ru>
26  * Pavel Boyko <boyko@iitp.ru>
27  */
28 #ifndef AODV_RQUEUE_H
29 #define AODV_RQUEUE_H
30 
31 #include <vector>
32 #include "ns3/ipv4-routing-protocol.h"
33 #include "ns3/simulator.h"
34 
35 
36 namespace ns3 {
37 namespace aodv {
38 
44 {
45 public:
51  ErrorCallback ecb = ErrorCallback (), Time exp = Simulator::Now ()) :
52  m_packet (pa), m_header (h), m_ucb (ucb), m_ecb (ecb),
53  m_expire (exp + Simulator::Now ())
54  {}
55 
60  bool operator== (QueueEntry const & o) const
61  {
62  return ((m_packet == o.m_packet) && (m_header.GetDestination () == o.m_header.GetDestination ()) && (m_expire == o.m_expire));
63  }
65  //\{
68  ErrorCallback GetErrorCallback () const { return m_ecb; }
69  void SetErrorCallback (ErrorCallback ecb) { m_ecb = ecb; }
70  Ptr<const Packet> GetPacket () const { return m_packet; }
72  Ipv4Header GetIpv4Header () const { return m_header; }
73  void SetIpv4Header (Ipv4Header h) { m_header = h; }
74  void SetExpireTime (Time exp) { m_expire = exp + Simulator::Now (); }
75  Time GetExpireTime () const { return m_expire - Simulator::Now (); }
76  //\}
77 private:
88 };
96 {
97 public:
99  RequestQueue (uint32_t maxLen, Time routeToQueueTimeout) :
100  m_maxLen (maxLen), m_queueTimeout (routeToQueueTimeout)
101  {
102  }
104  bool Enqueue (QueueEntry & entry);
106  bool Dequeue (Ipv4Address dst, QueueEntry & entry);
108  void DropPacketWithDst (Ipv4Address dst);
110  bool Find (Ipv4Address dst);
112  uint32_t GetSize ();
114  //\{
115  uint32_t GetMaxQueueLen () const { return m_maxLen; }
116  void SetMaxQueueLen (uint32_t len) { m_maxLen = len; }
117  Time GetQueueTimeout () const { return m_queueTimeout; }
119  //\}
120 
121 private:
122  std::vector<QueueEntry> m_queue;
124  void Purge ();
126  void Drop (QueueEntry en, std::string reason);
128  uint32_t m_maxLen;
131  static bool IsEqual (QueueEntry en, const Ipv4Address dst) { return (en.GetIpv4Header ().GetDestination () == dst); }
132 };
133 
134 
135 }
136 }
137 
138 #endif /* AODV_RQUEUE_H */