Congestion for Sprint-POP scenario (half-working)
diff --git a/examples/congestion-pop.cc b/examples/congestion-pop.cc
new file mode 100644
index 0000000..9dd3a35
--- /dev/null
+++ b/examples/congestion-pop.cc
@@ -0,0 +1,218 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
+ */
+
+
+#include "ns3/core-module.h"
+#include "ns3/network-module.h"
+#include "ns3/point-to-point-module.h"
+#include "ns3/NDNabstraction-module.h"
+#include "ns3/point-to-point-grid.h"
+#include "ns3/ipv4-global-routing-helper.h"
+#include "ns3/random-variable.h"
+
+#include <iostream>
+#include <sstream>
+#include <map>
+#include <list>
+#include <set>
+#include "ns3/rocketfuel-topology-reader.h"
+
+#include <boost/lexical_cast.hpp>
+#include <boost/foreach.hpp>
+
+using namespace ns3;
+using namespace std;
+using namespace boost;
+
+NS_LOG_COMPONENT_DEFINE ("Scenario");
+
+void PrintTime ()
+{
+ cout << "Progress: " << Simulator::Now ().ToDouble (Time::S) << "s" << endl;
+
+ Simulator::Schedule (Seconds (1.0), PrintTime);
+}
+
+class Experiment
+{
+public:
+ void
+ ConfigureTopology ()
+ {
+ string weights ("./src/NDNabstraction/examples/sprint-pops.weights");
+ string latencies ("./src/NDNabstraction/examples/sprint-pops.latencies");
+ string positions ("./src/NDNabstraction/examples/sprint-pops.positions");
+ string strategy ("ns3::CcnxBestRouteStrategy");
+ // string strategy ("ns3::CcnxFloodingStrategy");
+
+ RocketfuelWeightsReader reader ("/sprint");
+
+ reader.SetFileName (positions);
+ reader.SetFileType (RocketfuelWeightsReader::POSITIONS);
+ reader.Read ();
+
+ reader.SetFileName (weights);
+ reader.SetFileType (RocketfuelWeightsReader::WEIGHTS);
+ reader.Read ();
+
+ reader.SetFileName (latencies);
+ reader.SetFileType (RocketfuelWeightsReader::LATENCIES);
+ reader.Read ();
+
+ reader.Commit ();
+ NS_ASSERT_MSG (reader.LinksSize () != 0, "Problems reading the topology file. Failing.");
+
+ NS_LOG_INFO("Nodes = " << reader.GetNodes ().GetN());
+ NS_LOG_INFO("Links = " << reader.LinksSize ());
+
+ // ------------------------------------------------------------
+ // -- Read topology data.
+ // --------------------------------------------
+
+ InternetStackHelper stack;
+ Ipv4GlobalRoutingHelper ipv4RoutingHelper ("ns3::Ipv4GlobalRoutingOrderedNexthops");
+ stack.SetRoutingHelper (ipv4RoutingHelper);
+ stack.Install (reader.GetNodes ());
+
+ reader.AssignIpv4Addresses (Ipv4Address ("10.0.0.0"));
+
+ // Install CCNx stack
+ NS_LOG_INFO ("Installing CCNx stack");
+ CcnxStackHelper ccnxHelper;
+ ccnxHelper.SetForwardingStrategy (strategy);
+ ccnxHelper.EnableLimits (true, Seconds(0.1));
+ ccnxHelper.SetDefaultRoutes (false);
+ ccnxHelper.InstallAll ();
+
+ // // Populate FIB based on IPv4 global routing controller
+ ccnxHelper.InstallFakeGlobalRoutes ();
+ ccnxHelper.InstallRoutesToAll ();
+
+ m_rand = UniformVariable (0, reader.GetNodes ().GetN());
+ }
+
+public:
+ void
+ Run (const Time &finishTime)
+ {
+ cout << "Run Simulation.\n";
+ Simulator::Stop (finishTime);
+ Simulator::Schedule (Seconds (1.0), PrintTime);
+ Simulator::Run ();
+ Simulator::Destroy ();
+ cout << "Done.\n";
+ }
+
+
+ ApplicationContainer
+ AddRandomApplications (uint16_t numStreams)
+ {
+ map<uint32_t, set<uint32_t> > streams;
+ ApplicationContainer apps;
+
+ uint16_t createdStreams = 0;
+ uint16_t guard = 0;
+ while (createdStreams < numStreams && guard < (numeric_limits<uint16_t>::max ()-1))
+ {
+ guard ++;
+
+ uint32_t node1_num = m_rand.GetValue ();
+ uint32_t node2_num = m_rand.GetValue ();
+
+ if (node1_num == node2_num)
+ continue;
+
+ if (streams[node1_num].count (node2_num) > 0) // don't create duplicate streams
+ continue;
+
+ streams[node1_num].insert (node2_num);
+
+ Ptr<Node> node1 = Names::Find<Node> ("/sprint", lexical_cast<string> (node1_num));
+ Ptr<Node> node2 = Names::Find<Node> ("/sprint", lexical_cast<string> (node2_num));
+
+ CcnxAppHelper consumerHelper ("ns3::CcnxConsumer");
+ consumerHelper.SetPrefix ("/" + lexical_cast<string> (node2->GetId ()));
+ consumerHelper.SetAttribute ("MeanRate", StringValue ("2Mbps"));
+ consumerHelper.SetAttribute ("Size", StringValue ("2"));
+
+ CcnxAppHelper producerHelper ("ns3::CcnxProducer");
+ producerHelper.SetPrefix ("/" + lexical_cast<string> (node2->GetId ()));
+
+ apps.Add
+ (consumerHelper.Install (node1));
+
+ apps.Add
+ (producerHelper.Install (node2));
+
+ createdStreams ++;
+ }
+
+ return apps;
+ }
+
+
+ UniformVariable m_rand;
+};
+
+
+int
+main (int argc, char *argv[])
+{
+ cout << "Begin congestion-pop scenario\n";
+
+ Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
+ Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
+
+ Time finishTime = Seconds (20.0);
+
+ CommandLine cmd;
+ cmd.AddValue ("finish", "Finish time", finishTime);
+ cmd.Parse (argc, argv);
+
+ Experiment experiment;
+
+ for (uint32_t i = 0; i < 100; i++)
+ {
+
+ experiment.ConfigureTopology ();
+ ApplicationContainer apps = experiment.AddRandomApplications (20);
+
+ for (uint32_t i = 0; i < apps.GetN () / 2; i++)
+ {
+ cout << "From " << apps.Get (i*2)->GetNode ()->GetId ()
+ << " to " << apps.Get (i*2 + 1)->GetNode ()->GetId ();
+ cout << "\n";
+ }
+
+ CcnxTraceHelper traceHelper;
+ // traceHelper.EnableAggregateAppAll ("ns3::CcnxConsumer");
+ // traceHelper.EnableAggregateAppAll ("ns3::CcnxProducer");
+ // traceHelper.EnableAggregateL3All ();
+ // traceHelper.SetL3TraceFile ("trace-l3.log");
+ // traceHelper.SetAppTraceFile ("trace-app.log");
+ // traceHelper.EnableRateL3All ("rate-trace.log");
+ traceHelper.EnableSeqsAppAll ("ns3::CcnxConsumer", "consumers-seqs.log");
+
+ experiment.Run (finishTime);
+ }
+
+ cout << "Finish congestion-pop scenario\n";
+ return 0;
+}
diff --git a/examples/sprint-pops.positions b/examples/sprint-pops.positions
new file mode 100644
index 0000000..928e443
--- /dev/null
+++ b/examples/sprint-pops.positions
@@ -0,0 +1,53 @@
+router
+0 unknown -135.764 253.112
+1 unknown -124.26 242.106
+2 unknown -133.746 192.374
+3 unknown -125.181 203.615
+4 unknown -139.012 235.48
+5 unknown -114.553 255.538
+6 unknown -117.383 242.123
+7 unknown -124.098 258.288
+8 unknown -109.597 235.032
+9 unknown -114.699 219.473
+10 unknown -141.269 245.046
+11 unknown -104.331 242.371
+12 unknown -133.569 286.269
+13 unknown -123.315 277.497
+14 unknown -98.0591 218.885
+15 unknown -103.065 209.249
+16 unknown -97.6019 232.002
+17 unknown -104.764 227.93
+18 unknown -89.9659 217.538
+19 unknown -111.243 201.883
+20 unknown -105.782 215.929
+21 unknown -96.3977 226.003
+22 unknown -97.9862 200.901
+23 unknown -78.8835 225.308
+24 unknown -90.3514 236.091
+25 unknown -117.767 232.718
+26 unknown -114.42 224.798
+27 unknown -136.333 222.043
+28 unknown -122.444 228.514
+31 unknown -97.4791 241.611
+32 unknown -110.351 277.334
+33 unknown -117.777 292.69
+35 unknown -94.4122 211.85
+29 unknown -88.3097 226.526
+36 unknown -110.615 242.037
+38 unknown -88.4545 248.603
+39 unknown -103.356 298.492
+40 unknown -116.839 305.342
+34 unknown -131.979 243.096
+42 unknown -100.976 287.547
+45 unknown -82.2028 243.344
+46 unknown -96.0201 256.972
+37 unknown -103.425 254.683
+47 unknown -88.0706 256.064
+48 unknown -110.226 295.199
+44 unknown -97.4778 278.521
+49 unknown -106.546 309.269
+43 unknown -76.3178 258.2
+30 unknown -127.539 212.622
+50 unknown -74.0048 237.243
+41 unknown -105.291 188.236
+51 unknown -115.94 188.128
diff --git a/examples/wscript b/examples/wscript
deleted file mode 100644
index 0d2e449..0000000
--- a/examples/wscript
+++ /dev/null
@@ -1,8 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-
-def build(bld):
- if not bld.env['ENABLE_EXAMPLES']:
- return;
-
- # obj = bld.create_ns3_program('stupid-interest-generator', ['NDNabstraction'])
- # obj.source = 'stupid-interest-generator.cc'
diff --git a/model/rocketfuel-weights-reader.cc b/model/rocketfuel-weights-reader.cc
index f6895fa..4681e4e 100644
--- a/model/rocketfuel-weights-reader.cc
+++ b/model/rocketfuel-weights-reader.cc
@@ -146,7 +146,7 @@
break;
}
case LATENCIES:
- link->SetAttribute ("Delay", attribute);
+ link->SetAttribute ("Delay", attribute+"ms");
break;
default:
; //
@@ -195,17 +195,4 @@
}
}
-// void
-// RocketfuelWeightsReader::Cheat (NodeContainer &nodes)
-// {
-// double epsilon = 1;
-
-// for (NodeContainer::Iterator i = nodes.Begin ();
-// i != nodes.End ();
-// i++)
-// {
-
-// }
-// }
-
} /* namespace ns3 */
diff --git a/wscript b/wscript
index a65ff39..8c5b1bf 100644
--- a/wscript
+++ b/wscript
@@ -110,4 +110,7 @@
obj = bld.create_ns3_program('ccnx-synthetic-topology', ['NDNabstraction'])
obj.source = 'examples/synthetic-topology.cc'
+ obj = bld.create_ns3_program('congestion-pop', ['NDNabstraction'])
+ obj.source = 'examples/congestion-pop.cc'
+
bld.ns3_python_bindings()