21#include "ns3/double.h"
22#include "ns3/fifo-queue-disc.h"
24#include "ns3/object-factory.h"
25#include "ns3/packet.h"
27#include "ns3/simulator.h"
28#include "ns3/string.h"
30#include "ns3/uinteger.h"
91 void DoRun()
override;
109 :
TestCase(
"Sanity check on the fifo queue disc implementation")
116 std::vector<uint64_t> uids;
120 uint32_t modeSize = (q->GetMaxSize().GetUnit() == QueueSizeUnit::PACKETS ? 1 :
pktSize);
121 uint32_t numPackets = qSize / modeSize;
126 for (
uint32_t i = 1; i <= numPackets; i++)
129 uids.push_back(p->GetUid());
130 q->Enqueue(Create<FifoQueueDiscTestItem>(p, dest));
133 "There should be " << i <<
" packet(s) in there");
139 "There should be no room for another packet");
142 for (
uint32_t i = 1; i <= numPackets; i++)
147 (numPackets - i) * modeSize,
148 "There should be " << numPackets - i <<
" packet(s) in there");
151 "was this the right packet?");
167 queue = CreateObject<FifoQueueDisc>();
171 "Verify that the queue disc has no internal queue");
174 queue->SetAttributeFailSafe(
"MaxSize",
177 "Verify that we can actually set the attribute MaxSize");
184 queue = CreateObject<FifoQueueDisc>();
188 "Verify that the queue disc has no internal queue");
193 queue->SetAttributeFailSafe(
"MaxSize",
196 "Verify that we can actually set the attribute MaxSize");
201 queue = CreateObject<FifoQueueDisc>();
205 "Verify that the queue disc has no internal queue");
208 factory.
SetTypeId(
"ns3::DropTailQueue<QueueDiscItem>");
209 if (mode == QueueSizeUnit::PACKETS)
215 factory.
Set(
"MaxSize",
225 queue = CreateObject<FifoQueueDisc>();
229 "Verify that the queue disc has no internal queue");
235 "Verify that the queue disc got an internal queue");
239 if (mode == QueueSizeUnit::PACKETS)
242 iq->SetAttributeFailSafe(
"MaxSize",
245 "Verify that we can actually set the attribute MaxSize on the internal queue");
250 iq->SetAttributeFailSafe(
254 "Verify that we can actually set the attribute MaxSize on the internal queue");
Fifo Queue Disc Test Case.
void RunFifoTest(QueueSizeUnit mode)
Run test function.
void DoRun() override
Implementation to actually run this TestCase.
void DoRunFifoTest(Ptr< FifoQueueDisc > q, uint32_t qSize, uint32_t pktSize)
Run test function.
Fifo Queue Disc Test Item.
void AddHeader() override
Add the header to the packet.
FifoQueueDiscTestItem()=delete
~FifoQueueDiscTestItem() override
FifoQueueDiscTestItem(const FifoQueueDiscTestItem &)=delete
FifoQueueDiscTestItem & operator=(const FifoQueueDiscTestItem &)=delete
bool Mark() override
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
Fifo Queue Disc Test Suite.
a polymophic address class
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Smart pointer class similar to boost::intrusive_ptr.
Introspection did not find any typical Config paths.
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Class for representing queue sizes.
AttributeValue implementation for QueueSize.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
@ UNIT
This test suite implements a Unit Test.
QueueSizeUnit
Enumeration of the operating modes of queues.
#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.
FifoQueueDiscTestSuite g_fifoQueueTestSuite
the test suite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t pktSize
packet size used for the simulation (in bytes)