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"
53 virtual void AddHeader (
void);
54 virtual bool Mark (
void);
101 virtual void DoRun (
void);
138 :
TestCase (
"Sanity check on the pie queue disc implementation")
145 uint32_t pktSize = 0;
148 uint32_t modeSize = 1;
150 uint32_t qSize = 300;
156 "Verify that we can actually set the attribute Mode");
160 if (queue->
GetMode () == PieQueueDisc::QUEUE_DISC_MODE_BYTES)
165 qSize = qSize * modeSize;
169 "Verify that we can actually set the attribute QueueLimit");
172 p1 = Create<Packet> (pktSize);
173 p2 = Create<Packet> (pktSize);
174 p3 = Create<Packet> (pktSize);
175 p4 = Create<Packet> (pktSize);
176 p5 = Create<Packet> (pktSize);
177 p6 = Create<Packet> (pktSize);
178 p7 = Create<Packet> (pktSize);
179 p8 = Create<Packet> (pktSize);
183 queue->
Enqueue (Create<PieQueueDiscTestItem> (p1, dest, 0));
185 queue->
Enqueue (Create<PieQueueDiscTestItem> (p2, dest, 0));
187 queue->
Enqueue (Create<PieQueueDiscTestItem> (p3, dest, 0));
188 queue->
Enqueue (Create<PieQueueDiscTestItem> (p4, dest, 0));
189 queue->
Enqueue (Create<PieQueueDiscTestItem> (p5, dest, 0));
190 queue->
Enqueue (Create<PieQueueDiscTestItem> (p6, dest, 0));
191 queue->
Enqueue (Create<PieQueueDiscTestItem> (p7, dest, 0));
192 queue->
Enqueue (Create<PieQueueDiscTestItem> (p8, dest, 0));
205 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (),
"Was this the second packet ?");
223 queue = CreateObject<PieQueueDisc> ();
226 "Verify that we can actually set the attribute Mode");
228 "Verify that we can actually set the attribute QueueLimit");
230 "Verify that we can actually set the attribute A");
232 "Verify that we can actually set the attribute B");
234 "Verify that we can actually set the attribute Tupdate");
236 "Verify that we can actually set the attribute Supdate");
238 "Verify that we can actually set the attribute DequeueThreshold");
240 "Verify that we can actually set the attribute QueueDelayReference");
242 "Verify that we can actually set the attribute MaxBurstAllowance");
246 Simulator::Stop (
Seconds (8.0));
255 queue = CreateObject<PieQueueDisc> ();
257 "Verify that we can actually set the attribute Mode");
259 "Verify that we can actually set the attribute QueueLimit");
261 "Verify that we can actually set the attribute A");
263 "Verify that we can actually set the attribute B");
265 "Verify that we can actually set the attribute Tupdate");
267 "Verify that we can actually set the attribute Supdate");
269 "Verify that we can actually set the attribute DequeueThreshold");
271 "Verify that we can actually set the attribute QueueDelayReference");
273 "Verify that we can actually set the attribute MaxBurstAllowance");
274 queue->Initialize ();
277 Simulator::Stop (
Seconds (8.0));
279 st = queue->GetStats ();
286 queue = CreateObject<PieQueueDisc> ();
288 "Verify that we can actually set the attribute Mode");
290 "Verify that we can actually set the attribute QueueLimit");
292 "Verify that we can actually set the attribute A");
294 "Verify that we can actually set the attribute B");
296 "Verify that we can actually set the attribute Tupdate");
298 "Verify that we can actually set the attribute Supdate");
300 "Verify that we can actually set the attribute DequeueThreshold");
302 "Verify that we can actually set the attribute QueueDelayReference");
304 "Verify that we can actually set the attribute MaxBurstAllowance");
305 queue->Initialize ();
308 Simulator::Stop (
Seconds (8.0));
310 st = queue->GetStats ();
317 queue = CreateObject<PieQueueDisc> ();
319 "Verify that we can actually set the attribute Mode");
321 "Verify that we can actually set the attribute QueueLimit");
323 "Verify that we can actually set the attribute A");
325 "Verify that we can actually set the attribute B");
327 "Verify that we can actually set the attribute Tupdate");
329 "Verify that we can actually set the attribute Supdate");
331 "Verify that we can actually set the attribute DequeueThreshold");
333 "Verify that we can actually set the attribute QueueDelayReference");
335 "Verify that we can actually set the attribute MaxBurstAllowance");
336 queue->Initialize ();
339 Simulator::Stop (
Seconds (8.0));
341 st = queue->GetStats ();
351 for (uint32_t i = 0; i < nPkt; i++)
353 queue->
Enqueue (Create<PieQueueDiscTestItem> (Create<Packet> (size), dest, 0));
362 for (uint32_t i = 0; i < nPkt; i++)
371 for (uint32_t i = 0; i < nPkt; i++)
380 for (uint32_t i = 0; i < nPkt; i++)
391 Simulator::Destroy ();
QueueDiscMode GetMode(void)
Get the operating mode of this queue disc.
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.
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
Hold variables of type string.
void RunPieTest(StringValue mode)
Run test function.
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.
This test suite implements a Unit Test.
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.
virtual void AddHeader(void)
Add the header to the packet.
const Stats & GetStats(void)
Retrieve all the collected statistics.
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Ptr< QueueDiscItem > Dequeue(void)
Request the queue discipline to extract a packet.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GetQueueSize(void)
Get the current value of the queue in bytes or packets.
#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.
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'...
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.