Finalizing BGL-implementation of ccnx global routing controller. Also, several extensions in CcnxFib
diff --git a/helper/ccnx-global-routing-helper.cc b/helper/ccnx-global-routing-helper.cc
index 5fde9cb..b214d16 100644
--- a/helper/ccnx-global-routing-helper.cc
+++ b/helper/ccnx-global-routing-helper.cc
@@ -24,6 +24,7 @@
#include "../model/ccnx-net-device-face.h"
#include "../model/ccnx-global-router.h"
#include "ns3/ccnx-name-components.h"
+#include "ns3/ccnx-fib.h"
#include "ns3/node.h"
#include "ns3/net-device.h"
@@ -35,6 +36,7 @@
#include "ns3/channel-list.h"
#include <boost/lexical_cast.hpp>
+#include <boost/foreach.hpp>
#include <boost/concept/assert.hpp>
// #include <boost/graph/graph_concepts.hpp>
// #include <boost/graph/adjacency_list.hpp>
@@ -179,21 +181,20 @@
void
CcnxGlobalRoutingHelper::CalculateRoutes ()
{
- NS_LOG_DEBUG ("Enter");
+ /**
+ * Implementation of route calculation is heavily based on Boost Graph Library
+ * See http://www.boost.org/doc/libs/1_49_0/libs/graph/doc/table_of_contents.html for more details
+ */
+
BOOST_CONCEPT_ASSERT(( VertexListGraphConcept< CcnxGlobalRouterGraph > ));
BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept< CcnxGlobalRouterGraph > ));
- // BOOST_CONCEPT_ASSERT(( ReadablePropertyMapConcept< CcnxGlobalRouterGraph,
- // graph_traits < CcnxGlobalRouterGraph >::edge_descriptor > ));
- // BOOST_CONCEPT_ASSERT(( PropertyGraphConcept< CcnxGlobalRouterGraph,
- // graph_traits < CcnxGlobalRouterGraph >::edge_descriptor,
- // edge_weight_t> ));
- // BOOST_CONCEPT_ASSERT(( PropertyMapConcept< CcnxGlobalRouterGraph, edge_weight_t,
- // graph_traits < CcnxGlobalRouterGraph >::edge_descriptor> ));
-
CcnxGlobalRouterGraph graph;
typedef graph_traits < CcnxGlobalRouterGraph >::vertex_descriptor vertex_descriptor;
+ // For now we doing Dijkstra for every node. Can be replaced with Bellman-Ford or Floyd-Warshall.
+ // Other algorithms should be faster, but they need additional EdgeListGraph concept provided by the graph, which
+ // is not obviously how implement in an efficient manner
for (NodeList::Iterator node = NodeList::Begin (); node != NodeList::End (); node++)
{
Ptr<CcnxGlobalRouter> source = (*node)->GetObject<CcnxGlobalRouter> ();
@@ -203,7 +204,6 @@
continue;
}
- // PredecessorsMap predecessors;
DistancesMap distances;
dijkstra_shortest_paths (graph, source,
@@ -221,8 +221,12 @@
);
// NS_LOG_DEBUG (predecessors.size () << ", " << distances.size ());
-
- cout << "Reachability from Node: " << source->GetObject<Node> ()->GetId () << endl;
+
+ Ptr<CcnxFib> fib = source->GetObject<CcnxFib> ();
+ fib->InvalidateAll ();
+ NS_ASSERT (fib != 0);
+
+ // cout << "Reachability from Node: " << source->GetObject<Node> ()->GetId () << endl;
for (DistancesMap::iterator i = distances.begin ();
i != distances.end ();
i++)
@@ -231,17 +235,24 @@
continue;
else
{
- cout << " Node " << i->first->GetObject<Node> ()->GetId ();
- if (distances[i->first].get<0> () == 0)
- cout << " is unreachable" << endl;
+ // cout << " Node " << i->first->GetObject<Node> ()->GetId ();
+ if (i->second.get<0> () == 0)
+ {
+ // cout << " is unreachable" << endl;
+ }
else
- cout << " reachable via face " << *i->second.get<0> ()
- << " with distance " << i->second.get<1> () << endl;
+ {
+ // cout << " reachable via face " << *i->second.get<0> ()
+ // << " with distance " << i->second.get<1> () << endl;
+
+ BOOST_FOREACH (const Ptr<const CcnxNameComponents> &prefix, i->first->GetLocalPrefixes ())
+ {
+ fib->Add (prefix, i->second.get<0> (), i->second.get<1> ());
+ }
+ }
}
}
-
}
- // NS_LOG_DEBUG ("Exit");
}
diff --git a/helper/ccnx-stack-helper.h b/helper/ccnx-stack-helper.h
index 6cd3745..f7ebd62 100644
--- a/helper/ccnx-stack-helper.h
+++ b/helper/ccnx-stack-helper.h
@@ -171,44 +171,6 @@
void
SetDefaultRoutes (bool needSet);
- /**
- * \brief Install fake IPv4 routes that could be used to find nexthops for CCNx routes
- *
- * This method adds fake routes to all nodes, where each route is /32 and IPv4 address equal to node number.
- * For example, node 5 will have direct route to 0.0.0.5.
- */
- static void
- InstallFakeGlobalRoutes ();
-
- static void
- InstallFakeGlobalRoutesImpl ();
-
- /**
- * \brief Install CCNx route to `node` based on fake IPv4 routes
- *
- * Actual route is "/<nodeId>"
- *
- * \param node Pointer to a node, which should be reached from all other nodes
- */
- static void
- InstallRouteTo (Ptr<Node> node);
-
- /**
- * \brief Install CCNx route to /prefix which is installed on `node'
- *
- * Normally, prefix is /<node->GetId()>. Other values may be used in black-holing scenarios
- */
- static void
- InstallRouteTo (const std::string &prefix, Ptr<Node> node);
-
- /**
- * \brief Install CCNx route to all nodes based on fake IPv4 routes
- *
- * \see InstallRouteTo
- */
- static void
- InstallRoutesToAll ();
-
private:
CcnxStackHelper (const CcnxStackHelper &);
CcnxStackHelper &operator = (const CcnxStackHelper &o);
@@ -219,56 +181,7 @@
Time m_avgRtt;
uint32_t m_avgContentObjectSize;
uint32_t m_avgInterestSize;
- bool m_needSetDefaultRoutes;
-
- // /**
- // * @brief Enable pcap output the indicated Ccnx and interface pair.
- // * @internal
- // *
- // * @param prefix Filename prefix to use for pcap files.
- // * @param ccnx Ptr to the Ccnx interface on which you want to enable tracing.
- // * @param interface Interface ID on the Ccnx on which you want to enable tracing.
- // */
- // virtual void EnablePcapCcnxInternal (std::string prefix,
- // Ptr<Ccnx> ccnx,
- // uint32_t interface,
- // bool explicitFilename);
-
- // /**
- // * @brief Enable ascii trace output on the indicated Ccnx and interface pair.
- // * @internal
- // *
- // * @param stream An OutputStreamWrapper representing an existing file to use
- // * when writing trace data.
- // * @param prefix Filename prefix to use for ascii trace files.
- // * @param ccnx Ptr to the Ccnx interface on which you want to enable tracing.
- // * @param interface Interface ID on the Ccnx on which you want to enable tracing.
- // */
- // virtual void EnableAsciiCcnxInternal (Ptr<OutputStreamWrapper> stream,
- // std::string prefix,
- // Ptr<Ccnx> ccnx,
- // uint32_t interface,
- // bool explicitFilename);
-
- // // /**
- // // * \internal
- // // */
- // // static void CreateAndAggregateObjectFromTypeId (Ptr<Node> node, const std::string typeId);
-
- // /**
- // * \internal
- // */
- // static void Cleanup (void);
-
- // /**
- // * \internal
- // */
- // bool PcapHooked (Ptr<Ccnx> ccnx);
-
- // /**
- // * \internal
- // */
- // bool AsciiHooked (Ptr<Ccnx> ccnx);
+ bool m_needSetDefaultRoutes;
};
} // namespace ns3