10#include "ns3/drop-tail-queue.h"
11#include "ns3/packet.h"
12#include "ns3/queue-disc.h"
13#include "ns3/simulator.h"
285 qd->TraceConnectWithoutContext(
"DropBeforeEnqueue",
309 void DoRun()
override;
338 :
TestCase(
"Sanity check on the queue disc traces and statistics")
347 "Verify that the number of queued packets is computed correctly");
350 "Verify that the number of queued packets is computed correctly");
354 "Verify that the number of queued bytes is computed correctly");
357 "Verify that the number of queued bytes is computed correctly");
370 "Verify that the number of packets dropped before enqueue is computed correctly");
374 "Verify that the number of packets dropped before enqueue is computed correctly");
379 "Verify that the number of bytes dropped before enqueue is computed correctly");
383 "Verify that the number of bytes dropped before enqueue is computed correctly");
396 "Verify that the number of packets dropped after dequeue is computed correctly");
400 "Verify that the number of packets dropped after dequeue is computed correctly");
405 "Verify that the number of bytes dropped after dequeue is computed correctly");
409 "Verify that the number of bytes dropped after dequeue is computed correctly");
423 Ptr<QueueDisc> child = root->GetQueueDiscClass(0)->GetQueueDisc();
435 for (uint16_t i = 1; i <= 4; i++)
439 CheckQueued(root, i, pktSizeUnit * i * (i + 1) / 2);
443 CheckQueued(child, i, pktSizeUnit * i * (i + 1) / 2);
474 "The peeked packet has not the expected size");
490 "The peeked packet has not the expected size");
501 item = root->Dequeue();
506 "The dequeued packet has not the expected size");
517 item = root->Dequeue();
522 "The dequeued packet has not the expected size");
557 item = root->Dequeue();
562 "The dequeued packet has not the expected size");
void AddHeader() override
Add the header to the packet.
bool Mark() override
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
QdTestItem(Ptr< Packet > p, const Address &addr)
Constructor.
Queue Disc Traces Test Case.
QueueDiscTracesTestCase()
void DoRun() override
Implementation to actually run this TestCase.
std::map< Ptr< QueueDisc >, TestCounter > m_counter
counters for the queue discs
void CheckDroppedAfterDequeue(Ptr< QueueDisc > qd, uint32_t nDadPackets, uint32_t nDadBytes)
Check that packets/bytes dropped after dequeue are consistent with what is expected.
void CheckDroppedBeforeEnqueue(Ptr< QueueDisc > qd, uint32_t nDbePackets, uint32_t nDbeBytes)
Check that packets/bytes dropped before enqueue are consistent with what is expected.
void CheckQueued(Ptr< QueueDisc > qd, uint32_t nPackets, uint32_t nBytes)
Check that queued packets/bytes are consistent with what is expected.
QueueDiscTracesTestSuite()
static constexpr const char * AFTER_DEQUEUE
Drop after dequeue.
~TestChildQueueDisc() override
bool DoEnqueue(Ptr< QueueDiscItem > item) override
This function actually enqueues a packet into the queue disc.
Ptr< QueueDiscItem > DoDequeue() override
This function actually extracts a packet from the queue disc.
TestChildQueueDisc()
Constructor.
void InitializeParams() override
Initialize parameters (if any) before the first packet is enqueued.
static constexpr const char * BEFORE_ENQUEUE
Drop before enqueue.
bool CheckConfig() override
Check whether the current configuration is correct.
Keep statistics based on traces.
void PacketDequeued(Ptr< const QueueDiscItem > item)
Update statistics after a packet has been dequeued.
void PacketDad(Ptr< const QueueDiscItem > item, const char *reason)
Update statistics after a packet has been dropped after dequeue.
void PacketDbe(Ptr< const QueueDiscItem > item, const char *reason)
Update statistics after a packet has been dropped before enqueue.
friend class QueueDiscTracesTestCase
Needs to access private members.
uint32_t m_nDbeBytes
Number of packets dropped before enqueue.
void PacketEnqueued(Ptr< const QueueDiscItem > item)
Update statistics after a packet has been enqueued.
uint32_t m_nPackets
Number of queued packets.
uint32_t m_nBytes
Number of queued bytes.
TestCounter()
Constructor.
uint32_t m_nDbePackets
Number of packets dropped before enqueue.
uint32_t m_nDadBytes
Number of packets dropped after dequeue.
uint32_t m_nDadPackets
Number of packets dropped after dequeue.
void ConnectTraces(Ptr< QueueDisc > qd)
Connect private methods to the queue disc traces.
TestParentQueueDisc()
Constructor.
Ptr< QueueDiscItem > DoDequeue() override
This function actually extracts a packet from the queue disc.
bool CheckConfig() override
Check whether the current configuration is correct.
void InitializeParams() override
Initialize parameters (if any) before the first packet is enqueued.
bool DoEnqueue(Ptr< QueueDiscItem > item) override
This function actually enqueues a packet into the queue disc.
~TestParentQueueDisc() override
a polymophic address class
A FIFO packet queue that drops tail-end packets on overflow.
Smart pointer class similar to boost::intrusive_ptr.
void AddInternalQueue(Ptr< InternalQueue > queue)
Add an internal queue to the tail of the list of queues.
void AddQueueDiscClass(Ptr< QueueDiscClass > qdClass)
Add a queue disc class to the tail of the list of classes.
uint32_t GetNPackets() const
Get the number of packets stored by the queue disc.
QueueDisc(QueueDiscSizePolicy policy=QueueDiscSizePolicy::SINGLE_INTERNAL_QUEUE)
Constructor.
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
void DropAfterDequeue(Ptr< const QueueDiscItem > item, const char *reason)
Perform the actions required when the queue disc is notified of a packet dropped after dequeue.
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
void DropBeforeEnqueue(Ptr< const QueueDiscItem > item, const char *reason)
Perform the actions required when the queue disc is notified of a packet dropped before enqueue.
QueueDiscItem(Ptr< Packet > p, const Address &addr, uint16_t protocol)
Create a queue disc item.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
@ UNIT
This test suite implements a Unit Test.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
QueueDiscTracesTestSuite g_queueDiscTracesTestSuite
the test suite
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
@ SINGLE_INTERNAL_QUEUE
Used by queue discs with single internal queue.
@ SINGLE_CHILD_QUEUE_DISC
Used by queue discs with single child queue disc.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Structure that keeps the queue disc statistics.
uint64_t nTotalDroppedBytesBeforeEnqueue
Total bytes dropped before enqueue.
uint64_t nTotalDroppedBytesAfterDequeue
Total bytes dropped after dequeue.
uint32_t nTotalDroppedPacketsBeforeEnqueue
Total packets dropped before enqueue.
uint32_t nTotalDroppedPacketsAfterDequeue
Total packets dropped after dequeue.