30 #include <ns3/simulator.h>
31 #include <ns3/singleton.h>
32 #include <ns3/uinteger.h>
34 NS_LOG_COMPONENT_DEFINE(
"SatQueue");
39 NS_OBJECT_ENSURE_REGISTERED(SatQueue);
45 TypeId(
"ns3::SatQueue")
47 .AddConstructor<SatQueue>()
48 .AddAttribute(
"MaxPackets",
49 "The maximum number of packets accepted by this SatQueue.",
52 MakeUintegerChecker<uint32_t>())
53 .AddTraceSource(
"Enqueue",
54 "Enqueue a packet in the queue.",
56 "ns3::Packet::TracedCallback")
57 .AddTraceSource(
"Dequeue",
58 "Dequeue a packet from the queue.",
60 "ns3::Packet::TracedCallback")
61 .AddTraceSource(
"Drop",
62 "Drop a packet stored in the queue.",
64 "ns3::Packet::TracedCallback");
75 m_nTotalReceivedBytes(0),
77 m_nTotalReceivedPackets(0),
78 m_nTotalDroppedBytes(0),
79 m_nTotalDroppedPackets(),
80 m_nEnqueBytesSinceReset(0),
81 m_nDequeBytesSinceReset(0),
84 NS_LOG_FUNCTION(
this);
93 m_nTotalReceivedBytes(0),
95 m_nTotalReceivedPackets(0),
96 m_nTotalDroppedBytes(0),
97 m_nTotalDroppedPackets(),
98 m_nEnqueBytesSinceReset(0),
99 m_nDequeBytesSinceReset(0),
100 m_statResetTime(Seconds(0.0))
102 NS_LOG_FUNCTION(
this);
107 NS_LOG_FUNCTION(
this);
113 NS_LOG_FUNCTION(
this);
129 NS_LOG_FUNCTION(
this << flowId);
136 NS_LOG_FUNCTION(
this);
143 NS_LOG_FUNCTION(
this << p->GetSize());
145 NS_LOG_INFO(
"Enque " << p->GetSize() <<
" bytes");
149 NS_LOG_INFO(
"Queue full (at max packets) -- dropping pkt");
151 std::stringstream msg;
152 msg <<
"SatQueue is full: packet dropped!";
153 msg <<
" at: " << Now().GetSeconds() <<
"s";
162 if (p->PeekPacketTag(tag))
171 bool emptyBeforeEnque =
m_packets.empty();
183 NS_LOG_INFO(
"Number packets " <<
m_packets.size());
184 NS_LOG_INFO(
"Number bytes " <<
m_nBytes);
187 if (emptyBeforeEnque ==
true)
202 NS_LOG_FUNCTION(
this);
206 NS_LOG_INFO(
"Queue empty");
218 NS_LOG_INFO(
"Popped " << p);
219 NS_LOG_INFO(
"Number packets " <<
m_packets.size());
220 NS_LOG_INFO(
"Number bytes " <<
m_nBytes);
229 NS_LOG_FUNCTION(
this);
233 NS_LOG_INFO(
"Queue empty");
239 NS_LOG_INFO(
"Number packets " <<
m_packets.size());
240 NS_LOG_INFO(
"Number bytes " <<
m_nBytes);
248 NS_LOG_FUNCTION(
this << p->GetSize());
261 NS_LOG_FUNCTION(
this);
271 NS_LOG_FUNCTION(
this << p->GetSize());
276 NS_LOG_INFO(
"m_traceDrop (p)");
283 NS_LOG_FUNCTION(
this << &cb);
290 NS_LOG_FUNCTION(
this << &cb);
297 NS_LOG_FUNCTION(
this);
313 NS_LOG_FUNCTION(
this);
321 NS_LOG_FUNCTION(
this);
329 NS_LOG_FUNCTION(
this);
337 NS_LOG_FUNCTION(
this);
345 NS_LOG_FUNCTION(
this);
353 NS_LOG_FUNCTION(
this);
361 NS_LOG_FUNCTION(
this << reset);
366 if (duration.IsStrictlyPositive())
370 duration.GetSeconds();
373 duration.GetSeconds();
389 NS_LOG_FUNCTION(
this);
402 NS_LOG_FUNCTION(
this);
412 NS_LOG_FUNCTION(
this << maxPacketSizeBytes);
415 for (PacketContainer_t::const_iterator it =
m_packets.begin(); it !=
m_packets.end(); ++it)
417 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