23 #include "ns3/simulator.h" 24 #include "ns3/fq-codel-queue-disc.h" 25 #include "ns3/codel-queue-disc.h" 26 #include "ns3/ipv4-header.h" 27 #include "ns3/ipv4-packet-filter.h" 28 #include "ns3/ipv4-queue-disc-item.h" 29 #include "ns3/ipv4-address.h" 30 #include "ns3/ipv6-header.h" 31 #include "ns3/ipv6-packet-filter.h" 32 #include "ns3/ipv6-queue-disc-item.h" 33 #include "ns3/tcp-header.h" 34 #include "ns3/udp-header.h" 35 #include "ns3/string.h" 36 #include "ns3/pointer.h" 53 static TypeId GetTypeId (
void);
68 .SetGroupName (
"Internet")
104 virtual void DoRun (
void);
108 :
TestCase (
"Test packets that are not classified by any filter")
129 p = Create<Packet> ();
133 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
137 p = Create<Packet> (
reinterpret_cast<const uint8_t*
> (
"hello, world"), 12);
138 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
142 Simulator::Destroy ();
155 virtual void DoRun (
void);
160 :
TestCase (
"Test IP flows separation and packet limit")
195 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
202 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
207 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
211 Simulator::Destroy ();
224 virtual void DoRun (
void);
229 :
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 (), FqCoDelFlow::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 (), FqCoDelFlow::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 (), FqCoDelFlow::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 (), FqCoDelFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
302 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::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 (), FqCoDelFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
314 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::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 (), FqCoDelFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
326 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::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 (), FqCoDelFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
338 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::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")
411 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
417 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
424 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
433 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
439 Simulator::Destroy ();
452 virtual void DoRun (
void);
457 :
TestCase (
"Test UDP flows separation")
497 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
503 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
510 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
519 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
525 Simulator::Destroy ();
539 virtual void DoRun (
void);
560 for (uint32_t i = 0; i < nPkt; i++)
571 for (uint32_t i = 0; i < nPkt; i++)
580 for (uint32_t i = 0; i < nPkt; i++)
604 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
619 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
629 Simulator::Stop (
Seconds (8.0));
646 "with 20 packets, total bytes in the queue = 120 * 20 = 2400. First packet dequeues at 110ms which is greater than" 647 "test's default target value 5ms. Sojourn time has just gone above target from below, need to stay above for at" 648 "least q->interval before packet can be dropped. Second packet dequeues at 220ms which is greater than last dequeue" 649 "time plus q->interval(test default 100ms) so the packet is marked. Third packet dequeues at 330ms and the sojourn" 650 "time stayed above the target and dropnext value is less than 320 hence the packet is marked. 4 subsequent packets" 651 "are marked as the sojourn time stays above the target. With 8th dequeue number of bytes in queue = 120 * 12 = 1440" 652 "which is less m_minBytes(test's default value 1500 bytes) hence the packets stop getting marked");
654 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 6,
"There should be 6 marked packets");
655 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
656 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 6,
"There should be 6 marked packets");
657 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
660 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 4,
"There should be 4 dropped packets" 661 "with 20 packets, total bytes in the queue = 120 * 20 = 2400. First packet dequeues at 110ms which is greater than" 662 "test's default target value 5ms. Sojourn time has just gone above target from below, need to stay above for at" 663 "least q->interval before packet can be dropped. Second packet dequeues at 220ms which is greater than last dequeue" 664 "time plus q->interval(test default 100ms) so packet is dropped and next is dequeued. 4th packet dequeues at 330ms" 665 "and the sojourn time stayed above the target and dropnext value is less than 320 hence the packet is dropped and next" 666 "packet is dequeued. 6th packet dequeues at 440ms and 2 more packets are dropped as dropnext value is increased twice." 667 "12 Packets remaining in the queue, total number of bytes int the queue = 120 * 12 = 1440 which is less" 668 "m_minBytes(test's default value 1500 bytes) hence the packets stop getting dropped");
669 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 0,
"There should not be any marked packets");
670 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 4,
"There should be 4 dropped packets");
671 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 0,
"There should not be any marked packets");
675 NS_TEST_EXPECT_MSG_NE (pktQ0->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
677 NS_TEST_EXPECT_MSG_NE (pktQ1->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
679 NS_TEST_EXPECT_MSG_NE (pktQ2->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
681 Simulator::Destroy ();
684 queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
691 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
704 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
714 Simulator::Stop (
Seconds (8.0));
731 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued. sojourn time of 13th packet is 1.3ms which is" 732 "less than CE threshold");
735 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued. sojourn time of 8th packet is 2.1ms which is greater" 736 "than CE threshold and subsequent packet also have sojourn time more 8th packet hence remaining packet are marked.");
739 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued and all of them have sojourn time more than CE threshold");
749 pktQ0 = DynamicCast<const Ipv4QueueDiscItem> (q0->
Peek ());
750 NS_TEST_EXPECT_MSG_NE (pktQ0->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
751 pktQ1 = DynamicCast<const Ipv4QueueDiscItem> (q1->
Peek ());
752 NS_TEST_EXPECT_MSG_NE (pktQ1->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
753 pktQ2 = DynamicCast<const Ipv4QueueDiscItem> (q2->
Peek ());
754 NS_TEST_EXPECT_MSG_NE (pktQ2->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
756 Simulator::Destroy ();
787 virtual void DoRun (
void);
792 :
TestCase (
"Test credits and flows status")
847 "unexpected number of packets in the queue disc");
849 "unexpected number of packets in the first flow queue of set one");
851 "unexpected number of packets in the second flow queue of set one");
853 "unexpected number of packets in the third flow queue of set one");
855 "unexpected number of packets in the fourth flow queue of set one");
857 "unexpected number of packets in the fifth flow queue of set one");
859 "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");
863 "unexpected number of packets in the eighth flow queue of set one");
867 "unexpected number of packets in the first flow of set one");
871 "unexpected number of packets in the first flow of set two");
872 Simulator::Destroy ();
882 :
TestSuite (
"fq-codel-queue-disc", UNIT)
FqCoDelQueueDiscTestSuite()
Ptr< const QueueDiscItem > Peek(void)
Get a copy of the next packet the queue discipline will extract.
virtual int32_t DoClassify(Ptr< QueueDiscItem > item) const
Classify a packet.
void DequeueWithDelay(Ptr< FqCoDelQueueDisc > queue, double delay, uint32_t nPkt)
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header hdr, u_int32_t nPkt, u_int32_t nPktEnqueued, u_int32_t nQueueFlows)
virtual void DoRun(void)
Implementation to actually run this TestCase.
Simulation virtual time values and global simulation resolution.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
Smart pointer class similar to boost::intrusive_ptr.
AttributeValue implementation for Boolean.
FqCoDelQueueDiscECNMarking()
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
Hold variables of type string.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
void Dequeue(Ptr< FqCoDelQueueDisc > queue, uint32_t nPkt)
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
virtual ~FqCoDelQueueDiscUDPFlowsSeparation()
virtual ~FqCoDelQueueDiscTCPFlowsSeparation()
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header hdr)
virtual void DoRun(void)
Implementation to actually run this TestCase.
a polymophic address class
This class tests the TCP flows separation.
virtual ~Ipv4TestPacketFilter()
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header hdr)
AttributeValue implementation for Time.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
FqCoDelQueueDiscUDPFlowsSeparation()
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.
This class tests packets for which there is no suitable filter.
uint32_t GetQuantum(void) const
Get the quantum value.
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header ipHdr, TcpHeader tcpHdr)
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header ipHdr, UdpHeader udpHdr)
virtual ~FqCoDelQueueDiscECNMarking()
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header hdr)
const Stats & GetStats(void)
Retrieve all the collected statistics.
virtual ~FqCoDelQueueDiscNoSuitableFilter()
FqCoDelQueueDiscTCPFlowsSeparation()
virtual void DoRun(void)
Implementation to actually run this TestCase.
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any...
virtual void DoRun(void)
Implementation to actually run this TestCase.
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.
void SetQuantum(uint32_t quantum)
Set the quantum value.
virtual ~FqCoDelQueueDiscSetLinearProbing()
This class tests the UDP flows separation.
virtual bool CheckProtocol(Ptr< QueueDiscItem > item) const
Checks if the filter is able to classify a kind of items.
This class tests ECN marking Any future classifier options (e.g.
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.
virtual ~FqCoDelQueueDiscDeficit()
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report if not.
static FqCoDelQueueDiscTestSuite fqCoDelQueueDiscTestSuite
A CoDel packet queue disc.
This class tests the IP flows separation and the packet limit.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Ipv4 addresses are stored in host order in this class.
static TypeId GetTypeId(void)
Get the type ID.
FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit()
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 deficit per flow.
void AddPacketFilter(Ptr< PacketFilter > filter)
Add a packet filter to the tail of the list of filters used to classify packets.
FqCoDelQueueDiscSetLinearProbing()
Simple test packet filter able to classify IPv4 packets.
a unique identifier for an interface.
FqCoDelQueueDiscNoSuitableFilter()
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.
FqCoDelQueueDiscDeficit()
void AddHeader(const Header &header)
Add header to this packet.
virtual ~FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit()