A Discrete-Event Network Simulator
API
adaptive-red-tests.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 
66 #include "ns3/core-module.h"
67 #include "ns3/network-module.h"
68 #include "ns3/internet-module.h"
69 #include "ns3/flow-monitor-helper.h"
70 #include "ns3/point-to-point-module.h"
71 #include "ns3/applications-module.h"
72 #include "ns3/traffic-control-module.h"
73 
74 using namespace ns3;
75 
76 NS_LOG_COMPONENT_DEFINE ("AdaptiveRedTests");
77 
78 uint32_t checkTimes;
80 
81 // The times
88 
94 
100 
101 std::stringstream filePlotQueueDisc;
102 std::stringstream filePlotQueueDiscAvg;
103 
104 void
106 {
107  uint32_t qSize = StaticCast<RedQueueDisc> (queue)->GetQueueSize ();
108 
109  avgQueueDiscSize += qSize;
110  checkTimes++;
111 
112  // check queue disc size every 1/100 of a second
114 
115  std::ofstream fPlotQueueDisc (filePlotQueueDisc.str ().c_str (), std::ios::out | std::ios::app);
116  fPlotQueueDisc << Simulator::Now ().GetSeconds () << " " << qSize << std::endl;
117  fPlotQueueDisc.close ();
118 
119  std::ofstream fPlotQueueDiscAvg (filePlotQueueDiscAvg.str ().c_str (), std::ios::out | std::ios::app);
120  fPlotQueueDiscAvg << Simulator::Now ().GetSeconds () << " " << avgQueueDiscSize / checkTimes << std::endl;
121  fPlotQueueDiscAvg.close ();
122 }
123 
124 void
125 BuildAppsTest (uint32_t test)
126 {
127  // SINK is in the right side
128  uint16_t port = 50000;
129  Address sinkLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
130  PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
131  ApplicationContainer sinkApp = sinkHelper.Install (n3n4.Get (1));
132  sinkApp.Start (Seconds (sink_start_time));
133  sinkApp.Stop (Seconds (sink_stop_time));
134 
135  // Connection one
136  // Clients are in left side
137  /*
138  * Create the OnOff applications to send TCP to the server
139  * onoffhelper is a client that send data to TCP destination
140  */
141  OnOffHelper clientHelper1 ("ns3::TcpSocketFactory", Address ());
142  clientHelper1.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
143  clientHelper1.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
144  clientHelper1.SetAttribute ("PacketSize", UintegerValue (1000));
145 
146  // Connection two
147  OnOffHelper clientHelper2 ("ns3::TcpSocketFactory", Address ());
148  clientHelper2.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
149  clientHelper2.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
150  clientHelper2.SetAttribute ("PacketSize", UintegerValue (1000));
151 
152  if (test == 6 || test == 7 || test == 8 || test == 9 || test == 10 || test == 12)
153  {
154  clientHelper1.SetAttribute ("DataRate", DataRateValue (DataRate ("100Mb/s")));
155  clientHelper2.SetAttribute ("DataRate", DataRateValue (DataRate ("100Mb/s")));
156  }
157  else
158  {
159  clientHelper1.SetAttribute ("DataRate", DataRateValue (DataRate ("10Mb/s")));
160  clientHelper2.SetAttribute ("DataRate", DataRateValue (DataRate ("10Mb/s")));
161  }
162 
163  ApplicationContainer clientApps1;
164  AddressValue remoteAddress (InetSocketAddress (i3i4.GetAddress (1), port));
165  clientHelper1.SetAttribute ("Remote", remoteAddress);
166  clientApps1.Add (clientHelper1.Install (n0n2.Get (0)));
167  clientApps1.Start (Seconds (client_start_time));
168  clientApps1.Stop (Seconds (client_stop_time));
169 
170  ApplicationContainer clientApps2;
171  clientHelper2.SetAttribute ("Remote", remoteAddress);
172  clientApps2.Add (clientHelper2.Install (n1n2.Get (0)));
173  clientApps2.Start (Seconds (client_start_time));
174  clientApps2.Stop (Seconds (client_stop_time));
175 }
176 
177 int
178 main (int argc, char *argv[])
179 {
180  LogComponentEnable ("RedQueueDisc", LOG_LEVEL_INFO);
181 
182  uint32_t aredTest;
183  std::string aredLinkDataRate = "1.5Mbps";
184  std::string aredLinkDelay = "20ms";
185 
186  std::string pathOut;
187  bool writeForPlot = false;
188  bool writePcap = false;
189  bool flowMonitor = false;
190 
191  bool printAredStats = true;
192 
193  global_start_time = 0.0;
196  global_stop_time = 7.0;
199 
200  // Configuration and command line parameter parsing
201  aredTest = 1;
202  // Will only save in the directory if enable opts below
203  pathOut = "."; // Current directory
205  cmd.AddValue ("testNumber", "Run test 1, 2, 6, 7, 8, 9, 10, 12, 13, 14 or 15", aredTest);
206  cmd.AddValue ("pathOut", "Path to save results from --writeForPlot/--writePcap/--writeFlowMonitor", pathOut);
207  cmd.AddValue ("writeForPlot", "<0/1> to write results for plot (gnuplot)", writeForPlot);
208  cmd.AddValue ("writePcap", "<0/1> to write results in pcapfile", writePcap);
209  cmd.AddValue ("writeFlowMonitor", "<0/1> to enable Flow Monitor and write their results", flowMonitor);
210 
211  cmd.Parse (argc, argv);
212  if ( (aredTest != 1) && (aredTest != 2) && (aredTest != 6) && (aredTest != 7) && (aredTest != 8) && (aredTest != 9) && (aredTest != 10) && (aredTest != 12) && (aredTest != 13) && (aredTest != 14) && (aredTest != 15) )
213  {
214  std::cout << "Invalid test number. Supported tests are 1, 2, 6, 7, 8, 9, 10, 12, 13, 14 or 15" << std::endl;
215  exit (1);
216  }
217 
218  NS_LOG_INFO ("Create nodes");
219  NodeContainer c;
220  c.Create (6);
221  Names::Add ( "N0", c.Get (0));
222  Names::Add ( "N1", c.Get (1));
223  Names::Add ( "N2", c.Get (2));
224  Names::Add ( "N3", c.Get (3));
225  Names::Add ( "N4", c.Get (4));
226  Names::Add ( "N5", c.Get (5));
227  n0n2 = NodeContainer (c.Get (0), c.Get (2));
228  n1n2 = NodeContainer (c.Get (1), c.Get (2));
229  n2n3 = NodeContainer (c.Get (2), c.Get (3));
230  n3n4 = NodeContainer (c.Get (3), c.Get (4));
231  n3n5 = NodeContainer (c.Get (3), c.Get (5));
232 
233  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue ("ns3::TcpNewReno"));
234  // 42 = headers size
235  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000 - 42));
236  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
237  GlobalValue::Bind ("ChecksumEnabled", BooleanValue (false));
238 
239  uint32_t meanPktSize = 1000;
240 
241  // RED params
242  NS_LOG_INFO ("Set RED params");
243  Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_MODE_PACKETS"));
244  Config::SetDefault ("ns3::RedQueueDisc::MeanPktSize", UintegerValue (meanPktSize));
245  Config::SetDefault ("ns3::RedQueueDisc::Wait", BooleanValue (true));
246  Config::SetDefault ("ns3::RedQueueDisc::Gentle", BooleanValue (true));
247  Config::SetDefault ("ns3::RedQueueDisc::QW", DoubleValue (0.002));
248  Config::SetDefault ("ns3::RedQueueDisc::MinTh", DoubleValue (5));
249  Config::SetDefault ("ns3::RedQueueDisc::MaxTh", DoubleValue (15));
250  Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (1000));
251 
252  if (aredTest == 1) // test 1: red1
253  {
254  Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (25));
255  }
256  else if (aredTest == 2) // test 2: red1Adapt
257  {
258  Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true));
259  Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10));
260  Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (25));
261  }
262  else if (aredTest == 7) // test 7: fastlinkAutowq
263  {
264  Config::SetDefault ("ns3::RedQueueDisc::QW", DoubleValue (0.0));
265  }
266  else if (aredTest == 8) // test 8: fastlinkAutothresh
267  {
268  Config::SetDefault ("ns3::RedQueueDisc::MinTh", DoubleValue (0));
269  Config::SetDefault ("ns3::RedQueueDisc::MaxTh", DoubleValue (0));
270  }
271  else if (aredTest == 9) // test 9: fastlinkAdaptive
272  {
273  Config::SetDefault ("ns3::RedQueueDisc::AdaptMaxP", BooleanValue (true));
274  Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10));
275  }
276  else if (aredTest == 10) // test 10: fastlinkAllAdapt
277  {
278  Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true));
279  Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10));
280  }
281  else if (aredTest == 12) // test 12: fastlinkAllAdapt1
282  {
283  Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true));
284  Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10));
285  Config::SetDefault ("ns3::RedQueueDisc::TargetDelay", TimeValue (Seconds (0.2)));
286  }
287  else if (aredTest == 13) // test 13: longlink
288  {
289  Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (100));
290  }
291  else if (aredTest == 14) // test 14: longlinkAdapt
292  {
293  Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true));
294  Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10));
295  Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (100));
296  }
297  else if (aredTest == 15) // test 15: longlinkAdapt1
298  {
299  Config::SetDefault ("ns3::RedQueueDisc::QW", DoubleValue (-1.0));
300  Config::SetDefault ("ns3::RedQueueDisc::MinTh", DoubleValue (0));
301  Config::SetDefault ("ns3::RedQueueDisc::MaxTh", DoubleValue (0));
302  Config::SetDefault ("ns3::RedQueueDisc::AdaptMaxP", BooleanValue (true));
303  Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10));
304  Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (100));
305  }
306 
307  NS_LOG_INFO ("Install internet stack on all nodes.");
308  InternetStackHelper internet;
309  internet.Install (c);
310 
311  TrafficControlHelper tchPfifo;
312  uint16_t handle = tchPfifo.SetRootQueueDisc ("ns3::PfifoFastQueueDisc");
313  tchPfifo.AddInternalQueues (handle, 3, "ns3::DropTailQueue", "MaxPackets", UintegerValue (1000));
314  tchPfifo.AddPacketFilter (handle, "ns3::PfifoFastIpv4PacketFilter");
315 
316  TrafficControlHelper tchRed;
317  tchRed.SetRootQueueDisc ("ns3::RedQueueDisc", "LinkBandwidth", StringValue (aredLinkDataRate),
318  "LinkDelay", StringValue (aredLinkDelay));
319 
320  NS_LOG_INFO ("Create channels");
321  PointToPointHelper p2p;
322 
323  NetDeviceContainer devn0n2;
324  NetDeviceContainer devn1n2;
325  NetDeviceContainer devn2n3;
326  NetDeviceContainer devn3n4;
327  NetDeviceContainer devn3n5;
328 
329  QueueDiscContainer queueDiscs;
330 
331  if (aredTest == 1 || aredTest == 2)
332  {
333  p2p.SetQueue ("ns3::DropTailQueue");
334  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
335  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
336  devn0n2 = p2p.Install (n0n2);
337  tchPfifo.Install (devn0n2);
338 
339  p2p.SetQueue ("ns3::DropTailQueue");
340  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
341  p2p.SetChannelAttribute ("Delay", StringValue ("3ms"));
342  devn1n2 = p2p.Install (n1n2);
343  tchPfifo.Install (devn1n2);
344 
345  p2p.SetQueue ("ns3::DropTailQueue");
346  p2p.SetDeviceAttribute ("DataRate", StringValue (aredLinkDataRate));
347  p2p.SetChannelAttribute ("Delay", StringValue (aredLinkDelay));
348  devn2n3 = p2p.Install (n2n3);
349  // only backbone link has ARED queue disc
350  queueDiscs = tchRed.Install (devn2n3);
351 
352  p2p.SetQueue ("ns3::DropTailQueue");
353  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
354  p2p.SetChannelAttribute ("Delay", StringValue ("4ms"));
355  devn3n4 = p2p.Install (n3n4);
356  tchPfifo.Install (devn3n4);
357 
358  p2p.SetQueue ("ns3::DropTailQueue");
359  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
360  p2p.SetChannelAttribute ("Delay", StringValue ("5ms"));
361  devn3n5 = p2p.Install (n3n5);
362  tchPfifo.Install (devn3n5);
363  }
364  else if (aredTest == 13 || aredTest == 14 || aredTest == 15)
365  {
366  p2p.SetQueue ("ns3::DropTailQueue");
367  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
368  p2p.SetChannelAttribute ("Delay", StringValue ("0ms"));
369  devn0n2 = p2p.Install (n0n2);
370  tchPfifo.Install (devn0n2);
371 
372  p2p.SetQueue ("ns3::DropTailQueue");
373  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
374  p2p.SetChannelAttribute ("Delay", StringValue ("1ms"));
375  devn1n2 = p2p.Install (n1n2);
376  tchPfifo.Install (devn1n2);
377 
378  p2p.SetQueue ("ns3::DropTailQueue");
379  p2p.SetDeviceAttribute ("DataRate", StringValue (aredLinkDataRate));
380  p2p.SetChannelAttribute ("Delay", StringValue ("100ms"));
381  devn2n3 = p2p.Install (n2n3);
382  // only backbone link has ARED queue disc
383  queueDiscs = tchRed.Install (devn2n3);
384 
385  p2p.SetQueue ("ns3::DropTailQueue");
386  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
387  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
388  devn3n4 = p2p.Install (n3n4);
389  tchPfifo.Install (devn3n4);
390 
391  p2p.SetQueue ("ns3::DropTailQueue");
392  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
393  p2p.SetChannelAttribute ("Delay", StringValue ("3ms"));
394  devn3n5 = p2p.Install (n3n5);
395  tchPfifo.Install (devn3n5);
396  }
397  else if (aredTest == 6 || aredTest == 7 || aredTest == 8 || aredTest == 9 || aredTest == 10 || aredTest == 12)
398  {
399  p2p.SetQueue ("ns3::DropTailQueue");
400  p2p.SetDeviceAttribute ("DataRate", StringValue ("100Mbps"));
401  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
402  devn0n2 = p2p.Install (n0n2);
403  tchPfifo.Install (devn0n2);
404 
405  p2p.SetQueue ("ns3::DropTailQueue");
406  p2p.SetDeviceAttribute ("DataRate", StringValue ("100Mbps"));
407  p2p.SetChannelAttribute ("Delay", StringValue ("3ms"));
408  devn1n2 = p2p.Install (n1n2);
409  tchPfifo.Install (devn1n2);
410 
411  p2p.SetQueue ("ns3::DropTailQueue");
412  p2p.SetDeviceAttribute ("DataRate", StringValue ("15Mbps"));
413  p2p.SetChannelAttribute ("Delay", StringValue (aredLinkDelay));
414  devn2n3 = p2p.Install (n2n3);
415  // only backbone link has ARED queue disc
416  queueDiscs = tchRed.Install (devn2n3);
417 
418  p2p.SetQueue ("ns3::DropTailQueue");
419  p2p.SetDeviceAttribute ("DataRate", StringValue ("100Mbps"));
420  p2p.SetChannelAttribute ("Delay", StringValue ("4ms"));
421  devn3n4 = p2p.Install (n3n4);
422  tchPfifo.Install (devn3n4);
423 
424  p2p.SetQueue ("ns3::DropTailQueue");
425  p2p.SetDeviceAttribute ("DataRate", StringValue ("100Mbps"));
426  p2p.SetChannelAttribute ("Delay", StringValue ("5ms"));
427  devn3n5 = p2p.Install (n3n5);
428  tchPfifo.Install (devn3n5);
429  }
430 
431  NS_LOG_INFO ("Assign IP Addresses");
432  Ipv4AddressHelper ipv4;
433 
434  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
435  i0i2 = ipv4.Assign (devn0n2);
436 
437  ipv4.SetBase ("10.1.2.0", "255.255.255.0");
438  i1i2 = ipv4.Assign (devn1n2);
439 
440  ipv4.SetBase ("10.1.3.0", "255.255.255.0");
441  i2i3 = ipv4.Assign (devn2n3);
442 
443  ipv4.SetBase ("10.1.4.0", "255.255.255.0");
444  i3i4 = ipv4.Assign (devn3n4);
445 
446  ipv4.SetBase ("10.1.5.0", "255.255.255.0");
447  i3i5 = ipv4.Assign (devn3n5);
448 
449  // Set up the routing
451 
452  BuildAppsTest (aredTest);
453 
454  if (writePcap)
455  {
456  PointToPointHelper ptp;
457  std::stringstream stmp;
458  stmp << pathOut << "/ared";
459  ptp.EnablePcapAll (stmp.str ().c_str ());
460  }
461 
462  Ptr<FlowMonitor> flowmon;
463  if (flowMonitor)
464  {
465  FlowMonitorHelper flowmonHelper;
466  flowmon = flowmonHelper.InstallAll ();
467  }
468 
469  if (writeForPlot)
470  {
471  filePlotQueueDisc << pathOut << "/" << "ared-queue-disc.plotme";
472  filePlotQueueDiscAvg << pathOut << "/" << "ared-queue-disc_avg.plotme";
473 
474  remove (filePlotQueueDisc.str ().c_str ());
475  remove (filePlotQueueDiscAvg.str ().c_str ());
476  Ptr<QueueDisc> queue = queueDiscs.Get (0);
478  }
479 
481  Simulator::Run ();
482 
483  RedQueueDisc::Stats st = StaticCast<RedQueueDisc> (queueDiscs.Get (0))->GetStats ();
484 
485  if (aredTest == 1)
486  {
487  if (st.unforcedDrop > 2)
488  {
489  std::cout << "Drops due to prob mark should be around 1" << std::endl;
490  exit (-1);
491  }
492  else if (st.forcedDrop < 137 || st.forcedDrop > 139)
493  {
494  std::cout << "Drops due to hard mark not in expected range, should be around 138" << std::endl;
495  exit (-1);
496  }
497  else if (st.qLimDrop < 137 || st.qLimDrop > 139)
498  {
499  std::cout << "Drops due to queue full not in expected range, should be around 138" << std::endl;
500  exit (-1);
501  }
502  }
503  else if (aredTest == 2)
504  {
505  if (st.unforcedDrop < 6 || st.unforcedDrop > 17)
506  {
507  std::cout << "Drops due to prob mark not in expected range, should be around 14" << std::endl;
508  exit (-1);
509  }
510  else if (st.forcedDrop < 122 || st.forcedDrop > 133)
511  {
512  std::cout << "Drops due to hard mark not in expected range, should be around 126" << std::endl;
513  exit (-1);
514  }
515  else if (st.qLimDrop < 122 || st.qLimDrop > 133)
516  {
517  std::cout << "Drops due to queue full not in expected range, should be around 126" << std::endl;
518  exit (-1);
519  }
520  }
521  else if (aredTest == 6)
522  {
523  if (st.unforcedDrop < 32 || st.unforcedDrop > 56)
524  {
525  std::cout << "Drops due to prob mark not in expected range, should be around 48" << std::endl;
526  exit (-1);
527  }
528  else if (st.forcedDrop < 185 || st.forcedDrop > 202)
529  {
530  std::cout << "Drops due to hard mark not in expected range, should be around 201" << std::endl;
531  exit (-1);
532  }
533  else if (st.qLimDrop != 0)
534  {
535  std::cout << "There should be no drops due to queue full" << std::endl;
536  exit (-1);
537  }
538  }
539  else if (aredTest == 7)
540  {
541  if (st.unforcedDrop < 76 || st.unforcedDrop > 119)
542  {
543  std::cout << "Number of drops due to prob mark is not in expected range, should be around 110" << std::endl;
544  exit (-1);
545  }
546  else if (st.forcedDrop < 133 || st.forcedDrop > 138)
547  {
548  std::cout << "Number of drops due to hard mark is not in expected range, should be around 137" << std::endl;
549  exit (-1);
550  }
551  else if (st.qLimDrop != 0)
552  {
553  std::cout << "There should be no drops due to queue full" << std::endl;
554  exit (-1);
555  }
556  }
557  else if (aredTest == 8)
558  {
559  if (st.unforcedDrop < 32 || st.unforcedDrop > 56)
560  {
561  std::cout << "Number of drops due to prob mark is not in expected range, should be around 48" << std::endl;
562  exit (-1);
563  }
564  else if (st.forcedDrop < 185 || st.forcedDrop > 202)
565  {
566  std::cout << "Drops due to hard mark not in expected range, should be around 201" << std::endl;
567  exit (-1);
568  }
569  else if (st.qLimDrop != 0)
570  {
571  std::cout << "There should be no drops due to queue full" << std::endl;
572  exit (-1);
573  }
574  }
575  else if (aredTest == 9)
576  {
577  if (st.unforcedDrop < 38 || st.unforcedDrop > 69)
578  {
579  std::cout << "Number of drops due to prob mark is not in expected range, should be around 61" << std::endl;
580  exit (-1);
581  }
582  else if (st.forcedDrop < 178 || st.forcedDrop > 191)
583  {
584  std::cout << "Number of drops due to hard mark is not in expected range, should be around 187" << std::endl;
585  exit (-1);
586  }
587  else if (st.qLimDrop != 0)
588  {
589  std::cout << "There should be no drops due to queue full" << std::endl;
590  exit (-1);
591  }
592  }
593  else if (aredTest == 10)
594  {
595  if (st.unforcedDrop < 82 || st.unforcedDrop > 185)
596  {
597  std::cout << "Number of drops due to prob mark is not in expected range, should be around 89" << std::endl;
598  exit (-1);
599  }
600  else if (st.forcedDrop < 129 || st.forcedDrop > 133)
601  {
602  std::cout << "Number of drops due to hard mark is not in expected range, should be around 129" << std::endl;
603  exit (-1);
604  }
605  else if (st.qLimDrop != 0)
606  {
607  std::cout << "There should be no drops due to queue full" << std::endl;
608  exit (-1);
609  }
610  }
611  else if (aredTest == 12)
612  {
613  if (st.unforcedDrop < 162 || st.unforcedDrop > 204)
614  {
615  std::cout << "Number of drops due to prob mark is not in expected range, should be around 181" << std::endl;
616  exit (-1);
617  }
618  else if (st.forcedDrop > 43)
619  {
620  std::cout << "Number of drops due to hard mark is not in expected range, should be around 12" << std::endl;
621  exit (-1);
622  }
623  else if (st.qLimDrop != 0)
624  {
625  std::cout << "There should be no drops due to queue full" << std::endl;
626  exit (-1);
627  }
628  }
629  else if (aredTest == 13)
630  {
631  if (st.unforcedDrop < 30 || st.unforcedDrop > 49)
632  {
633  std::cout << "Number of drops due to prob mark is not in expected range, should be around 36" << std::endl;
634  exit (-1);
635  }
636  else if (st.forcedDrop < 240 || st.forcedDrop > 259)
637  {
638  std::cout << "Number of drops due to hard mark is not in expected range, should be around 253" << std::endl;
639  exit (-1);
640  }
641  else if (st.qLimDrop < 12 || st.qLimDrop > 31)
642  {
643  std::cout << "Number of drops due to queue full is not in expected range, should be around 25" << std::endl;
644  exit (-1);
645  }
646  }
647  else if (aredTest == 14)
648  {
649  if (st.unforcedDrop < 83 || st.unforcedDrop > 90)
650  {
651  std::cout << "Number of drops due to prob mark is not in expected range, should be around 88" << std::endl;
652  exit (-1);
653  }
654  else if (st.forcedDrop < 127 || st.forcedDrop > 132)
655  {
656  std::cout << "Number of drops due to hard mark is not in expected range, should be around 129" << std::endl;
657  exit (-1);
658  }
659  else if (st.qLimDrop != 0)
660  {
661  std::cout << "There should be no drops due to queue full" << std::endl;
662  exit (-1);
663  }
664  }
665  else if (aredTest == 15)
666  {
667  if (st.unforcedDrop < 83 || st.unforcedDrop > 90)
668  {
669  std::cout << "Number of drops due to prob mark is not in expected range, should be around 88" << std::endl;
670  exit (-1);
671  }
672  else if (st.forcedDrop < 127 || st.forcedDrop > 132)
673  {
674  std::cout << "Number of drops due to hard mark is not in expected range, should be around 129" << std::endl;
675  exit (-1);
676  }
677  else if (st.qLimDrop != 0)
678  {
679  std::cout << "There should be no drops due to queue full" << std::endl;
680  exit (-1);
681  }
682  }
683 
684  if (flowMonitor)
685  {
686  std::stringstream stmp;
687  stmp << pathOut << "/ared.flowmon";
688 
689  flowmon->SerializeToXmlFile (stmp.str ().c_str (), false, false);
690  }
691 
692  if (printAredStats)
693  {
694  std::cout << "*** ARED stats from Node 2 queue ***" << std::endl;
695  std::cout << "\t " << st.unforcedDrop << " drops due to prob mark" << std::endl;
696  std::cout << "\t " << st.forcedDrop << " drops due to hard mark" << std::endl;
697  std::cout << "\t " << st.qLimDrop << " drops due to queue full" << std::endl;
698  }
699 
701 
702  return 0;
703 }
holds a vector of ns3::Application pointers.
an Inet address class
static Ipv4Address GetAny(void)
AttributeValue implementation for Boolean.
Definition: boolean.h:34
QueueDiscContainer Install(NetDeviceContainer c)
holds a vector of std::pair of Ptr and interface index.
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
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
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
static void Run(void)
Run the simulation.
Definition: simulator.cc:200
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
double avgQueueDiscSize
aggregate IP/TCP/UDP functionality to existing Nodes.
LOG_INFO and above.
Definition: log.h:103
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
Build a set of PointToPointNetDevice objects.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void AddPacketFilter(uint16_t handle, 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 a packet filter (of the given type and with the given attributes) to the ...
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:42
tuple cmd
Definition: second.py:35
std::stringstream filePlotQueueDiscAvg
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.
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr obj.
Definition: names.cc:694
Class for representing data rates.
Definition: data-rate.h:88
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:341
double client_start_time
Ptr< QueueDisc > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:351
uint32_t forcedDrop
Forced drops, qavg > max threshold.
double sink_stop_time
void EnablePcapAll(std::string prefix, bool promiscuous=false)
Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created ...
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1216
void BuildAppsTest(uint32_t test)
AttributeValue implementation for Time.
Definition: nstime.h:957
Hold an unsigned integer type.
Definition: uinteger.h:44
uint32_t qLimDrop
Drops due to queue limits.
holds a vector of ns3::NetDevice pointers
uint32_t checkTimes
Build a set of QueueDisc objects.
static void Bind(std::string name, const AttributeValue &value)
Iterate over the set of GlobalValues until a matching name is found and then set its value with Globa...
Ptr< FlowMonitor > InstallAll()
Enable flow monitoring on all nodes.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Parse command-line arguments.
Definition: command-line.h:201
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:164
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...
NodeContainer n2n3
Helper to enable IP flow monitoring on a set of Nodes.
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:1379
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
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:241
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
Definition: command-line.h:491
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:208
void SerializeToXmlFile(std::string fileName, bool enableHistograms, bool enableProbes)
Same as SerializeToXmlStream, but writes to a file instead.
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
std::stringstream filePlotQueueDisc
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
void Parse(int argc, char *argv[])
Parse the program arguments.
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.
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
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
void CheckQueueDiscSize(Ptr< QueueDisc > queue)
void test(void)
Example use of ns3::SystemThread.
NodeContainer n1n2
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