satellite-queue.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 Magister Solutions Ltd.
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: Jani Puttonen <jani.puttonen@magister.fi>
19  */
20 
21 #ifndef SATELLITE_QUEUE_H_
22 #define SATELLITE_QUEUE_H_
23 
24 #include <ns3/nstime.h>
25 #include <ns3/object.h>
26 #include <ns3/packet.h>
27 #include <ns3/traced-callback.h>
28 
29 #include <queue>
30 
31 namespace ns3
32 {
33 
45 class SatQueue : public Object
46 {
47  public:
52  static TypeId GetTypeId(void);
53 
58  struct QueueStats_t
59  {
61  : m_incomingRateKbps(0.0),
62  m_outgoingRateKbps(0.0),
63  m_volumeInBytes(0),
66  {
67  }
68 
71  uint32_t m_volumeInBytes;
72  uint32_t m_volumeOutBytes;
73  uint32_t m_queueSizeBytes;
74  };
75 
76  typedef enum
77  {
81 
85  SatQueue();
86 
90  SatQueue(uint8_t flowId);
91 
95  ~SatQueue();
96 
100  virtual void DoDispose();
101 
107  typedef Callback<void, Ptr<Packet>> LogonCallback;
108 
115  typedef Callback<void, SatQueue::QueueEvent_t, uint8_t> QueueEventCallback;
116 
121  virtual bool IsEmpty(void) const;
122 
128  virtual bool Enqueue(Ptr<Packet> p);
129 
134  virtual Ptr<Packet> Dequeue(void);
135 
141  virtual void PushFront(Ptr<Packet> p);
142 
147  virtual Ptr<const Packet> Peek(void) const;
148 
152  void DequeueAll(void);
153 
158  void SetFlowId(uint32_t flowId);
159 
165 
171 
176  uint32_t GetNPackets(void) const;
177 
182  uint32_t GetNBytes(void) const;
183 
190  uint32_t GetTotalReceivedBytes(void) const;
191 
198  uint32_t GetTotalReceivedPackets(void) const;
205  uint32_t GetTotalDroppedBytes(void) const;
206 
213  uint32_t GetTotalDroppedPackets(void) const;
214 
219  void ResetStatistics(void);
220 
226  QueueStats_t GetQueueStatistics(bool reset);
227 
236  uint32_t GetNumSmallerPackets(uint32_t maxPacketSizeBytes) const;
237 
238  protected:
243  void Drop(Ptr<Packet> packet);
244 
245  private:
250  void SendEvent(SatQueue::QueueEvent_t event);
251 
257 
258  typedef std::vector<QueueEventCallback> EventCallbackContainer_t;
259  typedef std::deque<Ptr<Packet>> PacketContainer_t;
260 
265 
270 
274  uint32_t m_maxPackets;
275 
279  uint8_t m_flowId;
280 
281  // Statistics
282  uint32_t m_nBytes;
284  uint32_t m_nPackets;
288 
289  // Short term statistics
293 
294  // Trace callbacks
295  TracedCallback<Ptr<const Packet>> m_traceEnqueue;
296  TracedCallback<Ptr<const Packet>> m_traceDequeue;
297  TracedCallback<Ptr<const Packet>> m_traceDrop;
298 
303 };
304 
305 } // namespace ns3
306 
307 #endif /* SATELLITE_QUEUE_H_ */
SatQueue implements a queue utilized in the satellite module.
uint32_t m_nTotalReceivedPackets
~SatQueue()
Destructor for SatQueue.
static TypeId GetTypeId(void)
Get the type ID.
virtual void DoDispose()
Dispose of this class instance.
virtual Ptr< const Packet > Peek(void) const
Get a copy of the item at the front of the queue without removing it.
virtual bool IsEmpty(void) const
Is the queue empty.
PacketContainer_t m_packets
Packet container.
void SetFlowId(uint32_t flowId)
Configured flow index for this queue.
void ResetShortTermStatistics()
Reset the short term statistics.
uint32_t m_nEnqueBytesSinceReset
EventCallbackContainer_t m_queueEventCallbacks
Container of callbacks for queue related events.
virtual void PushFront(Ptr< Packet > p)
PushFront pushes a fragmented packet back to the front of the packet container.
Callback< void, SatQueue::QueueEvent_t, uint8_t > QueueEventCallback
Callback to indicate queue related event.
uint32_t GetTotalReceivedBytes(void) const
Get total number of bytes received by this queue since the simulation began, or since ResetStatistics...
void Drop(Ptr< Packet > packet)
Drop a packet.
Callback< void, Ptr< Packet > > LogonCallback
logon msg sending callback
void DequeueAll(void)
Flush the queue.
std::deque< Ptr< Packet > > PacketContainer_t
uint32_t m_nTotalReceivedBytes
void AddLogonCallback(SatQueue::LogonCallback cb)
Add queue event callback.
virtual bool Enqueue(Ptr< Packet > p)
Enque pushes packet to the packet container (back)
LogonCallback m_logonCallback
Callback to send control messages.
TracedCallback< Ptr< const Packet > > m_traceDrop
uint8_t m_flowId
An unique id for each queue.
uint32_t GetNumSmallerPackets(uint32_t maxPacketSizeBytes) const
Method checks how many packets are smaller or equal in size than the maximum packets size threshold s...
uint32_t GetTotalDroppedBytes(void) const
Get total number of bytes dropped by this Queue since the simulation began, or since ResetStatistics ...
TracedCallback< Ptr< const Packet > > m_traceEnqueue
uint32_t GetNPackets(void) const
Get number of packets currently stored in the queue.
uint32_t m_nTotalDroppedPackets
uint32_t m_nPackets
uint32_t m_nTotalDroppedBytes
void SendEvent(SatQueue::QueueEvent_t event)
Send queue event to all registered callbacks.
virtual Ptr< Packet > Dequeue(void)
Deque takes packet from the packet container (front)
uint32_t m_nDequeBytesSinceReset
void ResetStatistics(void)
Resets the counts for dropped packets, dropped bytes, received packets, and received bytes.
void AddQueueEventCallback(SatQueue::QueueEventCallback cb)
Add queue event callback.
TracedCallback< Ptr< const Packet > > m_traceDequeue
std::vector< QueueEventCallback > EventCallbackContainer_t
uint32_t GetTotalReceivedPackets(void) const
Get total number of packets received by this Queue since the simulation began, or since ResetStatisti...
uint32_t GetTotalDroppedPackets(void) const
Get total number of bytes dropped by this Queue since the simulation began, or since ResetStatistics ...
uint32_t m_maxPackets
Maximum allowed packets within the packet container.
uint32_t GetNBytes(void) const
Get number of bytes currently stored in the queue.
SatQueue()
Default constructor.
QueueStats_t GetQueueStatistics(bool reset)
GetQueueStatistics returns a struct of KPIs.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
QueueStats_t definition for passing queue related statistics to any interested modules.