30 #include <ns3/simulator.h>
31 #include <ns3/singleton.h>
32 #include <ns3/uinteger.h>
36 NS_LOG_COMPONENT_DEFINE(
"SatQueue");
41 NS_OBJECT_ENSURE_REGISTERED(SatQueue);
47 TypeId(
"ns3::SatQueue")
49 .AddConstructor<SatQueue>()
50 .AddAttribute(
"MaxPackets",
51 "The maximum number of packets accepted by this SatQueue.",
54 MakeUintegerChecker<uint32_t>())
55 .AddTraceSource(
"Enqueue",
56 "Enqueue a packet in the queue.",
58 "ns3::Packet::TracedCallback")
59 .AddTraceSource(
"Dequeue",
60 "Dequeue a packet from the queue.",
62 "ns3::Packet::TracedCallback")
63 .AddTraceSource(
"Drop",
64 "Drop a packet stored in the queue.",
66 "ns3::Packet::TracedCallback");
77 m_nTotalReceivedBytes(0),
79 m_nTotalReceivedPackets(0),
80 m_nTotalDroppedBytes(0),
81 m_nTotalDroppedPackets(),
82 m_nEnqueBytesSinceReset(0),
83 m_nDequeBytesSinceReset(0),
86 NS_LOG_FUNCTION(
this);
95 m_nTotalReceivedBytes(0),
97 m_nTotalReceivedPackets(0),
98 m_nTotalDroppedBytes(0),
99 m_nTotalDroppedPackets(),
100 m_nEnqueBytesSinceReset(0),
101 m_nDequeBytesSinceReset(0),
102 m_statResetTime(Seconds(0.0))
104 NS_LOG_FUNCTION(
this);
109 NS_LOG_FUNCTION(
this);
115 NS_LOG_FUNCTION(
this);
131 NS_LOG_FUNCTION(
this << flowId);
138 NS_LOG_FUNCTION(
this);
145 NS_LOG_FUNCTION(
this << p->GetSize());
147 NS_LOG_INFO(
"Enque " << p->GetSize() <<
" bytes");
151 NS_LOG_INFO(
"Queue full (at max packets) -- dropping pkt");
153 std::stringstream msg;
154 msg <<
"SatQueue is full: packet dropped!";
155 msg <<
" at: " << Now().GetSeconds() <<
"s";
164 if (p->PeekPacketTag(tag))
173 bool emptyBeforeEnque =
m_packets.empty();
185 NS_LOG_INFO(
"Number packets " <<
m_packets.size());
186 NS_LOG_INFO(
"Number bytes " <<
m_nBytes);
189 if (emptyBeforeEnque ==
true)
204 NS_LOG_FUNCTION(
this);
208 NS_LOG_INFO(
"Queue empty");
220 NS_LOG_INFO(
"Popped " << p);
221 NS_LOG_INFO(
"Number packets " <<
m_packets.size());
222 NS_LOG_INFO(
"Number bytes " <<
m_nBytes);
231 NS_LOG_FUNCTION(
this);
235 NS_LOG_INFO(
"Queue empty");
241 NS_LOG_INFO(
"Number packets " <<
m_packets.size());
242 NS_LOG_INFO(
"Number bytes " <<
m_nBytes);
250 NS_LOG_FUNCTION(
this << p->GetSize());
263 NS_LOG_FUNCTION(
this);
273 NS_LOG_FUNCTION(
this << p->GetSize());
278 NS_LOG_INFO(
"m_traceDrop (p)");
285 NS_LOG_FUNCTION(
this << &cb);
292 NS_LOG_FUNCTION(
this << &cb);
299 NS_LOG_FUNCTION(
this);
315 NS_LOG_FUNCTION(
this);
323 NS_LOG_FUNCTION(
this);
331 NS_LOG_FUNCTION(
this);
339 NS_LOG_FUNCTION(
this);
347 NS_LOG_FUNCTION(
this);
355 NS_LOG_FUNCTION(
this);
363 NS_LOG_FUNCTION(
this << reset);
368 if (duration.IsStrictlyPositive())
372 duration.GetSeconds();
375 duration.GetSeconds();
391 NS_LOG_FUNCTION(
this);
404 NS_LOG_FUNCTION(
this);
414 NS_LOG_FUNCTION(
this << maxPacketSizeBytes);
417 for (PacketContainer_t::const_iterator it =
m_packets.begin(); it !=
m_packets.end(); ++it)
419 if ((*it)->GetSize() <= maxPacketSizeBytes)
This class implements a tag that is used to identify control messages (packages).
@ SAT_LOGON_CTRL_MSG
SAT_LOGON_CTRL_MSG.
SatControlMsgType_t GetMsgType(void) const
Get type of the control message.
@ LOG_WARNING
LOG_WARNING.
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.
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_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
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.
constexpr uint32_t BITS_IN_KBIT
Number of bits consisting a kilobit.
constexpr uint32_t BITS_PER_BYTE
Number of bits in a byte.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
QueueStats_t definition for passing queue related statistics to any interested modules.
uint32_t m_volumeOutBytes
double m_outgoingRateKbps
double m_incomingRateKbps
uint32_t m_queueSizeBytes