12#include "ns3/cobalt-queue-disc.h" 
   13#include "ns3/fq-cobalt-queue-disc.h" 
   14#include "ns3/ipv4-address.h" 
   15#include "ns3/ipv4-header.h" 
   16#include "ns3/ipv4-packet-filter.h" 
   17#include "ns3/ipv4-queue-disc-item.h" 
   18#include "ns3/ipv6-header.h" 
   19#include "ns3/ipv6-packet-filter.h" 
   20#include "ns3/ipv6-queue-disc-item.h" 
   21#include "ns3/pointer.h" 
   22#include "ns3/simulator.h" 
   23#include "ns3/string.h" 
   24#include "ns3/tcp-header.h" 
   26#include "ns3/udp-header.h" 
   69    static TypeId tid = 
TypeId(
"ns3::Ipv4FqCobaltTestPacketFilter")
 
   71                            .SetGroupName(
"Internet")
 
 
  108    void DoRun() 
override;
 
 
  112    : 
TestCase(
"Test packets that are not classified by any filter")
 
 
  127    queueDisc->AddPacketFilter(filter);
 
  130    queueDisc->SetQuantum(1500);
 
  131    queueDisc->Initialize();
 
  139    queueDisc->Enqueue(item);
 
  142                          "no flow queue should have been created");
 
  144    p = 
Create<Packet>(
reinterpret_cast<const uint8_t*
>(
"hello, world"), 12);
 
  146    queueDisc->Enqueue(item);
 
  149                          "no flow queue should have been created");
 
 
  166    void DoRun() 
override;
 
 
  176    : 
TestCase(
"Test IP flows separation and packet limit")
 
 
  192    queue->Enqueue(item);
 
 
  201    queueDisc->SetQuantum(1500);
 
  202    queueDisc->Initialize();
 
  216                          "unexpected number of packets in the queue disc");
 
  219                          "unexpected number of packets in the flow queue");
 
  227                          "unexpected number of packets in the queue disc");
 
  230                          "unexpected number of packets in the flow queue");
 
  233                          "unexpected number of packets in the flow queue");
 
  239                          "unexpected number of packets in the queue disc");
 
  242                          "unexpected number of packets in the flow queue");
 
  245                          "unexpected number of packets in the flow queue");
 
 
  262    void DoRun() 
override;
 
 
  272    : 
TestCase(
"Test credits and flows status")
 
 
  286    queue->Enqueue(item);
 
 
  294    queueDisc->SetQuantum(90);
 
  295    queueDisc->Initialize();
 
  307                          "unexpected number of packets in the queue disc");
 
  310                          "unexpected number of packets in the first flow queue");
 
  313                          static_cast<int32_t>(queueDisc->GetQuantum()),
 
  314                          "the deficit of the first flow must equal the quantum");
 
  317                          "the first flow must be in the list of new queues");
 
  319    queueDisc->Dequeue();
 
  322                          "unexpected number of packets in the queue disc");
 
  325                          "unexpected number of packets in the first flow queue");
 
  334                          "unexpected number of packets in the queue disc");
 
  337                          "unexpected number of packets in the first flow queue");
 
  340                          "the first flow must still be in the list of new queues");
 
  348                          "unexpected number of packets in the queue disc");
 
  351                          "unexpected number of packets in the first flow queue");
 
  354                          "unexpected number of packets in the second flow queue");
 
  357                          static_cast<int32_t>(queueDisc->GetQuantum()),
 
  358                          "the deficit of the second flow must equal the quantum");
 
  361                          "the second flow must be in the list of new queues");
 
  364    queueDisc->Dequeue();
 
  367                          "unexpected number of packets in the queue disc");
 
  370                          "unexpected number of packets in the first flow queue");
 
  373                          "unexpected number of packets in the second flow queue");
 
  379                          "the first flow must be in the list of old queues");
 
  384                          "the second flow must be in the list of new queues");
 
  387    queueDisc->Dequeue();
 
  390                          "unexpected number of packets in the queue disc");
 
  393                          "unexpected number of packets in the first flow queue");
 
  396                          "unexpected number of packets in the second flow queue");
 
  401                          "the first flow must be in the list of old queues");
 
  407                          "the second flow must be in the list of new queues");
 
  410    queueDisc->Dequeue();
 
  413                          "unexpected number of packets in the queue disc");
 
  416                          "unexpected number of packets in the first flow queue");
 
  419                          "unexpected number of packets in the second flow queue");
 
  425                          "the first flow must be in the list of old queues");
 
  430                          "the second flow must be in the list of new queues");
 
  433    queueDisc->Dequeue();
 
  436                          "unexpected number of packets in the queue disc");
 
  439                          "unexpected number of packets in the first flow queue");
 
  442                          "unexpected number of packets in the second flow queue");
 
  447                          "the first flow must be in the list of old queues");
 
  453                          "the second flow must be in the list of new queues");
 
  456    queueDisc->Dequeue();
 
  467                          "the first flow must be inactive");
 
  471                          "the second flow must be inactive");
 
 
  488    void DoRun() 
override;
 
 
  499    : 
TestCase(
"Test TCP flows separation")
 
 
  513    p->AddHeader(tcpHdr);
 
  516    queue->Enqueue(item);
 
 
  525    queueDisc->SetQuantum(1500);
 
  526    queueDisc->Initialize();
 
  544                          "unexpected number of packets in the queue disc");
 
  547                          "unexpected number of packets in the first flow queue");
 
  554                          "unexpected number of packets in the queue disc");
 
  557                          "unexpected number of packets in the first flow queue");
 
  560                          "unexpected number of packets in the second flow queue");
 
  567                          "unexpected number of packets in the queue disc");
 
  570                          "unexpected number of packets in the first flow queue");
 
  573                          "unexpected number of packets in the second flow queue");
 
  576                          "unexpected number of packets in the third flow queue");
 
  584                          "unexpected number of packets in the queue disc");
 
  587                          "unexpected number of packets in the first flow queue");
 
  590                          "unexpected number of packets in the second flow queue");
 
  593                          "unexpected number of packets in the third flow queue");
 
  596                          "unexpected number of packets in the third flow queue");
 
 
  613    void DoRun() 
override;
 
 
  624    : 
TestCase(
"Test UDP flows separation")
 
 
  638    p->AddHeader(udpHdr);
 
  641    queue->Enqueue(item);
 
 
  650    queueDisc->SetQuantum(1500);
 
  651    queueDisc->Initialize();
 
  669                          "unexpected number of packets in the queue disc");
 
  672                          "unexpected number of packets in the first flow queue");
 
  679                          "unexpected number of packets in the queue disc");
 
  682                          "unexpected number of packets in the first flow queue");
 
  685                          "unexpected number of packets in the second flow queue");
 
  692                          "unexpected number of packets in the queue disc");
 
  695                          "unexpected number of packets in the first flow queue");
 
  698                          "unexpected number of packets in the second flow queue");
 
  701                          "unexpected number of packets in the third flow queue");
 
  709                          "unexpected number of packets in the queue disc");
 
  712                          "unexpected number of packets in the first flow queue");
 
  715                          "unexpected number of packets in the second flow queue");
 
  718                          "unexpected number of packets in the third flow queue");
 
  721                          "unexpected number of packets in the third flow queue");
 
 
  753    void DoRun() 
override;
 
 
  811        queue->Enqueue(item);
 
  815                          "unexpected number of flow queues");
 
  818                          "unexpected number of enqueued packets");
 
 
  825        queue->GetQueueDiscClass(3)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
  828    if (q3->GetNPackets() == 19)
 
  830        q3->TraceConnectWithoutContext(
 
 
  881    queueDisc->SetQuantum(1514);
 
  882    queueDisc->Initialize();
 
  951        queueDisc->GetQueueDiscClass(0)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
  953        queueDisc->GetQueueDiscClass(1)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
  955        queueDisc->GetQueueDiscClass(2)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
  957        queueDisc->GetQueueDiscClass(3)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
  959        queueDisc->GetQueueDiscClass(4)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
  964                          "There should be 19 marked packets." 
  965                          "As there is no CoDel minBytes parameter so all the packets apart from " 
  966                          "the first one gets marked. As q3 and q4 have" 
  967                          "NotEct packets and the queue delay is much higher than 5ms so the queue " 
  968                          "gets empty pretty quickly so more" 
  969                          "packets from q0 can be dequeued.");
 
  972                          "There should not be any dropped packets");
 
  975                          "There should be 16 marked packets" 
  976                          "As there is no CoDel minBytes parameter so all the packets apart from " 
  977                          "the first one until no more packets are dequeued" 
  981                          "There should not be any dropped packets");
 
  984                          "There should be 12 marked packets" 
  985                          "Each packet size is 120 bytes and the quantum is 1500 bytes so in the " 
  986                          "first turn (1514/120 = 12.61) 13 packets are" 
  987                          "dequeued and apart from the first one, all the packets are marked.");
 
  990                          "There should not be any dropped packets");
 
  995                          "The number of drops should" 
  996                          "be equal to the number of times m_dropNext is updated");
 
  999                          "There should not be any marked packets");
 
 1002                          "The number of drops should" 
 1003                          "be equal to the number of times m_dropNext is updated");
 
 1006                          "There should not be any marked packets");
 
 1017    queueDisc->SetQuantum(1514);
 
 1018    queueDisc->Initialize();
 
 1082    q0 = queueDisc->GetQueueDiscClass(0)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
 1083    q1 = queueDisc->GetQueueDiscClass(1)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
 1084    q2 = queueDisc->GetQueueDiscClass(2)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
 1085    q3 = queueDisc->GetQueueDiscClass(3)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
 1086    q4 = queueDisc->GetQueueDiscClass(4)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
 1091                          "There should not be any dropped packets");
 
 1095        "There should not be any marked packets" 
 1096        "with quantum of 1514, 13 packets of size 120 bytes can be dequeued. sojourn time of 13th " 
 1097        "packet is 1.3ms which is" 
 1098        "less than CE threshold");
 
 1101                          "There should not be any dropped packets");
 
 1105        "There should be 6 marked packets" 
 1106        "with quantum of 1514, 13 packets of size 120 bytes can be dequeued. sojourn time of 8th " 
 1107        "packet is 2.1ms which is greater" 
 1108        "than CE threshold and subsequent packet also have sojourn time more 8th packet hence " 
 1109        "remaining packet are marked.");
 
 1112                          "There should not be any dropped packets");
 
 1116        "There should be 13 marked packets" 
 1117        "with quantum of 1514, 13 packets of size 120 bytes can be dequeued and all of them have " 
 1118        "sojourn time more than CE threshold");
 
 1124        "There should not be any marked packets");
 
 1127                          "There should not be any dropped packets");
 
 1131        "There should not be any marked packets");
 
 1134                          "There should 1 dropped packet. As the queue" 
 1135                          "delay for the first dequeue is greater than the target (5ms), Cobalt " 
 1136                          "overloads the m_dropNext field as an activity timeout" 
 1137                          "and dropNext is to set to the current Time value so on the next dequeue " 
 1138                          "a packet is dropped.");
 
 1152    queueDisc->SetQuantum(1514);
 
 1153    queueDisc->Initialize();
 
 1220    q0 = queueDisc->GetQueueDiscClass(0)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
 1221    q1 = queueDisc->GetQueueDiscClass(1)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
 1222    q2 = queueDisc->GetQueueDiscClass(2)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
 1223    q3 = queueDisc->GetQueueDiscClass(3)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
 1224    q4 = queueDisc->GetQueueDiscClass(4)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
 1229                          "There should not be any dropped packets");
 
 1233        20 - q0->GetNPackets(),
 
 1234        "Number of CE threshold" 
 1235        " exceeded marks plus Number of Target exceeded marks should be equal to total number of " 
 1236        "packets dequeued");
 
 1239                          "There should not be any dropped packets");
 
 1243        20 - q1->GetNPackets(),
 
 1244        "Number of CE threshold" 
 1245        " exceeded marks plus Number of Target exceeded marks should be equal to total number of " 
 1246        "packets dequeued");
 
 1249                          "There should not be any dropped packets");
 
 1253        20 - q2->GetNPackets(),
 
 1254        "Number of CE threshold" 
 1255        " exceeded marks plus Number of Target exceeded marks should be equal to total number of " 
 1256        "packets dequeued");
 
 1262        "There should not be any marked packets");
 
 1265                          "The number of drops should" 
 1266                          "be equal to the number of times m_dropNext is updated");
 
 1270        "There should not be any marked packets");
 
 1273                          "The number of drops should" 
 1274                          "be equal to the number of times m_dropNext is updated");
 
 
 1310    void DoRun() 
override;
 
 
 1320    : 
TestCase(
"Test credits and flows status")
 
 
 1334    queue->Enqueue(item);
 
 
 1343    queueDisc->SetQuantum(90);
 
 1344    queueDisc->Initialize();
 
 1347    queueDisc->AddPacketFilter(filter);
 
 1378                          "unexpected number of packets in the queue disc");
 
 1381                          "unexpected number of packets in the first flow queue of set one");
 
 1384                          "unexpected number of packets in the second flow queue of set one");
 
 1387                          "unexpected number of packets in the third flow queue of set one");
 
 1390                          "unexpected number of packets in the fourth flow queue of set one");
 
 1393                          "unexpected number of packets in the fifth flow queue of set one");
 
 1396                          "unexpected number of packets in the sixth flow queue of set one");
 
 1399                          "unexpected number of packets in the seventh flow queue of set one");
 
 1402                          "unexpected number of packets in the eighth flow queue of set one");
 
 1407                          "unexpected number of packets in the first flow of set one");
 
 1412                          "unexpected number of packets in the first flow of set two");
 
 
 1438    void DoRun() 
override;
 
 
 1486    for (
uint32_t i = 0; i < nPkt; i++)
 
 1489        queue->Enqueue(item);
 
 
 1499    for (
uint32_t i = 0; i < nPkt; i++)
 
 
 1513    for (
uint32_t i = 0; i < nPkt; i++)
 
 
 1524    for (
uint32_t i = 0; i < nPkt; i++)
 
 
 1554    queueDisc->SetQuantum(1514);
 
 1555    queueDisc->Initialize();
 
 1565    double delay = 0.0005;
 
 1591        queueDisc->GetQueueDiscClass(0)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
 1593        queueDisc->GetQueueDiscClass(1)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
 1598        "There should be 66 marked packets" 
 1599        "4th packet is enqueued at 2ms and dequeued at 4ms hence the delay of 2ms which not " 
 1600        "greater than CE threshold" 
 1601        "5th packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and " 
 1602        "subsequent packet also do have delay" 
 1603        "greater than CE threshold so all the packets after 4th packet are marked");
 
 1606                          "There should not be any dropped packets");
 
 1609                          "There should not be any marked packets");
 
 1612                          "There should be 2 marked packets. Packets are dequeued" 
 1613                          "from q0 first, which leads to delay greater than 5ms for the first " 
 1614                          "dequeue from q1. Because of inactivity (started with high queue delay)" 
 1615                          "Cobalt keeps drop_next as now and the next packet is marked. With " 
 1616                          "second dequeue count increases to 2, drop_next becomes now plus around" 
 1617                          "70ms which is less than the running time(140), and as the queue delay " 
 1618                          "is persistently higher than 5ms, second packet is marked.");
 
 1621                          "There should not be any dropped packets");
 
 1637    queueDisc->SetQuantum(1514);
 
 1638    queueDisc->Initialize();
 
 1676    q0 = queueDisc->GetQueueDiscClass(0)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
 1677    q0 = queueDisc->GetQueueDiscClass(0)->GetQueueDisc()->GetObject<
CobaltQueueDisc>();
 
 1682        "There should be 68 marked packets" 
 1683        "2nd ECT1 packet is enqueued at 1.5ms and dequeued at 3ms hence the delay of 1.5ms which " 
 1684        "not greater than CE threshold" 
 1685        "3rd packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and " 
 1686        "subsequent packet also do have delay" 
 1687        "greater than CE threshold so all the packets after 2nd packet are marked");
 
 1690                          "There should not be any dropped packets");
 
 1693                          "There should be 1 marked packets");
 
 
This class tests the deficit per flow.
void DoRun() override
Implementation to actually run this TestCase.
FqCobaltQueueDiscDeficit()
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr)
Enqueue a packet.
~FqCobaltQueueDiscDeficit() override
This class tests ECN marking.
uint32_t m_dropNextCount
count the number of times m_dropNext is recalculated
void DequeueWithDelay(Ptr< FqCobaltQueueDisc > queue, double delay, uint32_t nPkt)
Dequeue the given number of packets at different times.
void Dequeue(Ptr< FqCobaltQueueDisc > queue, uint32_t nPkt)
Dequeue the given number of packets.
~FqCobaltQueueDiscEcnMarking() override
void DropNextTracer(int64_t oldVal, int64_t newVal)
Tracer for the DropNext attribute.
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, uint32_t nPkt, uint32_t nPktEnqueued, uint32_t nQueueFlows)
Enqueue the given number of packets.
FqCobaltQueueDiscEcnMarking()
void DoRun() override
Implementation to actually run this TestCase.
This class tests the IP flows separation and the packet limit.
~FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit() override
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr)
Enqueue a packet.
FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit()
void DoRun() override
Implementation to actually run this TestCase.
This class tests L4S mode.
~FqCobaltQueueDiscL4sMode() override
void DequeueWithDelay(Ptr< FqCobaltQueueDisc > queue, double delay, uint32_t nPkt)
Dequeue the given number of packets at different times.
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, uint32_t nPkt)
Enqueue the given number of packets.
void DoRun() override
Implementation to actually run this TestCase.
void Dequeue(Ptr< FqCobaltQueueDisc > queue, uint32_t nPkt)
Dequeue the given number of packets.
void AddPacketWithDelay(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, double delay, uint32_t nPkt)
Enqueue the given number of packets at different times.
FqCobaltQueueDiscL4sMode()
This class tests packets for which there is no suitable filter.
void DoRun() override
Implementation to actually run this TestCase.
~FqCobaltQueueDiscNoSuitableFilter() override
FqCobaltQueueDiscNoSuitableFilter()
This class tests linear probing, collision response, and set creation capability of set associative h...
void DoRun() override
Implementation to actually run this TestCase.
~FqCobaltQueueDiscSetLinearProbing() override
FqCobaltQueueDiscSetLinearProbing()
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr)
Enqueue a packet.
This class tests the TCP flows separation.
void DoRun() override
Implementation to actually run this TestCase.
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header ipHdr, TcpHeader tcpHdr)
Enqueue a packet.
~FqCobaltQueueDiscTCPFlowsSeparation() override
FqCobaltQueueDiscTCPFlowsSeparation()
FQ-COBALT queue disc test suite.
FqCobaltQueueDiscTestSuite()
This class tests the UDP flows separation.
~FqCobaltQueueDiscUDPFlowsSeparation() override
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header ipHdr, UdpHeader udpHdr)
Enqueue a packet.
void DoRun() override
Implementation to actually run this TestCase.
FqCobaltQueueDiscUDPFlowsSeparation()
Simple test packet filter able to classify IPv4 packets.
int32_t DoClassify(Ptr< QueueDiscItem > item) const override
Classify a QueueDiscItem.
~Ipv4FqCobaltTestPacketFilter() override
bool CheckProtocol(Ptr< QueueDiscItem > item) const override
Check the protocol.
Ipv4FqCobaltTestPacketFilter()
static TypeId GetTypeId()
Get the type ID.
a polymophic address class
AttributeValue implementation for Boolean.
Cobalt packet queue disc.
static constexpr const char * CE_THRESHOLD_EXCEEDED_MARK
Sojourn time above CE threshold.
static constexpr const char * TARGET_EXCEEDED_DROP
Sojourn time above target.
static constexpr const char * FORCED_MARK
forced marks by Codel on ECN-enabled
Ipv4 addresses are stored in host order in this class.
Ipv4PacketFilter is the abstract base class for filters defined for IPv4 packets.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
static FqCobaltQueueDiscTestSuite g_fqCobaltQueueDiscTestSuite
Do not forget to allocate an instance of this TestSuite.
static int32_t g_hash
Variable to assign g_hash to a new packet's flow.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#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.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.