OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * This program is free software; you can redistribute it and/or modify |
| 4 * it under the terms of the GNU General Public License version 2 as |
| 5 * published by the Free Software Foundation; |
| 6 * |
| 7 * This program is distributed in the hope that it will be useful, |
| 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 * GNU General Public License for more details. |
| 11 * |
| 12 * You should have received a copy of the GNU General Public License |
| 13 * along with this program; if not, write to the Free Software |
| 14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 15 * |
| 16 * Authors: Marcos Talau <talau@users.sourceforge.net> |
| 17 * Duy Nguyen <duy@soe.ucsc.edu> |
| 18 * |
| 19 */ |
| 20 |
| 21 /** |
| 22 * These validation tests are detailed in http://icir.org/floyd/papers/redsims.p
s |
| 23 * |
| 24 * In this code the tests 1, 3, 4 and 5 from the document above were written. |
| 25 */ |
| 26 |
| 27 /** Network topology |
| 28 * |
| 29 * 10Mb/s, 2ms 10Mb/s, 4ms |
| 30 * n0--------------| |---------------n4 |
| 31 * | 1.5Mbps/s, 20ms | |
| 32 * n2------------------n3 |
| 33 * 10Mb/s, 3ms | | 10Mb/s, 5ms |
| 34 * n1--------------| |---------------n5 |
| 35 * |
| 36 * |
| 37 */ |
| 38 |
| 39 #include "ns3/core-module.h" |
| 40 #include "ns3/network-module.h" |
| 41 #include "ns3/internet-module.h" |
| 42 #include "ns3/flow-monitor-helper.h" |
| 43 #include "ns3/point-to-point-module.h" |
| 44 #include "ns3/applications-module.h" |
| 45 #include "ns3/uinteger.h" |
| 46 #include "ns3/red-queue.h" |
| 47 |
| 48 using namespace ns3; |
| 49 |
| 50 NS_LOG_COMPONENT_DEFINE ("RedExamples"); |
| 51 |
| 52 uint32_t checkTimes; |
| 53 double avgQueueSize; |
| 54 |
| 55 // The times |
| 56 double global_start_time; |
| 57 double global_stop_time; |
| 58 double sink_start_time; |
| 59 double sink_stop_time; |
| 60 double client_start_time; |
| 61 double client_stop_time; |
| 62 |
| 63 NodeContainer n0n2; |
| 64 NodeContainer n1n2; |
| 65 NodeContainer n2n3; |
| 66 NodeContainer n3n4; |
| 67 NodeContainer n3n5; |
| 68 |
| 69 Ipv4InterfaceContainer i0i2; |
| 70 Ipv4InterfaceContainer i1i2; |
| 71 Ipv4InterfaceContainer i2i3; |
| 72 Ipv4InterfaceContainer i3i4; |
| 73 Ipv4InterfaceContainer i3i5; |
| 74 |
| 75 std::stringstream filePlotQueue; |
| 76 std::stringstream filePlotQueueAvg; |
| 77 |
| 78 void |
| 79 CheckQueueSize (Ptr<Queue> queue) |
| 80 { |
| 81 uint32_t qSize = StaticCast<RedQueue> (queue)->GetQueueSize (); |
| 82 |
| 83 avgQueueSize += qSize; |
| 84 checkTimes++; |
| 85 |
| 86 // check queue size every 1/100 of a second |
| 87 Simulator::Schedule (Seconds (0.01), &CheckQueueSize, queue); |
| 88 |
| 89 std::ofstream fPlotQueue (filePlotQueue.str ().c_str (), std::ios::out|std::io
s::app); |
| 90 fPlotQueue << Simulator::Now ().GetSeconds () << " " << qSize << std::endl; |
| 91 fPlotQueue.close(); |
| 92 |
| 93 std::ofstream fPlotQueueAvg (filePlotQueueAvg.str ().c_str (), std::ios::out|s
td::ios::app); |
| 94 fPlotQueueAvg << Simulator::Now ().GetSeconds () << " " << avgQueueSize / chec
kTimes << std::endl; |
| 95 fPlotQueueAvg.close(); |
| 96 } |
| 97 |
| 98 void |
| 99 BuildAppsTest (uint32_t test) |
| 100 { |
| 101 if ( (test == 1) || (test == 3) ) |
| 102 { |
| 103 // SINK is in the right side |
| 104 uint16_t port = 50000; |
| 105 Address sinkLocalAddress(InetSocketAddress (Ipv4Address::GetAny (), port))
; |
| 106 PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress); |
| 107 ApplicationContainer sinkApp = sinkHelper.Install (n3n4.Get(1)); |
| 108 sinkApp.Start (Seconds (sink_start_time)); |
| 109 sinkApp.Stop (Seconds (sink_stop_time)); |
| 110 |
| 111 // Connection one |
| 112 // Clients are in left side |
| 113 /* |
| 114 * Create the OnOff applications to send TCP to the server |
| 115 * onoffhelper is a client that send data to TCP destination |
| 116 */ |
| 117 OnOffHelper clientHelper1 ("ns3::TcpSocketFactory", Address ()); |
| 118 clientHelper1.SetAttribute· |
| 119 ("OnTime", RandomVariableValue (ConstantVariable (1))); |
| 120 clientHelper1.SetAttribute· |
| 121 ("OffTime", RandomVariableValue (ConstantVariable (0))); |
| 122 clientHelper1.SetAttribute· |
| 123 ("DataRate", DataRateValue (DataRate ("10Mb/s"))); |
| 124 clientHelper1.SetAttribute· |
| 125 ("PacketSize", UintegerValue (1000)); |
| 126 |
| 127 ApplicationContainer clientApps1; |
| 128 AddressValue remoteAddress |
| 129 (InetSocketAddress (i3i4.GetAddress (1), port)); |
| 130 clientHelper1.SetAttribute ("Remote", remoteAddress); |
| 131 clientApps1.Add(clientHelper1.Install (n0n2.Get(0))); |
| 132 clientApps1.Start (Seconds (client_start_time)); |
| 133 clientApps1.Stop (Seconds (client_stop_time)); |
| 134 |
| 135 // Connection two |
| 136 OnOffHelper clientHelper2 ("ns3::TcpSocketFactory", Address ()); |
| 137 clientHelper2.SetAttribute· |
| 138 ("OnTime", RandomVariableValue (ConstantVariable (1))); |
| 139 clientHelper2.SetAttribute· |
| 140 ("OffTime", RandomVariableValue (ConstantVariable (0))); |
| 141 clientHelper2.SetAttribute· |
| 142 ("DataRate", DataRateValue (DataRate ("10Mb/s"))); |
| 143 clientHelper2.SetAttribute· |
| 144 ("PacketSize", UintegerValue (1000)); |
| 145 |
| 146 ApplicationContainer clientApps2; |
| 147 clientHelper2.SetAttribute ("Remote", remoteAddress); |
| 148 clientApps2.Add(clientHelper2.Install (n1n2.Get(0))); |
| 149 clientApps2.Start (Seconds (3.0)); |
| 150 clientApps2.Stop (Seconds (client_stop_time)); |
| 151 } |
| 152 else // 4 or 5 |
| 153 { |
| 154 // SINKs |
| 155 // #1 |
| 156 uint16_t port1 = 50001; |
| 157 Address sinkLocalAddress1(InetSocketAddress (Ipv4Address::GetAny (), port1
)); |
| 158 PacketSinkHelper sinkHelper1 ("ns3::TcpSocketFactory", sinkLocalAddress1); |
| 159 ApplicationContainer sinkApp1 = sinkHelper1.Install (n3n4.Get(1)); |
| 160 sinkApp1.Start (Seconds (sink_start_time)); |
| 161 sinkApp1.Stop (Seconds (sink_stop_time)); |
| 162 // #2 |
| 163 uint16_t port2 = 50002; |
| 164 Address sinkLocalAddress2(InetSocketAddress (Ipv4Address::GetAny (), port2
)); |
| 165 PacketSinkHelper sinkHelper2 ("ns3::TcpSocketFactory", sinkLocalAddress2); |
| 166 ApplicationContainer sinkApp2 = sinkHelper2.Install (n3n5.Get(1)); |
| 167 sinkApp2.Start (Seconds (sink_start_time)); |
| 168 sinkApp2.Stop (Seconds (sink_stop_time)); |
| 169 // #3 |
| 170 uint16_t port3 = 50003; |
| 171 Address sinkLocalAddress3(InetSocketAddress (Ipv4Address::GetAny (), port3
)); |
| 172 PacketSinkHelper sinkHelper3 ("ns3::TcpSocketFactory", sinkLocalAddress3); |
| 173 ApplicationContainer sinkApp3 = sinkHelper3.Install (n0n2.Get(0)); |
| 174 sinkApp3.Start (Seconds (sink_start_time)); |
| 175 sinkApp3.Stop (Seconds (sink_stop_time)); |
| 176 // #4 |
| 177 uint16_t port4 = 50004; |
| 178 Address sinkLocalAddress4(InetSocketAddress (Ipv4Address::GetAny (), port4
)); |
| 179 PacketSinkHelper sinkHelper4 ("ns3::TcpSocketFactory", sinkLocalAddress4); |
| 180 ApplicationContainer sinkApp4 = sinkHelper4.Install (n1n2.Get(0)); |
| 181 sinkApp4.Start (Seconds (sink_start_time)); |
| 182 sinkApp4.Stop (Seconds (sink_stop_time)); |
| 183 |
| 184 // Connection #1 |
| 185 /* |
| 186 * Create the OnOff applications to send TCP to the server |
| 187 * onoffhelper is a client that send data to TCP destination |
| 188 */ |
| 189 OnOffHelper clientHelper1 ("ns3::TcpSocketFactory", Address ()); |
| 190 clientHelper1.SetAttribute· |
| 191 ("OnTime", RandomVariableValue (ConstantVariable (1))); |
| 192 clientHelper1.SetAttribute· |
| 193 ("OffTime", RandomVariableValue (ConstantVariable (0))); |
| 194 clientHelper1.SetAttribute· |
| 195 ("DataRate", DataRateValue (DataRate ("10Mb/s"))); |
| 196 clientHelper1.SetAttribute· |
| 197 ("PacketSize", UintegerValue (1000)); |
| 198 |
| 199 ApplicationContainer clientApps1; |
| 200 AddressValue remoteAddress1 |
| 201 (InetSocketAddress (i3i4.GetAddress (1), port1)); |
| 202 clientHelper1.SetAttribute ("Remote", remoteAddress1); |
| 203 clientApps1.Add(clientHelper1.Install (n0n2.Get(0))); |
| 204 clientApps1.Start (Seconds (client_start_time)); |
| 205 clientApps1.Stop (Seconds (client_stop_time)); |
| 206 |
| 207 // Connection #2 |
| 208 OnOffHelper clientHelper2 ("ns3::TcpSocketFactory", Address ()); |
| 209 clientHelper2.SetAttribute· |
| 210 ("OnTime", RandomVariableValue (ConstantVariable (1))); |
| 211 clientHelper2.SetAttribute· |
| 212 ("OffTime", RandomVariableValue (ConstantVariable (0))); |
| 213 clientHelper2.SetAttribute· |
| 214 ("DataRate", DataRateValue (DataRate ("10Mb/s"))); |
| 215 clientHelper2.SetAttribute· |
| 216 ("PacketSize", UintegerValue (1000)); |
| 217 |
| 218 ApplicationContainer clientApps2; |
| 219 AddressValue remoteAddress2 |
| 220 (InetSocketAddress (i3i5.GetAddress (1), port2)); |
| 221 clientHelper2.SetAttribute ("Remote", remoteAddress2); |
| 222 clientApps2.Add(clientHelper2.Install (n1n2.Get(0))); |
| 223 clientApps2.Start (Seconds (2.0)); |
| 224 clientApps2.Stop (Seconds (client_stop_time)); |
| 225 |
| 226 // Connection #3 |
| 227 OnOffHelper clientHelper3 ("ns3::TcpSocketFactory", Address ()); |
| 228 clientHelper3.SetAttribute· |
| 229 ("OnTime", RandomVariableValue (ConstantVariable (1))); |
| 230 clientHelper3.SetAttribute· |
| 231 ("OffTime", RandomVariableValue (ConstantVariable (0))); |
| 232 clientHelper3.SetAttribute· |
| 233 ("DataRate", DataRateValue (DataRate ("10Mb/s"))); |
| 234 clientHelper3.SetAttribute· |
| 235 ("PacketSize", UintegerValue (1000)); |
| 236 |
| 237 ApplicationContainer clientApps3; |
| 238 AddressValue remoteAddress3 |
| 239 (InetSocketAddress (i0i2.GetAddress (0), port3)); |
| 240 clientHelper3.SetAttribute ("Remote", remoteAddress3); |
| 241 clientApps3.Add(clientHelper3.Install (n3n4.Get(1))); |
| 242 clientApps3.Start (Seconds (3.5)); |
| 243 clientApps3.Stop (Seconds (client_stop_time)); |
| 244 |
| 245 // Connection #4 |
| 246 OnOffHelper clientHelper4 ("ns3::TcpSocketFactory", Address ()); |
| 247 clientHelper4.SetAttribute· |
| 248 ("OnTime", RandomVariableValue (ConstantVariable (1))); |
| 249 clientHelper4.SetAttribute· |
| 250 ("OffTime", RandomVariableValue (ConstantVariable (0))); |
| 251 clientHelper4.SetAttribute· |
| 252 ("DataRate", DataRateValue (DataRate ("40b/s"))); |
| 253 clientHelper4.SetAttribute· |
| 254 ("PacketSize", UintegerValue (5 * 8)); // telnet |
| 255 |
| 256 ApplicationContainer clientApps4; |
| 257 AddressValue remoteAddress4 |
| 258 (InetSocketAddress (i1i2.GetAddress (0), port4)); |
| 259 clientHelper4.SetAttribute ("Remote", remoteAddress4); |
| 260 clientApps4.Add(clientHelper4.Install (n3n5.Get(1))); |
| 261 clientApps4.Start (Seconds (1.0)); |
| 262 clientApps4.Stop (Seconds (client_stop_time)); |
| 263 } |
| 264 } |
| 265 |
| 266 int |
| 267 main (int argc, char *argv[]) |
| 268 { |
| 269 // LogComponentEnable ("RedExamples", LOG_LEVEL_INFO); |
| 270 // LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO); |
| 271 // LogComponentEnable ("RedQueue", LOG_LEVEL_FUNCTION); |
| 272 LogComponentEnable ("RedQueue", LOG_LEVEL_INFO); |
| 273 |
| 274 uint32_t redTest; |
| 275 std::string redLinkDataRate = "1.5Mbps"; |
| 276 std::string redLinkDelay = "20ms"; |
| 277 |
| 278 std::string pathOut; |
| 279 bool writeForPlot = false; |
| 280 bool writePcap = false; |
| 281 bool flowMonitor = false; |
| 282 |
| 283 bool printRedStats = true; |
| 284 |
| 285 global_start_time = 0.0; |
| 286 global_stop_time = 11;· |
| 287 sink_start_time = global_start_time; |
| 288 sink_stop_time = global_stop_time + 3.0; |
| 289 client_start_time = sink_start_time + 0.2; |
| 290 client_stop_time = global_stop_time - 2.0; |
| 291 |
| 292 // Configuration and command line parameter parsing |
| 293 redTest = 1; |
| 294 // Will only save in the directory if enable opts below |
| 295 pathOut = "/tmp"; |
| 296 CommandLine cmd; |
| 297 cmd.AddValue ("testNumber", "Run test 1, 3, 4 or 5", redTest); |
| 298 cmd.AddValue ("pathOut", "Path to save results from --writeForPlot/--writePcap
/--writeFlowMonitor", pathOut); |
| 299 cmd.AddValue ("writeForPlot", "<0/1> to write results for plot (gnuplot)", wri
teForPlot); |
| 300 cmd.AddValue ("writePcap", "<0/1> to write results in pcapfile", writePcap); |
| 301 cmd.AddValue ("writeFlowMonitor", "<0/1> to enable Flow Monitor and write thei
r results", flowMonitor); |
| 302 |
| 303 cmd.Parse (argc, argv); |
| 304 if ( (redTest != 1) && (redTest != 3) && (redTest != 4) && (redTest != 5) ) |
| 305 { |
| 306 NS_ABORT_MSG ("Invalid test number. Supported tests are 1, 3, 4 or 5"); |
| 307 } |
| 308 |
| 309 NS_LOG_INFO ("Create nodes"); |
| 310 NodeContainer c; |
| 311 c.Create (6); |
| 312 Names::Add ( "N0", c.Get (0)); |
| 313 Names::Add ( "N1", c.Get (1)); |
| 314 Names::Add ( "N2", c.Get (2)); |
| 315 Names::Add ( "N3", c.Get (3)); |
| 316 Names::Add ( "N4", c.Get (4)); |
| 317 Names::Add ( "N5", c.Get (5)); |
| 318 n0n2 = NodeContainer (c.Get (0), c.Get (2)); |
| 319 n1n2 = NodeContainer (c.Get (1), c.Get (2)); |
| 320 n2n3 = NodeContainer (c.Get (2), c.Get (3)); |
| 321 n3n4 = NodeContainer (c.Get (3), c.Get (4)); |
| 322 n3n5 = NodeContainer (c.Get (3), c.Get (5)); |
| 323 |
| 324 Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue ("ns3::TcpRe
no")); |
| 325 // 42 = headers size |
| 326 Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000 - 42)); |
| 327 Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1)); |
| 328 GlobalValue::Bind ("ChecksumEnabled", BooleanValue (false)); |
| 329 |
| 330 uint32_t meanPktSize = 500; |
| 331 |
| 332 // RED params |
| 333 NS_LOG_INFO ("Set RED params"); |
| 334 Config::SetDefault ("ns3::RedQueue::Mode", StringValue("Packets")); |
| 335 Config::SetDefault ("ns3::RedQueue::MeanPktSize", UintegerValue (meanPktSize))
; |
| 336 Config::SetDefault ("ns3::RedQueue::Wait", BooleanValue (true)); |
| 337 Config::SetDefault ("ns3::RedQueue::Gentle", BooleanValue (true)); |
| 338 Config::SetDefault ("ns3::RedQueue::QW", DoubleValue (0.002)); |
| 339 Config::SetDefault ("ns3::RedQueue::MinTh", DoubleValue (5)); |
| 340 Config::SetDefault ("ns3::RedQueue::MaxTh", DoubleValue (15)); |
| 341 Config::SetDefault ("ns3::RedQueue::QueueLimit", UintegerValue (25)); |
| 342 Config::SetDefault ("ns3::RedQueue::LinkBandwidth", StringValue(redLinkDataRat
e)); |
| 343 Config::SetDefault ("ns3::RedQueue::LinkDelay", StringValue(redLinkDelay)); |
| 344 |
| 345 if (redTest == 3) // test like 1, but with bad params |
| 346 { |
| 347 Config::SetDefault ("ns3::RedQueue::MaxTh", DoubleValue (10)); |
| 348 Config::SetDefault ("ns3::RedQueue::QW", DoubleValue (0.003)); |
| 349 } |
| 350 else if (redTest == 5) // test 5, same of test 4, but in byte mode |
| 351 { |
| 352 Config::SetDefault ("ns3::RedQueue::Mode", StringValue("Bytes")); |
| 353 Config::SetDefault ("ns3::RedQueue::Ns1Compat", BooleanValue (true)); |
| 354 Config::SetDefault ("ns3::RedQueue::MinTh", DoubleValue (5 * meanPktSize))
; |
| 355 Config::SetDefault ("ns3::RedQueue::MaxTh", DoubleValue (15 * meanPktSize)
); |
| 356 Config::SetDefault ("ns3::RedQueue::QueueLimit", UintegerValue (25 * meanP
ktSize)); |
| 357 } |
| 358 |
| 359 // fix the TCP window size |
| 360 // uint16_t wnd = 15000; |
| 361 // GlobalValue::Bind ("GlobalFixedTcpWindowSize", IntegerValue (wnd)); |
| 362 |
| 363 NS_LOG_INFO ("Install internet stack on all nodes."); |
| 364 InternetStackHelper internet; |
| 365 internet.Install (c); |
| 366 |
| 367 NS_LOG_INFO ("Create channels"); |
| 368 PointToPointHelper p2p; |
| 369 |
| 370 p2p.SetQueue ("ns3::DropTailQueue"); |
| 371 p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); |
| 372 p2p.SetChannelAttribute ("Delay", StringValue ("2ms")); |
| 373 NetDeviceContainer devn0n2 = p2p.Install (n0n2); |
| 374 |
| 375 p2p.SetQueue ("ns3::DropTailQueue"); |
| 376 p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); |
| 377 p2p.SetChannelAttribute ("Delay", StringValue ("3ms")); |
| 378 NetDeviceContainer devn1n2 = p2p.Install (n1n2); |
| 379 |
| 380 p2p.SetQueue("ns3::RedQueue"); // yeah, only backbone link have special queue |
| 381 p2p.SetDeviceAttribute ("DataRate", StringValue (redLinkDataRate)); |
| 382 p2p.SetChannelAttribute ("Delay", StringValue (redLinkDelay)); |
| 383 NetDeviceContainer devn2n3 = p2p.Install (n2n3); |
| 384 |
| 385 p2p.SetQueue ("ns3::DropTailQueue"); |
| 386 p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); |
| 387 p2p.SetChannelAttribute ("Delay", StringValue ("4ms")); |
| 388 NetDeviceContainer devn3n4 = p2p.Install (n3n4); |
| 389 |
| 390 p2p.SetQueue ("ns3::DropTailQueue"); |
| 391 p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); |
| 392 p2p.SetChannelAttribute ("Delay", StringValue ("5ms")); |
| 393 NetDeviceContainer devn3n5 = p2p.Install (n3n5); |
| 394 |
| 395 NS_LOG_INFO ("Assign IP Addresses"); |
| 396 Ipv4AddressHelper ipv4; |
| 397 |
| 398 ipv4.SetBase ("10.1.1.0", "255.255.255.0"); |
| 399 i0i2 = ipv4.Assign (devn0n2); |
| 400 |
| 401 ipv4.SetBase ("10.1.2.0", "255.255.255.0"); |
| 402 i1i2 = ipv4.Assign (devn1n2); |
| 403 |
| 404 ipv4.SetBase ("10.1.3.0", "255.255.255.0"); |
| 405 i2i3 = ipv4.Assign (devn2n3); |
| 406 |
| 407 ipv4.SetBase ("10.1.4.0", "255.255.255.0"); |
| 408 i3i4 = ipv4.Assign (devn3n4); |
| 409 |
| 410 ipv4.SetBase ("10.1.5.0", "255.255.255.0"); |
| 411 i3i5 = ipv4.Assign (devn3n5); |
| 412 |
| 413 // Set up the routing |
| 414 Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
| 415 |
| 416 if (redTest == 5) // byte mode |
| 417 { |
| 418 // like in ns2 test, r2 -> r1, have a queue in packet mode |
| 419 Ptr<PointToPointNetDevice> nd = StaticCast<PointToPointNetDevice> (devn2n3
.Get (1)); |
| 420 Ptr<Queue> queue = nd->GetQueue (); |
| 421 |
| 422 StaticCast<RedQueue> (queue)->SetMode (RedQueue::PACKETS); |
| 423 StaticCast<RedQueue> (queue)->SetTh (5, 15); |
| 424 StaticCast<RedQueue> (queue)->SetQueueLimit (25); |
| 425 } |
| 426 |
| 427 BuildAppsTest(redTest); |
| 428 |
| 429 if (writePcap) |
| 430 { |
| 431 PointToPointHelper ptp; |
| 432 std::stringstream stmp; |
| 433 stmp << pathOut << "/red"; |
| 434 ptp.EnablePcapAll (stmp.str ().c_str ()); |
| 435 } |
| 436 |
| 437 Ptr<FlowMonitor> flowmon; |
| 438 |
| 439 if (flowMonitor) |
| 440 { |
| 441 FlowMonitorHelper flowmonHelper; |
| 442 flowmon = flowmonHelper.InstallAll (); |
| 443 } |
| 444 |
| 445 if (writeForPlot) |
| 446 { |
| 447 filePlotQueue << pathOut << "/" << "red-queue.plotme"; |
| 448 filePlotQueueAvg << pathOut << "/" << "red-queue_avg.plotme"; |
| 449 |
| 450 remove (filePlotQueue.str ().c_str ()); |
| 451 remove (filePlotQueueAvg.str ().c_str ()); |
| 452 Ptr<PointToPointNetDevice> nd = StaticCast<PointToPointNetDevice> (devn2n3
.Get (0)); |
| 453 Ptr<Queue> queue = nd->GetQueue (); |
| 454 Simulator::ScheduleNow (&CheckQueueSize, queue); |
| 455 } |
| 456 |
| 457 Simulator::Stop (Seconds (sink_stop_time)); |
| 458 Simulator::Run (); |
| 459 |
| 460 if (flowMonitor) |
| 461 { |
| 462 std::stringstream stmp; |
| 463 stmp << pathOut << "/red.flowmon"; |
| 464 |
| 465 flowmon->SerializeToXmlFile (stmp.str ().c_str (), false, false); |
| 466 } |
| 467 |
| 468 if (printRedStats) |
| 469 { |
| 470 Ptr<PointToPointNetDevice> nd = StaticCast<PointToPointNetDevice> (devn2n3
.Get (0)); |
| 471 RedQueue::Stats st = StaticCast<RedQueue> (nd->GetQueue ())->GetStats (); |
| 472 std::cout << "*** RED stats from Node 2 queue ***" << std::endl; |
| 473 std::cout << "\t " << st.unforcedDrop << " drops due prob mark" << std::en
dl; |
| 474 std::cout << "\t " << st.forcedDrop << " drops due hard mark" << std::endl
; |
| 475 std::cout << "\t " << st.qLimDrop << " drops due queue full" << std::endl; |
| 476 |
| 477 nd = StaticCast<PointToPointNetDevice> (devn2n3.Get (1)); |
| 478 st = StaticCast<RedQueue> (nd->GetQueue ())->GetStats (); |
| 479 std::cout << "*** RED stats from Node 3 queue ***" << std::endl; |
| 480 std::cout << "\t " << st.unforcedDrop << " drops due prob mark" << std::en
dl; |
| 481 std::cout << "\t " << st.forcedDrop << " drops due hard mark" << std::endl
; |
| 482 std::cout << "\t " << st.qLimDrop << " drops due queue full" << std::endl; |
| 483 } |
| 484 |
| 485 Simulator::Destroy (); |
| 486 |
| 487 return 0; |
| 488 } |
OLD | NEW |