21 #include "ns3/double.h"
22 #include "ns3/fifo-queue-disc.h"
24 #include "ns3/object-factory.h"
25 #include "ns3/packet.h"
26 #include "ns3/queue.h"
27 #include "ns3/simulator.h"
28 #include "ns3/string.h"
30 #include "ns3/uinteger.h"
58 void AddHeader()
override;
91 void DoRun()
override;
109 :
TestCase(
"Sanity check on the fifo queue disc implementation")
116 std::vector<uint64_t> uids;
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?");
162 uint32_t numPackets = 10;
167 queue = CreateObject<FifoQueueDisc>();
171 "Verify that the queue disc has no internal queue");
174 queue->SetAttributeFailSafe(
"MaxSize",
175 QueueSizeValue(
QueueSize(mode, numPackets * modeSize))),
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",
194 QueueSizeValue(
QueueSize(mode, numPackets * modeSize))),
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>");
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");
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");
265 Simulator::Destroy();
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 & operator=(const FifoQueueDiscTestItem &)=delete
FifoQueueDiscTestItem(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.
uint64_t GetUid() const
Returns the packet's Uid.
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Template class for packet Queues.
Class for representing queue sizes.
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.
@ BYTES
Use number of bytes for queue size.
@ PACKETS
Use number of packets for queue size.
#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)