LEFT | RIGHT |
| 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 /** |
1 * NOTE: These validation tests are same as provided in ns-2· | 23 * NOTE: These validation tests are same as provided in ns-2· |
2 * (ns/tcl/test/test-suite-adaptive-red.tcl) | 24 * (ns/tcl/test/test-suite-adaptive-red.tcl) |
3 * | 25 * |
4 * In this code, tests 1, 2, 6, 7, 8, 9, 10, 12, 13, 14 and 15 refer to tests | 26 * In this code, tests 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14 and 15 refer t
o tests |
5 * named red1, red1Adapt, fastlink, fastlinkAutowq, fastlinkAutothresh, | 27 * named red1, red1Adapt, red1ECN, fastlink, fastlinkECN, fastlinkAutowq, fastli
nkAutothresh, |
6 * fastlinkAdaptive, fastlinkAllAdapt, fastlinkAllAdapt1, longlink, | 28 * fastlinkAdaptive, fastlinkAllAdapt, fastlinkAllAdaptECN, fastlinkAllAdapt1, l
onglink, |
7 * longlinkAdapt and longlinkAdapt1, respectively in the ns-2 file | 29 * longlinkAdapt and longlinkAdapt1, respectively in the ns-2 file |
8 * mentioned above. | 30 * mentioned above. |
9 */ | 31 */ |
10 | 32 |
11 /** Network topology for tests: 1 and 2 | 33 /** Network topology for tests: 1, 2, 3 and 4 |
12 * | 34 * |
13 * 10Mb/s, 2ms 10Mb/s, 4ms | 35 * 10Mb/s, 2ms 10Mb/s, 4ms |
14 * n0--------------| |---------------n4 | 36 * n0--------------| |---------------n4 |
| 37 * | 1.5Mbps, 20ms | |
| 38 * n2------------------n3 |
| 39 * 10Mb/s, 3ms | QueueLimit = 25 | 10Mb/s, 5ms |
| 40 * n1--------------| |---------------n5 |
| 41 * |
| 42 */ |
| 43 |
| 44 /** Network topology for tests: 6, 7, 8, 9, 10, 11 and 12 |
| 45 * |
| 46 * 100Mb/s, 2ms 100Mb/s, 4ms |
| 47 * n0--------------| |---------------n4 |
| 48 * | 15Mbps, 20ms | |
| 49 * n2------------------n3 |
| 50 * 100Mb/s, 3ms | QueueLimit = 1000 | 100Mb/s, 5ms |
| 51 * n1--------------| |---------------n5 |
| 52 * |
| 53 */ |
| 54 |
| 55 /** Network topology for tests: 13, 14 and 15 |
| 56 * |
| 57 * 10Mb/s, 0ms 10Mb/s, 2ms |
| 58 * n0--------------| |---------------n4 |
| 59 * | 1.5Mbps, 100ms | |
| 60 * n2------------------n3 |
| 61 * 10Mb/s, 1ms | QueueLimit = 100 | 10Mb/s, 3ms |
| 62 * n1--------------| |---------------n5 |
| 63 * |
| 64 */ |
| 65 |
| 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; |
| 79 double avgQueueDiscSize; |
| 80 |
| 81 // The times |
| 82 double global_start_time; |
| 83 double global_stop_time; |
| 84 double sink_start_time; |
| 85 double sink_stop_time; |
| 86 double client_start_time; |
| 87 double client_stop_time; |
| 88 |
| 89 NodeContainer n0n2; |
| 90 NodeContainer n1n2; |
| 91 NodeContainer n2n3; |
| 92 NodeContainer n3n4; |
| 93 NodeContainer n3n5; |
| 94 |
| 95 Ipv4InterfaceContainer i0i2; |
| 96 Ipv4InterfaceContainer i1i2; |
| 97 Ipv4InterfaceContainer i2i3; |
| 98 Ipv4InterfaceContainer i3i4; |
| 99 Ipv4InterfaceContainer i3i5; |
| 100 |
| 101 std::stringstream filePlotQueueDisc; |
| 102 std::stringstream filePlotQueueDiscAvg; |
| 103 |
| 104 void |
| 105 CheckQueueDiscSize (Ptr<QueueDisc> queue) |
| 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 |
| 113 Simulator::Schedule (Seconds (0.01), &CheckQueueDiscSize, queue); |
| 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::io
s::out | std::ios::app); |
| 120 fPlotQueueDiscAvg << Simulator::Now ().GetSeconds () << " " << avgQueueDiscSiz
e / 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::ConstantRandomVariabl
e[Constant=1]")); |
| 143 clientHelper1.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariab
le[Constant=0]")); |
| 144 clientHelper1.SetAttribute ("PacketSize", UintegerValue (1000)); |
| 145 |
| 146 // Connection two |
| 147 OnOffHelper clientHelper2 ("ns3::TcpSocketFactory", Address ()); |
| 148 clientHelper2.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariabl
e[Constant=1]")); |
| 149 clientHelper2.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariab
le[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; |
| 194 sink_start_time = global_start_time; |
| 195 client_start_time = global_start_time + 1.5; |
| 196 global_stop_time = 7.0; |
| 197 sink_stop_time = global_stop_time + 3.0; |
| 198 client_stop_time = global_stop_time - 2.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 |
| 204 CommandLine cmd; |
| 205 cmd.AddValue ("testNumber", "Run test 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 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)", wri
teForPlot); |
| 208 cmd.AddValue ("writePcap", "<0/1> to write results in pcapfile", writePcap); |
| 209 cmd.AddValue ("writeFlowMonitor", "<0/1> to enable Flow Monitor and write thei
r results", flowMonitor); |
| 210 |
| 211 cmd.Parse (argc, argv); |
| 212 if ((aredTest < 1) || (aredTest == 5) || (aredTest > 15)) |
| 213 { |
| 214 std::cout << "Invalid test number. Supported tests are 1, 2, 3, 4, 6, 7, 8
, 9, 10, 11, 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::TcpNe
wReno")); |
| 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_DISC_MODE_P
ACKETS")); |
| 244 Config::SetDefault ("ns3::RedQueueDisc::MeanPktSize", UintegerValue (meanPktSi
ze)); |
| 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 == 3) //test 3: red1ECN |
| 263 { |
| 264 Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (25)); |
| 265 Config::SetDefault ("ns3::TcpSocketBase::UseEcn", BooleanValue (true)); |
| 266 Config::SetDefault ("ns3::RedQueueDisc::UseEcn", BooleanValue (true)); |
| 267 }· |
| 268 else if (aredTest == 4) // test 4: red1AdaptECN |
| 269 { |
| 270 Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true)); |
| 271 Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10)); |
| 272 Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (25)); |
| 273 Config::SetDefault ("ns3::TcpSocketBase::UseEcn", BooleanValue (true)); |
| 274 Config::SetDefault ("ns3::RedQueueDisc::UseEcn", BooleanValue (true)); |
| 275 } |
| 276 else if (aredTest == 7) // test 7: fastlinkAutowq |
| 277 { |
| 278 Config::SetDefault ("ns3::RedQueueDisc::QW", DoubleValue (0.0)); |
| 279 } |
| 280 else if (aredTest == 8) // test 8: fastlinkAutothresh |
| 281 { |
| 282 Config::SetDefault ("ns3::RedQueueDisc::MinTh", DoubleValue (0)); |
| 283 Config::SetDefault ("ns3::RedQueueDisc::MaxTh", DoubleValue (0)); |
| 284 } |
| 285 else if (aredTest == 9) // test 9: fastlinkAdaptive |
| 286 { |
| 287 Config::SetDefault ("ns3::RedQueueDisc::AdaptMaxP", BooleanValue (true)); |
| 288 Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10)); |
| 289 } |
| 290 else if (aredTest == 10) // test 10: fastlinkAllAdapt |
| 291 { |
| 292 Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true)); |
| 293 Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10)); |
| 294 } |
| 295 else if (aredTest == 11) // test 11: fastlinkAllAdaptECN······ |
| 296 { |
| 297 Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true)); |
| 298 Config::SetDefault ("ns3::RedQueueDisc::UseHardDrop", BooleanValue (false)
); |
| 299 Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10)); |
| 300 Config::SetDefault ("ns3::TcpSocketBase::UseEcn", BooleanValue (true)); |
| 301 Config::SetDefault ("ns3::RedQueueDisc::UseEcn", BooleanValue (true));············ |
| 302 } |
| 303 else if (aredTest == 12) // test 12: fastlinkAllAdapt1 |
| 304 { |
| 305 Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true)); |
| 306 Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10)); |
| 307 Config::SetDefault ("ns3::RedQueueDisc::TargetDelay", TimeValue (Seconds (
0.2))); |
| 308 } |
| 309 else if (aredTest == 13) // test 13: longlink |
| 310 { |
| 311 Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (100)); |
| 312 } |
| 313 else if (aredTest == 14) // test 14: longlinkAdapt |
| 314 { |
| 315 Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true)); |
| 316 Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10)); |
| 317 Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (100)); |
| 318 } |
| 319 else if (aredTest == 15) // test 15: longlinkAdapt1 |
| 320 { |
| 321 Config::SetDefault ("ns3::RedQueueDisc::QW", DoubleValue (-1.0)); |
| 322 Config::SetDefault ("ns3::RedQueueDisc::MinTh", DoubleValue (0)); |
| 323 Config::SetDefault ("ns3::RedQueueDisc::MaxTh", DoubleValue (0)); |
| 324 Config::SetDefault ("ns3::RedQueueDisc::AdaptMaxP", BooleanValue (true)); |
| 325 Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10)); |
| 326 Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (100)); |
| 327 } |
| 328 |
| 329 NS_LOG_INFO ("Install internet stack on all nodes."); |
| 330 InternetStackHelper internet; |
| 331 internet.Install (c); |
| 332 |
| 333 TrafficControlHelper tchPfifo; |
| 334 uint16_t handle = tchPfifo.SetRootQueueDisc ("ns3::PfifoFastQueueDisc"); |
| 335 tchPfifo.AddInternalQueues (handle, 3, "ns3::DropTailQueue", "MaxPackets", Uin
tegerValue (1000)); |
| 336 |
| 337 TrafficControlHelper tchRed; |
| 338 tchRed.SetRootQueueDisc ("ns3::RedQueueDisc", "LinkBandwidth", StringValue (ar
edLinkDataRate), |
| 339 "LinkDelay", StringValue (aredLinkDelay)); |
| 340 |
| 341 NS_LOG_INFO ("Create channels"); |
| 342 PointToPointHelper p2p; |
| 343 |
| 344 NetDeviceContainer devn0n2; |
| 345 NetDeviceContainer devn1n2; |
| 346 NetDeviceContainer devn2n3; |
| 347 NetDeviceContainer devn3n4; |
| 348 NetDeviceContainer devn3n5; |
| 349 |
| 350 QueueDiscContainer queueDiscs; |
| 351 |
| 352 if (aredTest == 1 || aredTest == 2 || aredTest == 3 || aredTest == 4) |
| 353 { |
| 354 p2p.SetQueue ("ns3::DropTailQueue"); |
| 355 p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); |
| 356 p2p.SetChannelAttribute ("Delay", StringValue ("2ms")); |
| 357 devn0n2 = p2p.Install (n0n2); |
| 358 tchPfifo.Install (devn0n2); |
| 359 |
| 360 p2p.SetQueue ("ns3::DropTailQueue"); |
| 361 p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); |
| 362 p2p.SetChannelAttribute ("Delay", StringValue ("3ms")); |
| 363 devn1n2 = p2p.Install (n1n2); |
| 364 tchPfifo.Install (devn1n2); |
| 365 |
| 366 p2p.SetQueue ("ns3::DropTailQueue"); |
| 367 p2p.SetDeviceAttribute ("DataRate", StringValue (aredLinkDataRate)); |
| 368 p2p.SetChannelAttribute ("Delay", StringValue (aredLinkDelay)); |
| 369 devn2n3 = p2p.Install (n2n3); |
| 370 // only backbone link has ARED queue disc |
| 371 queueDiscs = tchRed.Install (devn2n3); |
| 372 |
| 373 p2p.SetQueue ("ns3::DropTailQueue"); |
| 374 p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); |
| 375 p2p.SetChannelAttribute ("Delay", StringValue ("4ms")); |
| 376 devn3n4 = p2p.Install (n3n4); |
| 377 tchPfifo.Install (devn3n4); |
| 378 |
| 379 p2p.SetQueue ("ns3::DropTailQueue"); |
| 380 p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); |
| 381 p2p.SetChannelAttribute ("Delay", StringValue ("5ms")); |
| 382 devn3n5 = p2p.Install (n3n5); |
| 383 tchPfifo.Install (devn3n5); |
| 384 } |
| 385 else if (aredTest == 13 || aredTest == 14 || aredTest == 15) |
| 386 { |
| 387 p2p.SetQueue ("ns3::DropTailQueue"); |
| 388 p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); |
| 389 p2p.SetChannelAttribute ("Delay", StringValue ("0ms")); |
| 390 devn0n2 = p2p.Install (n0n2); |
| 391 tchPfifo.Install (devn0n2); |
| 392 |
| 393 p2p.SetQueue ("ns3::DropTailQueue"); |
| 394 p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); |
| 395 p2p.SetChannelAttribute ("Delay", StringValue ("1ms")); |
| 396 devn1n2 = p2p.Install (n1n2); |
| 397 tchPfifo.Install (devn1n2); |
| 398 |
| 399 p2p.SetQueue ("ns3::DropTailQueue"); |
| 400 p2p.SetDeviceAttribute ("DataRate", StringValue (aredLinkDataRate)); |
| 401 p2p.SetChannelAttribute ("Delay", StringValue ("100ms")); |
| 402 devn2n3 = p2p.Install (n2n3); |
| 403 // only backbone link has ARED queue disc |
| 404 queueDiscs = tchRed.Install (devn2n3); |
| 405 |
| 406 p2p.SetQueue ("ns3::DropTailQueue"); |
| 407 p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); |
| 408 p2p.SetChannelAttribute ("Delay", StringValue ("2ms")); |
| 409 devn3n4 = p2p.Install (n3n4); |
| 410 tchPfifo.Install (devn3n4); |
| 411 |
| 412 p2p.SetQueue ("ns3::DropTailQueue"); |
| 413 p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); |
| 414 p2p.SetChannelAttribute ("Delay", StringValue ("3ms")); |
| 415 devn3n5 = p2p.Install (n3n5); |
| 416 tchPfifo.Install (devn3n5); |
| 417 } |
| 418 else if (aredTest == 6 || aredTest == 7 || aredTest == 8 || aredTest == 9 || a
redTest == 10 || aredTest ==11 || aredTest == 12) |
| 419 { |
| 420 p2p.SetQueue ("ns3::DropTailQueue"); |
| 421 p2p.SetDeviceAttribute ("DataRate", StringValue ("100Mbps")); |
| 422 p2p.SetChannelAttribute ("Delay", StringValue ("2ms")); |
| 423 devn0n2 = p2p.Install (n0n2); |
| 424 tchPfifo.Install (devn0n2); |
| 425 |
| 426 p2p.SetQueue ("ns3::DropTailQueue"); |
| 427 p2p.SetDeviceAttribute ("DataRate", StringValue ("100Mbps")); |
| 428 p2p.SetChannelAttribute ("Delay", StringValue ("3ms")); |
| 429 devn1n2 = p2p.Install (n1n2); |
| 430 tchPfifo.Install (devn1n2); |
| 431 |
| 432 p2p.SetQueue ("ns3::DropTailQueue"); |
| 433 p2p.SetDeviceAttribute ("DataRate", StringValue ("15Mbps")); |
| 434 p2p.SetChannelAttribute ("Delay", StringValue (aredLinkDelay)); |
| 435 devn2n3 = p2p.Install (n2n3); |
| 436 // only backbone link has ARED queue disc |
| 437 queueDiscs = tchRed.Install (devn2n3); |
| 438 |
| 439 p2p.SetQueue ("ns3::DropTailQueue"); |
| 440 p2p.SetDeviceAttribute ("DataRate", StringValue ("100Mbps")); |
| 441 p2p.SetChannelAttribute ("Delay", StringValue ("4ms")); |
| 442 devn3n4 = p2p.Install (n3n4); |
| 443 tchPfifo.Install (devn3n4); |
| 444 |
| 445 p2p.SetQueue ("ns3::DropTailQueue"); |
| 446 p2p.SetDeviceAttribute ("DataRate", StringValue ("100Mbps")); |
| 447 p2p.SetChannelAttribute ("Delay", StringValue ("5ms")); |
| 448 devn3n5 = p2p.Install (n3n5); |
| 449 tchPfifo.Install (devn3n5); |
| 450 } |
| 451 |
| 452 NS_LOG_INFO ("Assign IP Addresses"); |
| 453 Ipv4AddressHelper ipv4; |
| 454 |
| 455 ipv4.SetBase ("10.1.1.0", "255.255.255.0"); |
| 456 i0i2 = ipv4.Assign (devn0n2); |
| 457 |
| 458 ipv4.SetBase ("10.1.2.0", "255.255.255.0"); |
| 459 i1i2 = ipv4.Assign (devn1n2); |
| 460 |
| 461 ipv4.SetBase ("10.1.3.0", "255.255.255.0"); |
| 462 i2i3 = ipv4.Assign (devn2n3); |
| 463 |
| 464 ipv4.SetBase ("10.1.4.0", "255.255.255.0"); |
| 465 i3i4 = ipv4.Assign (devn3n4); |
| 466 |
| 467 ipv4.SetBase ("10.1.5.0", "255.255.255.0"); |
| 468 i3i5 = ipv4.Assign (devn3n5); |
| 469 |
| 470 // Set up the routing |
| 471 Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
| 472 |
| 473 BuildAppsTest (aredTest); |
| 474 |
| 475 if (writePcap) |
| 476 { |
| 477 PointToPointHelper ptp; |
| 478 std::stringstream stmp; |
| 479 stmp << pathOut << "/ared"; |
| 480 ptp.EnablePcapAll (stmp.str ().c_str ()); |
| 481 } |
| 482 |
| 483 Ptr<FlowMonitor> flowmon; |
| 484 if (flowMonitor) |
| 485 { |
| 486 FlowMonitorHelper flowmonHelper; |
| 487 flowmon = flowmonHelper.InstallAll (); |
| 488 } |
| 489 |
| 490 if (writeForPlot) |
| 491 { |
| 492 filePlotQueueDisc << pathOut << "/" << "ared-queue-disc.plotme"; |
| 493 filePlotQueueDiscAvg << pathOut << "/" << "ared-queue-disc_avg.plotme"; |
| 494 |
| 495 remove (filePlotQueueDisc.str ().c_str ()); |
| 496 remove (filePlotQueueDiscAvg.str ().c_str ()); |
| 497 Ptr<QueueDisc> queue = queueDiscs.Get (0); |
| 498 Simulator::ScheduleNow (&CheckQueueDiscSize, queue); |
| 499 } |
| 500 |
| 501 Simulator::Stop (Seconds (sink_stop_time)); |
| 502 Simulator::Run (); |
| 503 |
| 504 RedQueueDisc::Stats st = StaticCast<RedQueueDisc> (queueDiscs.Get (0))->GetSta
ts (); |
| 505 |
| 506 if (st.unforcedDrop == 0 && st.unforcedMark == 0) |
| 507 { |
| 508 std::cout << "There should be some unforced drops or marks" << std::endl; |
| 509 exit (1); |
| 510 } |
| 511 |
| 512 if (aredTest == 1 || aredTest == 2 || aredTest == 3 || aredTest == 4 || aredTe
st == 13) |
| 513 { |
| 514 if (st.qLimDrop == 0) |
| 515 { |
| 516 std::cout << "There should be some drops due to queue full" << std::en
dl; |
| 517 exit (1); |
| 518 } |
| 519 } |
| 520 else |
| 521 { |
| 522 if (st.qLimDrop != 0) |
| 523 { |
| 524 std::cout << "There should be zero drops due to queue full" << std::en
dl; |
| 525 exit (1); |
| 526 } |
| 527 } |
| 528 |
| 529 if (flowMonitor) |
| 530 { |
| 531 std::stringstream stmp; |
| 532 stmp << pathOut << "/ared.flowmon"; |
| 533 |
| 534 flowmon->SerializeToXmlFile (stmp.str ().c_str (), false, false); |
| 535 } |
| 536 |
| 537 if (printAredStats) |
| 538 { |
| 539 std::cout << "*** ARED stats from Node 2 queue ***" << std::endl; |
| 540 std::cout << "\t " << st.unforcedDrop << " drops due to prob mark" << std:
:endl; |
| 541 std::cout << "\t " << st.unforcedMark << " marks due to prob mark" << std:
:endl; |
| 542 std::cout << "\t " << st.forcedDrop << " drops due to hard mark" << std::e
ndl; |
| 543 std::cout << "\t " << st.forcedMark << " drops due to hard mark" << std::e
ndl; |
| 544 std::cout << "\t " << st.qLimDrop << " drops due to queue full" << std::en
dl; |
| 545 } |
| 546 |
| 547 Simulator::Destroy (); |
| 548 |
| 549 return 0; |
| 550 } |
LEFT | RIGHT |