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")
77 p->AddPacketTag(priorityTag);
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);
135 void DoRun()
override;
147 :
TestCase(
"Test DSCP-based prioritization")
167 p->AddPacketTag(priorityTag);
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);
230 void DoRun()
override;
259 p->AddPacketTag(priorityTag);
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);
289 "unexpected queue depth");
292 "unexpected queue depth");
295 "unexpected queue depth");
304 "unexpected queue depth");
307 "unexpected queue depth");
310 "unexpected queue depth");
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];
378 p->CopyData(buf, 100);
379 item = Create<Ipv6QueueDiscItem>(p, dest, 0, ipv6Header);
380 queueDisc->Enqueue(item);
383 "unexpected queue depth");
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
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static uint8_t IpTos2Priority(uint8_t ipTos)
Return the priority corresponding to a given TOS value.
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.