A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
39 namespace ns3 {
40 namespace dsdv {
46 {
47 public:
54  : m_packet (pa),
55  m_header (h),
56  m_ucb (ucb),
57  m_ecb (ecb),
58  m_expire (Seconds (0))
59  {
60  }
61 
66  bool operator== (QueueEntry const & o) const
67  {
68  return ((m_packet == o.m_packet) && (m_header.GetDestination () == o.m_header.GetDestination ()) && (m_expire == o.m_expire));
69  }
71  // \{
73  {
74  return m_ucb;
75  }
77  {
78  m_ucb = ucb;
79  }
81  {
82  return m_ecb;
83  }
85  {
86  m_ecb = ecb;
87  }
89  {
90  return m_packet;
91  }
93  {
94  m_packet = p;
95  }
97  {
98  return m_header;
99  }
101  {
102  m_header = h;
103  }
104  void SetExpireTime (Time exp)
105  {
106  m_expire = exp + Simulator::Now ();
107  }
109  {
110  return m_expire - Simulator::Now ();
111  }
112  // \}
113 private:
124 };
134 {
135 public:
138  {
139  }
141  bool Enqueue (QueueEntry & entry);
143  bool Dequeue (Ipv4Address dst, QueueEntry & entry);
145  void DropPacketWithDst (Ipv4Address dst);
147  bool Find (Ipv4Address dst);
149  uint32_t
152  uint32_t GetSize ();
154  // \{
155  uint32_t GetMaxQueueLen () const
156  {
157  return m_maxLen;
158  }
159  void SetMaxQueueLen (uint32_t len)
160  {
161  m_maxLen = len;
162  }
163  uint32_t GetMaxPacketsPerDst () const
164  {
165  return m_maxLenPerDst;
166  }
167  void SetMaxPacketsPerDst (uint32_t len)
168  {
169  m_maxLenPerDst = len;
170  }
172  {
173  return m_queueTimeout;
174  }
176  {
177  m_queueTimeout = t;
178  }
179  // \}
180 
181 private:
182  std::vector<QueueEntry> m_queue;
184  void Purge ();
186  void Drop (QueueEntry en, std::string reason);
188  uint32_t m_maxLen;
190  uint32_t m_maxLenPerDst;
193  static bool IsEqual (QueueEntry en, const Ipv4Address dst)
194  {
195  return (en.GetIpv4Header ().GetDestination () == dst);
196  }
197 };
198 }
199 }
200 #endif /* DSDV_PACKETQUEUE_H */