19 #include "ns3/drop-tail-queue.h"
21 #include "ns3/ipv4-queue-disc-item.h"
22 #include "ns3/ipv6-queue-disc-item.h"
23 #include "ns3/object-factory.h"
24 #include "ns3/pfifo-fast-queue-disc.h"
25 #include "ns3/pointer.h"
26 #include "ns3/simulator.h"
27 #include "ns3/socket.h"
28 #include "ns3/string.h"
45 void DoRun()
override;
57 :
TestCase(
"Test TOS-based prioritization")
76 priorityTag.
SetPriority(Socket::IpTos2Priority(tos));
83 "enqueued to unexpected band");
92 for (uint16_t i = 0; i < 3; i++)
95 bool ok = queue->SetAttributeFailSafe(
"MaxSize",
StringValue(
"1000p"));
97 queueDisc->AddInternalQueue(queue);
120 Simulator::Destroy();
135 void DoRun()
override;
147 :
TestCase(
"Test DSCP-based prioritization")
170 queue->Enqueue(item);
173 "enqueued to unexpected band");
182 for (uint16_t i = 0; i < 3; i++)
185 bool ok = queue->SetAttributeFailSafe(
"MaxSize",
StringValue(
"1000p"));
187 queueDisc->AddInternalQueue(queue);
215 Simulator::Destroy();
230 void DoRun()
override;
262 queue->Enqueue(item);
269 CreateObjectWithAttributes<PfifoFastQueueDisc>(
"MaxSize",
StringValue(
"6p"));
271 CreateObjectWithAttributes<DropTailQueue<QueueDiscItem>>(
"MaxSize",
StringValue(
"6p"));
273 CreateObjectWithAttributes<DropTailQueue<QueueDiscItem>>(
"MaxSize",
StringValue(
"6p"));
275 CreateObjectWithAttributes<DropTailQueue<QueueDiscItem>>(
"MaxSize",
StringValue(
"6p"));
276 queueDisc->AddInternalQueue(band0);
277 queueDisc->AddInternalQueue(band1);
278 queueDisc->AddInternalQueue(band2);
281 AddPacket(queueDisc, Ipv4Header::DSCP_AF42);
282 AddPacket(queueDisc, Ipv4Header::DSCP_AF42);
283 AddPacket(queueDisc, Ipv4Header::DSCP_AF13);
284 AddPacket(queueDisc, Ipv4Header::DSCP_AF13);
285 AddPacket(queueDisc, Ipv4Header::DSCP_AF11);
286 AddPacket(queueDisc, Ipv4Header::DSCP_AF11);
289 "unexpected queue depth");
292 "unexpected queue depth");
295 "unexpected queue depth");
298 AddPacket(queueDisc, Ipv4Header::DSCP_AF42);
299 AddPacket(queueDisc, Ipv4Header::DSCP_AF13);
300 AddPacket(queueDisc, Ipv4Header::DSCP_AF11);
304 "unexpected queue depth");
307 "unexpected queue depth");
310 "unexpected queue depth");
312 Simulator::Destroy();
328 void DoRun()
override;
332 :
TestCase(
"Test queue with no priority tag")
345 for (uint16_t i = 0; i < 3; i++)
348 bool ok = queue->SetAttributeFailSafe(
"MaxSize",
StringValue(
"1000p"));
350 queueDisc->AddInternalQueue(queue);
354 "unexpected queue depth");
356 p = Create<Packet>();
360 item = Create<Ipv6QueueDiscItem>(p, dest, 0, ipv6Header);
361 queueDisc->Enqueue(item);
364 "unexpected queue depth");
365 p = Create<Packet>(
reinterpret_cast<const uint8_t*
>(
"hello, world"), 12);
366 item = Create<Ipv6QueueDiscItem>(p, dest, 0, ipv6Header);
367 queueDisc->Enqueue(item);
370 "unexpected queue depth");
371 p = Create<Packet>(100);
372 auto buf =
new uint8_t[100];
374 for (uint32_t i = 0; i < 100; i++)
379 item = Create<Ipv6QueueDiscItem>(p, dest, 0, ipv6Header);
380 queueDisc->Enqueue(item);
383 "unexpected queue depth");
385 Simulator::Destroy();
400 :
TestSuite(
"pfifo-fast-queue-disc", UNIT)
This class tests that each possible DSCP is enqueued in the right band.
PfifoFastQueueDiscDscpPrioritization()
void TestDscpValue(Ptr< PfifoFastQueueDisc > queue, Ipv4Header::DscpType dscp, uint32_t band)
Enqueue a packet and checks that it's added to the proper band.
void DoRun() override
Implementation to actually run this TestCase.
~PfifoFastQueueDiscDscpPrioritization() override
This class tests that packets without a priority tag are handled by placing them into band 1.
PfifoFastQueueDiscNoPriority()
void DoRun() override
Implementation to actually run this TestCase.
~PfifoFastQueueDiscNoPriority() override
This class tests that each band is txqueuelen deep.
void DoRun() override
Implementation to actually run this TestCase.
PfifoFastQueueDiscOverflow()
void AddPacket(Ptr< PfifoFastQueueDisc > queue, Ipv4Header::DscpType dscp)
Enqueue a packet.
~PfifoFastQueueDiscOverflow() override
PfifoFast queue disc test suite.
PfifoFastQueueDiscTestSuite()
This class tests that each possible TOS is enqueued in the right band.
PfifoFastQueueDiscTosPrioritization()
~PfifoFastQueueDiscTosPrioritization() override
void DoRun() override
Implementation to actually run this TestCase.
void TestTosValue(Ptr< PfifoFastQueueDisc > queue, uint8_t tos, uint32_t band)
Enqueue a packet and checks that it's added to the proper band.
a polymophic address class
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Smart pointer class similar to boost::intrusive_ptr.
indicates whether the socket has a priority set.
void SetPriority(uint8_t priority)
Set the tag's priority.
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static PfifoFastQueueDiscTestSuite g_pfifoFastQueueTestSuite
Do not forget to allocate an instance of this TestSuite.