25 #include "ns3/simulator.h" 26 #include "ns3/fq-cobalt-queue-disc.h" 27 #include "ns3/cobalt-queue-disc.h" 28 #include "ns3/ipv4-header.h" 29 #include "ns3/ipv4-packet-filter.h" 30 #include "ns3/ipv4-queue-disc-item.h" 31 #include "ns3/ipv4-address.h" 32 #include "ns3/ipv6-header.h" 33 #include "ns3/ipv6-packet-filter.h" 34 #include "ns3/ipv6-queue-disc-item.h" 35 #include "ns3/tcp-header.h" 36 #include "ns3/udp-header.h" 37 #include "ns3/string.h" 38 #include "ns3/pointer.h" 55 static TypeId GetTypeId (
void);
68 static TypeId tid =
TypeId (
"ns3::Ipv4FqCobaltTestPacketFilter")
70 .SetGroupName (
"Internet")
106 virtual void DoRun (
void);
110 :
TestCase (
"Test packets that are not classified by any filter")
131 p = Create<Packet> ();
135 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
139 p = Create<Packet> (
reinterpret_cast<const uint8_t*
> (
"hello, world"), 12);
140 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
144 Simulator::Destroy ();
157 virtual void DoRun (
void);
162 :
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")
264 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
268 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::NEW_FLOW,
"the first flow must be in the list of new queues");
271 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
279 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
281 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::NEW_FLOW,
"the first flow must still be in the list of new queues");
287 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
291 NS_TEST_ASSERT_MSG_EQ (flow2->GetDeficit (),
static_cast<int32_t
> (queueDisc->
GetQuantum ()),
"the deficit of the second flow must equal the quantum");
292 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::NEW_FLOW,
"the second flow must be in the list of new queues");
296 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
301 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
304 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::NEW_FLOW,
"the second flow must be in the list of new queues");
308 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
313 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
316 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
320 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
325 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
328 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
332 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
337 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
340 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
355 Simulator::Destroy ();
368 virtual void DoRun (
void);
373 :
TestCase (
"Test TCP flows separation")
413 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
419 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
426 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
435 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
441 Simulator::Destroy ();
454 virtual void DoRun (
void);
459 :
TestCase (
"Test UDP flows separation")
499 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
505 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
512 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
521 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
527 Simulator::Destroy ();
553 virtual void DoRun (
void);
576 for (uint32_t i = 0; i < nPkt; i++)
596 for (uint32_t i = 0; i < nPkt; i++)
605 for (uint32_t i = 0; i < nPkt; i++)
638 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
653 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
663 Simulator::Stop (
Seconds (8.0));
672 "As there is no CoDel minBytes parameter so all the packets apart from the first one gets marked. As q3 and q4 have" 673 "NotEct packets and the queue delay is much higher than 5ms so the queue gets empty pretty quickly so more" 674 "packets from q0 can be dequeued.");
676 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 16,
"There should be 16 marked packets" 677 "As there is no CoDel minBytes parameter so all the packets apart from the first one until no more packets are dequeued" 679 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
680 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 12,
"There should be 12 marked packets" 681 "Each packet size is 120 bytes and the quantum is 1500 bytes so in the first turn (1514/120 = 12.61) 13 packets are" 682 "dequeued and apart from the first one, all the packets are marked.");
683 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
687 "be equal to the number of times m_dropNext is updated");
688 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 0,
"There should not be any marked packets");
690 "be equal to the number of times m_dropNext is updated");
691 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 0,
"There should not be any marked packets");
693 Simulator::Destroy ();
696 queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
703 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
716 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
726 Simulator::Stop (
Seconds (8.0));
736 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued. sojourn time of 13th packet is 1.3ms which is" 737 "less than CE threshold");
740 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued. sojourn time of 8th packet is 2.1ms which is greater" 741 "than CE threshold and subsequent packet also have sojourn time more 8th packet hence remaining packet are marked.");
744 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued and all of them have sojourn time more than CE threshold");
751 "delay for the first dequeue is greater than the target (5ms), Cobalt overloads the m_dropNext field as an activity timeout" 752 "and dropNext is to set to the current Time value so on the next dequeue a packet is dropped.");
754 Simulator::Destroy ();
757 queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
764 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
777 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
790 Simulator::Stop (
Seconds (8.0));
801 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
805 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
809 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
814 "be equal to the number of times m_dropNext is updated");
817 "be equal to the number of times m_dropNext is updated");
819 Simulator::Destroy ();
850 virtual void DoRun (
void);
855 :
TestCase (
"Test credits and flows status")
910 "unexpected number of packets in the queue disc");
912 "unexpected number of packets in the first flow queue of set one");
914 "unexpected number of packets in the second flow queue of set one");
916 "unexpected number of packets in the third flow queue of set one");
918 "unexpected number of packets in the fourth flow queue of set one");
920 "unexpected number of packets in the fifth flow queue of set one");
922 "unexpected number of packets in the sixth flow queue of set one");
924 "unexpected number of packets in the seventh flow queue of set one");
926 "unexpected number of packets in the eighth flow queue of set one");
930 "unexpected number of packets in the first flow of set one");
934 "unexpected number of packets in the first flow of set two");
935 Simulator::Destroy ();
957 virtual void DoRun (
void);
978 for (uint32_t i = 0; i < nPkt; i++)
988 for (uint32_t i = 0; i < nPkt; i++)
997 for (uint32_t i = 0; i < nPkt; i++)
1006 for (uint32_t i = 0; i < nPkt; i++)
1031 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
1035 double delay = 0.0005;
1039 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
1047 Simulator::Stop (
Seconds (8.0));
1052 "4th packet is enqueued at 2ms and dequeued at 4ms hence the delay of 2ms which not greater than CE threshold" 1053 "5th packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and subsequent packet also do have delay" 1054 "greater than CE threshold so all the packets after 4th packet are marked");
1057 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 2,
"There should be 2 marked packets. Packets are dequeued" 1058 "from q0 first, which leads to delay greater than 5ms for the first dequeue from q1. Because of inactivity (started with high queue delay)" 1059 "Cobalt keeps drop_next as now and the next packet is marked. With second dequeue count increases to 2, drop_next becomes now plus around" 1060 "70ms which is less than the running time(140), and as the queue delay is persistantly higher than 5ms, second packet is marked.");
1061 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
1063 Simulator::Destroy ();
1066 queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
1076 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
1085 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
1091 Simulator::Stop (
Seconds (8.0));
1096 "2nd ECT1 packet is enqueued at 1.5ms and dequeued at 3ms hence the delay of 1.5ms which not greater than CE threshold" 1097 "3rd packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and subsequent packet also do have delay" 1098 "greater than CE threshold so all the packets after 2nd packet are marked");
1102 Simulator::Destroy ();
1113 :
TestSuite (
"fq-cobalt-queue-disc", UNIT)
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.
Ipv4FqCobaltTestPacketFilter()
AttributeValue implementation for Boolean.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~Ipv4FqCobaltTestPacketFilter()
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
virtual int32_t DoClassify(Ptr< QueueDiscItem > item) const
Classify a packet.
Hold variables of type string.
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header ipHdr, TcpHeader tcpHdr)
This class tests the TCP flows separation.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
void DequeueWithDelay(Ptr< FqCobaltQueueDisc > queue, double delay, uint32_t nPkt)
This class tests L4S mode.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
#define NS_UNUSED(x)
Mark a local variable as unused.
This class tests ECN marking The test is divided into 3 sub test cases.
void Dequeue(Ptr< FqCobaltQueueDisc > queue, uint32_t nPkt)
void SetQuantum(uint32_t quantum)
Set the quantum value.
FqCobaltQueueDiscSetLinearProbing()
virtual ~FqCobaltQueueDiscSetLinearProbing()
FqCobaltQueueDiscL4sMode()
This class tests packets for which there is no suitable filter.
static FqCobaltQueueDiscTestSuite fqCobaltQueueDiscTestSuite
This class tests the IP flows separation and the packet limit.
a polymophic address class
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, u_int32_t nPkt)
virtual ~FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit()
virtual ~FqCobaltQueueDiscEcnMarking()
AttributeValue implementation for Time.
virtual ~FqCobaltQueueDiscUDPFlowsSeparation()
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
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.
Simple test packet filter able to classify IPv4 packets.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void Dequeue(Ptr< FqCobaltQueueDisc > queue, uint32_t nPkt)
FqCobaltQueueDiscTestSuite()
Cobalt packet queue disc.
const Stats & GetStats(void)
Retrieve all the collected statistics.
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
This class tests the deficit per flow.
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any...
virtual ~FqCobaltQueueDiscNoSuitableFilter()
virtual void DoRun(void)
Implementation to actually run this TestCase.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
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.
virtual ~FqCobaltQueueDiscL4sMode()
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.
FqCobaltQueueDiscUDPFlowsSeparation()
virtual ~FqCobaltQueueDiscTCPFlowsSeparation()
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr)
virtual void DoRun(void)
Implementation to actually run this TestCase.
void DropNextTracer(int64_t oldVal, int64_t newVal)
virtual bool CheckProtocol(Ptr< QueueDiscItem > item) const
Checks if the filter is able to classify a kind of items.
Ipv4 addresses are stored in host order in this class.
void DequeueWithDelay(Ptr< FqCobaltQueueDisc > queue, double delay, uint32_t nPkt)
uint32_t GetQuantum(void) const
Get the quantum value.
FqCobaltQueueDiscTCPFlowsSeparation()
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header ipHdr, UdpHeader udpHdr)
Ipv4PacketFilter is the abstract base class for filters defined for IPv4 packets. ...
Time Seconds(double value)
Construct a Time in the indicated unit.
FqCobaltQueueDiscNoSuitableFilter()
FqCobaltQueueDiscEcnMarking()
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, u_int32_t nPkt, u_int32_t nPktEnqueued, u_int32_t nQueueFlows)
void AddPacketFilter(Ptr< PacketFilter > filter)
Add a packet filter to the tail of the list of filters used to classify packets.
static TypeId GetTypeId(void)
Get the type ID.
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr)
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr)
uint32_t m_dropNextCount
count the number of times m_dropNext is recalculated
void AddPacketWithDelay(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, double delay, uint32_t nPkt)
a unique identifier for an interface.
virtual void DoRun(void)
Implementation to actually run this TestCase.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Inactive Period or unslotted CSMA-CA.
This class tests the UDP flows separation.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
FqCobaltQueueDiscDeficit()
void AddHeader(const Header &header)
Add header to this packet.
virtual void DoRun(void)
Implementation to actually run this TestCase.
FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit()
virtual ~FqCobaltQueueDiscDeficit()
virtual void DoRun(void)
Implementation to actually run this TestCase.