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