23 #include "ns3/red-queue-disc.h"
24 #include "ns3/drop-tail-queue.h"
25 #include "ns3/uinteger.h"
26 #include "ns3/string.h"
27 #include "ns3/double.h"
29 #include "ns3/simulator.h"
30 #include "ns3/ipv4-queue-disc-item.h"
32 #include "ns3/core-module.h"
33 #include "ns3/network-module.h"
34 #include "ns3/internet-module.h"
35 #include "ns3/point-to-point-module.h"
36 #include "ns3/applications-module.h"
37 #include "ns3/point-to-point-layout-module.h"
38 #include "ns3/traffic-control-module.h"
47 virtual void DoRun (
void);
54 :
TestCase (
"Sanity check on automatically set parameters of ARED")
62 uint32_t modeSize = 1;
66 "Verify that we can actually set the attribute Mode");
71 if (queue->
GetMode () == Queue::QUEUE_MODE_BYTES)
77 double minTh = 70 * modeSize;
78 double maxTh = 150 * modeSize;
79 uint32_t qSize = 300 * modeSize;
83 "Verify that we can actually set the attribute Mode");
85 "Verify that we can actually set the attribute MinTh");
87 "Verify that we can actually set the attribute MaxTh");
89 "Verify that we can actually set the attribute QueueLimit");
91 "Verify that we can actually set the attribute QW");
95 if (queue->
GetMode () == Queue::QUEUE_MODE_PACKETS)
101 else if (queue->
GetMode () == Queue::QUEUE_MODE_BYTES)
110 queue = CreateObject<RedQueueDisc> ();
112 "Verify that we can actually set the attribute Mode");
114 "Verify that we can actually set the attribute MinTh");
116 "Verify that we can actually set the attribute MaxTh");
118 "Verify that we can actually set the attribute QueueLimit");
120 "Verify that we can actually set the attribute QW");
122 "Verify that we can actually set the attribute LinkBandwidth");
125 st = StaticCast<RedQueueDisc> (queue)->GetStats ();
126 if (queue->
GetMode () == Queue::QUEUE_MODE_PACKETS)
132 else if (queue->
GetMode () == Queue::QUEUE_MODE_BYTES)
141 queue = CreateObject<RedQueueDisc> ();
143 "Verify that we can actually set the attribute Mode");
145 "Verify that we can actually set the attribute MinTh");
147 "Verify that we can actually set the attribute MaxTh");
149 "Verify that we can actually set the attribute QueueLimit");
151 "Verify that we can actually set the attribute QW");
154 st = StaticCast<RedQueueDisc> (queue)->GetStats ();
155 if (queue->
GetMode () == Queue::QUEUE_MODE_PACKETS)
161 else if (queue->
GetMode () == Queue::QUEUE_MODE_BYTES)
170 queue = CreateObject<RedQueueDisc> ();
172 "Verify that we can actually set the attribute Mode");
174 "Verify that we can actually set the attribute MinTh");
176 "Verify that we can actually set the attribute MaxTh");
178 "Verify that we can actually set the attribute QueueLimit");
180 "Verify that we can actually set the attribute QW");
182 "Verify that we can actually set the attribute LinkBandwidth");
185 st = StaticCast<RedQueueDisc> (queue)->GetStats ();
186 if (queue->
GetMode () == Queue::QUEUE_MODE_PACKETS)
192 else if (queue->
GetMode () == Queue::QUEUE_MODE_BYTES)
201 queue = CreateObject<RedQueueDisc> ();
203 "Verify that we can actually set the attribute Mode");
205 "Verify that we can actually set the attribute MinTh");
207 "Verify that we can actually set the attribute MaxTh");
209 "Verify that we can actually set the attribute QueueLimit");
211 "Verify that we can actually set the attribute QW");
214 st = StaticCast<RedQueueDisc> (queue)->GetStats ();
215 if (queue->
GetMode () == Queue::QUEUE_MODE_PACKETS)
221 else if (queue->
GetMode () == Queue::QUEUE_MODE_BYTES)
230 queue = CreateObject<RedQueueDisc> ();
232 "Verify that we can actually set the attribute Mode");
234 "Verify that we can actually set the attribute MinTh");
236 "Verify that we can actually set the attribute MaxTh");
238 "Verify that we can actually set the attribute QueueLimit");
240 "Verify that we can actually set the attribute QW");
242 "Verify that we can actually set the attribute LinkBandwidth");
245 st = StaticCast<RedQueueDisc> (queue)->GetStats ();
246 if (queue->
GetMode () == Queue::QUEUE_MODE_PACKETS)
252 else if (queue->
GetMode () == Queue::QUEUE_MODE_BYTES)
261 queue = CreateObject<RedQueueDisc> ();
263 "Verify that we can actually set the attribute Mode");
265 "Verify that we can actually set the attribute MinTh");
267 "Verify that we can actually set the attribute MaxTh");
269 "Verify that we can actually set the attribute QueueLimit");
270 if (queue->
GetMode () == Queue::QUEUE_MODE_BYTES)
273 "Verify that we can actually set the attribute MeanPktSize");
277 st = StaticCast<RedQueueDisc> (queue)->GetStats ();
278 if (queue->
GetMode () == Queue::QUEUE_MODE_PACKETS)
284 else if (queue->
GetMode () == Queue::QUEUE_MODE_BYTES)
293 queue = CreateObject<RedQueueDisc> ();
295 "Verify that we can actually set the attribute Mode");
297 "Verify that we can actually set the attribute MinTh");
299 "Verify that we can actually set the attribute MaxTh");
301 "Verify that we can actually set the attribute QueueLimit");
303 "Verify that we can actually set the attribute LinkBandwidth");
304 if (queue->
GetMode () == Queue::QUEUE_MODE_BYTES)
307 "Verify that we can actually set the attribute MeanPktSize");
311 st = StaticCast<RedQueueDisc> (queue)->GetStats ();
312 if (queue->
GetMode () == Queue::QUEUE_MODE_PACKETS)
318 else if (queue->
GetMode () == Queue::QUEUE_MODE_BYTES)
331 for (uint32_t i = 0; i < nPkt; i++)
333 queue->
Enqueue (Create<Ipv4QueueDiscItem> (Create<Packet> (size), dest, 0, ipHeader));
342 Simulator::Destroy ();
351 virtual void DoRun (
void);
357 :
TestCase (
"Sanity check on adaptive parameter of ARED")
364 uint32_t pktSize = 500;
365 uint32_t modeSize = 1;
374 "Verify that we can actually set the attribute Mode");
378 if (queue->
GetMode () == Queue::QUEUE_MODE_BYTES)
383 uint32_t qSize = 100 * modeSize;
400 nLeaf, pointToPointLeaf,
405 for (uint32_t i = 0; i < d.
LeftCount (); ++i)
409 for (uint32_t i = 0; i < d.
RightCount (); ++i)
431 PacketSinkHelper packetSinkHelper (
"ns3::TcpSocketFactory", sinkLocalAddress);
433 for (uint32_t i = 0; i < d.
LeftCount (); ++i)
441 for (uint32_t i = 0; i < d.
RightCount (); ++i)
451 Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
455 uint32_t totalRxBytesCounter = 0;
456 for (uint32_t i = 0; i < sinkApps.
GetN (); i++)
460 totalRxBytesCounter += pktSink->
GetTotalRx ();
463 if (queue->
GetMode () == Queue::QUEUE_MODE_PACKETS)
467 else if (queue->
GetMode () == Queue::QUEUE_MODE_BYTES)
472 Simulator::Destroy ();
480 Simulator::Destroy ();
holds a vector of ns3::Application pointers.
AdaptiveRedQueueDiscTestCase()
Smart pointer class similar to boost::intrusive_ptr.
AttributeValue implementation for Boolean.
QueueDiscContainer Install(NetDeviceContainer c)
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
Hold variables of type string.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
aggregate IP/TCP/UDP functionality to existing Nodes.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
void Enqueue(Ptr< RedQueueDisc > queue, uint32_t size, uint32_t nPkt)
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
Set a single attribute without raising errors.
AredQueueDiscTestSuite g_aredQueueDiscTestSuite
uint32_t GetN(void) const
Get the number of Ptr
stored in this container.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
Ptr< Node > GetRight() const
Build a set of PointToPointNetDevice objects.
This test suite implements a Unit Test.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Ptr< Node > GetLeft() const
a polymophic address class
Class for representing data rates.
void RunAdaptiveRedDiscTest(StringValue mode)
uint32_t forcedDrop
Forced drops, qavg > max threshold.
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Hold an unsigned integer type.
uint32_t qLimDrop
Drops due to queue limits.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Build a set of QueueDisc objects.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
uint32_t GetSerializedSize(void) const
Get the number of bytes needed to serialize the underlying Address Typically, this is GetLength () + ...
uint32_t LeftCount() const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< Application > Get(uint32_t i) const
Get the Ptr
stored in this container at a given index.
uint16_t SetRootQueueDisc(std::string type, std::string n01="", const AttributeValue &v01=EmptyAttributeValue(), std::string n02="", const AttributeValue &v02=EmptyAttributeValue(), std::string n03="", const AttributeValue &v03=EmptyAttributeValue(), std::string n04="", const AttributeValue &v04=EmptyAttributeValue(), std::string n05="", const AttributeValue &v05=EmptyAttributeValue(), std::string n06="", const AttributeValue &v06=EmptyAttributeValue(), std::string n07="", const AttributeValue &v07=EmptyAttributeValue(), std::string n08="", const AttributeValue &v08=EmptyAttributeValue(), std::string n09="", const AttributeValue &v09=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue(), std::string n11="", const AttributeValue &v11=EmptyAttributeValue(), std::string n12="", const AttributeValue &v12=EmptyAttributeValue(), std::string n13="", const AttributeValue &v13=EmptyAttributeValue(), std::string n14="", const AttributeValue &v14=EmptyAttributeValue(), std::string n15="", const AttributeValue &v15=EmptyAttributeValue())
Helper function used to set a root queue disc of the given type and with the given attributes...
AutoRedQueueDiscTestCase()
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Queue::QueueMode GetMode(void)
Get the encapsulation mode of this queue.
void RunAutoRedDiscTest(StringValue mode)
void AssignIpv4Addresses(Ipv4AddressHelper leftIp, Ipv4AddressHelper rightIp, Ipv4AddressHelper routerIp)
uint32_t GetTotalRx() const
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
uint32_t RightCount() const
AttributeValue implementation for Address.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
AttributeValue implementation for DataRate.
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetDefault(std::string name, const AttributeValue &value)
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
A helper to make it easier to create a dumbbell topology with p2p links.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
virtual void DoRun(void)
Implementation to actually run this TestCase.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Ipv4Address GetLeftIpv4Address(uint32_t i) const
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
uint32_t unforcedDrop
Early probability drops.