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 <deque>
30 #include <queue>
31 #include <stdint.h>
32 #include <vector>
33 
34 namespace ns3
35 {
36 
48 class SatQueue : public Object
49 {
50  public:
55  static TypeId GetTypeId(void);
56 
61  struct QueueStats_t
62  {
64  : m_incomingRateKbps(0.0),
65  m_outgoingRateKbps(0.0),
66  m_volumeInBytes(0),
69  {
70  }
71 
74  uint32_t m_volumeInBytes;
75  uint32_t m_volumeOutBytes;
76  uint32_t m_queueSizeBytes;
77  };
78 
79  typedef enum
80  {
84 
88  SatQueue();
89 
93  SatQueue(uint8_t flowId);
94 
98  ~SatQueue();
99 
103  virtual void DoDispose();
104 
110  typedef Callback<void, Ptr<Packet>> LogonCallback;
111 
118  typedef Callback<void, SatQueue::QueueEvent_t, uint8_t> QueueEventCallback;
119 
124  virtual bool IsEmpty(void) const;
125 
131  virtual bool Enqueue(Ptr<Packet> p);
132 
137  virtual Ptr<Packet> Dequeue(void);
138 
144  virtual void PushFront(Ptr<Packet> p);
145 
150  virtual Ptr<const Packet> Peek(void) const;
151 
155  void DequeueAll(void);
156 
161  void SetFlowId(uint32_t flowId);
162 
168 
174 
179  uint32_t GetNPackets(void) const;
180 
185  uint32_t GetNBytes(void) const;
186 
193  uint32_t GetTotalReceivedBytes(void) const;
194 
201  uint32_t GetTotalReceivedPackets(void) const;
208  uint32_t GetTotalDroppedBytes(void) const;
209 
216  uint32_t GetTotalDroppedPackets(void) const;
217 
222  void ResetStatistics(void);
223 
229  QueueStats_t GetQueueStatistics(bool reset);
230 
239  uint32_t GetNumSmallerPackets(uint32_t maxPacketSizeBytes) const;
240 
241  protected:
246  void Drop(Ptr<Packet> packet);
247 
248  private:
253  void SendEvent(SatQueue::QueueEvent_t event);
254 
260 
261  typedef std::vector<QueueEventCallback> EventCallbackContainer_t;
262  typedef std::deque<Ptr<Packet>> PacketContainer_t;
263 
268 
273 
277  uint32_t m_maxPackets;
278 
282  uint8_t m_flowId;
283 
284  // Statistics
285  uint32_t m_nBytes;
287  uint32_t m_nPackets;
291 
292  // Short term statistics
296 
297  // Trace callbacks
298  TracedCallback<Ptr<const Packet>> m_traceEnqueue;
299  TracedCallback<Ptr<const Packet>> m_traceDequeue;
300  TracedCallback<Ptr<const Packet>> m_traceDrop;
301 
306 };
307 
308 } // namespace ns3
309 
310 #endif /* SATELLITE_QUEUE_H_ */
311 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
312 /*
313  * Copyright (c) 2013 Magister Solutions Ltd.
314  *
315  * This program is free software; you can redistribute it and/or modify
316  * it under the terms of the GNU General Public License version 2 as
317  * published by the Free Software Foundation;
318  *
319  * This program is distributed in the hope that it will be useful,
320  * but WITHOUT ANY WARRANTY; without even the implied warranty of
321  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
322  * GNU General Public License for more details.
323  *
324  * You should have received a copy of the GNU General Public License
325  * along with this program; if not, write to the Free Software
326  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
327  *
328  * Author: Jani Puttonen <jani.puttonen@magister.fi>
329  */
330 
331 #ifndef SATELLITE_QUEUE_H_
332 #define SATELLITE_QUEUE_H_
333 
334 #include <ns3/nstime.h>
335 #include <ns3/object.h>
336 #include <ns3/packet.h>
337 #include <ns3/traced-callback.h>
338 
339 #include <queue>
340 
341 namespace ns3
342 {
343 
355 class SatQueue : public Object
356 {
357  public:
362  static TypeId GetTypeId(void);
363 
368  struct QueueStats_t
369  {
370  QueueStats_t()
371  : m_incomingRateKbps(0.0),
372  m_outgoingRateKbps(0.0),
373  m_volumeInBytes(0),
374  m_volumeOutBytes(0),
376  {
377  }
378 
379  double m_incomingRateKbps;
380  double m_outgoingRateKbps;
381  uint32_t m_volumeInBytes;
382  uint32_t m_volumeOutBytes;
383  uint32_t m_queueSizeBytes;
384  };
385 
386  typedef enum
387  {
390  } QueueEvent_t;
391 
395  SatQueue();
396 
400  SatQueue(uint8_t flowId);
401 
405  ~SatQueue();
406 
410  virtual void DoDispose();
411 
417  typedef Callback<void, Ptr<Packet>> LogonCallback;
418 
425  typedef Callback<void, SatQueue::QueueEvent_t, uint8_t> QueueEventCallback;
426 
431  virtual bool IsEmpty(void) const;
432 
438  virtual bool Enqueue(Ptr<Packet> p);
439 
444  virtual Ptr<Packet> Dequeue(void);
445 
451  virtual void PushFront(Ptr<Packet> p);
452 
457  virtual Ptr<const Packet> Peek(void) const;
458 
462  void DequeueAll(void);
463 
468  void SetFlowId(uint32_t flowId);
469 
475 
481 
486  uint32_t GetNPackets(void) const;
487 
492  uint32_t GetNBytes(void) const;
493 
500  uint32_t GetTotalReceivedBytes(void) const;
501 
508  uint32_t GetTotalReceivedPackets(void) const;
515  uint32_t GetTotalDroppedBytes(void) const;
516 
523  uint32_t GetTotalDroppedPackets(void) const;
524 
529  void ResetStatistics(void);
530 
536  QueueStats_t GetQueueStatistics(bool reset);
537 
546  uint32_t GetNumSmallerPackets(uint32_t maxPacketSizeBytes) const;
547 
548  protected:
553  void Drop(Ptr<Packet> packet);
554 
555  private:
560  void SendEvent(SatQueue::QueueEvent_t event);
561 
567 
568  typedef std::vector<QueueEventCallback> EventCallbackContainer_t;
569  typedef std::deque<Ptr<Packet>> PacketContainer_t;
570 
575 
580 
584  uint32_t m_maxPackets;
585 
589  uint8_t m_flowId;
590 
591  // Statistics
592  uint32_t m_nBytes;
593  uint32_t m_nTotalReceivedBytes;
594  uint32_t m_nPackets;
595  uint32_t m_nTotalReceivedPackets;
596  uint32_t m_nTotalDroppedBytes;
597  uint32_t m_nTotalDroppedPackets;
598 
599  // Short term statistics
600  uint32_t m_nEnqueBytesSinceReset;
601  uint32_t m_nDequeBytesSinceReset;
602  Time m_statResetTime;
603 
604  // Trace callbacks
605  TracedCallback<Ptr<const Packet>> m_traceEnqueue;
606  TracedCallback<Ptr<const Packet>> m_traceDequeue;
607  TracedCallback<Ptr<const Packet>> m_traceDrop;
608 
613 };
614 
615 } // namespace ns3
616 
617 #endif /* SATELLITE_QUEUE_H_ */
618 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
619 /*
620  * Copyright (c) 2013 Magister Solutions Ltd.
621  *
622  * This program is free software; you can redistribute it and/or modify
623  * it under the terms of the GNU General Public License version 2 as
624  * published by the Free Software Foundation;
625  *
626  * This program is distributed in the hope that it will be useful,
627  * but WITHOUT ANY WARRANTY; without even the implied warranty of
628  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
629  * GNU General Public License for more details.
630  *
631  * You should have received a copy of the GNU General Public License
632  * along with this program; if not, write to the Free Software
633  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
634  *
635  * Author: Jani Puttonen <jani.puttonen@magister.fi>
636  */
637 
638 #ifndef SATELLITE_QUEUE_H_
639 #define SATELLITE_QUEUE_H_
640 
641 #include <ns3/nstime.h>
642 #include <ns3/object.h>
643 #include <ns3/packet.h>
644 #include <ns3/traced-callback.h>
645 
646 #include <queue>
647 
648 namespace ns3
649 {
650 
662 class SatQueue : public Object
663 {
664  public:
669  static TypeId GetTypeId(void);
670 
675  struct QueueStats_t
676  {
677  QueueStats_t()
678  : m_incomingRateKbps(0.0),
679  m_outgoingRateKbps(0.0),
680  m_volumeInBytes(0),
681  m_volumeOutBytes(0),
683  {
684  }
685 
686  double m_incomingRateKbps;
687  double m_outgoingRateKbps;
688  uint32_t m_volumeInBytes;
689  uint32_t m_volumeOutBytes;
690  uint32_t m_queueSizeBytes;
691  };
692 
693  typedef enum
694  {
697  } QueueEvent_t;
698 
702  SatQueue();
703 
707  SatQueue(uint8_t flowId);
708 
712  ~SatQueue();
713 
717  virtual void DoDispose();
718 
724  typedef Callback<void, Ptr<Packet>> LogonCallback;
725 
732  typedef Callback<void, SatQueue::QueueEvent_t, uint8_t> QueueEventCallback;
733 
738  virtual bool IsEmpty(void) const;
739 
745  virtual bool Enqueue(Ptr<Packet> p);
746 
751  virtual Ptr<Packet> Dequeue(void);
752 
758  virtual void PushFront(Ptr<Packet> p);
759 
764  virtual Ptr<const Packet> Peek(void) const;
765 
769  void DequeueAll(void);
770 
775  void SetFlowId(uint32_t flowId);
776 
782 
788 
793  uint32_t GetNPackets(void) const;
794 
799  uint32_t GetNBytes(void) const;
800 
807  uint32_t GetTotalReceivedBytes(void) const;
808 
815  uint32_t GetTotalReceivedPackets(void) const;
822  uint32_t GetTotalDroppedBytes(void) const;
823 
830  uint32_t GetTotalDroppedPackets(void) const;
831 
836  void ResetStatistics(void);
837 
843  QueueStats_t GetQueueStatistics(bool reset);
844 
853  uint32_t GetNumSmallerPackets(uint32_t maxPacketSizeBytes) const;
854 
855  protected:
860  void Drop(Ptr<Packet> packet);
861 
862  private:
867  void SendEvent(SatQueue::QueueEvent_t event);
868 
874 
875  typedef std::vector<QueueEventCallback> EventCallbackContainer_t;
876  typedef std::deque<Ptr<Packet>> PacketContainer_t;
877 
882 
887 
891  uint32_t m_maxPackets;
892 
896  uint8_t m_flowId;
897 
898  // Statistics
899  uint32_t m_nBytes;
900  uint32_t m_nTotalReceivedBytes;
901  uint32_t m_nPackets;
902  uint32_t m_nTotalReceivedPackets;
903  uint32_t m_nTotalDroppedBytes;
904  uint32_t m_nTotalDroppedPackets;
905 
906  // Short term statistics
907  uint32_t m_nEnqueBytesSinceReset;
908  uint32_t m_nDequeBytesSinceReset;
909  Time m_statResetTime;
910 
911  // Trace callbacks
912  TracedCallback<Ptr<const Packet>> m_traceEnqueue;
913  TracedCallback<Ptr<const Packet>> m_traceDequeue;
914  TracedCallback<Ptr<const Packet>> m_traceDrop;
915 
920 };
921 
922 } // namespace ns3
923 
924 #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.