A Discrete-Event Network Simulator
API
adaptive-red-queue-disc-test-suite.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2015 NITK Surathkal
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mohit P. Tahiliani (tahiliani@nitk.edu.in)
19  *
20  */
21 
22 #include "ns3/core-module.h"
23 #include "ns3/network-module.h"
24 #include "ns3/internet-module.h"
25 #include "ns3/point-to-point-module.h"
26 #include "ns3/applications-module.h"
27 #include "ns3/traffic-control-module.h"
28 
29 using namespace ns3;
30 
31 // Tests to verify the working of *automatically set* parameters in ARED
33 {
34 public:
36  virtual void DoRun (void);
37 private:
38  void Enqueue (Ptr<RedQueueDisc> queue, uint32_t size, uint32_t nPkt);
39  void RunAutoRedDiscTest (StringValue mode);
40 };
41 
43  : TestCase ("Sanity check on automatically set parameters of ARED")
44 {
45 }
46 
47 void
49 {
50  uint32_t pktSize = 0;
51  uint32_t modeSize = 1; // 1 for packets; pktSize for bytes
52  Ptr<RedQueueDisc> queue = CreateObject<RedQueueDisc> ();
53 
54  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
55  "Verify that we can actually set the attribute Mode");
56 
57  Ipv4Header ipHeader;
58  Address dest;
59 
60  if (queue->GetMode () == Queue::QUEUE_MODE_BYTES)
61  {
62  pktSize = 500;
63  modeSize = pktSize + ipHeader.GetSerializedSize ();
64  }
65 
66  double minTh = 70 * modeSize;
67  double maxTh = 150 * modeSize;
68  uint32_t qSize = 300 * modeSize;
69 
70 
71  // test 1: Verify automatic setting of QW. [QW = 0.0 with default LinkBandwidth]
72  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
73  "Verify that we can actually set the attribute Mode");
74  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
75  "Verify that we can actually set the attribute MinTh");
76  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
77  "Verify that we can actually set the attribute MaxTh");
78  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
79  "Verify that we can actually set the attribute QueueLimit");
80  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.0)), true,
81  "Verify that we can actually set the attribute QW");
82  queue->Initialize ();
83  Enqueue (queue, pktSize, 300);
84  RedQueueDisc::Stats st = StaticCast<RedQueueDisc> (queue)->GetStats ();
85  uint32_t drops = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
86  NS_TEST_EXPECT_MSG_EQ (drops, 0, "There should be zero dropped packets");
87 
88 
89  // test 2: Verify automatic setting of QW. [QW = 0.0 with lesser LinkBandwidth]
90  queue = CreateObject<RedQueueDisc> ();
91  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
92  "Verify that we can actually set the attribute Mode");
93  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
94  "Verify that we can actually set the attribute MinTh");
95  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
96  "Verify that we can actually set the attribute MaxTh");
97  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
98  "Verify that we can actually set the attribute QueueLimit");
99  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.0)), true,
100  "Verify that we can actually set the attribute QW");
101  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LinkBandwidth", DataRateValue (DataRate ("0.015Mbps"))), true,
102  "Verify that we can actually set the attribute LinkBandwidth");
103  queue->Initialize ();
104  Enqueue (queue, pktSize, 300);
105  st = StaticCast<RedQueueDisc> (queue)->GetStats ();
106  drops = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
107  NS_TEST_EXPECT_MSG_NE (drops, 0, "There should be some dropped packets");
108 
109 
110  // test 3: Verify automatic setting of QW. [QW = -1.0 with default LinkBandwidth]
111  queue = CreateObject<RedQueueDisc> ();
112  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
113  "Verify that we can actually set the attribute Mode");
114  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
115  "Verify that we can actually set the attribute MinTh");
116  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
117  "Verify that we can actually set the attribute MaxTh");
118  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
119  "Verify that we can actually set the attribute QueueLimit");
120  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (-1.0)), true,
121  "Verify that we can actually set the attribute QW");
122  queue->Initialize ();
123  Enqueue (queue, pktSize, 300);
124  st = StaticCast<RedQueueDisc> (queue)->GetStats ();
125  drops = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
126  NS_TEST_EXPECT_MSG_EQ (drops, 0, "There should be zero dropped packets");
127 
128 
129  // test 4: Verify automatic setting of QW. [QW = -1.0 with lesser LinkBandwidth]
130  queue = CreateObject<RedQueueDisc> ();
131  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
132  "Verify that we can actually set the attribute Mode");
133  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
134  "Verify that we can actually set the attribute MinTh");
135  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
136  "Verify that we can actually set the attribute MaxTh");
137  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
138  "Verify that we can actually set the attribute QueueLimit");
139  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (-1.0)), true,
140  "Verify that we can actually set the attribute QW");
141  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LinkBandwidth", DataRateValue (DataRate ("0.015Mbps"))), true,
142  "Verify that we can actually set the attribute LinkBandwidth");
143  queue->Initialize ();
144  Enqueue (queue, pktSize, 300);
145  st = StaticCast<RedQueueDisc> (queue)->GetStats ();
146  drops = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
147  NS_TEST_EXPECT_MSG_NE (drops, 0, "There should be some dropped packets");
148 
149 
150  // test 5: Verify automatic setting of QW. [QW = -2.0 with default LinkBandwidth]
151  queue = CreateObject<RedQueueDisc> ();
152  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
153  "Verify that we can actually set the attribute Mode");
154  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
155  "Verify that we can actually set the attribute MinTh");
156  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
157  "Verify that we can actually set the attribute MaxTh");
158  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
159  "Verify that we can actually set the attribute QueueLimit");
160  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (-2.0)), true,
161  "Verify that we can actually set the attribute QW");
162  queue->Initialize ();
163  Enqueue (queue, pktSize, 300);
164  st = StaticCast<RedQueueDisc> (queue)->GetStats ();
165  uint32_t test5 = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
166  NS_TEST_EXPECT_MSG_NE (test5, 0, "There should be some dropped packets");
167 
168 
169  // test 6: Verify automatic setting of QW. [QW = -2.0 with lesser LinkBandwidth]
170  queue = CreateObject<RedQueueDisc> ();
171  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
172  "Verify that we can actually set the attribute Mode");
173  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
174  "Verify that we can actually set the attribute MinTh");
175  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
176  "Verify that we can actually set the attribute MaxTh");
177  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
178  "Verify that we can actually set the attribute QueueLimit");
179  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (-2.0)), true,
180  "Verify that we can actually set the attribute QW");
181  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LinkBandwidth", DataRateValue (DataRate ("0.015Mbps"))), true,
182  "Verify that we can actually set the attribute LinkBandwidth");
183  queue->Initialize ();
184  Enqueue (queue, pktSize, 300);
185  st = StaticCast<RedQueueDisc> (queue)->GetStats ();
186  uint32_t test6 = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
187  NS_TEST_EXPECT_MSG_GT (test6, test5, "Test 6 should have more drops than Test 5");
188 
189 
190  // test 7: Verify automatic setting of minTh and maxTh. [minTh = maxTh = 0.0, with default LinkBandwidth]
191  queue = CreateObject<RedQueueDisc> ();
192  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
193  "Verify that we can actually set the attribute Mode");
194  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (0.0)), true,
195  "Verify that we can actually set the attribute MinTh");
196  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (0.0)), true,
197  "Verify that we can actually set the attribute MaxTh");
198  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
199  "Verify that we can actually set the attribute QueueLimit");
200  if (queue->GetMode () == Queue::QUEUE_MODE_BYTES)
201  {
202  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MeanPktSize", UintegerValue (modeSize)), true,
203  "Verify that we can actually set the attribute MeanPktSize");
204  }
205  queue->Initialize ();
206  Enqueue (queue, pktSize, 300);
207  st = StaticCast<RedQueueDisc> (queue)->GetStats ();
208  drops = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
209  NS_TEST_EXPECT_MSG_NE (drops, 0, "There should be some dropped packets");
210  NS_TEST_EXPECT_MSG_GT (st.forcedDrop, st.unforcedDrop, "There should be more packets dropped due to hard mark");
211 
212 
213  // test 8: Verify automatic setting of minTh and maxTh. [minTh = maxTh = 0.0, with higher LinkBandwidth]
214  queue = CreateObject<RedQueueDisc> ();
215  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
216  "Verify that we can actually set the attribute Mode");
217  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (0.0)), true,
218  "Verify that we can actually set the attribute MinTh");
219  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (0.0)), true,
220  "Verify that we can actually set the attribute MaxTh");
221  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
222  "Verify that we can actually set the attribute QueueLimit");
223  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LinkBandwidth", DataRateValue (DataRate ("150Mbps"))), true,
224  "Verify that we can actually set the attribute LinkBandwidth");
225  if (queue->GetMode () == Queue::QUEUE_MODE_BYTES)
226  {
227  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MeanPktSize", UintegerValue (modeSize)), true,
228  "Verify that we can actually set the attribute MeanPktSize");
229  }
230  queue->Initialize ();
231  Enqueue (queue, pktSize, 300);
232  st = StaticCast<RedQueueDisc> (queue)->GetStats ();
233  drops = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
234  NS_TEST_EXPECT_MSG_EQ (drops, 0, "There should be zero dropped packets");
235 }
236 
237 void
238 AutoRedQueueDiscTestCase::Enqueue (Ptr<RedQueueDisc> queue, uint32_t size, uint32_t nPkt)
239 {
240  Ipv4Header ipHeader;
241  Address dest;
242  for (uint32_t i = 0; i < nPkt; i++)
243  {
244  queue->Enqueue (Create<Ipv4QueueDiscItem> (Create<Packet> (size), dest, 0, ipHeader));
245  }
246 }
247 
248 void
250 {
251  RunAutoRedDiscTest (StringValue ("QUEUE_MODE_PACKETS"));
252  RunAutoRedDiscTest (StringValue ("QUEUE_MODE_BYTES"));
253  Simulator::Destroy ();
254 }
255 
256 
257 // Tests to verify the working of *adaptive* parameter in ARED
259 {
260 public:
262  virtual void DoRun (void);
263 private:
265 };
266 
268  : TestCase ("Sanity check on adaptive parameter of ARED")
269 {
270 }
271 
272 void
274 {
275  uint32_t pktSize = 1000;
276  uint32_t modeSize = 1; // 1 for packets; pktSize for bytes
277  std::string aredLinkDataRate = "1.5Mbps";
278  std::string aredLinkDelay = "20ms";
279 
280  double global_start_time = 0.0;
281  double global_stop_time = 7.0;
283  double sink_stop_time = global_stop_time + 3.0;
284  double client_start_time = global_start_time + 1.5;
285  double client_stop_time = global_stop_time - 2.0;
286 
292 
298 
299  NodeContainer c;
300  c.Create (6);
301  n0n2 = NodeContainer (c.Get (0), c.Get (2));
302  n1n2 = NodeContainer (c.Get (1), c.Get (2));
303  n2n3 = NodeContainer (c.Get (2), c.Get (3));
304  n3n4 = NodeContainer (c.Get (3), c.Get (4));
305  n3n5 = NodeContainer (c.Get (3), c.Get (5));
306 
307  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue ("ns3::TcpNewReno"));
308  // 42 = headers size
309  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000 - 42));
310  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
311  GlobalValue::Bind ("ChecksumEnabled", BooleanValue (false));
312 
313  uint32_t meanPktSize = 1000;
314 
315  Ptr<RedQueueDisc> queue = CreateObject<RedQueueDisc> ();
316 
317  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
318  "Verify that we can actually set the attribute Mode");
319 
320  Ipv4Header ipHeader;
321 
322  if (queue->GetMode () == Queue::QUEUE_MODE_BYTES)
323  {
324  modeSize = pktSize + ipHeader.GetSerializedSize ();
325  }
326 
327  uint32_t qSize = 25 * modeSize;
328 
329  Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true));
330  Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10.0));
331  Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (qSize));
332  Config::SetDefault ("ns3::RedQueueDisc::MeanPktSize", UintegerValue (meanPktSize + ipHeader.GetSerializedSize ()));
333  Config::SetDefault ("ns3::RedQueueDisc::TargetDelay", TimeValue (Seconds (0.2)));
334 
335  InternetStackHelper internet;
336  internet.Install (c);
337 
338  TrafficControlHelper tchPfifo;
339  uint16_t handle = tchPfifo.SetRootQueueDisc ("ns3::PfifoFastQueueDisc");
340  tchPfifo.AddInternalQueues (handle, 3, "ns3::DropTailQueue", "MaxPackets", UintegerValue (1000));
341 
342  TrafficControlHelper tchRed;
343  tchRed.SetRootQueueDisc ("ns3::RedQueueDisc", "LinkBandwidth", StringValue (aredLinkDataRate),
344  "LinkDelay", StringValue (aredLinkDelay));
345 
346  PointToPointHelper p2p;
347 
348  NetDeviceContainer devn0n2;
349  NetDeviceContainer devn1n2;
350  NetDeviceContainer devn2n3;
351  NetDeviceContainer devn3n4;
352  NetDeviceContainer devn3n5;
353 
354  QueueDiscContainer queueDiscs;
355 
356  p2p.SetQueue ("ns3::DropTailQueue");
357  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
358  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
359  devn0n2 = p2p.Install (n0n2);
360  tchPfifo.Install (devn0n2);
361 
362  p2p.SetQueue ("ns3::DropTailQueue");
363  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
364  p2p.SetChannelAttribute ("Delay", StringValue ("3ms"));
365  devn1n2 = p2p.Install (n1n2);
366  tchPfifo.Install (devn1n2);
367 
368  p2p.SetQueue ("ns3::DropTailQueue");
369  p2p.SetDeviceAttribute ("DataRate", StringValue (aredLinkDataRate));
370  p2p.SetChannelAttribute ("Delay", StringValue (aredLinkDelay));
371  devn2n3 = p2p.Install (n2n3);
372  // only backbone link has ARED queue disc
373  queueDiscs = tchRed.Install (devn2n3);
374 
375  p2p.SetQueue ("ns3::DropTailQueue");
376  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
377  p2p.SetChannelAttribute ("Delay", StringValue ("4ms"));
378  devn3n4 = p2p.Install (n3n4);
379  tchPfifo.Install (devn3n4);
380 
381  p2p.SetQueue ("ns3::DropTailQueue");
382  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
383  p2p.SetChannelAttribute ("Delay", StringValue ("5ms"));
384  devn3n5 = p2p.Install (n3n5);
385  tchPfifo.Install (devn3n5);
386 
387  Ipv4AddressHelper ipv4;
388  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
389  i0i2 = ipv4.Assign (devn0n2);
390  ipv4.SetBase ("10.1.2.0", "255.255.255.0");
391  i1i2 = ipv4.Assign (devn1n2);
392  ipv4.SetBase ("10.1.3.0", "255.255.255.0");
393  i2i3 = ipv4.Assign (devn2n3);
394  ipv4.SetBase ("10.1.4.0", "255.255.255.0");
395  i3i4 = ipv4.Assign (devn3n4);
396  ipv4.SetBase ("10.1.5.0", "255.255.255.0");
397  i3i5 = ipv4.Assign (devn3n5);
398 
399  // Set up the routing
400  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
401 
402  // SINK is in the right side
403  uint16_t port = 50000;
404  Address sinkLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
405  PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
406  ApplicationContainer sinkApp = sinkHelper.Install (n3n4.Get (1));
407  sinkApp.Start (Seconds (sink_start_time));
408  sinkApp.Stop (Seconds (sink_stop_time));
409 
410  // Connection one
411  // Clients are in left side
412  /*
413  * Create the OnOff applications to send TCP to the server
414  * onoffhelper is a client that send data to TCP destination
415  */
416  OnOffHelper clientHelper1 ("ns3::TcpSocketFactory", Address ());
417  clientHelper1.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
418  clientHelper1.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
419  clientHelper1.SetAttribute ("PacketSize", UintegerValue (pktSize));
420  clientHelper1.SetAttribute ("DataRate", DataRateValue (DataRate ("100Mbps")));
421 
422  // Connection two
423  OnOffHelper clientHelper2 ("ns3::TcpSocketFactory", Address ());
424  clientHelper2.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
425  clientHelper2.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
426  clientHelper2.SetAttribute ("PacketSize", UintegerValue (pktSize));
427  clientHelper2.SetAttribute ("DataRate", DataRateValue (DataRate ("100Mbps")));
428 
429  ApplicationContainer clientApps1;
430  AddressValue remoteAddress (InetSocketAddress (i3i4.GetAddress (1), port));
431  clientHelper1.SetAttribute ("Remote", remoteAddress);
432  clientApps1.Add (clientHelper1.Install (n0n2.Get (0)));
433  clientApps1.Start (Seconds (client_start_time));
434  clientApps1.Stop (Seconds (client_stop_time));
435 
436  ApplicationContainer clientApps2;
437  clientHelper2.SetAttribute ("Remote", remoteAddress);
438  clientApps2.Add (clientHelper2.Install (n1n2.Get (0)));
439  clientApps2.Start (Seconds (client_start_time));
440  clientApps2.Stop (Seconds (client_stop_time));
441 
442  Simulator::Stop (Seconds (sink_stop_time));
443  Simulator::Run ();
444 
445  RedQueueDisc::Stats st = StaticCast<RedQueueDisc> (queueDiscs.Get (0))->GetStats ();
446 
447  NS_TEST_EXPECT_MSG_LT (st.unforcedDrop, st.forcedDrop, "forcedDrop should be more than unforcedDrop");
448 
449  Simulator::Destroy ();
450 }
451 
452 void
454 {
455  RunAdaptiveRedDiscTest (StringValue ("QUEUE_MODE_PACKETS"));
456  RunAdaptiveRedDiscTest (StringValue ("QUEUE_MODE_BYTES"));
457  Simulator::Destroy ();
458 }
459 
460 static class AredQueueDiscTestSuite : public TestSuite
461 {
462 public:
464  : TestSuite ("adaptive-red-queue-disc", UNIT)
465  {
466  AddTestCase (new AutoRedQueueDiscTestCase (), TestCase::QUICK); // Tests for automatically set parameters of ARED
467  AddTestCase (new AdaptiveRedQueueDiscTestCase (), TestCase::QUICK); // Tests for adaptive parameter of ARED
468  }
holds a vector of ns3::Application pointers.
an Inet address class
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
AttributeValue implementation for Boolean.
Definition: boolean.h:34
QueueDiscContainer Install(NetDeviceContainer c)
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
Definition: queue-disc.cc:451
holds a vector of std::pair of Ptr and interface index.
Hold variables of type string.
Definition: string.h:41
NodeContainer n3n5
NetDeviceContainer Install(NodeContainer c)
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
Ipv4InterfaceContainer i3i5
A suite of tests to run.
Definition: test.h:1333
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 point to point net device must have a queue to pass packets through.
Ipv4InterfaceContainer i1i2
Ipv4InterfaceContainer i3i4
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.
Definition: test.h:278
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.
Definition: object-base.cc:211
AredQueueDiscTestSuite g_aredQueueDiscTestSuite
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
Build a set of PointToPointNetDevice objects.
encapsulates test code
Definition: test.h:1147
This test suite implements a Unit Test.
Definition: test.h:1343
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.
Definition: on-off-helper.h:42
uint16_t port
Definition: dsdv-manet.cc:44
a polymophic address class
Definition: address.h:90
NodeContainer n3n4
Holds a vector of ns3::QueueDisc pointers.
Class for representing data rates.
Definition: data-rate.h:88
Packet header for IPv4.
Definition: ipv4-header.h:33
double client_start_time
Ptr< QueueDisc > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
uint32_t forcedDrop
Forced drops, qavg > max threshold.
double sink_stop_time
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:298
AttributeValue implementation for Time.
Definition: nstime.h:957
virtual void DoRun(void)
Implementation to actually run this TestCase.
Hold an unsigned integer type.
Definition: uinteger.h:44
uint32_t qLimDrop
Drops due to queue limits.
holds a vector of ns3::NetDevice pointers
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 () + ...
Definition: address.cc:147
double sink_start_time
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
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...
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.
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report if not.
Definition: test.h:732
NodeContainer n2n3
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report if not.
Definition: test.h:1083
Ipv4InterfaceContainer i0i2
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
double client_stop_time
double global_start_time
AttributeValue implementation for Address.
Definition: address.h:278
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
void AddInternalQueues(uint16_t handle, uint16_t count, 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())
Helper function used to add the given number of internal queues (of the given type and with the given...
AttributeValue implementation for DataRate.
Definition: data-rate.h:242
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:774
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
Definition: test.h:896
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
virtual void DoRun(void)
Implementation to actually run this TestCase.
NodeContainer n0n2
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
double global_stop_time
virtual uint32_t GetSerializedSize(void) const
Definition: ipv4-header.cc:375
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
NodeContainer n1n2
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
Definition: object.cc:183
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
Ipv4InterfaceContainer i2i3
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
uint32_t unforcedDrop
Early probability drops.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const