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 */
UnicastForwardCallback GetUnicastForwardCallback() const
Definition: aodv-rqueue.h:66
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
Control the scheduling of simulation events.
Definition: simulator.h:63
Callback template class.
Definition: callback.h:924
AODV route request queue.
Definition: aodv-rqueue.h:95
Ipv4Header GetIpv4Header() const
Definition: aodv-rqueue.h:72
void Drop(QueueEntry en, std::string reason)
Notify that packet is dropped from queue by timeout.
Definition: aodv-rqueue.cc:141
Ipv4Address GetDestination(void) const
Definition: ipv4-header.cc:304
void SetMaxQueueLen(uint32_t len)
Definition: aodv-rqueue.h:116
void SetUnicastForwardCallback(UnicastForwardCallback ucb)
Definition: aodv-rqueue.h:67
QueueEntry(Ptr< const Packet > pa=0, Ipv4Header const &h=Ipv4Header(), UnicastForwardCallback ucb=UnicastForwardCallback(), ErrorCallback ecb=ErrorCallback(), Time exp=Simulator::Now())
c-tor
Definition: aodv-rqueue.h:49
UnicastForwardCallback m_ucb
Unicast forward callback.
Definition: aodv-rqueue.h:83
void SetExpireTime(Time exp)
Definition: aodv-rqueue.h:74
Ipv4RoutingProtocol::ErrorCallback ErrorCallback
Definition: aodv-rqueue.h:47
bool Enqueue(QueueEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue...
Definition: aodv-rqueue.cc:49
Packet header for IPv4.
Definition: ipv4-header.h:31
void SetErrorCallback(ErrorCallback ecb)
Definition: aodv-rqueue.h:69
Time GetQueueTimeout() const
Definition: aodv-rqueue.h:117
void SetIpv4Header(Ipv4Header h)
Definition: aodv-rqueue.h:73
bool operator==(QueueEntry const &o) const
Compare queue entries.
Definition: aodv-rqueue.h:60
Time m_expire
Expire time for queue entry.
Definition: aodv-rqueue.h:87
std::vector< QueueEntry > m_queue
Definition: aodv-rqueue.h:122
uint32_t GetMaxQueueLen() const
Definition: aodv-rqueue.h:115
Ptr< const Packet > GetPacket() const
Definition: aodv-rqueue.h:70
Ipv4RoutingProtocol::UnicastForwardCallback UnicastForwardCallback
Definition: aodv-rqueue.h:46
void DropPacketWithDst(Ipv4Address dst)
Remove all packets with destination IP address dst.
Definition: aodv-rqueue.cc:71
Ptr< const Packet > m_packet
Data packet.
Definition: aodv-rqueue.h:79
AODV Queue Entry.
Definition: aodv-rqueue.h:43
ErrorCallback GetErrorCallback() const
Definition: aodv-rqueue.h:68
uint32_t GetSize()
Number of entries.
Definition: aodv-rqueue.cc:42
Time m_queueTimeout
The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
Definition: aodv-rqueue.h:130
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
Time GetExpireTime() const
Definition: aodv-rqueue.h:75
ErrorCallback m_ecb
Error callback.
Definition: aodv-rqueue.h:85
Ipv4Header m_header
IP header.
Definition: aodv-rqueue.h:81
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
void SetQueueTimeout(Time t)
Definition: aodv-rqueue.h:118
void Purge()
Remove all expired entries.
Definition: aodv-rqueue.cc:125
static bool IsEqual(QueueEntry en, const Ipv4Address dst)
Definition: aodv-rqueue.h:131
uint32_t m_maxLen
The maximum number of packets that we allow a routing protocol to buffer.
Definition: aodv-rqueue.h:128
bool Find(Ipv4Address dst)
Finds whether a packet with destination dst exists in the queue.
Definition: aodv-rqueue.cc:104
RequestQueue(uint32_t maxLen, Time routeToQueueTimeout)
Default c-tor.
Definition: aodv-rqueue.h:99
bool Dequeue(Ipv4Address dst, QueueEntry &entry)
Return first found (the earliest) entry for given destination.
Definition: aodv-rqueue.cc:88
void SetPacket(Ptr< const Packet > p)
Definition: aodv-rqueue.h:71