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 virtual void DoRun (
void);
53 :
TestCase (
"Test packets that are not classified by any filter")
73 p = Create<Packet> ();
77 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
81 p = Create<Packet> (
reinterpret_cast<const uint8_t*
> (
"hello, world"), 12);
82 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
86 Simulator::Destroy ();
99 virtual void DoRun (
void);
104 :
TestCase (
"Test IP flows separation and packet limit")
143 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
150 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
155 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
159 Simulator::Destroy ();
172 virtual void DoRun (
void);
177 :
TestCase (
"Test credits and flows status")
214 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
218 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::NEW_FLOW,
"the first flow must be in the list of new queues");
221 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
229 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
231 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::NEW_FLOW,
"the first flow must still be in the list of new queues");
237 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
241 NS_TEST_ASSERT_MSG_EQ (flow2->GetDeficit (),
static_cast<int32_t
> (queueDisc->
GetQuantum ()),
"the deficit of the second flow must equal the quantum");
242 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::NEW_FLOW,
"the second flow must be in the list of new queues");
246 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
251 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
254 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::NEW_FLOW,
"the second flow must be in the list of new queues");
258 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
263 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
266 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
270 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
275 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
278 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
282 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"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::OLD_FLOW,
"the second flow must be in the list of new queues");
301 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::INACTIVE,
"the first flow must be inactive");
303 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::INACTIVE,
"the second flow must be inactive");
305 Simulator::Destroy ();
318 virtual void DoRun (
void);
323 :
TestCase (
"Test TCP flows separation")
367 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
373 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
380 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
389 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
395 Simulator::Destroy ();
408 virtual void DoRun (
void);
413 :
TestCase (
"Test UDP flows separation")
457 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
463 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
470 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
479 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
485 Simulator::Destroy ();
495 :
TestSuite (
"fq-codel-queue-disc", UNIT)
FqCoDelQueueDiscTestSuite()
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
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.
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.
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< QueueDiscItem > Dequeue(void)
Request the queue discipline to extract a packet.
uint32_t GetQuantum(void) const
Get the quantum value.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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.
FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit()
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.
FqCoDelQueueDiscNoSuitableFilter()
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
FqCoDelQueueDiscDeficit()
void AddHeader(const Header &header)
Add header to this packet.
Ptr< QueueDiscClass > GetQueueDiscClass(uint32_t i) const
Get the i-th queue disc class.
virtual ~FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit()