23 #include "ns3/queue-disc.h" 24 #include "ns3/drop-tail-queue.h" 25 #include "ns3/packet.h" 26 #include "ns3/simulator.h" 48 virtual void AddHeader (
void);
49 virtual bool Mark (
void);
329 virtual void DoRun (
void);
358 :
TestCase (
"Sanity check on the queue disc traces and statistics")
366 "Verify that the number of queued packets is computed correctly");
368 "Verify that the number of queued packets is computed correctly");
371 "Verify that the number of queued bytes is computed correctly");
373 "Verify that the number of queued bytes is computed correctly");
382 "Verify that the number of packets dropped before enqueue is computed correctly");
384 "Verify that the number of packets dropped before enqueue is computed correctly");
387 "Verify that the number of bytes dropped before enqueue is computed correctly");
389 "Verify that the number of bytes dropped before enqueue is computed correctly");
398 "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");
403 "Verify that the number of bytes dropped after dequeue is computed correctly");
405 "Verify that the number of bytes dropped after dequeue is computed correctly");
412 uint32_t pktSizeUnit = 100;
431 for (uint16_t i = 1; i <= 4; i++)
433 root->
Enqueue (Create<qdTestItem> (Create<Packet>(pktSizeUnit * i), dest));
435 CheckQueued (root, i, pktSizeUnit * i * (i+1) / 2);
439 CheckQueued (child, i, pktSizeUnit * i * (i+1) / 2);
446 root->
Enqueue (Create<qdTestItem> (Create<Packet>(pktSizeUnit * 5), dest));
465 item = root->
Peek ();
479 item = root->
Peek ();
521 item = root->
Peek ();
534 root->
Enqueue (Create<qdTestItem> (Create<Packet>(pktSizeUnit), dest));
558 Simulator::Destroy ();
Structure that keeps the queue disc statistics.
QueueDiscTracesTestSuite()
Ptr< const QueueDiscItem > Peek(void)
Get a copy of the next packet the queue discipline will extract.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
void PacketDad(Ptr< const QueueDiscItem > item, const char *reason)
Update statistics after a packet has been dropped after dequeue.
uint32_t m_nDadBytes
Number of packets dropped after dequeue.
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
void AddQueueDiscClass(Ptr< QueueDiscClass > qdClass)
Add a queue disc class to the tail of the list of classes.
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...
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
void PacketEnqueued(Ptr< const QueueDiscItem > item)
Update statistics after a packet has been enqueued.
virtual ~TestParentQueueDisc()
std::map< Ptr< QueueDisc >, TestCounter > m_counter
counters for the queue discs
void SetQueueDisc(Ptr< QueueDisc > qd)
Set the queue disc attached to this class.
Test Child Queue Disc that may drop packets before enqueue or after dequeue.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
static constexpr const char * BEFORE_ENQUEUE
Drop before enqueue.
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
Queue Disc Traces Test Case.
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
QueueDiscTracesTestSuite g_queueDiscTracesTestSuite
the test suite
Used by queue discs with single child queue disc.
uint32_t nTotalDroppedPacketsBeforeEnqueue
Total packets dropped before enqueue.
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
a polymophic address class
void PacketDequeued(Ptr< const QueueDiscItem > item)
Update statistics after a packet has been dequeued.
void CheckDroppedBeforeEnqueue(Ptr< QueueDisc > qd, uint32_t nDbePackets, uint32_t nDbeBytes)
Check that packets/bytes dropped before enqueue are consistent with what is expected.
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
void ConnectTraces(Ptr< QueueDisc > qd)
Connect private methods to the queue disc traces.
void AddInternalQueue(Ptr< InternalQueue > queue)
Add an internal queue to the tail of the list of queues.
void CheckDroppedAfterDequeue(Ptr< QueueDisc > qd, uint32_t nDadPackets, uint32_t nDadBytes)
Check that packets/bytes dropped after dequeue are consistent with what is expected.
virtual uint32_t GetSize(void) const
Use this method (instead of GetPacket ()->GetSize ()) to get the packet size.
uint32_t m_nDbeBytes
Number of packets dropped before enqueue.
qdTestItem(Ptr< Packet > p, const Address &addr)
Constructor.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Queue Disc Traces Test Suite.
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
uint32_t m_nBytes
Number of queued bytes.
static constexpr const char * AFTER_DEQUEUE
Drop after dequeue.
virtual void InitializeParams(void)
Initialize parameters (if any) before the first packet is enqueued.
uint32_t m_nDbePackets
Number of packets dropped before enqueue.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
const Stats & GetStats(void)
Retrieve all the collected statistics.
virtual ~TestChildQueueDisc()
uint64_t nTotalDroppedBytesBeforeEnqueue
Total bytes dropped before enqueue.
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
void CheckQueued(Ptr< QueueDisc > qd, uint32_t nPackets, uint32_t nBytes)
Check that queued packets/bytes are consistent with what is expected.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any...
Introspection did not find any typical Config paths.
uint32_t m_nPackets
Number of queued packets.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
uint32_t nTotalDroppedPacketsAfterDequeue
Total packets dropped after dequeue.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
QueueDiscTracesTestCase()
TestChildQueueDisc()
Constructor.
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report if not.
TestCounter()
Constructor.
TestParentQueueDisc()
Constructor.
Keep statistics based on traces.
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
Used by queue discs with single internal queue.
uint64_t nTotalDroppedBytesAfterDequeue
Total bytes dropped after dequeue.
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification...
virtual void AddHeader(void)
Add the header to the packet.
Test Parent Queue Disc having a child of type TestChildQueueDisc.
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...
uint32_t m_nDadPackets
Number of packets dropped after dequeue.
Ptr< T > CreateObject(void)
Create an object by type, with varying number of constructor parameters.
virtual void InitializeParams(void)
Initialize parameters (if any) before the first packet is enqueued.
This test suite implements a Unit Test.
void PacketDbe(Ptr< const QueueDiscItem > item, const char *reason)
Update statistics after a packet has been dropped before enqueue.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.