A Discrete-Event Network Simulator
API
aodv-rqueue.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 IITP RAS
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Based on
18  * NS-2 AODV model developed by the CMU/MONARCH group and optimized and
19  * tuned by Samir Das and Mahesh Marina, University of Cincinnati;
20  *
21  * AODV-UU implementation by Erik Nordström of Uppsala University
22  * https://web.archive.org/web/20100527072022/http://core.it.uu.se/core/index.php/AODV-UU
23  *
24  * Authors: Elena Buchatskaia <borovkovaes@iitp.ru>
25  * Pavel Boyko <boyko@iitp.ru>
26  */
27 #ifndef AODV_RQUEUE_H
28 #define AODV_RQUEUE_H
29 
30 #include "ns3/ipv4-routing-protocol.h"
31 #include "ns3/simulator.h"
32 
33 #include <vector>
34 
35 namespace ns3
36 {
37 namespace aodv
38 {
39 
45 {
46  public:
51 
62  const Ipv4Header& h = Ipv4Header(),
65  Time exp = Simulator::Now())
66  : m_packet(pa),
67  m_header(h),
68  m_ucb(ucb),
69  m_ecb(ecb),
70  m_expire(exp + Simulator::Now())
71  {
72  }
73 
79  bool operator==(const QueueEntry& o) const
80  {
81  return ((m_packet == o.m_packet) &&
83  (m_expire == o.m_expire));
84  }
85 
86  // Fields
92  {
93  return m_ucb;
94  }
95 
101  {
102  m_ucb = ucb;
103  }
104 
110  {
111  return m_ecb;
112  }
113 
119  {
120  m_ecb = ecb;
121  }
122 
128  {
129  return m_packet;
130  }
131 
137  {
138  m_packet = p;
139  }
140 
146  {
147  return m_header;
148  }
149 
155  {
156  m_header = h;
157  }
158 
163  void SetExpireTime(Time exp)
164  {
165  m_expire = exp + Simulator::Now();
166  }
167 
173  {
174  return m_expire - Simulator::Now();
175  }
176 
177  private:
188 };
189 
197 {
198  public:
205  RequestQueue(uint32_t maxLen, Time routeToQueueTimeout)
206  : m_maxLen(maxLen),
207  m_queueTimeout(routeToQueueTimeout)
208  {
209  }
210 
217  bool Enqueue(QueueEntry& entry);
225  bool Dequeue(Ipv4Address dst, QueueEntry& entry);
230  void DropPacketWithDst(Ipv4Address dst);
237  bool Find(Ipv4Address dst);
241  uint32_t GetSize();
242 
243  // Fields
248  uint32_t GetMaxQueueLen() const
249  {
250  return m_maxLen;
251  }
252 
257  void SetMaxQueueLen(uint32_t len)
258  {
259  m_maxLen = len;
260  }
261 
267  {
268  return m_queueTimeout;
269  }
270 
276  {
277  m_queueTimeout = t;
278  }
279 
280  private:
282  std::vector<QueueEntry> m_queue;
284  void Purge();
290  void Drop(QueueEntry en, std::string reason);
292  uint32_t m_maxLen;
296 };
297 
298 } // namespace aodv
299 } // namespace ns3
300 
301 #endif /* AODV_RQUEUE_H */
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Packet header for IPv4.
Definition: ipv4-header.h:34
Ipv4Address GetDestination() const
Definition: ipv4-header.cc:316
Control the scheduling of simulation events.
Definition: simulator.h:68
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
AODV Queue Entry.
Definition: aodv-rqueue.h:45
Time GetExpireTime() const
Get expire time.
Definition: aodv-rqueue.h:172
Ipv4RoutingProtocol::ErrorCallback ErrorCallback
IPv4 routing error callback typedef.
Definition: aodv-rqueue.h:50
Ipv4Header m_header
IP header.
Definition: aodv-rqueue.h:181
void SetErrorCallback(ErrorCallback ecb)
Set error callback.
Definition: aodv-rqueue.h:118
Ptr< const Packet > m_packet
Data packet.
Definition: aodv-rqueue.h:179
bool operator==(const QueueEntry &o) const
Compare queue entries.
Definition: aodv-rqueue.h:79
UnicastForwardCallback m_ucb
Unicast forward callback.
Definition: aodv-rqueue.h:183
ErrorCallback GetErrorCallback() const
Get error callback.
Definition: aodv-rqueue.h:109
void SetPacket(Ptr< const Packet > p)
Set packet in entry.
Definition: aodv-rqueue.h:136
ErrorCallback m_ecb
Error callback.
Definition: aodv-rqueue.h:185
void SetUnicastForwardCallback(UnicastForwardCallback ucb)
Set unicast forward callback.
Definition: aodv-rqueue.h:100
void SetExpireTime(Time exp)
Set expire time.
Definition: aodv-rqueue.h:163
Ipv4Header GetIpv4Header() const
Get IPv4 header.
Definition: aodv-rqueue.h:145
Ipv4RoutingProtocol::UnicastForwardCallback UnicastForwardCallback
IPv4 routing unicast forward callback typedef.
Definition: aodv-rqueue.h:48
UnicastForwardCallback GetUnicastForwardCallback() const
Get unicast forward callback.
Definition: aodv-rqueue.h:91
QueueEntry(Ptr< const Packet > pa=nullptr, const Ipv4Header &h=Ipv4Header(), UnicastForwardCallback ucb=UnicastForwardCallback(), ErrorCallback ecb=ErrorCallback(), Time exp=Simulator::Now())
constructor
Definition: aodv-rqueue.h:61
Time m_expire
Expire time for queue entry.
Definition: aodv-rqueue.h:187
Ptr< const Packet > GetPacket() const
Get packet from entry.
Definition: aodv-rqueue.h:127
void SetIpv4Header(Ipv4Header h)
Set IPv4 header.
Definition: aodv-rqueue.h:154
AODV route request queue.
Definition: aodv-rqueue.h:197
bool Dequeue(Ipv4Address dst, QueueEntry &entry)
Return first found (the earliest) entry for given destination.
Definition: aodv-rqueue.cc:91
uint32_t m_maxLen
The maximum number of packets that we allow a routing protocol to buffer.
Definition: aodv-rqueue.h:292
void SetMaxQueueLen(uint32_t len)
Set maximum queue length.
Definition: aodv-rqueue.h:257
bool Find(Ipv4Address dst)
Finds whether a packet with destination dst exists in the queue.
Definition: aodv-rqueue.cc:107
Time GetQueueTimeout() const
Get queue timeout.
Definition: aodv-rqueue.h:266
void Purge()
Remove all expired entries.
Definition: aodv-rqueue.cc:137
std::vector< QueueEntry > m_queue
The queue.
Definition: aodv-rqueue.h:282
void SetQueueTimeout(Time t)
Set queue timeout.
Definition: aodv-rqueue.h:275
Time m_queueTimeout
The maximum period of time that a routing protocol is allowed to buffer a packet for,...
Definition: aodv-rqueue.h:295
void DropPacketWithDst(Ipv4Address dst)
Remove all packets with destination IP address dst.
Definition: aodv-rqueue.cc:73
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:51
RequestQueue(uint32_t maxLen, Time routeToQueueTimeout)
constructor
Definition: aodv-rqueue.h:205
void Drop(QueueEntry en, std::string reason)
Notify that packet is dropped from queue by timeout.
Definition: aodv-rqueue.cc:151
uint32_t GetMaxQueueLen() const
Get maximum queue length.
Definition: aodv-rqueue.h:248
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:305
Every class exported by the ns3 library is enclosed in the ns3 namespace.