23 #include "ns3/fifo-queue-disc.h"
24 #include "ns3/queue.h"
25 #include "ns3/packet.h"
26 #include "ns3/uinteger.h"
27 #include "ns3/string.h"
28 #include "ns3/double.h"
30 #include "ns3/simulator.h"
31 #include "ns3/object-factory.h"
58 virtual void AddHeader (
void);
59 virtual bool Mark (
void);
95 virtual void DoRun (
void);
112 :
TestCase (
"Sanity check on the fifo queue disc implementation")
119 std::vector<uint64_t> uids;
124 uint32_t numPackets = qSize / modeSize;
129 for (uint32_t i = 1; i <= numPackets; i++)
132 uids.push_back (p->
GetUid ());
133 q->Enqueue (Create<FifoQueueDiscTestItem> (p, dest));
134 NS_TEST_ASSERT_MSG_EQ (q->GetCurrentSize ().GetValue (), i * modeSize,
"There should be " << i <<
" packet(s) in there");
139 false,
"There should be no room for another packet");
142 for (uint32_t i = 1; i <= numPackets; i++)
144 item = q->Dequeue ();
146 NS_TEST_ASSERT_MSG_EQ (q->GetCurrentSize ().GetValue (), (numPackets-i) * modeSize,
"There should be " << numPackets-i <<
" packet(s) in there");
150 item = q->Dequeue ();
158 uint32_t numPackets = 10;
163 queue = CreateObject<FifoQueueDisc> ();
165 NS_TEST_ASSERT_MSG_EQ (queue->GetNInternalQueues (), 0,
"Verify that the queue disc has no internal queue");
169 true,
"Verify that we can actually set the attribute MaxSize");
171 queue->Initialize ();
177 queue = CreateObject<FifoQueueDisc> ();
179 NS_TEST_ASSERT_MSG_EQ (queue->GetNInternalQueues (), 0,
"Verify that the queue disc has no internal queue");
181 queue->Initialize ();
185 true,
"Verify that we can actually set the attribute MaxSize");
191 queue = CreateObject<FifoQueueDisc> ();
193 NS_TEST_ASSERT_MSG_EQ (queue->GetNInternalQueues (), 0,
"Verify that the queue disc has no internal queue");
196 factory.
SetTypeId (
"ns3::DropTailQueue<QueueDiscItem>");
207 queue->Initialize ();
213 queue = CreateObject<FifoQueueDisc> ();
215 NS_TEST_ASSERT_MSG_EQ (queue->GetNInternalQueues (), 0,
"Verify that the queue disc has no internal queue");
217 queue->Initialize ();
219 NS_TEST_ASSERT_MSG_EQ (queue->GetNInternalQueues (), 1,
"Verify that the queue disc got an internal queue");
227 true,
"Verify that we can actually set the attribute MaxSize on the internal queue");
233 true,
"Verify that we can actually set the attribute MaxSize on the internal queue");
244 Simulator::Destroy ();
Fifo Queue Disc Test Case.
void RunFifoTest(QueueSizeUnit mode)
Run test function.
virtual void DoRun(void)
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.
virtual void AddHeader(void)
Add the header to the packet.
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
FifoQueueDiscTestItem(const FifoQueueDiscTestItem &)=delete
virtual ~FifoQueueDiscTestItem()
Fifo Queue Disc Test Suite.
a polymophic address class
Instantiate subclasses of ns3::Object.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
uint64_t GetUid(void) const
Returns the packet's Uid.
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.
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.
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)