28 #include "ns3/fq-pie-queue-disc.h"
29 #include "ns3/ipv4-address.h"
30 #include "ns3/ipv4-header.h"
31 #include "ns3/ipv4-packet-filter.h"
32 #include "ns3/ipv4-queue-disc-item.h"
33 #include "ns3/ipv6-header.h"
34 #include "ns3/ipv6-packet-filter.h"
35 #include "ns3/ipv6-queue-disc-item.h"
36 #include "ns3/pie-queue-disc.h"
37 #include "ns3/pointer.h"
38 #include "ns3/simulator.h"
39 #include "ns3/string.h"
40 #include "ns3/tcp-header.h"
42 #include "ns3/udp-header.h"
85 static TypeId tid =
TypeId(
"ns3::Ipv4FqPieTestPacketFilter")
87 .SetGroupName(
"Internet")
124 void DoRun()
override;
128 :
TestCase(
"Test packets that are not classified by any filter")
141 CreateObjectWithAttributes<FqPieQueueDisc>(
"MaxSize",
StringValue(
"4p"));
143 queueDisc->AddPacketFilter(filter);
146 queueDisc->SetQuantum(1500);
147 queueDisc->Initialize();
150 p = Create<Packet>();
154 item = Create<Ipv6QueueDiscItem>(p, dest, 0, ipv6Header);
155 queueDisc->Enqueue(item);
158 "no flow queue should have been created");
160 p = Create<Packet>(
reinterpret_cast<const uint8_t*
>(
"hello, world"), 12);
161 item = Create<Ipv6QueueDiscItem>(p, dest, 0, ipv6Header);
162 queueDisc->Enqueue(item);
165 "no flow queue should have been created");
167 Simulator::Destroy();
182 void DoRun()
override;
192 :
TestCase(
"Test IP flows separation and packet limit")
206 queue->Enqueue(item);
213 CreateObjectWithAttributes<FqPieQueueDisc>(
"MaxSize",
StringValue(
"4p"));
215 queueDisc->SetQuantum(1500);
216 queueDisc->Initialize();
230 "unexpected number of packets in the queue disc");
233 "unexpected number of packets in the flow queue");
241 "unexpected number of packets in the queue disc");
244 "unexpected number of packets in the flow queue");
247 "unexpected number of packets in the flow queue");
253 "unexpected number of packets in the queue disc");
256 "unexpected number of packets in the flow queue");
259 "unexpected number of packets in the flow queue");
261 Simulator::Destroy();
276 void DoRun()
override;
286 :
TestCase(
"Test credits and flows status")
300 queue->Enqueue(item);
308 queueDisc->SetQuantum(90);
309 queueDisc->Initialize();
321 "unexpected number of packets in the queue disc");
324 "unexpected number of packets in the first flow queue");
325 Ptr<FqPieFlow> flow1 = StaticCast<FqPieFlow>(queueDisc->GetQueueDiscClass(0));
327 static_cast<int32_t
>(queueDisc->GetQuantum()),
328 "the deficit of the first flow must equal the quantum");
331 "the first flow must be in the list of new queues");
333 queueDisc->Dequeue();
336 "unexpected number of packets in the queue disc");
339 "unexpected number of packets in the first flow queue");
348 "unexpected number of packets in the queue disc");
351 "unexpected number of packets in the first flow queue");
354 "the first flow must still be in the list of new queues");
362 "unexpected number of packets in the queue disc");
365 "unexpected number of packets in the first flow queue");
368 "unexpected number of packets in the second flow queue");
369 Ptr<FqPieFlow> flow2 = StaticCast<FqPieFlow>(queueDisc->GetQueueDiscClass(1));
371 static_cast<int32_t
>(queueDisc->GetQuantum()),
372 "the deficit of the second flow must equal the quantum");
375 "the second flow must be in the list of new queues");
378 queueDisc->Dequeue();
381 "unexpected number of packets in the queue disc");
384 "unexpected number of packets in the first flow queue");
387 "unexpected number of packets in the second flow queue");
393 "the first flow must be in the list of old queues");
398 "the second flow must be in the list of new queues");
401 queueDisc->Dequeue();
404 "unexpected number of packets in the queue disc");
407 "unexpected number of packets in the first flow queue");
410 "unexpected number of packets in the second flow queue");
415 "the first flow must be in the list of old queues");
421 "the second flow must be in the list of new queues");
424 queueDisc->Dequeue();
427 "unexpected number of packets in the queue disc");
430 "unexpected number of packets in the first flow queue");
433 "unexpected number of packets in the second flow queue");
439 "the first flow must be in the list of old queues");
444 "the second flow must be in the list of new queues");
447 queueDisc->Dequeue();
450 "unexpected number of packets in the queue disc");
453 "unexpected number of packets in the first flow queue");
456 "unexpected number of packets in the second flow queue");
461 "the first flow must be in the list of old queues");
467 "the second flow must be in the list of new queues");
470 queueDisc->Dequeue();
481 "the first flow must be inactive");
485 "the second flow must be inactive");
487 Simulator::Destroy();
502 void DoRun()
override;
513 :
TestCase(
"Test TCP flows separation")
530 queue->Enqueue(item);
537 CreateObjectWithAttributes<FqPieQueueDisc>(
"MaxSize",
StringValue(
"10p"));
539 queueDisc->SetQuantum(1500);
540 queueDisc->Initialize();
558 "unexpected number of packets in the queue disc");
561 "unexpected number of packets in the first flow queue");
568 "unexpected number of packets in the queue disc");
571 "unexpected number of packets in the first flow queue");
574 "unexpected number of packets in the second flow queue");
581 "unexpected number of packets in the queue disc");
584 "unexpected number of packets in the first flow queue");
587 "unexpected number of packets in the second flow queue");
590 "unexpected number of packets in the third flow queue");
598 "unexpected number of packets in the queue disc");
601 "unexpected number of packets in the first flow queue");
604 "unexpected number of packets in the second flow queue");
607 "unexpected number of packets in the third flow queue");
610 "unexpected number of packets in the third flow queue");
612 Simulator::Destroy();
627 void DoRun()
override;
638 :
TestCase(
"Test UDP flows separation")
655 queue->Enqueue(item);
662 CreateObjectWithAttributes<FqPieQueueDisc>(
"MaxSize",
StringValue(
"10p"));
664 queueDisc->SetQuantum(1500);
665 queueDisc->Initialize();
683 "unexpected number of packets in the queue disc");
686 "unexpected number of packets in the first flow queue");
693 "unexpected number of packets in the queue disc");
696 "unexpected number of packets in the first flow queue");
699 "unexpected number of packets in the second flow queue");
706 "unexpected number of packets in the queue disc");
709 "unexpected number of packets in the first flow queue");
712 "unexpected number of packets in the second flow queue");
715 "unexpected number of packets in the third flow queue");
723 "unexpected number of packets in the queue disc");
726 "unexpected number of packets in the first flow queue");
729 "unexpected number of packets in the second flow queue");
732 "unexpected number of packets in the third flow queue");
735 "unexpected number of packets in the third flow queue");
737 Simulator::Destroy();
773 void DoRun()
override;
783 :
TestCase(
"Test credits and flows status")
797 queue->Enqueue(item);
804 CreateObjectWithAttributes<FqPieQueueDisc>(
"EnableSetAssociativeHash",
BooleanValue(
true));
805 queueDisc->SetQuantum(90);
806 queueDisc->Initialize();
809 queueDisc->AddPacketFilter(filter);
840 "unexpected number of packets in the queue disc");
843 "unexpected number of packets in the first flow queue of set one");
846 "unexpected number of packets in the second flow queue of set one");
849 "unexpected number of packets in the third flow queue of set one");
852 "unexpected number of packets in the fourth flow queue of set one");
855 "unexpected number of packets in the fifth flow queue of set one");
858 "unexpected number of packets in the sixth flow queue of set one");
861 "unexpected number of packets in the seventh flow queue of set one");
864 "unexpected number of packets in the eighth flow queue of set one");
869 "unexpected number of packets in the first flow of set one");
874 "unexpected number of packets in the first flow of set two");
875 Simulator::Destroy();
899 void DoRun()
override;
944 for (uint32_t i = 0; i < nPkt; i++)
947 queue->Enqueue(item);
957 for (uint32_t i = 0; i < nPkt; i++)
959 Simulator::Schedule(
Time(
Seconds((i + 1) * delay)),
971 for (uint32_t i = 0; i < nPkt; i++)
980 for (uint32_t i = 0; i < nPkt; i++)
982 Simulator::Schedule(
Time(
Seconds((i + 1) * delay)),
999 CreateObjectWithAttributes<FqPieQueueDisc>(
"MaxSize",
1010 queueDisc->SetQuantum(1514);
1011 queueDisc->Initialize();
1017 hdr.
SetEcn(Ipv4Header::ECN_ECT1);
1021 double delay = 0.0005;
1031 hdr.
SetEcn(Ipv4Header::ECN_ECT0);
1044 Simulator::Stop(
Seconds(10.0));
1048 queueDisc->GetQueueDiscClass(0)->GetQueueDisc()->GetObject<
PieQueueDisc>();
1050 queueDisc->GetQueueDiscClass(1)->GetQueueDisc()->GetObject<
PieQueueDisc>();
1053 q0->GetStats().GetNMarkedPackets(PieQueueDisc::CE_THRESHOLD_EXCEEDED_MARK),
1055 "There should be 66 marked packets"
1056 "4th packet is enqueued at 2ms and dequeued at 4ms hence the delay of 2ms which not "
1057 "greater than CE threshold"
1058 "5th packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and "
1059 "subsequent packet also do have delay"
1060 "greater than CE threshold so all the packets after 4th packet are marked");
1063 "Queue delay is less than max burst allowance so"
1064 "There should not be any dropped packets");
1067 "There should not be any marked packets");
1070 "There should not be marked packets.");
1073 "There should not be any dropped packets");
1075 Simulator::Destroy();
1078 queueDisc = CreateObjectWithAttributes<FqPieQueueDisc>(
"MaxSize",
1089 queueDisc->SetQuantum(1514);
1090 queueDisc->Initialize();
1095 hdr.
SetEcn(Ipv4Header::ECN_ECT1);
1115 hdr.
SetEcn(Ipv4Header::ECN_ECT0);
1126 Simulator::Stop(
Seconds(1.0));
1128 q0 = queueDisc->GetQueueDiscClass(0)->GetQueueDisc()->GetObject<
PieQueueDisc>();
1129 q0 = queueDisc->GetQueueDiscClass(0)->GetQueueDisc()->GetObject<
PieQueueDisc>();
1132 q0->GetStats().GetNMarkedPackets(PieQueueDisc::CE_THRESHOLD_EXCEEDED_MARK),
1134 "There should be 68 marked packets"
1135 "2nd ECT1 packet is enqueued at 1.5ms and dequeued at 3ms hence the delay of 1.5ms which "
1136 "not greater than CE threshold"
1137 "3rd packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and "
1138 "subsequent packet also do have delay"
1139 "greater than CE threshold so all the packets after 2nd packet are marked");
1142 "Queue delay is less than max burst allowance so"
1143 "There should not be any dropped packets");
1146 "There should not be any marked packets");
1148 Simulator::Destroy();
This class tests the deficit per flow.
void DoRun() override
Implementation to actually run this TestCase.
~FqPieQueueDiscDeficit() override
void AddPacket(Ptr< FqPieQueueDisc > queue, Ipv4Header hdr)
Enqueue a packet.
This class tests the IP flows separation and the packet limit.
void AddPacket(Ptr< FqPieQueueDisc > queue, Ipv4Header hdr)
Enqueue a packet.
FqPieQueueDiscIPFlowsSeparationAndPacketLimit()
void DoRun() override
Implementation to actually run this TestCase.
~FqPieQueueDiscIPFlowsSeparationAndPacketLimit() override
This class tests L4S mode.
void AddPacketWithDelay(Ptr< FqPieQueueDisc > queue, Ipv4Header hdr, double delay, uint32_t nPkt)
Enqueue the given number of packets at different times.
void DoRun() override
Implementation to actually run this TestCase.
void DequeueWithDelay(Ptr< FqPieQueueDisc > queue, double delay, uint32_t nPkt)
Dequeue the given number of packets at different times.
void AddPacket(Ptr< FqPieQueueDisc > queue, Ipv4Header hdr, uint32_t nPkt)
Enqueue the given number of packets.
~FqPieQueueDiscL4sMode() override
void Dequeue(Ptr< FqPieQueueDisc > queue, uint32_t nPkt)
Dequeue the given number of packets.
This class tests packets for which there is no suitable filter.
FqPieQueueDiscNoSuitableFilter()
~FqPieQueueDiscNoSuitableFilter() override
void DoRun() override
Implementation to actually run this TestCase.
This class tests linear probing, collision response, and set creation capability of set associative h...
FqPieQueueDiscSetLinearProbing()
~FqPieQueueDiscSetLinearProbing() override
void DoRun() override
Implementation to actually run this TestCase.
void AddPacket(Ptr< FqPieQueueDisc > queue, Ipv4Header hdr)
Enqueue a packet.
This class tests the TCP flows separation.
FqPieQueueDiscTCPFlowsSeparation()
void DoRun() override
Implementation to actually run this TestCase.
void AddPacket(Ptr< FqPieQueueDisc > queue, Ipv4Header ipHdr, TcpHeader tcpHdr)
Enqueue a packet.
~FqPieQueueDiscTCPFlowsSeparation() override
FQ-PIE queue disc test suite.
FqPieQueueDiscTestSuite()
This class tests the UDP flows separation.
void DoRun() override
Implementation to actually run this TestCase.
void AddPacket(Ptr< FqPieQueueDisc > queue, Ipv4Header ipHdr, UdpHeader udpHdr)
Enqueue a packet.
~FqPieQueueDiscUDPFlowsSeparation() override
FqPieQueueDiscUDPFlowsSeparation()
Simple test packet filter able to classify IPv4 packets.
Ipv4FqPieTestPacketFilter()
~Ipv4FqPieTestPacketFilter() override
static TypeId GetTypeId()
Get the type ID.
bool CheckProtocol(Ptr< QueueDiscItem > item) const override
Check the protocol.
int32_t DoClassify(Ptr< QueueDiscItem > item) const override
Classify a QueueDiscItem.
a polymophic address class
Ipv4 addresses are stored in host order in this class.
Ipv4PacketFilter is the abstract base class for filters defined for IPv4 packets.
void AddHeader(const Header &header)
Add header to this packet.
Implements PIE Active Queue Management discipline.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
static FqPieQueueDiscTestSuite g_fqPieQueueDiscTestSuite
Do not forget to allocate an instance of this TestSuite.
static int32_t g_hash
Variable to assign g_hash to a new packet's flow.
@ INACTIVE
Inactive Period or unslotted CSMA-CA.
#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.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.