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"
53 virtual void AddHeader (
void);
54 virtual bool Mark (
void);
101 virtual void DoRun (
void);
118 :
TestCase (
"Sanity check on the fifo queue disc implementation")
125 std::vector<uint64_t> uids;
130 uint32_t numPackets = qSize / modeSize;
135 for (uint32_t i = 1; i <= numPackets; i++)
138 uids.push_back (p->
GetUid ());
139 q->Enqueue (Create<FifoQueueDiscTestItem> (p, dest));
140 NS_TEST_EXPECT_MSG_EQ (q->GetCurrentSize ().GetValue (), i * modeSize,
"There should be " << i <<
" packet(s) in there");
145 false,
"There should be no room for another packet");
148 for (uint32_t i = 1; i <= numPackets; i++)
150 item = q->Dequeue ();
152 NS_TEST_EXPECT_MSG_EQ (q->GetCurrentSize ().GetValue (), (numPackets-i) * modeSize,
"There should be " << numPackets-i <<
" packet(s) in there");
156 item = q->Dequeue ();
164 uint32_t numPackets = 10;
169 queue = CreateObject<FifoQueueDisc> ();
171 NS_TEST_EXPECT_MSG_EQ (queue->GetNInternalQueues (), 0,
"Verify that the queue disc has no internal queue");
175 true,
"Verify that we can actually set the attribute MaxSize");
177 queue->Initialize ();
183 queue = CreateObject<FifoQueueDisc> ();
185 NS_TEST_EXPECT_MSG_EQ (queue->GetNInternalQueues (), 0,
"Verify that the queue disc has no internal queue");
187 queue->Initialize ();
191 true,
"Verify that we can actually set the attribute MaxSize");
197 queue = CreateObject<FifoQueueDisc> ();
199 NS_TEST_EXPECT_MSG_EQ (queue->GetNInternalQueues (), 0,
"Verify that the queue disc has no internal queue");
202 factory.
SetTypeId (
"ns3::DropTailQueue<QueueDiscItem>");
213 queue->Initialize ();
219 queue = CreateObject<FifoQueueDisc> ();
221 NS_TEST_EXPECT_MSG_EQ (queue->GetNInternalQueues (), 0,
"Verify that the queue disc has no internal queue");
223 queue->Initialize ();
225 NS_TEST_EXPECT_MSG_EQ (queue->GetNInternalQueues (), 1,
"Verify that the queue disc got an internal queue");
233 true,
"Verify that we can actually set the attribute MaxSize on the internal queue");
239 true,
"Verify that we can actually set the attribute MaxSize on the internal queue");
250 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.
virtual ~FifoQueueDiscTestItem()
FifoQueueDiscTestItem(const FifoQueueDiscTestItem &)
Copy constructor Disable default implementation to avoid misuse.
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.
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_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report 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)