A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
dsr-network-queue.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Yufei Cheng
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: Yufei Cheng <yfcheng@ittc.ku.edu>
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 DSR_NETWORK_QUEUE_H
33 #define DSR_NETWORK_QUEUE_H
34 
35 #include <vector>
36 #include "ns3/ipv4-routing-protocol.h"
37 #include "ns3/simulator.h"
38 #include "ns3/ipv4-header.h"
39 #include "dsr-option-header.h"
40 
41 namespace ns3 {
42 namespace dsr {
43 
45 {
48 };
54 {
55 public:
58  Time exp = Simulator::Now (), Ptr<Ipv4Route> r = 0)
59  : m_packet (pa),
60  m_srcAddr (s),
61  m_nextHopAddr (n),
62  tstamp (exp),
63  m_ipv4Route (r)
64  {
65  }
70  bool operator== (DsrNetworkQueueEntry const & o) const
71  {
72  return ((m_packet == o.m_packet) && (m_srcAddr == o.m_srcAddr) && (m_nextHopAddr == o.m_nextHopAddr)
73  && (tstamp == o.tstamp) && (m_ipv4Route == o.m_ipv4Route));
74  }
75 
77  //\{
79  {
80  return m_packet;
81  }
83  {
84  m_packet = p;
85  }
87  {
88  return m_ipv4Route;
89  }
91  {
92  m_ipv4Route = route;
93  }
95  {
96  return m_srcAddr;
97  }
99  {
100  m_srcAddr = addr;
101  }
103  {
104  return m_nextHopAddr;
105  }
107  {
108  m_nextHopAddr = addr;
109  }
111  {
112  return tstamp;
113  }
115  {
116  tstamp = time;
117  }
118  //\}
119 private:
127 };
128 
129 class DsrNetworkQueue : public Object
130 {
131 public:
132  static TypeId GetTypeID (void);
134  DsrNetworkQueue ();
135  DsrNetworkQueue (uint32_t maxLen, Time maxDelay);
136  ~DsrNetworkQueue ();
138  bool Enqueue (DsrNetworkQueueEntry & entry);
140  bool Dequeue (DsrNetworkQueueEntry & entry);
142  uint32_t GetSize ();
143 
144  void SetMaxNetworkSize (uint32_t maxSize);
145  void SetMaxNetworkDelay (Time delay);
146  uint32_t GetMaxNetworkSize (void) const;
147  Time GetMaxNetworkDelay (void) const;
148  void Flush (void);
149 
150  std::vector<DsrNetworkQueueEntry> & GetQueue ()
151  {
152  return m_dsrNetworkQueue;
153  }
154 
155 private:
156  void Cleanup (void);
157  std::vector<DsrNetworkQueueEntry> m_dsrNetworkQueue;
158  uint32_t m_size;
159  uint32_t m_maxSize;
161 };
162 
163 } // namespace dsr
164 } // namespace ns3
165 
166 #endif /* DSR_NETWORK_QUEUE_H */