30 #include "ns3/simulator.h" 31 #include "ns3/fq-pie-queue-disc.h" 32 #include "ns3/pie-queue-disc.h" 33 #include "ns3/ipv4-header.h" 34 #include "ns3/ipv4-packet-filter.h" 35 #include "ns3/ipv4-queue-disc-item.h" 36 #include "ns3/ipv4-address.h" 37 #include "ns3/ipv6-header.h" 38 #include "ns3/ipv6-packet-filter.h" 39 #include "ns3/ipv6-queue-disc-item.h" 40 #include "ns3/tcp-header.h" 41 #include "ns3/udp-header.h" 42 #include "ns3/string.h" 43 #include "ns3/pointer.h" 61 static TypeId GetTypeId (
void);
74 static TypeId tid =
TypeId (
"ns3::Ipv4FqPieTestPacketFilter")
76 .SetGroupName (
"Internet")
110 virtual void DoRun (
void);
114 :
TestCase (
"Test packets that are not classified by any filter")
133 p = Create<Packet> ();
137 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
141 p = Create<Packet> (
reinterpret_cast<const uint8_t*
> (
"hello, world"), 12);
142 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
146 Simulator::Destroy ();
159 virtual void DoRun (
void);
164 :
TestCase (
"Test IP flows separation and packet limit")
197 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
204 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
209 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
213 Simulator::Destroy ();
226 virtual void DoRun (
void);
231 :
TestCase (
"Test credits and flows status")
262 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
266 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqPieFlow::NEW_FLOW,
"the first flow must be in the list of new queues");
269 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
277 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
279 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqPieFlow::NEW_FLOW,
"the first flow must still be in the list of new queues");
285 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
289 NS_TEST_ASSERT_MSG_EQ (flow2->GetDeficit (),
static_cast<int32_t
> (queueDisc->
GetQuantum ()),
"the deficit of the second flow must equal the quantum");
290 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqPieFlow::NEW_FLOW,
"the second flow must be in the list of new queues");
294 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
299 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqPieFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
302 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqPieFlow::NEW_FLOW,
"the second flow must be in the list of new queues");
306 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
311 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqPieFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
314 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqPieFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
318 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
323 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqPieFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
326 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqPieFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
330 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
335 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqPieFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
338 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqPieFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
353 Simulator::Destroy ();
366 virtual void DoRun (
void);
371 :
TestCase (
"Test TCP flows separation")
409 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
415 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
422 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
431 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
437 Simulator::Destroy ();
450 virtual void DoRun (
void);
455 :
TestCase (
"Test UDP flows separation")
493 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
499 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
506 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
515 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
521 Simulator::Destroy ();
554 virtual void DoRun (
void);
559 :
TestCase (
"Test credits and flows status")
612 "unexpected number of packets in the queue disc");
614 "unexpected number of packets in the first flow queue of set one");
616 "unexpected number of packets in the second flow queue of set one");
618 "unexpected number of packets in the third flow queue of set one");
620 "unexpected number of packets in the fourth flow queue of set one");
622 "unexpected number of packets in the fifth flow queue of set one");
624 "unexpected number of packets in the sixth flow queue of set one");
626 "unexpected number of packets in the seventh flow queue of set one");
628 "unexpected number of packets in the eighth flow queue of set one");
632 "unexpected number of packets in the first flow of set one");
636 "unexpected number of packets in the first flow of set two");
637 Simulator::Destroy ();
659 virtual void DoRun (
void);
678 for (uint32_t i = 0; i < nPkt; i++)
688 for (uint32_t i = 0; i < nPkt; i++)
697 for (uint32_t i = 0; i < nPkt; i++)
706 for (uint32_t i = 0; i < nPkt; i++)
731 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
735 double delay = 0.0005;
739 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
746 Simulator::Stop (
Seconds (10.0));
753 "4th packet is enqueued at 2ms and dequeued at 4ms hence the delay of 2ms which not greater than CE threshold" 754 "5th packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and subsequent packet also do have delay" 755 "greater than CE threshold so all the packets after 4th packet are marked");
757 "There should not be any dropped packets");
759 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (PieQueueDisc::UNFORCED_MARK), 0,
"There should not be marked packets.");
760 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (PieQueueDisc::UNFORCED_DROP), 0,
"There should not be any dropped packets");
762 Simulator::Destroy ();
765 queueDisc = CreateObjectWithAttributes<FqPieQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
775 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
784 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
789 Simulator::Stop (
Seconds (1.0));
795 "2nd ECT1 packet is enqueued at 1.5ms and dequeued at 3ms hence the delay of 1.5ms which not greater than CE threshold" 796 "3rd packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and subsequent packet also do have delay" 797 "greater than CE threshold so all the packets after 2nd packet are marked");
799 "There should not be any dropped packets");
802 Simulator::Destroy ();
FqPieQueueDiscTCPFlowsSeparation()
void SetQuantum(uint32_t quantum)
Set the quantum value.
Simulation virtual time values and global simulation resolution.
Smart pointer class similar to boost::intrusive_ptr.
AttributeValue implementation for Boolean.
virtual ~FqPieQueueDiscNoSuitableFilter()
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
Hold variables of type string.
void AddPacket(Ptr< FqPieQueueDisc > queue, Ipv4Header hdr)
This class tests the UDP flows separation.
virtual void DoRun(void)
Implementation to actually run this TestCase.
This class tests packets for which there is no suitable filter.
FqPieQueueDiscTestSuite()
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
virtual int32_t DoClassify(Ptr< QueueDiscItem > item) const
Classify a packet.
Implements PIE Active Queue Management discipline.
static TypeId GetTypeId(void)
Get the type ID.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~FqPieQueueDiscIPFlowsSeparationAndPacketLimit()
a polymophic address class
void AddPacket(Ptr< FqPieQueueDisc > queue, Ipv4Header ipHdr, UdpHeader udpHdr)
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t GetQuantum(void) const
Get the quantum value.
void Dequeue(Ptr< FqPieQueueDisc > queue, uint32_t nPkt)
AttributeValue implementation for Time.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
virtual ~FqPieQueueDiscL4sMode()
virtual void DoRun(void)
Implementation to actually run this TestCase.
Hold an unsigned integer type.
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
#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.
virtual ~FqPieQueueDiscSetLinearProbing()
const Stats & GetStats(void)
Retrieve all the collected statistics.
static FqPieQueueDiscTestSuite FqPieQueueDiscTestSuite
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
void AddPacket(Ptr< FqPieQueueDisc > queue, Ipv4Header hdr, u_int32_t nPkt)
This class tests the IP flows separation and the packet limit.
virtual ~FqPieQueueDiscDeficit()
FqPieQueueDiscIPFlowsSeparationAndPacketLimit()
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::size_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
This class tests the deficit per flow.
This class tests L4S mode.
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.
Ipv4FqPieTestPacketFilter()
virtual void DoRun(void)
Implementation to actually run this TestCase.
Simple test packet filter able to classify IPv4 packets.
virtual ~Ipv4FqPieTestPacketFilter()
Ipv4 addresses are stored in host order in this class.
FqPieQueueDiscUDPFlowsSeparation()
void DequeueWithDelay(Ptr< FqPieQueueDisc > queue, double delay, uint32_t nPkt)
void AddPacket(Ptr< FqPieQueueDisc > queue, Ipv4Header hdr)
Ipv4PacketFilter is the abstract base class for filters defined for IPv4 packets. ...
Time Seconds(double value)
Construct a Time in the indicated unit.
This class tests the TCP flows separation.
void AddPacketFilter(Ptr< PacketFilter > filter)
Add a packet filter to the tail of the list of filters used to classify packets.
FqPieQueueDiscSetLinearProbing()
void AddPacketWithDelay(Ptr< FqPieQueueDisc > queue, Ipv4Header hdr, double delay, uint32_t nPkt)
virtual ~FqPieQueueDiscTCPFlowsSeparation()
virtual bool CheckProtocol(Ptr< QueueDiscItem > item) const
Checks if the filter is able to classify a kind of items.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AddPacket(Ptr< FqPieQueueDisc > queue, Ipv4Header ipHdr, TcpHeader tcpHdr)
FqPieQueueDiscNoSuitableFilter()
void AddPacket(Ptr< FqPieQueueDisc > queue, Ipv4Header hdr)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Inactive Period or unslotted CSMA-CA.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
virtual ~FqPieQueueDiscUDPFlowsSeparation()
void AddHeader(const Header &header)
Add header to this packet.
virtual void DoRun(void)
Implementation to actually run this TestCase.