23 #include "ns3/simulator.h" 24 #include "ns3/fq-codel-queue-disc.h" 25 #include "ns3/ipv4-header.h" 26 #include "ns3/ipv4-packet-filter.h" 27 #include "ns3/ipv4-queue-disc-item.h" 28 #include "ns3/ipv4-address.h" 29 #include "ns3/ipv6-header.h" 30 #include "ns3/ipv6-packet-filter.h" 31 #include "ns3/ipv6-queue-disc-item.h" 32 #include "ns3/tcp-header.h" 33 #include "ns3/udp-header.h" 34 #include "ns3/string.h" 35 #include "ns3/pointer.h" 49 static TypeId GetTypeId (
void);
63 .SetGroupName (
"Internet")
93 virtual void DoRun (
void);
97 :
TestCase (
"Test packets that are not classified by any filter")
117 p = Create<Packet> ();
121 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
125 p = Create<Packet> (
reinterpret_cast<const uint8_t*
> (
"hello, world"), 12);
126 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
130 Simulator::Destroy ();
143 virtual void DoRun (
void);
148 :
TestCase (
"Test IP flows separation and packet limit")
183 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
190 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
195 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
199 Simulator::Destroy ();
212 virtual void DoRun (
void);
217 :
TestCase (
"Test credits and flows status")
250 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
254 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::NEW_FLOW,
"the first flow must be in the list of new queues");
257 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
265 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
267 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::NEW_FLOW,
"the first flow must still be in the list of new queues");
273 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
277 NS_TEST_ASSERT_MSG_EQ (flow2->GetDeficit (),
static_cast<int32_t
> (queueDisc->
GetQuantum ()),
"the deficit of the second flow must equal the quantum");
278 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::NEW_FLOW,
"the second flow must be in the list of new queues");
282 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
287 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
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 (), 2,
"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::OLD_FLOW,
"the second flow must be in the list of new queues");
306 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"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 (), 0,
"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");
337 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::INACTIVE,
"the first flow must be inactive");
339 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::INACTIVE,
"the second flow must be inactive");
341 Simulator::Destroy ();
354 virtual void DoRun (
void);
359 :
TestCase (
"Test TCP flows separation")
399 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
405 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
412 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
421 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
427 Simulator::Destroy ();
440 virtual void DoRun (
void);
445 :
TestCase (
"Test UDP flows separation")
485 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
491 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
498 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
507 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
513 Simulator::Destroy ();
523 :
TestSuite (
"fq-codel-queue-disc", UNIT)
FqCoDelQueueDiscTestSuite()
virtual int32_t DoClassify(Ptr< QueueDiscItem > item) const
Classify a packet.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Smart pointer class similar to boost::intrusive_ptr.
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.
virtual ~FqCoDelQueueDiscUDPFlowsSeparation()
virtual ~FqCoDelQueueDiscTCPFlowsSeparation()
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header hdr)
a polymophic address class
This class tests the TCP flows separation.
virtual ~Ipv4TestPacketFilter()
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
FqCoDelQueueDiscUDPFlowsSeparation()
#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 void DoRun(void)
Implementation to actually run this TestCase.
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header hdr)
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...
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.
This class tests the UDP flows separation.
virtual ~FqCoDelQueueDiscDeficit()
static FqCoDelQueueDiscTestSuite fqCoDelQueueDiscTestSuite
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. ...
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.
Simple test packet filter able to classify IPv4 packets.
a unique identifier for an interface.
FqCoDelQueueDiscNoSuitableFilter()
TypeId SetParent(TypeId tid)
Set the parent TypeId.
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()