A Discrete-Event Network Simulator
API
dsdv-packet-queue.h
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2010 Hemanth Narra
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 * Author: Hemanth Narra <hemanth@ittc.ku.com>
19 *
20 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21 * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22 * Information and Telecommunication Technology Center (ITTC)
23 * and Department of Electrical Engineering and Computer Science
24 * The University of Kansas Lawrence, KS USA.
25 *
26 * Work supported in part by NSF FIND (Future Internet Design) Program
27 * under grant CNS-0626918 (Postmodern Internet Architecture),
28 * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
29 * US Department of Defense (DoD), and ITTC at The University of Kansas.
30 */
31
32#ifndef DSDV_PACKETQUEUE_H
33#define DSDV_PACKETQUEUE_H
34
35#include <vector>
36#include "ns3/ipv4-routing-protocol.h"
37#include "ns3/simulator.h"
38
39namespace ns3 {
40namespace dsdv {
46{
47public:
63 : m_packet (pa),
64 m_header (h),
65 m_ucb (ucb),
66 m_ecb (ecb),
67 m_expire (Seconds (0))
68 {
69 }
70
76 bool operator== (QueueEntry const & o) const
77 {
78 return ((m_packet == o.m_packet) && (m_header.GetDestination () == o.m_header.GetDestination ()) && (m_expire == o.m_expire));
79 }
80
81 // Fields
87 {
88 return m_ucb;
89 }
95 {
96 m_ucb = ucb;
97 }
103 {
104 return m_ecb;
105 }
111 {
112 m_ecb = ecb;
113 }
119 {
120 return m_packet;
121 }
127 {
128 m_packet = p;
129 }
135 {
136 return m_header;
137 }
143 {
144 m_header = h;
145 }
151 {
152 m_expire = exp + Simulator::Now ();
153 }
159 {
160 return m_expire - Simulator::Now ();
161 }
162
163private:
174};
184{
185public:
188 {
189 }
195 bool Enqueue (QueueEntry & entry);
203 bool Dequeue (Ipv4Address dst, QueueEntry & entry);
214 bool Find (Ipv4Address dst);
226 uint32_t GetSize ();
227
228 // Fields
234 {
235 return m_maxLen;
236 }
242 {
243 m_maxLen = len;
244 }
250 {
251 return m_maxLenPerDst;
252 }
258 {
259 m_maxLenPerDst = len;
260 }
266 {
267 return m_queueTimeout;
268 }
274 {
275 m_queueTimeout = t;
276 }
277
278private:
279 std::vector<QueueEntry> m_queue;
281 void Purge ();
287 void Drop (QueueEntry en, std::string reason);
294};
295}
296}
297#endif /* DSDV_PACKETQUEUE_H */
Callback template class.
Definition: callback.h:1279
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Packet header for IPv4.
Definition: ipv4-header.h:34
Ipv4Address GetDestination(void) const
Definition: ipv4-header.cc:304
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
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.
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==(QueueEntry const &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.
QueueEntry(Ptr< const Packet > pa=0, Ipv4Header const &h=Ipv4Header(), UnicastForwardCallback ucb=UnicastForwardCallback(), ErrorCallback ecb=ErrorCallback())
c-tor
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:1244
Every class exported by the ns3 library is enclosed in the ns3 namespace.