|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
26 #include "ns3/uinteger.h"
27 #include "ns3/pointer.h"
28 #include "ns3/string.h"
29 #include "ns3/double.h"
31 #include "ns3/simulator.h"
32 #include "ns3/node-container.h"
33 #include "ns3/traffic-control-layer.h"
34 #include "ns3/traffic-control-helper.h"
35 #include "ns3/simple-net-device-helper.h"
36 #include "ns3/data-rate.h"
37 #include "ns3/net-device-queue-interface.h"
38 #include "ns3/queue.h"
39 #include "ns3/config.h"
58 virtual void AddHeader (
void);
59 virtual bool Mark(
void);
113 virtual void DoRun (
void);
147 :
TestCase (
"Test the operation of the flow control mechanism"),
148 m_type (tt), m_deviceQueueLength(deviceQueueLength), m_totalTxPackets(totalTxPackets)
160 for (uint16_t i = 0; i < nPackets; i++)
162 tc->
Send (
n->GetDevice (0), Create<QueueDiscTestItem> (Create<Packet> (1000)));
179 NS_ASSERT_MSG (ndqi,
"A device queue interface has not been aggregated to the device");
198 n.Get (0)->AggregateObject (CreateObject<TrafficControlLayer> ());
199 n.Get (1)->AggregateObject (CreateObject<TrafficControlLayer> ());
206 simple.
SetQueue (
"ns3::DropTailQueue",
"MaxSize",
241 uint32_t checkTimeMs = 0;
242 uint32_t deviceQueuePackets = 0;
243 uint32_t qdiscPackets = 0;
245 uint32_t txPackets = 0;
248 checkTimeMs = 8 * (txPackets - 1) + 1;
253 Simulator::Schedule (
256 "The device queue must be stopped after " + std::to_string (checkTimeMs) +
"ms");
263 "The device queue must not be stopped after " +
264 std::to_string (checkTimeMs) +
"ms");
267 Simulator::Schedule (
269 this, txDev, deviceQueuePackets,
270 "There must be " + std::to_string (
m_deviceQueueLength) +
" packets in the device after " +
271 std::to_string (checkTimeMs) +
"ms");
273 Simulator::Schedule (
275 this, txDev, qdiscPackets,
276 "There must be " + std::to_string (qdiscPackets) +
277 " packets in the queue disc after " + std::to_string (checkTimeMs) +
"ms");
292 this, txDev, 3,
"There must be 3 packets in the device queue after 1ms");
294 this, txDev,
true,
"The device queue must be stopped after 1ms");
296 this, txDev, 6,
"There must be 6 packets in the queue disc after 1ms");
300 this, txDev, 3,
"There must be 3 packets in the device queue after 9ms");
302 this, txDev,
true,
"The device queue must be stopped after 9ms");
304 this, txDev, 5,
"There must be 5 packets in the queue disc after 9ms");
308 this, txDev, 3,
"There must be 3 packets in the device queue after 17ms");
310 this, txDev,
true,
"The device queue must be stopped after 17ms");
312 this, txDev, 4,
"There must be 4 packets in the queue disc after 17ms");
316 this, txDev, 3,
"There must be 3 packets in the device queue after 25ms");
318 this, txDev,
true,
"The device queue must be stopped after 25ms");
320 this, txDev, 3,
"There must be 3 packets in the queue disc after 25ms");
324 this, txDev, 3,
"There must be 3 packets in the device queue after 33ms");
326 this, txDev,
true,
"The device queue must be stopped after 33ms");
328 this, txDev, 2,
"There must be 2 packets in the queue disc after 33ms");
332 this, txDev, 3,
"There must be 3 packets in the device queue after 41ms");
334 this, txDev,
true,
"The device queue must be stopped after 41ms");
336 this, txDev, 1,
"There must be 1 packet in the queue disc after 41ms");
340 this, txDev, 3,
"There must be 3 packets in the device queue after 49ms");
342 this, txDev,
true,
"The device queue must be stopped after 49ms");
344 this, txDev, 0,
"The queue disc must be empty after 49ms");
348 this, txDev, 2,
"There must be 2 packets in the device queue after 57ms");
350 this, txDev,
false,
"The device queue must not be stopped after 57ms");
352 this, txDev, 0,
"The queue disc must be empty after 57ms");
356 this, txDev, 0,
"The device queue must be empty after 81ms");
358 this, txDev,
false,
"The device queue must not be stopped after 81ms");
360 this, txDev, 0,
"The queue disc must be empty after 81ms");
364 Simulator::Destroy ();
holds a vector of ns3::NetDevice pointers
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
AttributeValue implementation for DataRate.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
void SetQueue(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue())
Each net device must have a queue to pass packets through.
Ptr< NetDeviceQueue > GetTxQueue(std::size_t i) const
Get the i-th transmission queue of the device.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
QueueDiscTestItem(const QueueDiscTestItem &)
Copy constructor Disable default implementation to avoid misuse.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Hold objects of type Ptr<T>.
@ PACKETS
Use number of packets for queue size.
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
virtual ~QueueDiscTestItem()
uint32_t m_deviceQueueLength
bool GetAttributeFailSafe(std::string name, AttributeValue &value) const
Get the value of an attribute without raising erros.
Class for representing data rates.
virtual bool SetMtu(const uint16_t mtu)=0
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
Traffic Control Flow Control Test Case.
QueueDiscContainer Install(NetDeviceContainer c)
virtual Ptr< Node > GetNode(void) const =0
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
build a set of SimpleNetDevice objects
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Simulation virtual time values and global simulation resolution.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
void CheckDeviceQueueStopped(Ptr< NetDevice > dev, bool value, const std::string msg)
Check if the device queue is in the expected status (stopped or not)
virtual Ptr< Channel > GetChannel(void) const =0
Hold variables of type string.
Network device transmission queue interface.
void CheckPacketsInQueueDisc(Ptr< NetDevice > dev, uint16_t nPackets, const std::string msg)
Check if the queue disc stores the expected number of packets.
virtual ~TcFlowControlTestCase()
Introspection did not find any typical Config paths.
@ UNIT
This test suite implements a Unit Test.
virtual void Send(Ptr< NetDevice > device, Ptr< QueueDiscItem > item)
Called from upper layer to queue a packet for the transmission.
virtual void AddHeader(void)
Add the header to the packet.
uint32_t m_totalTxPackets
Time Seconds(double value)
Construct a Time in the indicated unit.
Build a set of QueueDisc objects.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual Ptr< QueueDisc > GetRootQueueDiscOnDevice(Ptr< NetDevice > device) const
This method can be used to get the root queue disc installed on a device.
@ BYTES
Use number of bytes for queue size.
void SendPackets(Ptr< Node > n, uint16_t nPackets)
Instruct a node to send a specified number of packets.
keep track of a set of node pointers.
QueueSizeUnit
Enumeration of the operating modes of queues.
TcFlowControlTestSuite g_tcFlowControlTestSuite
the test suite
Traffic Control Flow Control Test Suite.
TcFlowControlTestCase(QueueSizeUnit tt, uint32_t deviceQueueLength, uint32_t totalTxPackets)
Constructor.
void CheckPacketsInDeviceQueue(Ptr< NetDevice > dev, uint16_t nPackets, const std::string msg)
Check if the device queue stores the expected number of packets.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
QueueSizeUnit m_type
the test type