shortest path calculation added
diff --git a/apps/ccnx-consumer.h b/apps/ccnx-consumer.h
index 4bffbaf..8fe885d 100644
--- a/apps/ccnx-consumer.h
+++ b/apps/ccnx-consumer.h
@@ -27,7 +27,8 @@
#include "ns3/ccnx-name-components.h"
#include "ns3/nstime.h"
#include "ns3/data-rate.h"
-#include "ns3/rtt-estimator.h"
+#include "../../internet/model/rtt-estimator.h"
+//#include "ns3/internet-module.h"
#include <set>
diff --git a/examples/base-experiment.h b/examples/base-experiment.h
index 873a956..c00c127 100644
--- a/examples/base-experiment.h
+++ b/examples/base-experiment.h
@@ -29,6 +29,7 @@
BaseExperiment ()
: m_rand (0,52)
, reader (0)
+ , m_numNodes (52)
{ }
~BaseExperiment ()
@@ -146,6 +147,7 @@
list<tuple<uint32_t,uint32_t> > m_pairs;
set<uint32_t> m_usedNodes;
+ const int m_numNodes;
};
#endif
diff --git a/examples/blackhole-sprint.cc b/examples/blackhole-sprint.cc
index d826ce6..9b8fcfc 100644
--- a/examples/blackhole-sprint.cc
+++ b/examples/blackhole-sprint.cc
@@ -36,6 +36,14 @@
#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>
+#include <boost/config.hpp>
+#include <iostream>
+#include <fstream>
+
+#include <boost/graph/graph_traits.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/dijkstra_shortest_paths.hpp>
+
using namespace ns3;
using namespace std;
using namespace boost;
@@ -54,6 +62,184 @@
class Experiment : public BaseExperiment
{
public:
+ enum nodes {N0,N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11,N12,N13,N14,N15,N16,N17,N18,N19,N20,N21,N22,N23,N24,N25,N26,N27,N28,N29,N30,N31,N32,N33,N34,N35,N36,N37,N38,N39,N40,N41,N42,N43,N44,N45,N46,N47,N48,N49,N50,N51};
+
+ typedef std::pair<int, int> Edge;
+ const Edge edge_array[84];
+
+ Experiment ()
+ : edge_array((Edge[84]){
+ Edge(N0, N1),
+ Edge(N2, N3),
+ Edge(N1, N4),
+ Edge(N1, N5),
+ Edge(N1, N6),
+ Edge(N1, N7),
+ Edge(N1, N8),
+ Edge(N1, N9),
+ Edge(N1, N10),
+ Edge(N1, N11),
+ Edge(N12, N13),
+ Edge(N14, N15),
+ Edge(N14, N16),
+ Edge(N14, N17),
+ Edge(N15, N18),
+ Edge(N15, N19),
+ Edge(N20, N21),
+ Edge(N20, N22),
+ Edge(N23, N24),
+ Edge(N25, N26),
+ Edge(N27, N28),
+ Edge(N8, N20),
+ Edge(N8, N16),
+ Edge(N8, N28),
+ Edge(N8, N24),
+ Edge(N8, N26),
+ Edge(N21, N31),
+ Edge(N13, N32),
+ Edge(N13, N33),
+ Edge(N17, N35),
+ Edge(N17, N20),
+ Edge(N17, N18),
+ Edge(N17, N28),
+ Edge(N17, N24),
+ Edge(N17, N25),
+ Edge(N17, N26),
+ Edge(N17, N29),
+ Edge(N17, N36),
+ Edge(N11, N24),
+ Edge(N11, N38),
+ Edge(N11, N17),
+ Edge(N33, N39),
+ Edge(N33, N40),
+ Edge(N6, N7),
+ Edge(N6, N28),
+ Edge(N6, N25),
+ Edge(N6, N8),
+ Edge(N6, N17),
+ Edge(N6, N34),
+ Edge(N6, N11),
+ Edge(N39, N42),
+ Edge(N16, N24),
+ Edge(N16, N29),
+ Edge(N16, N17),
+ Edge(N31, N45),
+ Edge(N31, N46),
+ Edge(N31, N37),
+ Edge(N31, N47),
+ Edge(N32, N48),
+ Edge(N32, N44),
+ Edge(N32, N42),
+ Edge(N48, N49),
+ Edge(N7, N13),
+ Edge(N38, N43),
+ Edge(N9, N15),
+ Edge(N9, N20),
+ Edge(N9, N31),
+ Edge(N9, N30),
+ Edge(N9, N17),
+ Edge(N9, N19),
+ Edge(N5, N32),
+ Edge(N5, N8),
+ Edge(N5, N7),
+ Edge(N18, N23),
+ Edge(N40, N48),
+ Edge(N40, N49),
+ Edge(N24, N38),
+ Edge(N24, N31),
+ Edge(N24, N45),
+ Edge(N24, N50),
+ Edge(N3, N9),
+ Edge(N19, N41),
+ Edge(N19, N20),
+ Edge(N19, N51)
+ })
+ { }
+
+
+ int
+ ComputeShortestWeightsPath(uint32_t sourceNode, uint32_t destinationNode)
+ {
+ typedef adjacency_list < listS, vecS, undirectedS,
+ no_property, property < edge_weight_t, int > > graph_t;
+ typedef graph_traits < graph_t >::vertex_descriptor vertex_descriptor;
+ typedef graph_traits < graph_t >::edge_descriptor edge_descriptor;
+
+ //string name[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51"};
+
+
+ int weights[] = { 312, 10786, 222, 2500, 4000, 2500, 3860, 11769, 352, 3500, 2622, 500, 14192, 8909, 11747, 44530, 19775, 345, 5337, 2184, 645, 11409, 8282, 3000, 7735, 5500, 20741, 7552, 1500, 2091, 14409, 4337, 4000, 5735, 1315, 2500, 3282, 2478, 5096, 3235, 4360, 2000, 3000, 2500, 6860, 5176, 5860, 3860, 802, 5500, 699, 1547, 3000, 5282, 500, 268, 3375, 2708, 1712, 2329, 3352, 3201, 30890, 1643, 5500, 2500, 4735, 124, 13909, 42030, 28338, 2360, 2000, 5735, 2340, 2529, 2860, 9909, 10409, 92, 59812, 26190, 39530, 14125 };
+
+ int num_arcs = sizeof(edge_array) / sizeof(Edge);
+
+ graph_t g(edge_array, edge_array + num_arcs, weights, m_numNodes);
+ property_map<graph_t, edge_weight_t>::type weightmap = get(edge_weight, g);
+
+ std::vector<vertex_descriptor> p(num_vertices(g));
+ std::vector<int> d(num_vertices(g));
+
+ vertex_descriptor s = vertex(static_cast<nodes>(sourceNode), g);
+
+ dijkstra_shortest_paths(g, s, predecessor_map(&p[0]).distance_map(&d[0]));
+
+ NS_LOG_INFO("Shortest distance (weights) from Node"<<sourceNode << " to Node"<<destinationNode<<" equals " << d[destinationNode]);
+
+ /*
+ //PRINTING
+ NS_LOG_INFO ("distances and parents:");
+ graph_traits < graph_t >::vertex_iterator vi, vend;
+
+ for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi)
+ {
+ NS_LOG_INFO("distance(" << name[*vi] << ") = " << d[*vi] << ", ");
+ NS_LOG_INFO("parent(" << name[*vi] << ") = " << name[p[*vi]] << std::endl);
+ }
+ */
+
+ return d[destinationNode];
+ }
+
+ double
+ ComputeShortestDelayPath(uint32_t sourceNode, uint32_t destinationNode)
+ {
+ typedef adjacency_list < listS, vecS, undirectedS,
+ no_property, property < edge_weight_t, double > > graph_t;
+ typedef graph_traits < graph_t >::vertex_descriptor vertex_descriptor;
+ typedef graph_traits < graph_t >::edge_descriptor edge_descriptor;
+
+ //string name[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51"};
+
+ double weights[] = {0.312, 10.786, 0.222, 1.035, 1.414, 1.24, 0.814, 19.532, 0.352, 4.593, 2.622, 0.207, 12.098, 13.941, 7.791, 38.946, 19.775, 0.345, 5.337, 0.276, 0.645, 19.787, 8.352, 1.578, 10.459, 5.005, 20.741, 4.737, 1.424, 2.091, 14.409, 7.13, 6.214, 6.437, 1.315, 1.176, 3.282, 2.478, 5.751, 3.235, 4.718, 1.817, 2.035, 0.327, 0.97, 5.176, 0.612, 5.725, 0.802, 6.007, 0.699, 3.655, 0.135, 3.286, 0.268, 0.268, 3.375, 2.708, 1.712, 2.329, 1.595, 3.201, 31.13, 1.643, 5.513, 0.437, 2.648, 0.124, 14.774, 42.03, 28.338, 0.359, 0.316, 0.779, 2.34, 2.529, 7.706, 9.827, 10.045, 0.092, 59.812, 26.19, 42.057, 14.125};
+
+ int num_arcs = sizeof(edge_array) / sizeof(Edge);
+
+ graph_t g(edge_array, edge_array + num_arcs, weights, m_numNodes);
+ property_map<graph_t, edge_weight_t>::type weightmap = get(edge_weight, g);
+
+ std::vector<vertex_descriptor> p(num_vertices(g));
+ std::vector<double> d(num_vertices(g));
+
+ vertex_descriptor s = vertex(static_cast<nodes>(sourceNode), g);
+
+ dijkstra_shortest_paths(g, s, predecessor_map(&p[0]).distance_map(&d[0]));
+
+ NS_LOG_INFO("Shortest distance (delay) from Node"<<sourceNode << " to Node"<<destinationNode<<" equals " << d[destinationNode]);
+
+ /*
+ //PRINTING
+ NS_LOG_INFO ("distances and parents:");
+ graph_traits < graph_t >::vertex_iterator vi, vend;
+
+ for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi)
+ {
+ NS_LOG_INFO("distance(" << name[*vi] << ") = " << d[*vi] << ", ");
+ NS_LOG_INFO("parent(" << name[*vi] << ") = " << name[p[*vi]] << std::endl);
+ }
+ */
+
+ return d[destinationNode];
+ }
+
//We are creating 10 pairs of producer-hijacker and everybody else is a consumer
ApplicationContainer
AddApplications ()
@@ -155,6 +341,8 @@
Experiment experiment;
experiment.GenerateRandomPairs (10);
+ experiment.ComputeShortestWeightsPath(1,12);
+ experiment.ComputeShortestDelayPath(1,12);
cout << "Run " << i << endl;
string prefix = "blackhole-" + lexical_cast<string> (i) + "-";