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-helper.h" 33 #include "ns3/data-rate.h" 34 #include "ns3/net-device-queue-interface.h" 35 #include "ns3/queue.h" 36 #include "ns3/config.h" 55 virtual void AddHeader (
void);
56 virtual bool Mark(
void);
110 virtual void DoRun (
void);
142 :
TestCase (
"Test the operation of the flow control mechanism"),
155 for (uint16_t i = 0; i < nPackets; i++)
157 tc->
Send (
n->GetDevice (0), Create<QueueDiscTestItem> (Create<Packet> (1000)));
174 NS_ASSERT_MSG (ndqi,
"A device queue interface has not been aggregated to the device");
193 n.Get (0)->AggregateObject (CreateObject<TrafficControlLayer> ());
194 n.Get (1)->AggregateObject (CreateObject<TrafficControlLayer> ());
201 simple.
SetQueue (
"ns3::DropTailQueue",
"MaxSize",
205 txDev = simple.
Install (
n.Get (0), DynamicCast<SimpleChannel> (rxDevC.
Get (0)->GetChannel ())).
Get (0);
213 this,
n.Get (0), 10);
226 this, txDev, 5,
"There must be 5 packets in the device queue after 1ms");
228 this, txDev,
true,
"The device queue must be stopped after 1ms");
230 this, txDev, 4,
"There must be 4 packets in the queue disc after 1ms");
234 this, txDev, 5,
"There must be 5 packets in the device queue after 9ms");
236 this, txDev,
true,
"The device queue must be stopped after 9ms");
238 this, txDev, 3,
"There must be 3 packets in the queue disc after 9ms");
242 this, txDev, 5,
"There must be 5 packets in the device queue after 17ms");
244 this, txDev,
true,
"The device queue must be stopped after 17ms");
246 this, txDev, 2,
"There must be 2 packets in the queue disc after 17ms");
250 this, txDev, 5,
"There must be 5 packets in the device queue after 25ms");
252 this, txDev,
true,
"The device queue must be stopped after 25ms");
254 this, txDev, 1,
"There must be 1 packet in the queue disc after 25ms");
258 this, txDev, 5,
"There must be 5 packets in the device queue after 33ms");
260 this, txDev,
true,
"The device queue must be stopped after 33ms");
262 this, txDev, 0,
"The queue disc must be empty after 33ms");
266 this, txDev, 4,
"There must be 4 packets in the device queue after 41ms");
268 this, txDev,
false,
"The device queue must not be stopped after 41ms");
270 this, txDev, 0,
"The queue disc must be empty after 41ms");
274 this, txDev, 0,
"The device queue must be empty after 81ms");
276 this, txDev,
false,
"The device queue must not be stopped after 81ms");
278 this, txDev, 0,
"The queue disc must be empty after 81ms");
291 this, txDev, 3,
"There must be 3 packets in the device queue after 1ms");
293 this, txDev,
true,
"The device queue must be stopped after 1ms");
295 this, txDev, 6,
"There must be 6 packets in the queue disc after 1ms");
299 this, txDev, 3,
"There must be 3 packets in the device queue after 9ms");
301 this, txDev,
true,
"The device queue must be stopped after 9ms");
303 this, txDev, 5,
"There must be 5 packets in the queue disc after 9ms");
307 this, txDev, 3,
"There must be 3 packets in the device queue after 17ms");
309 this, txDev,
true,
"The device queue must be stopped after 17ms");
311 this, txDev, 4,
"There must be 4 packets in the queue disc after 17ms");
315 this, txDev, 3,
"There must be 3 packets in the device queue after 25ms");
317 this, txDev,
true,
"The device queue must be stopped after 25ms");
319 this, txDev, 3,
"There must be 3 packets in the queue disc after 25ms");
323 this, txDev, 3,
"There must be 3 packets in the device queue after 33ms");
325 this, txDev,
true,
"The device queue must be stopped after 33ms");
327 this, txDev, 2,
"There must be 2 packets in the queue disc after 33ms");
331 this, txDev, 3,
"There must be 3 packets in the device queue after 41ms");
333 this, txDev,
true,
"The device queue must be stopped after 41ms");
335 this, txDev, 1,
"There must be 1 packet in the queue disc after 41ms");
339 this, txDev, 3,
"There must be 3 packets in the device queue after 49ms");
341 this, txDev,
true,
"The device queue must be stopped after 49ms");
343 this, txDev, 0,
"The queue disc must be empty after 49ms");
347 this, txDev, 2,
"There must be 2 packets in the device queue after 57ms");
349 this, txDev,
false,
"The device queue must not be stopped after 57ms");
351 this, txDev, 0,
"The queue disc must be empty after 57ms");
355 this, txDev, 0,
"The device queue must be empty after 81ms");
357 this, txDev,
false,
"The device queue must not be stopped after 81ms");
359 this, txDev, 0,
"The queue disc must be empty after 81ms");
363 Simulator::Destroy ();
QueueSizeUnit m_type
the test type
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
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.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
Hold variables of type string.
Introspection did not find any typical Config paths.
QueueSizeUnit
Enumeration of the operating modes of queues.
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.
bool GetAttributeFailSafe(std::string name, AttributeValue &value) const
Get the value of an attribute without raising erros.
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.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Use number of packets for queue size.
holds a vector of ns3::NetDevice pointers
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
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)
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
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<T>.
virtual void AddHeader(void)
Add the header to the packet.
TcFlowControlTestCase(QueueSizeUnit tt)
Constructor.
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.
virtual void Send(Ptr< NetDevice > device, Ptr< QueueDiscItem > item)
Called from upper layer to queue a packet for the transmission.
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification...
virtual ~TcFlowControlTestCase()
AttributeValue implementation for DataRate.
virtual ~QueueDiscTestItem()
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.
Ptr< NetDeviceQueue > GetTxQueue(std::size_t i) const
Get the i-th transmission queue of the device.
build a set of SimpleNetDevice objects
Traffic Control Flow Control Test Suite.
This test suite implements a Unit Test.
virtual bool SetMtu(const uint16_t mtu)=0
void SendPackets(Ptr< Node > n, uint16_t nPackets)
Instruct a node to send a specified number of packets.
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
Use number of bytes for queue size.
virtual Ptr< QueueDisc > GetRootQueueDiscOnDevice(Ptr< NetDevice > device) const
This method can be used to get the root queue disc installed on a device.