17#include "ns3/fq-pie-queue-disc.h"
18#include "ns3/ipv4-address.h"
19#include "ns3/ipv4-header.h"
20#include "ns3/ipv4-packet-filter.h"
21#include "ns3/ipv4-queue-disc-item.h"
22#include "ns3/ipv6-header.h"
23#include "ns3/ipv6-packet-filter.h"
24#include "ns3/ipv6-queue-disc-item.h"
25#include "ns3/pie-queue-disc.h"
26#include "ns3/pointer.h"
27#include "ns3/simulator.h"
28#include "ns3/string.h"
29#include "ns3/tcp-header.h"
31#include "ns3/udp-header.h"
74 static TypeId tid =
TypeId(
"ns3::Ipv4FqPieTestPacketFilter")
76 .SetGroupName(
"Internet")
113 void DoRun()
override;
117 :
TestCase(
"Test packets that are not classified by any filter")
132 queueDisc->AddPacketFilter(filter);
135 queueDisc->SetQuantum(1500);
136 queueDisc->Initialize();
144 queueDisc->Enqueue(item);
147 "no flow queue should have been created");
149 p =
Create<Packet>(
reinterpret_cast<const uint8_t*
>(
"hello, world"), 12);
151 queueDisc->Enqueue(item);
154 "no flow queue should have been created");
171 void DoRun()
override;
181 :
TestCase(
"Test IP flows separation and packet limit")
195 queue->Enqueue(item);
204 queueDisc->SetQuantum(1500);
205 queueDisc->Initialize();
219 "unexpected number of packets in the queue disc");
222 "unexpected number of packets in the flow queue");
230 "unexpected number of packets in the queue disc");
233 "unexpected number of packets in the flow queue");
236 "unexpected number of packets in the flow queue");
242 "unexpected number of packets in the queue disc");
245 "unexpected number of packets in the flow queue");
248 "unexpected number of packets in the flow queue");
265 void DoRun()
override;
275 :
TestCase(
"Test credits and flows status")
289 queue->Enqueue(item);
297 queueDisc->SetQuantum(90);
298 queueDisc->Initialize();
310 "unexpected number of packets in the queue disc");
313 "unexpected number of packets in the first flow queue");
316 static_cast<int32_t>(queueDisc->GetQuantum()),
317 "the deficit of the first flow must equal the quantum");
320 "the first flow must be in the list of new queues");
322 queueDisc->Dequeue();
325 "unexpected number of packets in the queue disc");
328 "unexpected number of packets in the first flow queue");
337 "unexpected number of packets in the queue disc");
340 "unexpected number of packets in the first flow queue");
343 "the first flow must still be in the list of new queues");
351 "unexpected number of packets in the queue disc");
354 "unexpected number of packets in the first flow queue");
357 "unexpected number of packets in the second flow queue");
360 static_cast<int32_t>(queueDisc->GetQuantum()),
361 "the deficit of the second flow must equal the quantum");
364 "the second flow must be in the list of new queues");
367 queueDisc->Dequeue();
370 "unexpected number of packets in the queue disc");
373 "unexpected number of packets in the first flow queue");
376 "unexpected number of packets in the second flow queue");
382 "the first flow must be in the list of old queues");
387 "the second flow must be in the list of new queues");
390 queueDisc->Dequeue();
393 "unexpected number of packets in the queue disc");
396 "unexpected number of packets in the first flow queue");
399 "unexpected number of packets in the second flow queue");
404 "the first flow must be in the list of old queues");
410 "the second flow must be in the list of new queues");
413 queueDisc->Dequeue();
416 "unexpected number of packets in the queue disc");
419 "unexpected number of packets in the first flow queue");
422 "unexpected number of packets in the second flow queue");
428 "the first flow must be in the list of old queues");
433 "the second flow must be in the list of new queues");
436 queueDisc->Dequeue();
439 "unexpected number of packets in the queue disc");
442 "unexpected number of packets in the first flow queue");
445 "unexpected number of packets in the second flow queue");
450 "the first flow must be in the list of old queues");
456 "the second flow must be in the list of new queues");
459 queueDisc->Dequeue();
470 "the first flow must be inactive");
474 "the second flow must be inactive");
491 void DoRun()
override;
502 :
TestCase(
"Test TCP flows separation")
516 p->AddHeader(tcpHdr);
519 queue->Enqueue(item);
528 queueDisc->SetQuantum(1500);
529 queueDisc->Initialize();
547 "unexpected number of packets in the queue disc");
550 "unexpected number of packets in the first flow queue");
557 "unexpected number of packets in the queue disc");
560 "unexpected number of packets in the first flow queue");
563 "unexpected number of packets in the second flow queue");
570 "unexpected number of packets in the queue disc");
573 "unexpected number of packets in the first flow queue");
576 "unexpected number of packets in the second flow queue");
579 "unexpected number of packets in the third flow queue");
587 "unexpected number of packets in the queue disc");
590 "unexpected number of packets in the first flow queue");
593 "unexpected number of packets in the second flow queue");
596 "unexpected number of packets in the third flow queue");
599 "unexpected number of packets in the third flow queue");
616 void DoRun()
override;
627 :
TestCase(
"Test UDP flows separation")
641 p->AddHeader(udpHdr);
644 queue->Enqueue(item);
653 queueDisc->SetQuantum(1500);
654 queueDisc->Initialize();
672 "unexpected number of packets in the queue disc");
675 "unexpected number of packets in the first flow queue");
682 "unexpected number of packets in the queue disc");
685 "unexpected number of packets in the first flow queue");
688 "unexpected number of packets in the second flow queue");
695 "unexpected number of packets in the queue disc");
698 "unexpected number of packets in the first flow queue");
701 "unexpected number of packets in the second flow queue");
704 "unexpected number of packets in the third flow queue");
712 "unexpected number of packets in the queue disc");
715 "unexpected number of packets in the first flow queue");
718 "unexpected number of packets in the second flow queue");
721 "unexpected number of packets in the third flow queue");
724 "unexpected number of packets in the third flow queue");
762 void DoRun()
override;
772 :
TestCase(
"Test credits and flows status")
786 queue->Enqueue(item);
794 queueDisc->SetQuantum(90);
795 queueDisc->Initialize();
798 queueDisc->AddPacketFilter(filter);
829 "unexpected number of packets in the queue disc");
832 "unexpected number of packets in the first flow queue of set one");
835 "unexpected number of packets in the second flow queue of set one");
838 "unexpected number of packets in the third flow queue of set one");
841 "unexpected number of packets in the fourth flow queue of set one");
844 "unexpected number of packets in the fifth flow queue of set one");
847 "unexpected number of packets in the sixth flow queue of set one");
850 "unexpected number of packets in the seventh flow queue of set one");
853 "unexpected number of packets in the eighth flow queue of set one");
858 "unexpected number of packets in the first flow of set one");
863 "unexpected number of packets in the first flow of set two");
888 void DoRun()
override;
936 queue->Enqueue(item);
999 queueDisc->SetQuantum(1514);
1000 queueDisc->Initialize();
1010 double delay = 0.0005;
1037 queueDisc->GetQueueDiscClass(0)->GetQueueDisc()->GetObject<
PieQueueDisc>();
1039 queueDisc->GetQueueDiscClass(1)->GetQueueDisc()->GetObject<
PieQueueDisc>();
1044 "There should be 66 marked packets"
1045 "4th packet is enqueued at 2ms and dequeued at 4ms hence the delay of 2ms which not "
1046 "greater than CE threshold"
1047 "5th packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and "
1048 "subsequent packet also do have delay"
1049 "greater than CE threshold so all the packets after 4th packet are marked");
1052 "Queue delay is less than max burst allowance so"
1053 "There should not be any dropped packets");
1056 "There should not be any marked packets");
1059 "There should not be marked packets.");
1062 "There should not be any dropped packets");
1078 queueDisc->SetQuantum(1514);
1079 queueDisc->Initialize();
1117 q0 = queueDisc->GetQueueDiscClass(0)->GetQueueDisc()->GetObject<
PieQueueDisc>();
1118 q0 = queueDisc->GetQueueDiscClass(0)->GetQueueDisc()->GetObject<
PieQueueDisc>();
1123 "There should be 68 marked packets"
1124 "2nd ECT1 packet is enqueued at 1.5ms and dequeued at 3ms hence the delay of 1.5ms which "
1125 "not greater than CE threshold"
1126 "3rd packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and "
1127 "subsequent packet also do have delay"
1128 "greater than CE threshold so all the packets after 2nd packet are marked");
1131 "Queue delay is less than max burst allowance so"
1132 "There should not be any dropped packets");
1135 "There should not be any marked packets");
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
AttributeValue implementation for Boolean.
Ipv4 addresses are stored in host order in this class.
Ipv4PacketFilter is the abstract base class for filters defined for IPv4 packets.
Implements PIE Active Queue Management discipline.
static constexpr const char * UNFORCED_DROP
Early probability drops: proactive.
static constexpr const char * CE_THRESHOLD_EXCEEDED_MARK
Early probability marks: proactive.
static constexpr const char * UNFORCED_MARK
Early probability marks: proactive.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.