10#include "ns3/config.h" 
   11#include "ns3/data-rate.h" 
   12#include "ns3/double.h" 
   14#include "ns3/net-device-queue-interface.h" 
   15#include "ns3/node-container.h" 
   16#include "ns3/pointer.h" 
   18#include "ns3/simple-net-device-helper.h" 
   19#include "ns3/simulator.h" 
   20#include "ns3/string.h" 
   22#include "ns3/traffic-control-helper.h" 
   23#include "ns3/traffic-control-layer.h" 
   24#include "ns3/uinteger.h" 
   95    void DoRun() 
override;
 
 
  131    : 
TestCase(
"Test the operation of the flow control mechanism"),
 
  133      m_deviceQueueLength(deviceQueueLength),
 
  134      m_totalTxPackets(totalTxPackets)
 
 
  146    for (uint16_t i = 0; i < nPackets; i++)
 
 
  155                                                 const std::string msg)
 
  158    dev->GetAttributeFailSafe(
"TxQueue", ptr);
 
 
  166                                               const std::string msg)
 
  169    NS_ASSERT_MSG(ndqi, 
"A device queue interface has not been aggregated to the device");
 
 
  176                                               const std::string msg)
 
 
  197    simple.
SetQueue(
"ns3::DropTailQueue",
 
  218    if (
m_type == QueueSizeUnit::PACKETS)
 
  244            checkTimeMs = 8 * (txPackets - 1) + 1; 
 
  254                                    "The device queue must be stopped after " +
 
  255                                        std::to_string(checkTimeMs) + 
"ms");
 
  264                                    "The device queue must not be stopped after " +
 
  265                                        std::to_string(checkTimeMs) + 
"ms");
 
  274                                    " packets in the device after " + std::to_string(checkTimeMs) +
 
  282                                "There must be " + std::to_string(qdiscPackets) +
 
  283                                    " packets in the queue disc after " +
 
  284                                    std::to_string(checkTimeMs) + 
"ms");
 
  303                            "There must be 3 packets in the device queue after 1ms");
 
  309                            "The device queue must be stopped after 1ms");
 
  315                            "There must be 6 packets in the queue disc after 1ms");
 
  323                            "There must be 3 packets in the device queue after 9ms");
 
  329                            "The device queue must be stopped after 9ms");
 
  335                            "There must be 5 packets in the queue disc after 9ms");
 
  343                            "There must be 3 packets in the device queue after 17ms");
 
  349                            "The device queue must be stopped after 17ms");
 
  355                            "There must be 4 packets in the queue disc after 17ms");
 
  363                            "There must be 3 packets in the device queue after 25ms");
 
  369                            "The device queue must be stopped after 25ms");
 
  375                            "There must be 3 packets in the queue disc after 25ms");
 
  383                            "There must be 3 packets in the device queue after 33ms");
 
  389                            "The device queue must be stopped after 33ms");
 
  395                            "There must be 2 packets in the queue disc after 33ms");
 
  403                            "There must be 3 packets in the device queue after 41ms");
 
  409                            "The device queue must be stopped after 41ms");
 
  415                            "There must be 1 packet in the queue disc after 41ms");
 
  423                            "There must be 3 packets in the device queue after 49ms");
 
  429                            "The device queue must be stopped after 49ms");
 
  435                            "The queue disc must be empty after 49ms");
 
  444                            "There must be 2 packets in the device queue after 57ms");
 
  450                            "The device queue must not be stopped after 57ms");
 
  456                            "The queue disc must be empty after 57ms");
 
  465                            "The device queue must be empty after 81ms");
 
  471                            "The device queue must not be stopped after 81ms");
 
  477                            "The queue disc must be empty after 81ms");
 
 
  496                    TestCase::Duration::QUICK);
 
  498                    TestCase::Duration::QUICK);
 
  500                    TestCase::Duration::QUICK);
 
  502                    TestCase::Duration::QUICK);
 
  504                    TestCase::Duration::QUICK);
 
  506                    TestCase::Duration::QUICK);
 
  508                    TestCase::Duration::QUICK);
 
  510                    TestCase::Duration::QUICK);
 
  512                    TestCase::Duration::QUICK);
 
  517                    TestCase::Duration::QUICK);
 
 
 
bool Mark() override
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
QueueDiscTestItem(const QueueDiscTestItem &)=delete
QueueDiscTestItem()=delete
QueueDiscTestItem & operator=(const QueueDiscTestItem &)=delete
~QueueDiscTestItem() override
void AddHeader() override
Add the header to the packet.
Traffic Control Flow Control Test Case.
uint32_t m_deviceQueueLength
the queue length of the device
void CheckPacketsInQueueDisc(Ptr< NetDevice > dev, uint16_t nPackets, const std::string msg)
Check if the queue disc stores the expected number of packets.
void DoRun() override
Implementation to actually run this TestCase.
void SendPackets(Ptr< Node > n, uint16_t nPackets)
Instruct a node to send a specified number of packets.
TcFlowControlTestCase(QueueSizeUnit tt, uint32_t deviceQueueLength, uint32_t totalTxPackets)
Constructor.
void CheckDeviceQueueStopped(Ptr< NetDevice > dev, bool value, const std::string msg)
Check if the device queue is in the expected status (stopped or not)
~TcFlowControlTestCase() override
QueueSizeUnit m_type
the test type
void CheckPacketsInDeviceQueue(Ptr< NetDevice > dev, uint16_t nPackets, const std::string msg)
Check if the device queue stores the expected number of packets.
uint32_t m_totalTxPackets
the toal number of packets to transmit
Traffic Control Flow Control Test Suite.
Class for representing data rates.
AttributeValue implementation for DataRate.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Network device transmission queue interface.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Template class for packet Queues.
build a set of SimpleNetDevice objects
void SetQueue(std::string type, Ts &&... args)
Each net device must have a queue to pass packets through.
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
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.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
static constexpr auto UNIT
Build a set of QueueDisc objects.
QueueDiscContainer Install(NetDeviceContainer c)
static TrafficControlHelper Default(std::size_t nTxQueues=1)
The Traffic Control layer aims at introducing an equivalent of the Linux Traffic Control infrastructu...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
QueueSizeUnit
Enumeration of the operating modes of queues.
#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.
TcFlowControlTestSuite g_tcFlowControlTestSuite
the test suite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.