25 #include "ns3/pie-queue-disc.h" 26 #include "ns3/packet.h" 27 #include "ns3/uinteger.h" 28 #include "ns3/string.h" 29 #include "ns3/double.h" 31 #include "ns3/simulator.h" 52 virtual void AddHeader (
void);
53 virtual bool Mark (
void);
100 virtual void DoRun (
void);
137 :
TestCase (
"Sanity check on the pie queue disc implementation")
144 uint32_t pktSize = 0;
147 uint32_t modeSize = 1;
149 uint32_t qSize = 300;
161 qSize = qSize * modeSize;
165 true,
"Verify that we can actually set the attribute MaxSize");
168 p1 = Create<Packet> (pktSize);
169 p2 = Create<Packet> (pktSize);
170 p3 = Create<Packet> (pktSize);
171 p4 = Create<Packet> (pktSize);
172 p5 = Create<Packet> (pktSize);
173 p6 = Create<Packet> (pktSize);
174 p7 = Create<Packet> (pktSize);
175 p8 = Create<Packet> (pktSize);
179 queue->
Enqueue (Create<PieQueueDiscTestItem> (p1, dest));
181 queue->
Enqueue (Create<PieQueueDiscTestItem> (p2, dest));
183 queue->
Enqueue (Create<PieQueueDiscTestItem> (p3, dest));
184 queue->
Enqueue (Create<PieQueueDiscTestItem> (p4, dest));
185 queue->
Enqueue (Create<PieQueueDiscTestItem> (p5, dest));
186 queue->
Enqueue (Create<PieQueueDiscTestItem> (p6, dest));
187 queue->
Enqueue (Create<PieQueueDiscTestItem> (p7, dest));
188 queue->
Enqueue (Create<PieQueueDiscTestItem> (p8, dest));
201 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (),
"Was this the second packet ?");
219 queue = CreateObject<PieQueueDisc> ();
222 true,
"Verify that we can actually set the attribute MaxSize");
224 "Verify that we can actually set the attribute A");
226 "Verify that we can actually set the attribute B");
228 "Verify that we can actually set the attribute Tupdate");
230 "Verify that we can actually set the attribute Supdate");
232 "Verify that we can actually set the attribute DequeueThreshold");
234 "Verify that we can actually set the attribute QueueDelayReference");
236 "Verify that we can actually set the attribute MaxBurstAllowance");
240 Simulator::Stop (
Seconds (8.0));
249 queue = CreateObject<PieQueueDisc> ();
251 true,
"Verify that we can actually set the attribute MaxSize");
253 "Verify that we can actually set the attribute A");
255 "Verify that we can actually set the attribute B");
257 "Verify that we can actually set the attribute Tupdate");
259 "Verify that we can actually set the attribute Supdate");
261 "Verify that we can actually set the attribute DequeueThreshold");
263 "Verify that we can actually set the attribute QueueDelayReference");
265 "Verify that we can actually set the attribute MaxBurstAllowance");
266 queue->Initialize ();
269 Simulator::Stop (
Seconds (8.0));
271 st = queue->GetStats ();
278 queue = CreateObject<PieQueueDisc> ();
280 true,
"Verify that we can actually set the attribute MaxSize");
282 "Verify that we can actually set the attribute A");
284 "Verify that we can actually set the attribute B");
286 "Verify that we can actually set the attribute Tupdate");
288 "Verify that we can actually set the attribute Supdate");
290 "Verify that we can actually set the attribute DequeueThreshold");
292 "Verify that we can actually set the attribute QueueDelayReference");
294 "Verify that we can actually set the attribute MaxBurstAllowance");
295 queue->Initialize ();
298 Simulator::Stop (
Seconds (8.0));
300 st = queue->GetStats ();
307 queue = CreateObject<PieQueueDisc> ();
309 true,
"Verify that we can actually set the attribute MaxSize");
311 "Verify that we can actually set the attribute A");
313 "Verify that we can actually set the attribute B");
315 "Verify that we can actually set the attribute Tupdate");
317 "Verify that we can actually set the attribute Supdate");
319 "Verify that we can actually set the attribute DequeueThreshold");
321 "Verify that we can actually set the attribute QueueDelayReference");
323 "Verify that we can actually set the attribute MaxBurstAllowance");
324 queue->Initialize ();
327 Simulator::Stop (
Seconds (8.0));
329 st = queue->GetStats ();
339 for (uint32_t i = 0; i < nPkt; i++)
341 queue->
Enqueue (Create<PieQueueDiscTestItem> (Create<Packet> (size), dest));
350 for (uint32_t i = 0; i < nPkt; i++)
359 for (uint32_t i = 0; i < nPkt; i++)
368 for (uint32_t i = 0; i < nPkt; i++)
379 Simulator::Destroy ();
Structure that keeps the queue disc statistics.
Pie Queue Disc Test Case.
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification...
Simulation virtual time values and global simulation resolution.
Class for representing queue sizes.
void RunPieTest(QueueSizeUnit mode)
Run test function.
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
uint32_t GetValue() const
Get the underlying value.
QueueSizeUnit
Enumeration of the operating modes of queues.
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets, otherwise.
void Dequeue(Ptr< PieQueueDisc > queue, uint32_t nPkt)
Dequeue function.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
Set a single attribute without raising errors.
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
a polymophic address class
virtual void DoRun(void)
Implementation to actually run this TestCase.
AttributeValue implementation for Time.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Hold an unsigned integer type.
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Use number of packets for queue size.
virtual void AddHeader(void)
Add the header to the packet.
const Stats & GetStats(void)
Retrieve all the collected statistics.
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report if not.
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report if not.
void EnqueueWithDelay(Ptr< PieQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue with delay function.
Pie Queue Disc Test Item.
PieQueueDiscTestSuite g_pieQueueTestSuite
the test suite
virtual ~PieQueueDiscTestItem()
Time Seconds(double value)
Construct a Time in the indicated unit.
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
Pie Queue Disc Test Suite.
void DequeueWithDelay(Ptr< PieQueueDisc > queue, double delay, uint32_t nPkt)
Dequeue with delay function.
This test suite implements a Unit Test.
void Enqueue(Ptr< PieQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue function.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Use number of bytes for queue size.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.