A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
dsdv-packet-queue.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Hemanth Narra
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 * Author: Hemanth Narra <hemanth@ittc.ku.com>
18 *
19 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
20 * ResiliNets Research Group https://resilinets.org/
21 * Information and Telecommunication Technology Center (ITTC)
22 * and Department of Electrical Engineering and Computer Science
23 * The University of Kansas Lawrence, KS USA.
24 *
25 * Work supported in part by NSF FIND (Future Internet Design) Program
26 * under grant CNS-0626918 (Postmodern Internet Architecture),
27 * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
28 * US Department of Defense (DoD), and ITTC at The University of Kansas.
29 */
30
31#ifndef DSDV_PACKETQUEUE_H
32#define DSDV_PACKETQUEUE_H
33
34#include "ns3/ipv4-routing-protocol.h"
35#include "ns3/simulator.h"
36
37#include <vector>
38
39namespace ns3
40{
41namespace dsdv
42{
48{
49 public:
54
64 const Ipv4Header& h = Ipv4Header(),
67 : m_packet(pa),
68 m_header(h),
69 m_ucb(ucb),
70 m_ecb(ecb),
72 {
73 }
74
80 bool operator==(const QueueEntry& o) const
81 {
82 return ((m_packet == o.m_packet) &&
84 (m_expire == o.m_expire));
85 }
86
87 // Fields
93 {
94 return m_ucb;
95 }
96
102 {
103 m_ucb = ucb;
104 }
105
111 {
112 return m_ecb;
113 }
114
120 {
121 m_ecb = ecb;
122 }
123
129 {
130 return m_packet;
131 }
132
138 {
139 m_packet = p;
140 }
141
147 {
148 return m_header;
149 }
150
156 {
157 m_header = h;
158 }
159
165 {
166 m_expire = exp + Simulator::Now();
167 }
168
174 {
175 return m_expire - Simulator::Now();
176 }
177
178 private:
189};
190
200{
201 public:
204 {
205 }
206
213 bool Enqueue(QueueEntry& entry);
221 bool Dequeue(Ipv4Address dst, QueueEntry& entry);
232 bool Find(Ipv4Address dst);
244
245 // Fields
251 {
252 return m_maxLen;
253 }
254
260 {
261 m_maxLen = len;
262 }
263
269 {
270 return m_maxLenPerDst;
271 }
272
278 {
279 m_maxLenPerDst = len;
280 }
281
287 {
288 return m_queueTimeout;
289 }
290
296 {
297 m_queueTimeout = t;
298 }
299
300 private:
301 std::vector<QueueEntry> m_queue;
303 void Purge();
309 void Drop(QueueEntry en, std::string reason);
317};
318} // namespace dsdv
319} // namespace ns3
320#endif /* DSDV_PACKETQUEUE_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
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:199
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
DSDV Packet queue.
std::vector< QueueEntry > m_queue
the queue
bool Find(Ipv4Address dst)
Finds whether a packet with destination dst exists in the queue.
bool Enqueue(QueueEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue.
uint32_t GetMaxPacketsPerDst() const
Get maximum packets per destination.
void SetQueueTimeout(Time t)
Set queue timeout.
bool Dequeue(Ipv4Address dst, QueueEntry &entry)
Return first found (the earliest) entry for given destination.
void SetMaxPacketsPerDst(uint32_t len)
Set maximum packets per destination.
void DropPacketWithDst(Ipv4Address dst)
Remove all packets with destination IP address dst.
uint32_t GetSize()
Get the number of entries.
void Drop(QueueEntry en, std::string reason)
Notify that the packet is dropped from queue due to timeout.
Time GetQueueTimeout() const
Get queue timeout.
uint32_t GetCountForPacketsWithDst(Ipv4Address dst)
Get count of packets with destination dst in the queue.
PacketQueue()
Default c-tor.
uint32_t m_maxLenPerDst
The maximum number of packets that we allow per destination to buffer.
uint32_t GetMaxQueueLen() const
Get maximum queue length.
void SetMaxQueueLen(uint32_t len)
Set maximum queue length.
uint32_t m_maxLen
The maximum number of packets that we allow a routing protocol to buffer.
void Purge()
Remove all expired entries.
Time m_queueTimeout
The maximum period of time that a routing protocol is allowed to buffer a packet for,...
DSDV Queue Entry.
Ptr< const Packet > GetPacket() const
Get packet.
void SetErrorCallback(ErrorCallback ecb)
Set error callback function.
void SetUnicastForwardCallback(UnicastForwardCallback ucb)
Set unicast forward callback function.
void SetExpireTime(Time exp)
Set expire time.
QueueEntry(Ptr< const Packet > pa=nullptr, const Ipv4Header &h=Ipv4Header(), UnicastForwardCallback ucb=UnicastForwardCallback(), ErrorCallback ecb=ErrorCallback())
c-tor
Time GetExpireTime() const
Get expire time.
void SetPacket(Ptr< const Packet > p)
Set packet.
Ipv4RoutingProtocol::UnicastForwardCallback UnicastForwardCallback
Unicast forward call back function typedef.
Ptr< const Packet > m_packet
Data packet.
UnicastForwardCallback m_ucb
Unicast forward callback.
ErrorCallback GetErrorCallback() const
Get error callback function.
bool operator==(const QueueEntry &o) const
Compare queue entries.
ErrorCallback m_ecb
Error callback.
Ipv4Header GetIpv4Header() const
Get IP header.
Ipv4Header m_header
IP header.
Time m_expire
Expire time for queue entry.
Ipv4RoutingProtocol::ErrorCallback ErrorCallback
Error callback function typedef.
void SetIpv4Header(Ipv4Header h)
Set IP header.
UnicastForwardCallback GetUnicastForwardCallback() const
Get unicast forward callback function.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1336
Every class exported by the ns3 library is enclosed in the ns3 namespace.