23 #include "ns3/uinteger.h"
24 #include "ns3/pointer.h"
25 #include "ns3/string.h"
26 #include "ns3/double.h"
28 #include "ns3/simulator.h"
29 #include "ns3/node-container.h"
30 #include "ns3/traffic-control-layer.h"
31 #include "ns3/traffic-control-helper.h"
32 #include "ns3/simple-net-device.h"
33 #include "ns3/simple-channel.h"
34 #include "ns3/drop-tail-queue.h"
35 #include "ns3/net-device-queue-interface.h"
36 #include "ns3/config.h"
55 virtual void AddHeader (
void);
56 virtual bool Mark(
void);
117 virtual void DoRun (
void);
149 :
TestCase (
"Test the operation of the flow control mechanism"),
162 for (uint16_t i = 0; i < nPackets; i++)
164 tc->
Send (n->
GetDevice (0), Create<QueueDiscTestItem> (Create<Packet> (1000)));
206 queue = CreateObjectWithAttributes<DropTailQueue<Packet> > (
"Mode",
EnumValue (QueueBase::QUEUE_MODE_PACKETS),
211 queue = CreateObjectWithAttributes<DropTailQueue<Packet> > (
"Mode",
EnumValue (QueueBase::QUEUE_MODE_BYTES),
217 txDev = CreateObjectWithAttributes<SimpleNetDevice> (
"TxQueue",
PointerValue (queue),
219 rxDev = CreateObject<SimpleNetDevice> ();
224 rxDev->SetChannel (channel1);
233 this, n.
Get (0), 10);
246 this, txDev, 5,
"There must be 5 packets in the device queue after 1ms");
248 this, txDev,
true,
"The device queue must be stopped after 1ms");
250 this, txDev, 4,
"There must be 4 packets in the queue disc after 1ms");
254 this, txDev, 5,
"There must be 5 packets in the device queue after 9ms");
256 this, txDev,
true,
"The device queue must be stopped after 9ms");
258 this, txDev, 3,
"There must be 3 packets in the queue disc after 9ms");
262 this, txDev, 5,
"There must be 5 packets in the device queue after 17ms");
264 this, txDev,
true,
"The device queue must be stopped after 17ms");
266 this, txDev, 2,
"There must be 2 packets in the queue disc after 17ms");
270 this, txDev, 5,
"There must be 5 packets in the device queue after 25ms");
272 this, txDev,
true,
"The device queue must be stopped after 25ms");
274 this, txDev, 1,
"There must be 1 packet in the queue disc after 25ms");
278 this, txDev, 5,
"There must be 5 packets in the device queue after 33ms");
280 this, txDev,
true,
"The device queue must be stopped after 33ms");
282 this, txDev, 0,
"The queue disc must be empty after 33ms");
286 this, txDev, 4,
"There must be 4 packets in the device queue after 41ms");
288 this, txDev,
false,
"The device queue must not be stopped after 41ms");
290 this, txDev, 0,
"The queue disc must be empty after 41ms");
294 this, txDev, 0,
"The device queue must be empty after 81ms");
296 this, txDev,
false,
"The device queue must not be stopped after 81ms");
298 this, txDev, 0,
"The queue disc must be empty after 81ms");
311 this, txDev, 3,
"There must be 3 packets in the device queue after 1ms");
313 this, txDev,
true,
"The device queue must be stopped after 1ms");
315 this, txDev, 6,
"There must be 6 packets in the queue disc after 1ms");
319 this, txDev, 3,
"There must be 3 packets in the device queue after 9ms");
321 this, txDev,
true,
"The device queue must be stopped after 9ms");
323 this, txDev, 5,
"There must be 5 packets in the queue disc after 9ms");
327 this, txDev, 3,
"There must be 3 packets in the device queue after 17ms");
329 this, txDev,
true,
"The device queue must be stopped after 17ms");
331 this, txDev, 4,
"There must be 4 packets in the queue disc after 17ms");
335 this, txDev, 3,
"There must be 3 packets in the device queue after 25ms");
337 this, txDev,
true,
"The device queue must be stopped after 25ms");
339 this, txDev, 3,
"There must be 3 packets in the queue disc after 25ms");
343 this, txDev, 3,
"There must be 3 packets in the device queue after 33ms");
345 this, txDev,
true,
"The device queue must be stopped after 33ms");
347 this, txDev, 2,
"There must be 2 packets in the queue disc after 33ms");
351 this, txDev, 3,
"There must be 3 packets in the device queue after 41ms");
353 this, txDev,
true,
"The device queue must be stopped after 41ms");
355 this, txDev, 1,
"There must be 1 packet in the queue disc after 41ms");
359 this, txDev, 3,
"There must be 3 packets in the device queue after 49ms");
361 this, txDev,
true,
"The device queue must be stopped after 49ms");
363 this, txDev, 0,
"The queue disc must be empty after 49ms");
367 this, txDev, 2,
"There must be 2 packets in the device queue after 57ms");
369 this, txDev,
false,
"The device queue must not be stopped after 57ms");
371 this, txDev, 0,
"The queue disc must be empty after 57ms");
375 this, txDev, 0,
"The device queue must be empty after 81ms");
377 this, txDev,
false,
"The device queue must not be stopped after 81ms");
379 this, txDev, 0,
"The queue disc must be empty after 81ms");
383 Simulator::Destroy ();
Simulation virtual time values and global simulation resolution.
QueueDiscContainer Install(NetDeviceContainer c)
void CheckPacketsInDeviceQueue(Ptr< NetDevice > dev, uint16_t nPackets, const char *msg)
Check if the device queue stores the expected number of packets.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Introspection did not find any typical Config paths.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
virtual Ptr< Node > GetNode(void) const =0
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
This test suite implements a Unit Test.
bool GetAttributeFailSafe(std::string name, AttributeValue &value) const
Get the value of an attribute without raising erros.
TcFlowControlTestCase(TestType tt)
Constructor.
void CheckPacketsInQueueDisc(Ptr< NetDevice > dev, uint16_t nPackets, const char *msg)
Check if the queue disc stores the expected number of packets.
Class for representing data rates.
Hold variables of type enum.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
TestType
Device queue operating mode.
Hold an unsigned integer type.
virtual bool SetMtu(const uint16_t mtu)
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Build a set of QueueDisc objects.
Network device transmission queue interface.
void CheckDeviceQueueStopped(Ptr< NetDevice > dev, bool value, const char *msg)
Check if the device queue is in the expected status (stopped or not)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr.
TestType m_type
the test type
virtual void AddHeader(void)
Add the header to the packet.
virtual void Send(Ptr< NetDevice > device, Ptr< QueueDiscItem > item)
Called from upper layer to queue a packet for the transmission.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification...
virtual Ptr< QueueDisc > GetRootQueueDiscOnDevice(Ptr< NetDevice > device) const
This method can be used to get the root queue disc installed on a device.
virtual ~TcFlowControlTestCase()
AttributeValue implementation for DataRate.
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
virtual ~QueueDiscTestItem()
Ptr< NetDeviceQueue > GetTxQueue(uint8_t i) const
Get the i-th transmission queue of the device.
Time Seconds(double value)
Construct a Time in the indicated unit.
TcFlowControlTestSuite g_tcFlowControlTestSuite
the test suite
virtual void DoRun(void)
Implementation to actually run this TestCase.
Traffic Control Flow Control Test Case.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Traffic Control Flow Control Test Suite.
void SendPackets(Ptr< Node > n, uint16_t nPackets)
Instruct a node to send a specified number of packets.
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.