src: Updating code style to conform (more or less) to ndn-cxx style
Also, adding .clang-format that describes the applied style. Note that
this style requires a slightly customized version of clang-format.
diff --git a/helper/boost-graph-ndn-global-routing-helper.hpp b/helper/boost-graph-ndn-global-routing-helper.hpp
index e615494..85bac72 100644
--- a/helper/boost-graph-ndn-global-routing-helper.hpp
+++ b/helper/boost-graph-ndn-global-routing-helper.hpp
@@ -18,7 +18,6 @@
* Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-
#ifndef BOOST_GRAPH_NDN_GLOBAL_ROUTING_HELPER_H
#define BOOST_GRAPH_NDN_GLOBAL_ROUTING_HELPER_H
@@ -38,51 +37,45 @@
namespace boost {
-class NdnGlobalRouterGraph
-{
+class NdnGlobalRouterGraph {
public:
- typedef ns3::Ptr< ns3::ndn::GlobalRouter > Vertice;
+ typedef ns3::Ptr<ns3::ndn::GlobalRouter> Vertice;
typedef uint16_t edge_property_type;
typedef uint32_t vertex_property_type;
-
- NdnGlobalRouterGraph ()
- {
- for (ns3::NodeList::Iterator node = ns3::NodeList::Begin (); node != ns3::NodeList::End (); node++)
- {
- ns3::Ptr<ns3::ndn::GlobalRouter> gr = (*node)->GetObject<ns3::ndn::GlobalRouter> ();
- if (gr != 0)
- m_vertices.push_back (gr);
- }
- for (ns3::ChannelList::Iterator channel = ns3::ChannelList::Begin (); channel != ns3::ChannelList::End (); channel++)
- {
- ns3::Ptr<ns3::ndn::GlobalRouter> gr = (*channel)->GetObject<ns3::ndn::GlobalRouter> ();
- if (gr != 0)
- m_vertices.push_back (gr);
- }
+ NdnGlobalRouterGraph()
+ {
+ for (ns3::NodeList::Iterator node = ns3::NodeList::Begin(); node != ns3::NodeList::End();
+ node++) {
+ ns3::Ptr<ns3::ndn::GlobalRouter> gr = (*node)->GetObject<ns3::ndn::GlobalRouter>();
+ if (gr != 0)
+ m_vertices.push_back(gr);
+ }
+
+ for (ns3::ChannelList::Iterator channel = ns3::ChannelList::Begin();
+ channel != ns3::ChannelList::End(); channel++) {
+ ns3::Ptr<ns3::ndn::GlobalRouter> gr = (*channel)->GetObject<ns3::ndn::GlobalRouter>();
+ if (gr != 0)
+ m_vertices.push_back(gr);
+ }
}
- const std::list< Vertice > &
- GetVertices () const
+ const std::list<Vertice>&
+ GetVertices() const
{
return m_vertices;
}
-
+
public:
- std::list< Vertice > m_vertices;
+ std::list<Vertice> m_vertices;
};
-
-class ndn_global_router_graph_category :
- public virtual vertex_list_graph_tag,
- public virtual incidence_graph_tag
-{
+class ndn_global_router_graph_category : public virtual vertex_list_graph_tag,
+ public virtual incidence_graph_tag {
};
-
template<>
-struct graph_traits< NdnGlobalRouterGraph >
-{
+struct graph_traits<NdnGlobalRouterGraph> {
// Graph concept
typedef NdnGlobalRouterGraph::Vertice vertex_descriptor;
typedef ns3::ndn::GlobalRouter::Incidency edge_descriptor;
@@ -91,7 +84,7 @@
typedef ndn_global_router_graph_category traversal_category;
// VertexList concept
- typedef std::list< vertex_descriptor >::const_iterator vertex_iterator;
+ typedef std::list<vertex_descriptor>::const_iterator vertex_iterator;
typedef size_t vertices_size_type;
// AdjacencyGraph concept
@@ -103,265 +96,223 @@
} // namespace boost
-namespace boost
-{
+namespace boost {
-inline
-graph_traits< NdnGlobalRouterGraph >::vertex_descriptor
-source(
- graph_traits< NdnGlobalRouterGraph >::edge_descriptor e,
- const NdnGlobalRouterGraph& g)
+inline graph_traits<NdnGlobalRouterGraph>::vertex_descriptor
+source(graph_traits<NdnGlobalRouterGraph>::edge_descriptor e, const NdnGlobalRouterGraph& g)
{
- return e.get<0> ();
+ return e.get<0>();
}
-inline
-graph_traits< NdnGlobalRouterGraph >::vertex_descriptor
-target(
- graph_traits< NdnGlobalRouterGraph >::edge_descriptor e,
- const NdnGlobalRouterGraph& g)
+inline graph_traits<NdnGlobalRouterGraph>::vertex_descriptor
+target(graph_traits<NdnGlobalRouterGraph>::edge_descriptor e, const NdnGlobalRouterGraph& g)
{
- return e.get<2> ();
+ return e.get<2>();
}
-inline
-std::pair< graph_traits< NdnGlobalRouterGraph >::vertex_iterator,
- graph_traits< NdnGlobalRouterGraph >::vertex_iterator >
-vertices (const NdnGlobalRouterGraph&g)
+inline std::pair<graph_traits<NdnGlobalRouterGraph>::vertex_iterator,
+ graph_traits<NdnGlobalRouterGraph>::vertex_iterator>
+vertices(const NdnGlobalRouterGraph& g)
{
- return make_pair (g.GetVertices ().begin (), g.GetVertices ().end ());
+ return make_pair(g.GetVertices().begin(), g.GetVertices().end());
}
-inline
-graph_traits< NdnGlobalRouterGraph >::vertices_size_type
-num_vertices(const NdnGlobalRouterGraph &g)
+inline graph_traits<NdnGlobalRouterGraph>::vertices_size_type
+num_vertices(const NdnGlobalRouterGraph& g)
{
- return g.GetVertices ().size ();
-}
-
-
-inline
-std::pair< graph_traits< NdnGlobalRouterGraph >::out_edge_iterator,
- graph_traits< NdnGlobalRouterGraph >::out_edge_iterator >
-out_edges(
- graph_traits< NdnGlobalRouterGraph >::vertex_descriptor u,
- const NdnGlobalRouterGraph& g)
-{
- return std::make_pair(u->GetIncidencies ().begin (),
- u->GetIncidencies ().end ());
+ return g.GetVertices().size();
}
-inline
-graph_traits< NdnGlobalRouterGraph >::degree_size_type
-out_degree(
- graph_traits< NdnGlobalRouterGraph >::vertex_descriptor u,
- const NdnGlobalRouterGraph& g)
+inline std::pair<graph_traits<NdnGlobalRouterGraph>::out_edge_iterator,
+ graph_traits<NdnGlobalRouterGraph>::out_edge_iterator>
+out_edges(graph_traits<NdnGlobalRouterGraph>::vertex_descriptor u, const NdnGlobalRouterGraph& g)
{
- return u->GetIncidencies ().size ();
+ return std::make_pair(u->GetIncidencies().begin(), u->GetIncidencies().end());
}
+inline graph_traits<NdnGlobalRouterGraph>::degree_size_type
+out_degree(graph_traits<NdnGlobalRouterGraph>::vertex_descriptor u, const NdnGlobalRouterGraph& g)
+{
+ return u->GetIncidencies().size();
+}
//////////////////////////////////////////////////////////////
// Property maps
-struct EdgeWeights
-{
- EdgeWeights (const NdnGlobalRouterGraph &graph)
- : m_graph (graph)
- {
+struct EdgeWeights {
+ EdgeWeights(const NdnGlobalRouterGraph& graph)
+ : m_graph(graph)
+ {
}
private:
- const NdnGlobalRouterGraph &m_graph;
+ const NdnGlobalRouterGraph& m_graph;
};
-
-struct VertexIds
-{
- VertexIds (const NdnGlobalRouterGraph &graph)
- : m_graph (graph)
- {
+struct VertexIds {
+ VertexIds(const NdnGlobalRouterGraph& graph)
+ : m_graph(graph)
+ {
}
private:
- const NdnGlobalRouterGraph &m_graph;
+ const NdnGlobalRouterGraph& m_graph;
};
template<>
-struct property_map< NdnGlobalRouterGraph, edge_weight_t >
-{
+struct property_map<NdnGlobalRouterGraph, edge_weight_t> {
typedef const EdgeWeights const_type;
typedef EdgeWeights type;
};
template<>
-struct property_map< NdnGlobalRouterGraph, vertex_index_t >
-{
+struct property_map<NdnGlobalRouterGraph, vertex_index_t> {
typedef const VertexIds const_type;
typedef VertexIds type;
};
-
template<>
-struct property_traits< EdgeWeights >
-{
+struct property_traits<EdgeWeights> {
// Metric property map
- typedef tuple< ns3::Ptr<ns3::ndn::Face>, uint16_t, double > value_type;
- typedef tuple< ns3::Ptr<ns3::ndn::Face>, uint16_t, double > reference;
+ typedef tuple<ns3::Ptr<ns3::ndn::Face>, uint16_t, double> value_type;
+ typedef tuple<ns3::Ptr<ns3::ndn::Face>, uint16_t, double> reference;
typedef ns3::ndn::GlobalRouter::Incidency key_type;
typedef readable_property_map_tag category;
};
-const property_traits< EdgeWeights >::value_type WeightZero (0, 0, 0.0);
-const property_traits< EdgeWeights >::value_type WeightInf (0, std::numeric_limits<uint16_t>::max (), 0.0);
+const property_traits<EdgeWeights>::value_type WeightZero(0, 0, 0.0);
+const property_traits<EdgeWeights>::value_type
+ WeightInf(0, std::numeric_limits<uint16_t>::max(), 0.0);
-struct WeightCompare :
- public std::binary_function<property_traits< EdgeWeights >::reference,
- property_traits< EdgeWeights >::reference,
- bool>
-{
+struct WeightCompare : public std::binary_function<property_traits<EdgeWeights>::reference,
+ property_traits<EdgeWeights>::reference, bool> {
bool
- operator () (tuple< ns3::Ptr<ns3::ndn::Face>, uint32_t, double > a,
- tuple< ns3::Ptr<ns3::ndn::Face>, uint32_t, double > b) const
+ operator()(tuple<ns3::Ptr<ns3::ndn::Face>, uint32_t, double> a,
+ tuple<ns3::Ptr<ns3::ndn::Face>, uint32_t, double> b) const
{
- return a.get<1> () < b.get<1> ();
+ return a.get<1>() < b.get<1>();
}
bool
- operator () (property_traits< EdgeWeights >::reference a,
- uint32_t b) const
+ operator()(property_traits<EdgeWeights>::reference a, uint32_t b) const
{
- return a.get<1> () < b;
+ return a.get<1>() < b;
}
-
+
bool
- operator () (uint32_t a,
- uint32_t b) const
+ operator()(uint32_t a, uint32_t b) const
{
return a < b;
}
-
};
-struct WeightCombine :
- public std::binary_function<uint32_t,
- property_traits< EdgeWeights >::reference,
- uint32_t>
-{
+struct WeightCombine
+ : public std::binary_function<uint32_t, property_traits<EdgeWeights>::reference, uint32_t> {
uint32_t
- operator () (uint32_t a, property_traits< EdgeWeights >::reference b) const
+ operator()(uint32_t a, property_traits<EdgeWeights>::reference b) const
{
- return a + b.get<1> ();
+ return a + b.get<1>();
}
- tuple< ns3::Ptr<ns3::ndn::Face>, uint32_t, double >
- operator () (tuple< ns3::Ptr<ns3::ndn::Face>, uint32_t, double > a,
- property_traits< EdgeWeights >::reference b) const
+ tuple<ns3::Ptr<ns3::ndn::Face>, uint32_t, double>
+ operator()(tuple<ns3::Ptr<ns3::ndn::Face>, uint32_t, double> a,
+ property_traits<EdgeWeights>::reference b) const
{
- if (a.get<0> () == 0)
- return make_tuple (b.get<0> (), a.get<1> () + b.get<1> (), a.get<2> () + b.get<2> ());
+ if (a.get<0>() == 0)
+ return make_tuple(b.get<0>(), a.get<1>() + b.get<1>(), a.get<2>() + b.get<2>());
else
- return make_tuple (a.get<0> (), a.get<1> () + b.get<1> (), a.get<2> () + b.get<2> ());
+ return make_tuple(a.get<0>(), a.get<1>() + b.get<1>(), a.get<2>() + b.get<2>());
}
};
-
+
template<>
-struct property_traits< VertexIds >
-{
+struct property_traits<VertexIds> {
// Metric property map
typedef uint32_t value_type;
typedef uint32_t reference;
- typedef ns3::Ptr< ns3::ndn::GlobalRouter > key_type;
+ typedef ns3::Ptr<ns3::ndn::GlobalRouter> key_type;
typedef readable_property_map_tag category;
};
-
inline EdgeWeights
-get(edge_weight_t,
- const NdnGlobalRouterGraph &g)
+get(edge_weight_t, const NdnGlobalRouterGraph& g)
{
- return EdgeWeights (g);
+ return EdgeWeights(g);
}
-
inline VertexIds
-get(vertex_index_t,
- const NdnGlobalRouterGraph &g)
+get(vertex_index_t, const NdnGlobalRouterGraph& g)
{
- return VertexIds (g);
+ return VertexIds(g);
}
template<class M, class K, class V>
inline void
-put (reference_wrapper< M > mapp,
- K a, V p)
+put(reference_wrapper<M> mapp, K a, V p)
{
- mapp.get ()[a] = p;
+ mapp.get()[a] = p;
}
// void
// put (cref< std::map< ns3::Ptr<ns3::ndn::GlobalRouter>, ns3::Ptr<ns3::ndn::GlobalRouter> > > map,
inline uint32_t
-get (const boost::VertexIds&, ns3::Ptr<ns3::ndn::GlobalRouter> &gr)
+get(const boost::VertexIds&, ns3::Ptr<ns3::ndn::GlobalRouter>& gr)
{
- return gr->GetId ();
+ return gr->GetId();
}
-inline property_traits< EdgeWeights >::reference
-get(const boost::EdgeWeights&, ns3::ndn::GlobalRouter::Incidency &edge)
+inline property_traits<EdgeWeights>::reference
+get(const boost::EdgeWeights&, ns3::ndn::GlobalRouter::Incidency& edge)
{
- if (edge.get<1> () == 0)
- return property_traits< EdgeWeights >::reference (0, 0, 0.0);
- else
+ if (edge.get<1>() == 0)
+ return property_traits<EdgeWeights>::reference(0, 0, 0.0);
+ else {
+ ns3::Ptr<ns3::ndn::Limits> limits = edge.get<1>()->GetObject<ns3::ndn::Limits>();
+ double delay = 0.0;
+ if (limits != 0) // valid limits object
{
- ns3::Ptr<ns3::ndn::Limits> limits = edge.get<1> ()->GetObject<ns3::ndn::Limits> ();
- double delay = 0.0;
- if (limits != 0) // valid limits object
- {
- delay = limits->GetLinkDelay ();
- }
- return property_traits< EdgeWeights >::reference (edge.get<1> (), edge.get<1> ()->GetMetric (), delay);
+ delay = limits->GetLinkDelay();
}
+ return property_traits<EdgeWeights>::reference(edge.get<1>(), edge.get<1>()->GetMetric(),
+ delay);
+ }
}
-struct PredecessorsMap :
- public std::map< ns3::Ptr< ns3::ndn::GlobalRouter >, ns3::Ptr< ns3::ndn::GlobalRouter > >
-{
+struct PredecessorsMap
+ : public std::map<ns3::Ptr<ns3::ndn::GlobalRouter>, ns3::Ptr<ns3::ndn::GlobalRouter>> {
};
template<>
-struct property_traits< reference_wrapper<PredecessorsMap> >
-{
+struct property_traits<reference_wrapper<PredecessorsMap>> {
// Metric property map
- typedef ns3::Ptr< ns3::ndn::GlobalRouter > value_type;
- typedef ns3::Ptr< ns3::ndn::GlobalRouter > reference;
- typedef ns3::Ptr< ns3::ndn::GlobalRouter > key_type;
+ typedef ns3::Ptr<ns3::ndn::GlobalRouter> value_type;
+ typedef ns3::Ptr<ns3::ndn::GlobalRouter> reference;
+ typedef ns3::Ptr<ns3::ndn::GlobalRouter> key_type;
typedef read_write_property_map_tag category;
};
-
-struct DistancesMap :
- public std::map< ns3::Ptr< ns3::ndn::GlobalRouter >, tuple< ns3::Ptr<ns3::ndn::Face>, uint32_t, double > >
-{
+struct DistancesMap : public std::map<ns3::Ptr<ns3::ndn::GlobalRouter>,
+ tuple<ns3::Ptr<ns3::ndn::Face>, uint32_t, double>> {
};
template<>
-struct property_traits< reference_wrapper<DistancesMap> >
-{
+struct property_traits<reference_wrapper<DistancesMap>> {
// Metric property map
- typedef tuple< ns3::Ptr<ns3::ndn::Face>, uint32_t, double > value_type;
- typedef tuple< ns3::Ptr<ns3::ndn::Face>, uint32_t, double > reference;
- typedef ns3::Ptr< ns3::ndn::GlobalRouter > key_type;
+ typedef tuple<ns3::Ptr<ns3::ndn::Face>, uint32_t, double> value_type;
+ typedef tuple<ns3::Ptr<ns3::ndn::Face>, uint32_t, double> reference;
+ typedef ns3::Ptr<ns3::ndn::GlobalRouter> key_type;
typedef read_write_property_map_tag category;
};
-inline tuple< ns3::Ptr<ns3::ndn::Face>, uint32_t, double >
-get (DistancesMap &map, ns3::Ptr<ns3::ndn::GlobalRouter> key)
+inline tuple<ns3::Ptr<ns3::ndn::Face>, uint32_t, double>
+get(DistancesMap& map, ns3::Ptr<ns3::ndn::GlobalRouter> key)
{
- boost::DistancesMap::iterator i = map.find (key);
- if (i == map.end ())
- return tuple< ns3::Ptr<ns3::ndn::Face>, uint32_t, double > (0, std::numeric_limits<uint32_t>::max (), 0.0);
+ boost::DistancesMap::iterator i = map.find(key);
+ if (i == map.end())
+ return tuple<ns3::Ptr<ns3::ndn::Face>, uint32_t, double>(0,
+ std::numeric_limits<uint32_t>::max(),
+ 0.0);
else
return i->second;
}
diff --git a/helper/ndn-app-helper.cpp b/helper/ndn-app-helper.cpp
index b181f3b..f1f4381 100644
--- a/helper/ndn-app-helper.cpp
+++ b/helper/ndn-app-helper.cpp
@@ -28,75 +28,72 @@
#include "ns3/mpi-interface.h"
#endif
-NS_LOG_COMPONENT_DEFINE ("ndn.AppHelper");
+NS_LOG_COMPONENT_DEFINE("ndn.AppHelper");
namespace ns3 {
namespace ndn {
-AppHelper::AppHelper (const std::string &app)
+AppHelper::AppHelper(const std::string& app)
{
- m_factory.SetTypeId (app);
+ m_factory.SetTypeId(app);
}
void
-AppHelper::SetPrefix (const std::string &prefix)
+AppHelper::SetPrefix(const std::string& prefix)
{
- m_factory.Set ("Prefix", StringValue(prefix));
+ m_factory.Set("Prefix", StringValue(prefix));
}
-void
-AppHelper::SetAttribute (std::string name, const AttributeValue &value)
+void
+AppHelper::SetAttribute(std::string name, const AttributeValue& value)
{
- m_factory.Set (name, value);
+ m_factory.Set(name, value);
}
-
+
ApplicationContainer
-AppHelper::Install (Ptr<Node> node)
+AppHelper::Install(Ptr<Node> node)
{
ApplicationContainer apps;
- Ptr<Application> app = InstallPriv (node);
+ Ptr<Application> app = InstallPriv(node);
if (app != 0)
- apps.Add (app);
-
+ apps.Add(app);
+
return apps;
}
-
+
ApplicationContainer
-AppHelper::Install (std::string nodeName)
+AppHelper::Install(std::string nodeName)
{
- Ptr<Node> node = Names::Find<Node> (nodeName);
- return Install (node);
+ Ptr<Node> node = Names::Find<Node>(nodeName);
+ return Install(node);
}
-
+
ApplicationContainer
-AppHelper::Install (NodeContainer c)
+AppHelper::Install(NodeContainer c)
{
ApplicationContainer apps;
- for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
- {
- Ptr<Application> app = InstallPriv (*i);
- if (app != 0)
- apps.Add (app);
- }
-
+ for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) {
+ Ptr<Application> app = InstallPriv(*i);
+ if (app != 0)
+ apps.Add(app);
+ }
+
return apps;
}
-
+
Ptr<Application>
-AppHelper::InstallPriv (Ptr<Node> node)
+AppHelper::InstallPriv(Ptr<Node> node)
{
#ifdef NS3_MPI
- if (MpiInterface::IsEnabled () &&
- node->GetSystemId () != MpiInterface::GetSystemId ())
- {
- // don't create an app if MPI is enabled and node is not in the correct partition
- return 0;
- }
+ if (MpiInterface::IsEnabled() && node->GetSystemId() != MpiInterface::GetSystemId()) {
+ // don't create an app if MPI is enabled and node is not in the correct partition
+ return 0;
+ }
#endif
-
- Ptr<Application> app = m_factory.Create<Application> ();
- node->AddApplication (app);
-
+
+ Ptr<Application> app = m_factory.Create<Application>();
+ node->AddApplication(app);
+
return app;
}
diff --git a/helper/ndn-app-helper.hpp b/helper/ndn-app-helper.hpp
index e559260..63fa705 100644
--- a/helper/ndn-app-helper.hpp
+++ b/helper/ndn-app-helper.hpp
@@ -35,69 +35,72 @@
* \brief A helper to make it easier to instantiate an ns3::NdnConsumer Application
* on a set of nodes.
*/
-class AppHelper
-{
+class AppHelper {
public:
-
/**
* \brief Create an NdnAppHelper to make it easier to work with Ndn apps
*
* \param app Class of the application
*/
- AppHelper (const std::string &prefix);
+ AppHelper(const std::string& prefix);
/**
* @brief Set the prefix consumer will be requesting
*/
void
- SetPrefix (const std::string &prefix);
-
+ SetPrefix(const std::string& prefix);
+
/**
* \brief Helper function used to set the underlying application attributes.
*
* \param name the name of the application attribute to set
* \param value the value of the application attribute to set
*/
- void SetAttribute (std::string name, const AttributeValue &value);
-
+ void
+ SetAttribute(std::string name, const AttributeValue& value);
+
/**
* Install an ns3::NdnConsumer on each node of the input container
* configured with all the attributes set with SetAttribute.
*
- * \param c NodeContainer of the set of nodes on which an NdnConsumer
+ * \param c NodeContainer of the set of nodes on which an NdnConsumer
* will be installed.
* \returns Container of Ptr to the applications installed.
*/
- ApplicationContainer Install (NodeContainer c);
-
+ ApplicationContainer
+ Install(NodeContainer c);
+
/**
- * Install an ns3::NdnConsumer on the node configured with all the
+ * Install an ns3::NdnConsumer on the node configured with all the
* attributes set with SetAttribute.
*
* \param node The node on which an NdnConsumer will be installed.
* \returns Container of Ptr to the applications installed.
*/
- ApplicationContainer Install (Ptr<Node> node);
-
+ ApplicationContainer
+ Install(Ptr<Node> node);
+
/**
- * Install an ns3::NdnConsumer on the node configured with all the
+ * Install an ns3::NdnConsumer on the node configured with all the
* attributes set with SetAttribute.
*
* \param nodeName The node on which an NdnConsumer will be installed.
* \returns Container of Ptr to the applications installed.
*/
- ApplicationContainer Install (std::string nodeName);
-
+ ApplicationContainer
+ Install(std::string nodeName);
+
private:
/**
* \internal
- * Install an ns3::NdnConsumer on the node configured with all the
+ * Install an ns3::NdnConsumer on the node configured with all the
* attributes set with SetAttribute.
*
* \param node The node on which an NdnConsumer will be installed.
* \returns Ptr to the application installed.
*/
- Ptr<Application> InstallPriv (Ptr<Node> node);
+ Ptr<Application>
+ InstallPriv(Ptr<Node> node);
ObjectFactory m_factory;
};
@@ -105,4 +108,3 @@
} // namespace ns3
#endif // NDN_APP_HELPER_H
-
diff --git a/helper/ndn-face-container.cpp b/helper/ndn-face-container.cpp
index 69e90c9..150eea3 100644
--- a/helper/ndn-face-container.cpp
+++ b/helper/ndn-face-container.cpp
@@ -27,57 +27,55 @@
namespace ns3 {
namespace ndn {
-FaceContainer::FaceContainer ()
+FaceContainer::FaceContainer()
{
}
-FaceContainer::FaceContainer (const FaceContainer &other)
+FaceContainer::FaceContainer(const FaceContainer& other)
{
- AddAll (other);
+ AddAll(other);
}
FaceContainer&
FaceContainer::operator= (const FaceContainer &other)
{
- m_faces.clear ();
- AddAll (other);
+ m_faces.clear();
+ AddAll(other);
return *this;
}
-
void
-FaceContainer::AddAll (Ptr<FaceContainer> other)
+FaceContainer::AddAll(Ptr<FaceContainer> other)
{
- AddAll (*other);
+ AddAll(*other);
}
void
-FaceContainer::AddAll (const FaceContainer &other)
+FaceContainer::AddAll(const FaceContainer& other)
{
- m_faces.insert (m_faces.end (),
- other.m_faces.begin (), other.m_faces.end ());
+ m_faces.insert(m_faces.end(), other.m_faces.begin(), other.m_faces.end());
}
FaceContainer::Iterator
-FaceContainer::Begin (void) const
+FaceContainer::Begin(void) const
{
- return m_faces.begin ();
+ return m_faces.begin();
}
FaceContainer::Iterator
-FaceContainer::End (void) const
+FaceContainer::End(void) const
{
- return m_faces.end ();
+ return m_faces.end();
}
uint32_t
-FaceContainer::GetN (void) const
+FaceContainer::GetN(void) const
{
- return m_faces.size ();
+ return m_faces.size();
}
-// void
+// void
// FaceContainer::SetMetricToAll (uint16_t metric)
// {
// for (FaceContainer::iterator it=m_faces.begin ();
@@ -88,14 +86,14 @@
// }
// }
-void
-FaceContainer::Add (const Ptr<Face> &face)
+void
+FaceContainer::Add(const Ptr<Face>& face)
{
- m_faces.push_back (face);
+ m_faces.push_back(face);
}
Ptr<Face>
-FaceContainer::Get (FaceContainer::Iterator i) const
+FaceContainer::Get(FaceContainer::Iterator i) const
{
return *i;
}
diff --git a/helper/ndn-face-container.hpp b/helper/ndn-face-container.hpp
index f430c96..776a5ec 100644
--- a/helper/ndn-face-container.hpp
+++ b/helper/ndn-face-container.hpp
@@ -34,30 +34,30 @@
/**
* @ingroup ndn-helpers
* \brief A pool for Ndn faces
- *
+ *
* Provides tools to perform basic manipulation on faces, such as
* setting metrics and states on faces
*
* \see NdnStackHelper
*/
-class FaceContainer : public SimpleRefCount<FaceContainer>
-{
+class FaceContainer : public SimpleRefCount<FaceContainer> {
private:
- typedef std::vector< Ptr<Face> > Container;
+ typedef std::vector<Ptr<Face>> Container;
+
public:
typedef Container::const_iterator Iterator; ///< \brief Iterator over FaceContainer
/**
* \brief Create an empty FaceContainer.
*/
- FaceContainer ();
+ FaceContainer();
/**
* \brief Copy constructor for FaceContainer. Calls AddAll method
*
* \see FaceContainer::AddAll
*/
- FaceContainer (const FaceContainer &other);
+ FaceContainer(const FaceContainer& other);
/**
* \brief Copy operator for FaceContainer. Empties vector and calls AddAll method
@@ -66,21 +66,24 @@
*
* \see FaceContainer::AddAll
*/
- FaceContainer& operator= (const FaceContainer &other);
-
+ FaceContainer&
+ operator=(const FaceContainer& other);
+
/**
* \brief Add all entries from other container
*
* \param other smart pointer to a container
*/
- void AddAll (Ptr<FaceContainer> other);
+ void
+ AddAll(Ptr<FaceContainer> other);
/**
* \brief Add all entries from other container
*
* \param other container
*/
- void AddAll (const FaceContainer &other);
+ void
+ AddAll(const FaceContainer& other);
/**
* \brief Get an iterator which refers to the first pair in the
@@ -88,22 +91,25 @@
*
* \returns an iterator which refers to the first pair in the container.
*/
- Iterator Begin () const;
+ Iterator
+ Begin() const;
/**
- * \brief Get an iterator which indicates past-the-last Node in the
+ * \brief Get an iterator which indicates past-the-last Node in the
* container.
*
* \returns an iterator which indicates an ending condition for a loop.
*/
- Iterator End () const;
+ Iterator
+ End() const;
/**
* \brief Get the number of faces stored in this container
*
* \returns the number of faces stored in this container
*/
- uint32_t GetN () const;
+ uint32_t
+ GetN() const;
// /**
// * \brief Set a metric for all faces in the container
@@ -119,7 +125,8 @@
*
* @see Face
*/
- void Add (const Ptr<Face> &face);
+ void
+ Add(const Ptr<Face>& face);
/**
* Get a smart pointer to Face-derived object stored in the container
@@ -130,7 +137,8 @@
*
* @see Face
*/
- Ptr<Face> Get (Iterator i) const;
+ Ptr<Face>
+ Get(Iterator i) const;
private:
Container m_faces;
diff --git a/helper/ndn-global-routing-helper.cpp b/helper/ndn-global-routing-helper.cpp
index ac462c0..0528be3 100644
--- a/helper/ndn-global-routing-helper.cpp
+++ b/helper/ndn-global-routing-helper.cpp
@@ -54,7 +54,7 @@
#include <math.h>
-NS_LOG_COMPONENT_DEFINE ("ndn.GlobalRoutingHelper");
+NS_LOG_COMPONENT_DEFINE("ndn.GlobalRoutingHelper");
using namespace std;
using namespace boost;
@@ -63,398 +63,352 @@
namespace ndn {
void
-GlobalRoutingHelper::Install (Ptr<Node> node)
+GlobalRoutingHelper::Install(Ptr<Node> node)
{
- NS_LOG_LOGIC ("Node: " << node->GetId ());
+ NS_LOG_LOGIC("Node: " << node->GetId());
- Ptr<L3Protocol> ndn = node->GetObject<L3Protocol> ();
- NS_ASSERT_MSG (ndn != 0, "Cannot install GlobalRoutingHelper before Ndn is installed on a node");
+ Ptr<L3Protocol> ndn = node->GetObject<L3Protocol>();
+ NS_ASSERT_MSG(ndn != 0, "Cannot install GlobalRoutingHelper before Ndn is installed on a node");
- Ptr<GlobalRouter> gr = node->GetObject<GlobalRouter> ();
- if (gr != 0)
- {
- NS_LOG_DEBUG ("GlobalRouter is already installed: " << gr);
- return; // already installed
+ Ptr<GlobalRouter> gr = node->GetObject<GlobalRouter>();
+ if (gr != 0) {
+ NS_LOG_DEBUG("GlobalRouter is already installed: " << gr);
+ return; // already installed
+ }
+
+ gr = CreateObject<GlobalRouter>();
+ node->AggregateObject(gr);
+
+ for (uint32_t faceId = 0; faceId < ndn->GetNFaces(); faceId++) {
+ Ptr<NetDeviceFace> face = DynamicCast<NetDeviceFace>(ndn->GetFace(faceId));
+ if (face == 0) {
+ NS_LOG_DEBUG("Skipping non-netdevice face");
+ continue;
}
- gr = CreateObject<GlobalRouter> ();
- node->AggregateObject (gr);
-
- for (uint32_t faceId = 0; faceId < ndn->GetNFaces (); faceId++)
- {
- Ptr<NetDeviceFace> face = DynamicCast<NetDeviceFace> (ndn->GetFace (faceId));
- if (face == 0)
- {
- NS_LOG_DEBUG ("Skipping non-netdevice face");
- continue;
- }
-
- Ptr<NetDevice> nd = face->GetNetDevice ();
- if (nd == 0)
- {
- NS_LOG_DEBUG ("Not a NetDevice associated with NetDeviceFace");
- continue;
- }
-
- Ptr<Channel> ch = nd->GetChannel ();
-
- if (ch == 0)
- {
- NS_LOG_DEBUG ("Channel is not associated with NetDevice");
- continue;
- }
-
- if (ch->GetNDevices () == 2) // e.g., point-to-point channel
- {
- for (uint32_t deviceId = 0; deviceId < ch->GetNDevices (); deviceId ++)
- {
- Ptr<NetDevice> otherSide = ch->GetDevice (deviceId);
- if (nd == otherSide) continue;
-
- Ptr<Node> otherNode = otherSide->GetNode ();
- NS_ASSERT (otherNode != 0);
-
- Ptr<GlobalRouter> otherGr = otherNode->GetObject<GlobalRouter> ();
- if (otherGr == 0)
- {
- Install (otherNode);
- }
- otherGr = otherNode->GetObject<GlobalRouter> ();
- NS_ASSERT (otherGr != 0);
- gr->AddIncidency (face, otherGr);
- }
- }
- else
- {
- Ptr<GlobalRouter> grChannel = ch->GetObject<GlobalRouter> ();
- if (grChannel == 0)
- {
- Install (ch);
- }
- grChannel = ch->GetObject<GlobalRouter> ();
-
- gr->AddIncidency (face, grChannel);
- }
+ Ptr<NetDevice> nd = face->GetNetDevice();
+ if (nd == 0) {
+ NS_LOG_DEBUG("Not a NetDevice associated with NetDeviceFace");
+ continue;
}
+
+ Ptr<Channel> ch = nd->GetChannel();
+
+ if (ch == 0) {
+ NS_LOG_DEBUG("Channel is not associated with NetDevice");
+ continue;
+ }
+
+ if (ch->GetNDevices() == 2) // e.g., point-to-point channel
+ {
+ for (uint32_t deviceId = 0; deviceId < ch->GetNDevices(); deviceId++) {
+ Ptr<NetDevice> otherSide = ch->GetDevice(deviceId);
+ if (nd == otherSide)
+ continue;
+
+ Ptr<Node> otherNode = otherSide->GetNode();
+ NS_ASSERT(otherNode != 0);
+
+ Ptr<GlobalRouter> otherGr = otherNode->GetObject<GlobalRouter>();
+ if (otherGr == 0) {
+ Install(otherNode);
+ }
+ otherGr = otherNode->GetObject<GlobalRouter>();
+ NS_ASSERT(otherGr != 0);
+ gr->AddIncidency(face, otherGr);
+ }
+ }
+ else {
+ Ptr<GlobalRouter> grChannel = ch->GetObject<GlobalRouter>();
+ if (grChannel == 0) {
+ Install(ch);
+ }
+ grChannel = ch->GetObject<GlobalRouter>();
+
+ gr->AddIncidency(face, grChannel);
+ }
+ }
}
void
-GlobalRoutingHelper::Install (Ptr<Channel> channel)
+GlobalRoutingHelper::Install(Ptr<Channel> channel)
{
- NS_LOG_LOGIC ("Channel: " << channel->GetId ());
+ NS_LOG_LOGIC("Channel: " << channel->GetId());
- Ptr<GlobalRouter> gr = channel->GetObject<GlobalRouter> ();
+ Ptr<GlobalRouter> gr = channel->GetObject<GlobalRouter>();
if (gr != 0)
return;
- gr = CreateObject<GlobalRouter> ();
- channel->AggregateObject (gr);
+ gr = CreateObject<GlobalRouter>();
+ channel->AggregateObject(gr);
- for (uint32_t deviceId = 0; deviceId < channel->GetNDevices (); deviceId ++)
- {
- Ptr<NetDevice> dev = channel->GetDevice (deviceId);
+ for (uint32_t deviceId = 0; deviceId < channel->GetNDevices(); deviceId++) {
+ Ptr<NetDevice> dev = channel->GetDevice(deviceId);
- Ptr<Node> node = dev->GetNode ();
- NS_ASSERT (node != 0);
+ Ptr<Node> node = dev->GetNode();
+ NS_ASSERT(node != 0);
- Ptr<GlobalRouter> grOther = node->GetObject<GlobalRouter> ();
- if (grOther == 0)
- {
- Install (node);
- }
- grOther = node->GetObject<GlobalRouter> ();
- NS_ASSERT (grOther != 0);
-
- gr->AddIncidency (0, grOther);
+ Ptr<GlobalRouter> grOther = node->GetObject<GlobalRouter>();
+ if (grOther == 0) {
+ Install(node);
}
+ grOther = node->GetObject<GlobalRouter>();
+ NS_ASSERT(grOther != 0);
+
+ gr->AddIncidency(0, grOther);
+ }
}
void
-GlobalRoutingHelper::Install (const NodeContainer &nodes)
+GlobalRoutingHelper::Install(const NodeContainer& nodes)
{
- for (NodeContainer::Iterator node = nodes.Begin ();
- node != nodes.End ();
- node ++)
- {
- Install (*node);
+ for (NodeContainer::Iterator node = nodes.Begin(); node != nodes.End(); node++) {
+ Install(*node);
+ }
+}
+
+void
+GlobalRoutingHelper::InstallAll()
+{
+ Install(NodeContainer::GetGlobal());
+}
+
+void
+GlobalRoutingHelper::AddOrigin(const std::string& prefix, Ptr<Node> node)
+{
+ Ptr<GlobalRouter> gr = node->GetObject<GlobalRouter>();
+ NS_ASSERT_MSG(gr != 0, "GlobalRouter is not installed on the node");
+
+ Ptr<Name> name = Create<Name>(boost::lexical_cast<Name>(prefix));
+ gr->AddLocalPrefix(name);
+}
+
+void
+GlobalRoutingHelper::AddOrigins(const std::string& prefix, const NodeContainer& nodes)
+{
+ for (NodeContainer::Iterator node = nodes.Begin(); node != nodes.End(); node++) {
+ AddOrigin(prefix, *node);
+ }
+}
+
+void
+GlobalRoutingHelper::AddOrigin(const std::string& prefix, const std::string& nodeName)
+{
+ Ptr<Node> node = Names::Find<Node>(nodeName);
+ NS_ASSERT_MSG(node != 0, nodeName << "is not a Node");
+
+ AddOrigin(prefix, node);
+}
+
+void
+GlobalRoutingHelper::AddOriginsForAll()
+{
+ for (NodeList::Iterator node = NodeList::Begin(); node != NodeList::End(); node++) {
+ Ptr<GlobalRouter> gr = (*node)->GetObject<GlobalRouter>();
+ string name = Names::FindName(*node);
+
+ if (gr != 0 && !name.empty()) {
+ AddOrigin("/" + name, *node);
}
+ }
}
void
-GlobalRoutingHelper::InstallAll ()
-{
- Install (NodeContainer::GetGlobal ());
-}
-
-
-void
-GlobalRoutingHelper::AddOrigin (const std::string &prefix, Ptr<Node> node)
-{
- Ptr<GlobalRouter> gr = node->GetObject<GlobalRouter> ();
- NS_ASSERT_MSG (gr != 0,
- "GlobalRouter is not installed on the node");
-
- Ptr<Name> name = Create<Name> (boost::lexical_cast<Name> (prefix));
- gr->AddLocalPrefix (name);
-}
-
-void
-GlobalRoutingHelper::AddOrigins (const std::string &prefix, const NodeContainer &nodes)
-{
- for (NodeContainer::Iterator node = nodes.Begin ();
- node != nodes.End ();
- node++)
- {
- AddOrigin (prefix, *node);
- }
-}
-
-void
-GlobalRoutingHelper::AddOrigin (const std::string &prefix, const std::string &nodeName)
-{
- Ptr<Node> node = Names::Find<Node> (nodeName);
- NS_ASSERT_MSG (node != 0, nodeName << "is not a Node");
-
- AddOrigin (prefix, node);
-}
-
-void
-GlobalRoutingHelper::AddOriginsForAll ()
-{
- for (NodeList::Iterator node = NodeList::Begin (); node != NodeList::End (); node ++)
- {
- Ptr<GlobalRouter> gr = (*node)->GetObject<GlobalRouter> ();
- string name = Names::FindName (*node);
-
- if (gr != 0 && !name.empty ())
- {
- AddOrigin ("/"+name, *node);
- }
- }
-}
-
-void
-GlobalRoutingHelper::CalculateRoutes (bool invalidatedRoutes/* = true*/)
+GlobalRoutingHelper::CalculateRoutes(bool invalidatedRoutes /* = true*/)
{
/**
* 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< NdnGlobalRouterGraph > ));
- BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept< NdnGlobalRouterGraph > ));
+ BOOST_CONCEPT_ASSERT((VertexListGraphConcept<NdnGlobalRouterGraph>));
+ BOOST_CONCEPT_ASSERT((IncidenceGraphConcept<NdnGlobalRouterGraph>));
NdnGlobalRouterGraph graph;
// typedef graph_traits < NdnGlobalRouterGraph >::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
+ // 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<GlobalRouter> source = (*node)->GetObject<GlobalRouter> ();
- if (source == 0)
- {
- NS_LOG_DEBUG ("Node " << (*node)->GetId () << " does not export GlobalRouter interface");
- continue;
- }
+ for (NodeList::Iterator node = NodeList::Begin(); node != NodeList::End(); node++) {
+ Ptr<GlobalRouter> source = (*node)->GetObject<GlobalRouter>();
+ if (source == 0) {
+ NS_LOG_DEBUG("Node " << (*node)->GetId() << " does not export GlobalRouter interface");
+ continue;
+ }
- DistancesMap distances;
+ DistancesMap distances;
- dijkstra_shortest_paths (graph, source,
- // predecessor_map (boost::ref(predecessors))
- // .
- distance_map (boost::ref(distances))
- .
- distance_inf (WeightInf)
- .
- distance_zero (WeightZero)
- .
- distance_compare (boost::WeightCompare ())
- .
- distance_combine (boost::WeightCombine ())
- );
+ dijkstra_shortest_paths(graph, source,
+ // predecessor_map (boost::ref(predecessors))
+ // .
+ distance_map(boost::ref(distances))
+ .distance_inf(WeightInf)
+ .distance_zero(WeightZero)
+ .distance_compare(boost::WeightCompare())
+ .distance_combine(boost::WeightCombine()));
+
+ // NS_LOG_DEBUG (predecessors.size () << ", " << distances.size ());
+
+ Ptr<Fib> fib = source->GetObject<Fib>();
+ if (invalidatedRoutes) {
+ fib->InvalidateAll();
+ }
+ NS_ASSERT(fib != 0);
+
+ NS_LOG_DEBUG("Reachability from Node: " << source->GetObject<Node>()->GetId());
+ for (DistancesMap::iterator i = distances.begin(); i != distances.end(); i++) {
+ if (i->first == source)
+ continue;
+ else {
+ // cout << " Node " << i->first->GetObject<Node> ()->GetId ();
+ if (i->second.get<0>() == 0) {
+ // cout << " is unreachable" << endl;
+ }
+ else {
+ BOOST_FOREACH (const Ptr<const Name>& prefix, i->first->GetLocalPrefixes()) {
+ NS_LOG_DEBUG(" prefix " << prefix << " reachable via face " << *i->second.get<0>()
+ << " with distance " << i->second.get<1>() << " with delay "
+ << i->second.get<2>());
+
+ Ptr<fib::Entry> entry = fib->Add(prefix, i->second.get<0>(), i->second.get<1>());
+ entry->SetRealDelayToProducer(i->second.get<0>(), Seconds(i->second.get<2>()));
+
+ Ptr<Limits> faceLimits = i->second.get<0>()->GetObject<Limits>();
+
+ Ptr<Limits> fibLimits = entry->GetObject<Limits>();
+ if (fibLimits != 0) {
+ // if it was created by the forwarding strategy via DidAddFibEntry event
+ fibLimits->SetLimits(faceLimits->GetMaxRate(), 2 * i->second.get<2>() /*exact RTT*/);
+ NS_LOG_DEBUG("Set limit for prefix "
+ << *prefix << " " << faceLimits->GetMaxRate() << " / "
+ << 2 * i->second.get<2>() << "s ("
+ << faceLimits->GetMaxRate() * 2 * i->second.get<2>() << ")");
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void
+GlobalRoutingHelper::CalculateAllPossibleRoutes(bool invalidatedRoutes /* = true*/)
+{
+ /**
+ * 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<NdnGlobalRouterGraph>));
+ BOOST_CONCEPT_ASSERT((IncidenceGraphConcept<NdnGlobalRouterGraph>));
+
+ NdnGlobalRouterGraph graph;
+ // typedef graph_traits < NdnGlobalRouterGraph >::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<GlobalRouter> source = (*node)->GetObject<GlobalRouter>();
+ if (source == 0) {
+ NS_LOG_DEBUG("Node " << (*node)->GetId() << " does not export GlobalRouter interface");
+ continue;
+ }
+
+ Ptr<Fib> fib = source->GetObject<Fib>();
+ if (invalidatedRoutes) {
+ fib->InvalidateAll();
+ }
+ NS_ASSERT(fib != 0);
+
+ NS_LOG_DEBUG("===========");
+ NS_LOG_DEBUG("Reachability from Node: " << source->GetObject<Node>()->GetId() << " ("
+ << Names::FindName(source->GetObject<Node>()) << ")");
+
+ Ptr<L3Protocol> l3 = source->GetObject<L3Protocol>();
+ NS_ASSERT(l3 != 0);
+
+ // remember interface statuses
+ std::vector<uint16_t> originalMetric(l3->GetNFaces());
+ for (uint32_t faceId = 0; faceId < l3->GetNFaces(); faceId++) {
+ originalMetric[faceId] = l3->GetFace(faceId)->GetMetric();
+ l3->GetFace(faceId)
+ ->SetMetric(std::numeric_limits<uint16_t>::max()
+ - 1); // value std::numeric_limits<uint16_t>::max () MUST NOT be used (reserved)
+ }
+
+ for (uint32_t enabledFaceId = 0; enabledFaceId < l3->GetNFaces(); enabledFaceId++) {
+ if (DynamicCast<ndn::NetDeviceFace>(l3->GetFace(enabledFaceId)) == 0)
+ continue;
+
+ // enabling only faceId
+ l3->GetFace(enabledFaceId)->SetMetric(originalMetric[enabledFaceId]);
+
+ DistancesMap distances;
+
+ NS_LOG_DEBUG("-----------");
+
+ dijkstra_shortest_paths(graph, source,
+ // predecessor_map (boost::ref(predecessors))
+ // .
+ distance_map(boost::ref(distances))
+ .distance_inf(WeightInf)
+ .distance_zero(WeightZero)
+ .distance_compare(boost::WeightCompare())
+ .distance_combine(boost::WeightCombine()));
// NS_LOG_DEBUG (predecessors.size () << ", " << distances.size ());
- Ptr<Fib> fib = source->GetObject<Fib> ();
- if (invalidatedRoutes)
- {
- fib->InvalidateAll ();
- }
- NS_ASSERT (fib != 0);
+ for (DistancesMap::iterator i = distances.begin(); i != distances.end(); i++) {
+ if (i->first == source)
+ continue;
+ else {
+ // cout << " Node " << i->first->GetObject<Node> ()->GetId ();
+ if (i->second.get<0>() == 0) {
+ // cout << " is unreachable" << endl;
+ }
+ else {
+ BOOST_FOREACH (const Ptr<const Name>& prefix, i->first->GetLocalPrefixes()) {
+ NS_LOG_DEBUG(" prefix " << *prefix << " reachable via face " << *i->second.get<0>()
+ << " with distance " << i->second.get<1>() << " with delay "
+ << i->second.get<2>());
- NS_LOG_DEBUG ("Reachability from Node: " << source->GetObject<Node> ()->GetId ());
- for (DistancesMap::iterator i = distances.begin ();
- i != distances.end ();
- i++)
- {
- if (i->first == source)
- continue;
- else
- {
- // cout << " Node " << i->first->GetObject<Node> ()->GetId ();
- if (i->second.get<0> () == 0)
- {
- // cout << " is unreachable" << endl;
- }
- else
- {
- BOOST_FOREACH (const Ptr<const Name> &prefix, i->first->GetLocalPrefixes ())
- {
- NS_LOG_DEBUG (" prefix " << prefix << " reachable via face " << *i->second.get<0> ()
- << " with distance " << i->second.get<1> ()
- << " with delay " << i->second.get<2> ());
-
- Ptr<fib::Entry> entry = fib->Add (prefix, i->second.get<0> (), i->second.get<1> ());
- entry->SetRealDelayToProducer (i->second.get<0> (), Seconds (i->second.get<2> ()));
-
- Ptr<Limits> faceLimits = i->second.get<0> ()->GetObject<Limits> ();
-
- Ptr<Limits> fibLimits = entry->GetObject<Limits> ();
- if (fibLimits != 0)
- {
- // if it was created by the forwarding strategy via DidAddFibEntry event
- fibLimits->SetLimits (faceLimits->GetMaxRate (), 2 * i->second.get<2> () /*exact RTT*/);
- NS_LOG_DEBUG ("Set limit for prefix " << *prefix << " " << faceLimits->GetMaxRate () << " / " <<
- 2*i->second.get<2> () << "s (" << faceLimits->GetMaxRate () * 2 * i->second.get<2> () << ")");
- }
- }
- }
- }
- }
- }
-}
-
-void
-GlobalRoutingHelper::CalculateAllPossibleRoutes (bool invalidatedRoutes/* = true*/)
-{
- /**
- * 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< NdnGlobalRouterGraph > ));
- BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept< NdnGlobalRouterGraph > ));
-
- NdnGlobalRouterGraph graph;
- // typedef graph_traits < NdnGlobalRouterGraph >::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<GlobalRouter> source = (*node)->GetObject<GlobalRouter> ();
- if (source == 0)
- {
- NS_LOG_DEBUG ("Node " << (*node)->GetId () << " does not export GlobalRouter interface");
- continue;
- }
-
- Ptr<Fib> fib = source->GetObject<Fib> ();
- if (invalidatedRoutes)
- {
- fib->InvalidateAll ();
- }
- NS_ASSERT (fib != 0);
-
- NS_LOG_DEBUG ("===========");
- NS_LOG_DEBUG ("Reachability from Node: " << source->GetObject<Node> ()->GetId () << " (" << Names::FindName (source->GetObject<Node> ()) << ")");
-
- Ptr<L3Protocol> l3 = source->GetObject<L3Protocol> ();
- NS_ASSERT (l3 != 0);
-
- // remember interface statuses
- std::vector<uint16_t> originalMetric (l3->GetNFaces ());
- for (uint32_t faceId = 0; faceId < l3->GetNFaces (); faceId++)
- {
- originalMetric[faceId] = l3->GetFace (faceId)->GetMetric ();
- l3->GetFace (faceId)->SetMetric (std::numeric_limits<uint16_t>::max ()-1); // value std::numeric_limits<uint16_t>::max () MUST NOT be used (reserved)
- }
-
- for (uint32_t enabledFaceId = 0; enabledFaceId < l3->GetNFaces (); enabledFaceId++)
- {
- if (DynamicCast<ndn::NetDeviceFace> (l3->GetFace (enabledFaceId)) == 0)
- continue;
-
- // enabling only faceId
- l3->GetFace (enabledFaceId)->SetMetric (originalMetric[enabledFaceId]);
-
- DistancesMap distances;
-
- NS_LOG_DEBUG ("-----------");
-
- dijkstra_shortest_paths (graph, source,
- // predecessor_map (boost::ref(predecessors))
- // .
- distance_map (boost::ref(distances))
- .
- distance_inf (WeightInf)
- .
- distance_zero (WeightZero)
- .
- distance_compare (boost::WeightCompare ())
- .
- distance_combine (boost::WeightCombine ())
- );
-
- // NS_LOG_DEBUG (predecessors.size () << ", " << distances.size ());
-
- for (DistancesMap::iterator i = distances.begin ();
- i != distances.end ();
- i++)
- {
- if (i->first == source)
+ if (i->second.get<0>()->GetMetric() == std::numeric_limits<uint16_t>::max() - 1)
continue;
- else
- {
- // cout << " Node " << i->first->GetObject<Node> ()->GetId ();
- if (i->second.get<0> () == 0)
- {
- // cout << " is unreachable" << endl;
- }
- else
- {
- BOOST_FOREACH (const Ptr<const Name> &prefix, i->first->GetLocalPrefixes ())
- {
- NS_LOG_DEBUG (" prefix " << *prefix << " reachable via face " << *i->second.get<0> ()
- << " with distance " << i->second.get<1> ()
- << " with delay " << i->second.get<2> ());
- if (i->second.get<0> ()->GetMetric () == std::numeric_limits<uint16_t>::max ()-1)
- continue;
+ Ptr<fib::Entry> entry = fib->Add(prefix, i->second.get<0>(), i->second.get<1>());
+ entry->SetRealDelayToProducer(i->second.get<0>(), Seconds(i->second.get<2>()));
- Ptr<fib::Entry> entry = fib->Add (prefix, i->second.get<0> (), i->second.get<1> ());
- entry->SetRealDelayToProducer (i->second.get<0> (), Seconds (i->second.get<2> ()));
+ Ptr<Limits> faceLimits = i->second.get<0>()->GetObject<Limits>();
- Ptr<Limits> faceLimits = i->second.get<0> ()->GetObject<Limits> ();
-
- Ptr<Limits> fibLimits = entry->GetObject<Limits> ();
- if (fibLimits != 0)
- {
- // if it was created by the forwarding strategy via DidAddFibEntry event
- fibLimits->SetLimits (faceLimits->GetMaxRate (), 2 * i->second.get<2> () /*exact RTT*/);
- NS_LOG_DEBUG ("Set limit for prefix " << *prefix << " " << faceLimits->GetMaxRate () << " / " <<
- 2*i->second.get<2> () << "s (" << faceLimits->GetMaxRate () * 2 * i->second.get<2> () << ")");
- }
- }
- }
- }
+ Ptr<Limits> fibLimits = entry->GetObject<Limits>();
+ if (fibLimits != 0) {
+ // if it was created by the forwarding strategy via DidAddFibEntry event
+ fibLimits->SetLimits(faceLimits->GetMaxRate(),
+ 2 * i->second.get<2>() /*exact RTT*/);
+ NS_LOG_DEBUG("Set limit for prefix "
+ << *prefix << " " << faceLimits->GetMaxRate() << " / "
+ << 2 * i->second.get<2>() << "s ("
+ << faceLimits->GetMaxRate() * 2 * i->second.get<2>() << ")");
+ }
}
-
- // disabling the face again
- l3->GetFace (enabledFaceId)->SetMetric (std::numeric_limits<uint16_t>::max ()-1);
+ }
}
+ }
- // recover original interface statuses
- for (uint32_t faceId = 0; faceId < l3->GetNFaces (); faceId++)
- {
- l3->GetFace (faceId)->SetMetric (originalMetric[faceId]);
- }
+ // disabling the face again
+ l3->GetFace(enabledFaceId)->SetMetric(std::numeric_limits<uint16_t>::max() - 1);
}
-}
+ // recover original interface statuses
+ for (uint32_t faceId = 0; faceId < l3->GetNFaces(); faceId++) {
+ l3->GetFace(faceId)->SetMetric(originalMetric[faceId]);
+ }
+ }
+}
} // namespace ndn
} // namespace ns3
diff --git a/helper/ndn-global-routing-helper.hpp b/helper/ndn-global-routing-helper.hpp
index fa7dabd..a765ebf 100644
--- a/helper/ndn-global-routing-helper.hpp
+++ b/helper/ndn-global-routing-helper.hpp
@@ -35,8 +35,7 @@
* @ingroup ndn-helpers
* @brief Helper for GlobalRouter interface
*/
-class GlobalRoutingHelper
-{
+class GlobalRoutingHelper {
public:
/**
* @brief Install GlobalRouter interface on a node
@@ -46,8 +45,7 @@
* @param node Node to install GlobalRouter interface
*/
void
- Install (Ptr<Node> node);
-
+ Install(Ptr<Node> node);
/**
* @brief Install GlobalRouter interface on nodes
@@ -57,13 +55,13 @@
* @param nodes NodeContainer to install GlobalRouter interface
*/
void
- Install (const NodeContainer &nodes);
+ Install(const NodeContainer& nodes);
/**
* @brief Install GlobalRouter interface on all nodes
*/
void
- InstallAll ();
+ InstallAll();
/**
* @brief Add `prefix' as origin on `node'
@@ -71,7 +69,7 @@
* @param node Pointer to a node
*/
void
- AddOrigin (const std::string &prefix, Ptr<Node> node);
+ AddOrigin(const std::string& prefix, Ptr<Node> node);
/**
* @brief Add `prefix' as origin on all `nodes'
@@ -79,7 +77,7 @@
* @param nodes NodeContainer
*/
void
- AddOrigins (const std::string &prefix, const NodeContainer &nodes);
+ AddOrigins(const std::string& prefix, const NodeContainer& nodes);
/**
* @brief Add `prefix' as origin on node `nodeName'
@@ -87,37 +85,40 @@
* @param nodeName Name of the node that is associated with Ptr<Node> using ns3::Names
*/
void
- AddOrigin (const std::string &prefix, const std::string &nodeName);
+ AddOrigin(const std::string& prefix, const std::string& nodeName);
/**
* @brief Add origin to each node based on the node's name (using Names class)
*/
void
- AddOriginsForAll ();
+ AddOriginsForAll();
/**
* @brief Calculate for every node shortest path trees and install routes to all prefix origins
*
- * @param invalidatedRoutes flag indicating whether existing routes should be invalidated or keps as is
+ * @param invalidatedRoutes flag indicating whether existing routes should be invalidated or keps
+ *as is
*/
static void
- CalculateRoutes (bool invalidatedRoutes = true);
+ CalculateRoutes(bool invalidatedRoutes = true);
/**
* @brief Calculate all possible next-hop independent alternative routes
*
- * @param invalidatedRoutes flag indicating whether existing routes should be invalidated or keps as is
+ * @param invalidatedRoutes flag indicating whether existing routes should be invalidated or keps
+ *as is
*
* Refer to the implementation for more details.
*
- * Note that this method is highly experimental and should be used with caution (very time consuming).
+ * Note that this method is highly experimental and should be used with caution (very time
+ *consuming).
*/
static void
- CalculateAllPossibleRoutes (bool invalidatedRoutes = true);
+ CalculateAllPossibleRoutes(bool invalidatedRoutes = true);
private:
void
- Install (Ptr<Channel> channel);
+ Install(Ptr<Channel> channel);
};
} // namespace ndn
diff --git a/helper/ndn-link-control-helper.cpp b/helper/ndn-link-control-helper.cpp
index 1c43666..524ba46 100644
--- a/helper/ndn-link-control-helper.cpp
+++ b/helper/ndn-link-control-helper.cpp
@@ -31,109 +31,110 @@
#include "ns3/ndn-l3-protocol.hpp"
#include "ns3/ndn-net-device-face.hpp"
-NS_LOG_COMPONENT_DEFINE ("ndn.LinkControlHelper");
+NS_LOG_COMPONENT_DEFINE("ndn.LinkControlHelper");
namespace ns3 {
namespace ndn {
void
-LinkControlHelper::FailLink (Ptr<Node> node1, Ptr<Node> node2)
+LinkControlHelper::FailLink(Ptr<Node> node1, Ptr<Node> node2)
{
- NS_LOG_FUNCTION (node1 << node2);
-
- NS_ASSERT (node1 != 0);
- NS_ASSERT (node2 != 0);
-
- Ptr<ndn::L3Protocol> ndn1 = node1->GetObject<ndn::L3Protocol> ();
- Ptr<ndn::L3Protocol> ndn2 = node2->GetObject<ndn::L3Protocol> ();
+ NS_LOG_FUNCTION(node1 << node2);
- NS_ASSERT (ndn1 != 0);
- NS_ASSERT (ndn2 != 0);
+ NS_ASSERT(node1 != 0);
+ NS_ASSERT(node2 != 0);
+
+ Ptr<ndn::L3Protocol> ndn1 = node1->GetObject<ndn::L3Protocol>();
+ Ptr<ndn::L3Protocol> ndn2 = node2->GetObject<ndn::L3Protocol>();
+
+ NS_ASSERT(ndn1 != 0);
+ NS_ASSERT(ndn2 != 0);
// iterate over all faces to find the right one
- for (uint32_t faceId = 0; faceId < ndn1->GetNFaces (); faceId++)
- {
- Ptr<ndn::NetDeviceFace> ndFace = ndn1->GetFace (faceId)->GetObject<ndn::NetDeviceFace> ();
- if (ndFace == 0) continue;
+ for (uint32_t faceId = 0; faceId < ndn1->GetNFaces(); faceId++) {
+ Ptr<ndn::NetDeviceFace> ndFace = ndn1->GetFace(faceId)->GetObject<ndn::NetDeviceFace>();
+ if (ndFace == 0)
+ continue;
- Ptr<PointToPointNetDevice> nd1 = ndFace->GetNetDevice ()->GetObject<PointToPointNetDevice> ();
- if (nd1 == 0) continue;
+ Ptr<PointToPointNetDevice> nd1 = ndFace->GetNetDevice()->GetObject<PointToPointNetDevice>();
+ if (nd1 == 0)
+ continue;
- Ptr<Channel> channel = nd1->GetChannel ();
- if (channel == 0) continue;
+ Ptr<Channel> channel = nd1->GetChannel();
+ if (channel == 0)
+ continue;
- Ptr<PointToPointChannel> ppChannel = DynamicCast<PointToPointChannel> (channel);
+ Ptr<PointToPointChannel> ppChannel = DynamicCast<PointToPointChannel>(channel);
- Ptr<NetDevice> nd2 = ppChannel->GetDevice (0);
- if (nd2->GetNode () == node1)
- nd2 = ppChannel->GetDevice (1);
+ Ptr<NetDevice> nd2 = ppChannel->GetDevice(0);
+ if (nd2->GetNode() == node1)
+ nd2 = ppChannel->GetDevice(1);
- if (nd2->GetNode () == node2)
- {
- Ptr<ndn::Face> face1 = ndn1->GetFaceByNetDevice (nd1);
- Ptr<ndn::Face> face2 = ndn2->GetFaceByNetDevice (nd2);
+ if (nd2->GetNode() == node2) {
+ Ptr<ndn::Face> face1 = ndn1->GetFaceByNetDevice(nd1);
+ Ptr<ndn::Face> face2 = ndn2->GetFaceByNetDevice(nd2);
- face1->SetUp (false);
- face2->SetUp (false);
- break;
- }
+ face1->SetUp(false);
+ face2->SetUp(false);
+ break;
}
+ }
}
void
-LinkControlHelper::FailLinkByName (const std::string &node1, const std::string &node2)
+LinkControlHelper::FailLinkByName(const std::string& node1, const std::string& node2)
{
- FailLink (Names::Find<Node> (node1), Names::Find<Node> (node2));
+ FailLink(Names::Find<Node>(node1), Names::Find<Node>(node2));
}
void
-LinkControlHelper::UpLink (Ptr<Node> node1, Ptr<Node> node2)
+LinkControlHelper::UpLink(Ptr<Node> node1, Ptr<Node> node2)
{
- NS_LOG_FUNCTION (node1 << node2);
+ NS_LOG_FUNCTION(node1 << node2);
- NS_ASSERT (node1 != 0);
- NS_ASSERT (node2 != 0);
-
- Ptr<ndn::L3Protocol> ndn1 = node1->GetObject<ndn::L3Protocol> ();
- Ptr<ndn::L3Protocol> ndn2 = node2->GetObject<ndn::L3Protocol> ();
+ NS_ASSERT(node1 != 0);
+ NS_ASSERT(node2 != 0);
- NS_ASSERT (ndn1 != 0);
- NS_ASSERT (ndn2 != 0);
+ Ptr<ndn::L3Protocol> ndn1 = node1->GetObject<ndn::L3Protocol>();
+ Ptr<ndn::L3Protocol> ndn2 = node2->GetObject<ndn::L3Protocol>();
+
+ NS_ASSERT(ndn1 != 0);
+ NS_ASSERT(ndn2 != 0);
// iterate over all faces to find the right one
- for (uint32_t faceId = 0; faceId < ndn1->GetNFaces (); faceId++)
- {
- Ptr<ndn::NetDeviceFace> ndFace = ndn1->GetFace (faceId)->GetObject<ndn::NetDeviceFace> ();
- if (ndFace == 0) continue;
+ for (uint32_t faceId = 0; faceId < ndn1->GetNFaces(); faceId++) {
+ Ptr<ndn::NetDeviceFace> ndFace = ndn1->GetFace(faceId)->GetObject<ndn::NetDeviceFace>();
+ if (ndFace == 0)
+ continue;
- Ptr<PointToPointNetDevice> nd1 = ndFace->GetNetDevice ()->GetObject<PointToPointNetDevice> ();
- if (nd1 == 0) continue;
+ Ptr<PointToPointNetDevice> nd1 = ndFace->GetNetDevice()->GetObject<PointToPointNetDevice>();
+ if (nd1 == 0)
+ continue;
- Ptr<Channel> channel = nd1->GetChannel ();
- if (channel == 0) continue;
+ Ptr<Channel> channel = nd1->GetChannel();
+ if (channel == 0)
+ continue;
- Ptr<PointToPointChannel> ppChannel = DynamicCast<PointToPointChannel> (channel);
+ Ptr<PointToPointChannel> ppChannel = DynamicCast<PointToPointChannel>(channel);
- Ptr<NetDevice> nd2 = ppChannel->GetDevice (0);
- if (nd2->GetNode () == node1)
- nd2 = ppChannel->GetDevice (1);
+ Ptr<NetDevice> nd2 = ppChannel->GetDevice(0);
+ if (nd2->GetNode() == node1)
+ nd2 = ppChannel->GetDevice(1);
- if (nd2->GetNode () == node2)
- {
- Ptr<ndn::Face> face1 = ndn1->GetFaceByNetDevice (nd1);
- Ptr<ndn::Face> face2 = ndn2->GetFaceByNetDevice (nd2);
+ if (nd2->GetNode() == node2) {
+ Ptr<ndn::Face> face1 = ndn1->GetFaceByNetDevice(nd1);
+ Ptr<ndn::Face> face2 = ndn2->GetFaceByNetDevice(nd2);
- face1->SetUp (true);
- face2->SetUp (true);
- break;
- }
+ face1->SetUp(true);
+ face2->SetUp(true);
+ break;
}
+ }
}
void
-LinkControlHelper::UpLinkByName (const std::string &node1, const std::string &node2)
+LinkControlHelper::UpLinkByName(const std::string& node1, const std::string& node2)
{
- UpLink (Names::Find<Node> (node1), Names::Find<Node> (node2));
+ UpLink(Names::Find<Node>(node1), Names::Find<Node>(node2));
}
-
}
}
diff --git a/helper/ndn-link-control-helper.hpp b/helper/ndn-link-control-helper.hpp
index 1fb3251..6411a39 100644
--- a/helper/ndn-link-control-helper.hpp
+++ b/helper/ndn-link-control-helper.hpp
@@ -30,10 +30,10 @@
/**
* @ingroup ndn-helpers
- * @brief Helper class to control the up or down statuss of an NDN link connecting two specific nodes
+ * @brief Helper class to control the up or down statuss of an NDN link connecting two specific
+ * nodes
*/
-class LinkControlHelper
-{
+class LinkControlHelper {
public:
/**
* @brief Fail NDN link between two nodes
@@ -47,7 +47,7 @@
* @param node2 another node
*/
static void
- FailLink (Ptr<Node> node1, Ptr<Node> node2);
+ FailLink(Ptr<Node> node1, Ptr<Node> node2);
/**
* @brief Fail NDN link between two nodes
@@ -63,7 +63,7 @@
* @param node2 another node's name
*/
static void
- FailLinkByName (const std::string &node1, const std::string &node2);
+ FailLinkByName(const std::string& node1, const std::string& node2);
/**
* @brief Re-enable NDN link between two nodes
@@ -77,8 +77,8 @@
* @param node2 another node
*/
static void
- UpLink (Ptr<Node> node1, Ptr<Node> node2);
-
+ UpLink(Ptr<Node> node1, Ptr<Node> node2);
+
/**
* @brief Re-enable NDN link between two nodes
*
@@ -93,10 +93,9 @@
* @param node2 another node's name
*/
static void
- UpLinkByName (const std::string &node1, const std::string &node2);
+ UpLinkByName(const std::string& node1, const std::string& node2);
}; // end: LinkControlHelper
-
} // ndn
} // ns3
diff --git a/helper/ndn-stack-helper.cpp b/helper/ndn-stack-helper.cpp
index fe736b3..d1c2577 100644
--- a/helper/ndn-stack-helper.cpp
+++ b/helper/ndn-stack-helper.cpp
@@ -58,131 +58,129 @@
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
-NS_LOG_COMPONENT_DEFINE ("ndn.StackHelper");
+NS_LOG_COMPONENT_DEFINE("ndn.StackHelper");
namespace ns3 {
namespace ndn {
-StackHelper::StackHelper ()
- : m_limitsEnabled (false)
- , m_needSetDefaultRoutes (false)
+StackHelper::StackHelper()
+ : m_limitsEnabled(false)
+ , m_needSetDefaultRoutes(false)
{
- m_ndnFactory. SetTypeId ("ns3::ndn::L3Protocol");
- m_strategyFactory. SetTypeId ("ns3::ndn::fw::Flooding");
- m_contentStoreFactory.SetTypeId ("ns3::ndn::cs::Lru");
- m_fibFactory. SetTypeId ("ns3::ndn::fib::Default");
- m_pitFactory. SetTypeId ("ns3::ndn::pit::Persistent");
+ m_ndnFactory.SetTypeId("ns3::ndn::L3Protocol");
+ m_strategyFactory.SetTypeId("ns3::ndn::fw::Flooding");
+ m_contentStoreFactory.SetTypeId("ns3::ndn::cs::Lru");
+ m_fibFactory.SetTypeId("ns3::ndn::fib::Default");
+ m_pitFactory.SetTypeId("ns3::ndn::pit::Persistent");
- m_netDeviceCallbacks.push_back (std::make_pair (PointToPointNetDevice::GetTypeId (), MakeCallback (&StackHelper::PointToPointNetDeviceCallback, this)));
+ m_netDeviceCallbacks.push_back(
+ std::make_pair(PointToPointNetDevice::GetTypeId(),
+ MakeCallback(&StackHelper::PointToPointNetDeviceCallback, this)));
// default callback will be fired if non of others callbacks fit or did the job
}
-StackHelper::~StackHelper ()
+StackHelper::~StackHelper()
{
}
void
-StackHelper::SetStackAttributes (const std::string &attr1, const std::string &value1,
- const std::string &attr2, const std::string &value2,
- const std::string &attr3, const std::string &value3,
- const std::string &attr4, const std::string &value4)
+StackHelper::SetStackAttributes(const std::string& attr1, const std::string& value1,
+ const std::string& attr2, const std::string& value2,
+ const std::string& attr3, const std::string& value3,
+ const std::string& attr4, const std::string& value4)
{
if (attr1 != "")
- m_ndnFactory.Set (attr1, StringValue (value1));
+ m_ndnFactory.Set(attr1, StringValue(value1));
if (attr2 != "")
- m_ndnFactory.Set (attr2, StringValue (value2));
+ m_ndnFactory.Set(attr2, StringValue(value2));
if (attr3 != "")
- m_ndnFactory.Set (attr3, StringValue (value3));
+ m_ndnFactory.Set(attr3, StringValue(value3));
if (attr4 != "")
- m_ndnFactory.Set (attr4, StringValue (value4));
+ m_ndnFactory.Set(attr4, StringValue(value4));
}
void
-StackHelper::SetForwardingStrategy (const std::string &strategy,
- const std::string &attr1, const std::string &value1,
- const std::string &attr2, const std::string &value2,
- const std::string &attr3, const std::string &value3,
- const std::string &attr4, const std::string &value4)
+StackHelper::SetForwardingStrategy(const std::string& strategy, const std::string& attr1,
+ const std::string& value1, const std::string& attr2,
+ const std::string& value2, const std::string& attr3,
+ const std::string& value3, const std::string& attr4,
+ const std::string& value4)
{
- m_strategyFactory.SetTypeId (strategy);
+ m_strategyFactory.SetTypeId(strategy);
if (attr1 != "")
- m_strategyFactory.Set (attr1, StringValue (value1));
+ m_strategyFactory.Set(attr1, StringValue(value1));
if (attr2 != "")
- m_strategyFactory.Set (attr2, StringValue (value2));
+ m_strategyFactory.Set(attr2, StringValue(value2));
if (attr3 != "")
- m_strategyFactory.Set (attr3, StringValue (value3));
+ m_strategyFactory.Set(attr3, StringValue(value3));
if (attr4 != "")
- m_strategyFactory.Set (attr4, StringValue (value4));
+ m_strategyFactory.Set(attr4, StringValue(value4));
}
void
-StackHelper::SetContentStore (const std::string &contentStore,
- const std::string &attr1, const std::string &value1,
- const std::string &attr2, const std::string &value2,
- const std::string &attr3, const std::string &value3,
- const std::string &attr4, const std::string &value4)
+StackHelper::SetContentStore(const std::string& contentStore, const std::string& attr1,
+ const std::string& value1, const std::string& attr2,
+ const std::string& value2, const std::string& attr3,
+ const std::string& value3, const std::string& attr4,
+ const std::string& value4)
{
- m_contentStoreFactory.SetTypeId (contentStore);
+ m_contentStoreFactory.SetTypeId(contentStore);
if (attr1 != "")
- m_contentStoreFactory.Set (attr1, StringValue (value1));
+ m_contentStoreFactory.Set(attr1, StringValue(value1));
if (attr2 != "")
- m_contentStoreFactory.Set (attr2, StringValue (value2));
+ m_contentStoreFactory.Set(attr2, StringValue(value2));
if (attr3 != "")
- m_contentStoreFactory.Set (attr3, StringValue (value3));
+ m_contentStoreFactory.Set(attr3, StringValue(value3));
if (attr4 != "")
- m_contentStoreFactory.Set (attr4, StringValue (value4));
+ m_contentStoreFactory.Set(attr4, StringValue(value4));
}
void
-StackHelper::SetPit (const std::string &pitClass,
- const std::string &attr1, const std::string &value1,
- const std::string &attr2, const std::string &value2,
- const std::string &attr3, const std::string &value3,
- const std::string &attr4, const std::string &value4)
+StackHelper::SetPit(const std::string& pitClass, const std::string& attr1,
+ const std::string& value1, const std::string& attr2, const std::string& value2,
+ const std::string& attr3, const std::string& value3, const std::string& attr4,
+ const std::string& value4)
{
- m_pitFactory.SetTypeId (pitClass);
+ m_pitFactory.SetTypeId(pitClass);
if (attr1 != "")
- m_pitFactory.Set (attr1, StringValue (value1));
+ m_pitFactory.Set(attr1, StringValue(value1));
if (attr2 != "")
- m_pitFactory.Set (attr2, StringValue (value2));
+ m_pitFactory.Set(attr2, StringValue(value2));
if (attr3 != "")
- m_pitFactory.Set (attr3, StringValue (value3));
+ m_pitFactory.Set(attr3, StringValue(value3));
if (attr4 != "")
- m_pitFactory.Set (attr4, StringValue (value4));
+ m_pitFactory.Set(attr4, StringValue(value4));
}
void
-StackHelper::SetFib (const std::string &fibClass,
- const std::string &attr1, const std::string &value1,
- const std::string &attr2, const std::string &value2,
- const std::string &attr3, const std::string &value3,
- const std::string &attr4, const std::string &value4)
+StackHelper::SetFib(const std::string& fibClass, const std::string& attr1,
+ const std::string& value1, const std::string& attr2, const std::string& value2,
+ const std::string& attr3, const std::string& value3, const std::string& attr4,
+ const std::string& value4)
{
- m_fibFactory.SetTypeId (fibClass);
+ m_fibFactory.SetTypeId(fibClass);
if (attr1 != "")
- m_fibFactory.Set (attr1, StringValue (value1));
+ m_fibFactory.Set(attr1, StringValue(value1));
if (attr2 != "")
- m_fibFactory.Set (attr2, StringValue (value2));
+ m_fibFactory.Set(attr2, StringValue(value2));
if (attr3 != "")
- m_fibFactory.Set (attr3, StringValue (value3));
+ m_fibFactory.Set(attr3, StringValue(value3));
if (attr4 != "")
- m_fibFactory.Set (attr4, StringValue (value4));
+ m_fibFactory.Set(attr4, StringValue(value4));
}
void
-StackHelper::SetDefaultRoutes (bool needSet)
+StackHelper::SetDefaultRoutes(bool needSet)
{
- NS_LOG_FUNCTION (this << needSet);
+ NS_LOG_FUNCTION(this << needSet);
m_needSetDefaultRoutes = needSet;
}
void
-StackHelper::EnableLimits (bool enable/* = true*/,
- Time avgRtt/*=Seconds(0.1)*/,
- uint32_t avgData/*=1100*/,
- uint32_t avgInterest/*=40*/)
+StackHelper::EnableLimits(bool enable /* = true*/, Time avgRtt /*=Seconds(0.1)*/,
+ uint32_t avgData /*=1100*/, uint32_t avgInterest /*=40*/)
{
- NS_LOG_INFO ("EnableLimits: " << enable);
+ NS_LOG_INFO("EnableLimits: " << enable);
m_limitsEnabled = enable;
m_avgRtt = avgRtt;
m_avgDataSize = avgData;
@@ -190,276 +188,277 @@
}
Ptr<FaceContainer>
-StackHelper::Install (const NodeContainer &c) const
+StackHelper::Install(const NodeContainer& c) const
{
- Ptr<FaceContainer> faces = Create<FaceContainer> ();
- for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
- {
- faces->AddAll (Install (*i));
- }
+ Ptr<FaceContainer> faces = Create<FaceContainer>();
+ for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) {
+ faces->AddAll(Install(*i));
+ }
return faces;
}
Ptr<FaceContainer>
-StackHelper::InstallAll () const
+StackHelper::InstallAll() const
{
- return Install (NodeContainer::GetGlobal ());
+ return Install(NodeContainer::GetGlobal());
}
Ptr<FaceContainer>
-StackHelper::Install (Ptr<Node> node) const
+StackHelper::Install(Ptr<Node> node) const
{
- // NS_ASSERT_MSG (m_forwarding, "SetForwardingHelper() should be set prior calling Install() method");
- Ptr<FaceContainer> faces = Create<FaceContainer> ();
+ // NS_ASSERT_MSG (m_forwarding, "SetForwardingHelper() should be set prior calling Install()
+ // method");
+ Ptr<FaceContainer> faces = Create<FaceContainer>();
- if (node->GetObject<L3Protocol> () != 0)
- {
- NS_FATAL_ERROR ("StackHelper::Install (): Installing "
- "a NdnStack to a node with an existing Ndn object");
- return 0;
- }
+ if (node->GetObject<L3Protocol>() != 0) {
+ NS_FATAL_ERROR("StackHelper::Install (): Installing "
+ "a NdnStack to a node with an existing Ndn object");
+ return 0;
+ }
// Create L3Protocol
- Ptr<L3Protocol> ndn = m_ndnFactory.Create<L3Protocol> ();
+ Ptr<L3Protocol> ndn = m_ndnFactory.Create<L3Protocol>();
// Create and aggregate FIB
- Ptr<Fib> fib = m_fibFactory.Create<Fib> ();
- ndn->AggregateObject (fib);
+ Ptr<Fib> fib = m_fibFactory.Create<Fib>();
+ ndn->AggregateObject(fib);
// Create and aggregate PIT
- ndn->AggregateObject (m_pitFactory.Create<Pit> ());
+ ndn->AggregateObject(m_pitFactory.Create<Pit>());
// Create and aggregate forwarding strategy
- ndn->AggregateObject (m_strategyFactory.Create<ForwardingStrategy> ());
+ ndn->AggregateObject(m_strategyFactory.Create<ForwardingStrategy>());
// Create and aggregate content store
- ndn->AggregateObject (m_contentStoreFactory.Create<ContentStore> ());
+ ndn->AggregateObject(m_contentStoreFactory.Create<ContentStore>());
// Aggregate L3Protocol on node
- node->AggregateObject (ndn);
+ node->AggregateObject(ndn);
- for (uint32_t index=0; index < node->GetNDevices (); index++)
- {
- Ptr<NetDevice> device = node->GetDevice (index);
- // This check does not make sense: LoopbackNetDevice is installed only if IP stack is installed,
- // Normally, ndnSIM works without IP stack, so no reason to check
- // if (DynamicCast<LoopbackNetDevice> (device) != 0)
- // continue; // don't create face for a LoopbackNetDevice
+ for (uint32_t index = 0; index < node->GetNDevices(); index++) {
+ Ptr<NetDevice> device = node->GetDevice(index);
+ // This check does not make sense: LoopbackNetDevice is installed only if IP stack is installed,
+ // Normally, ndnSIM works without IP stack, so no reason to check
+ // if (DynamicCast<LoopbackNetDevice> (device) != 0)
+ // continue; // don't create face for a LoopbackNetDevice
- Ptr<NetDeviceFace> face;
+ Ptr<NetDeviceFace> face;
- for (std::list< std::pair<TypeId, NetDeviceFaceCreateCallback> >::const_iterator item = m_netDeviceCallbacks.begin ();
- item != m_netDeviceCallbacks.end ();
- item++)
- {
- if (device->GetInstanceTypeId () == item->first ||
- device->GetInstanceTypeId ().IsChildOf (item->first))
- {
- face = item->second (node, ndn, device);
- if (face != 0)
- break;
- }
- }
- if (face == 0)
- {
- face = DefaultNetDeviceCallback (node, ndn, device);
- }
-
- if (m_needSetDefaultRoutes)
- {
- // default route with lowest priority possible
- AddRoute (node, "/", StaticCast<Face> (face), std::numeric_limits<int32_t>::max ());
- }
-
- face->SetUp ();
- faces->Add (face);
+ for (std::list<std::pair<TypeId, NetDeviceFaceCreateCallback>>::const_iterator item =
+ m_netDeviceCallbacks.begin();
+ item != m_netDeviceCallbacks.end(); item++) {
+ if (device->GetInstanceTypeId() == item->first
+ || device->GetInstanceTypeId().IsChildOf(item->first)) {
+ face = item->second(node, ndn, device);
+ if (face != 0)
+ break;
+ }
}
+ if (face == 0) {
+ face = DefaultNetDeviceCallback(node, ndn, device);
+ }
+
+ if (m_needSetDefaultRoutes) {
+ // default route with lowest priority possible
+ AddRoute(node, "/", StaticCast<Face>(face), std::numeric_limits<int32_t>::max());
+ }
+
+ face->SetUp();
+ faces->Add(face);
+ }
return faces;
}
void
-StackHelper::AddNetDeviceFaceCreateCallback (TypeId netDeviceType, StackHelper::NetDeviceFaceCreateCallback callback)
+StackHelper::AddNetDeviceFaceCreateCallback(TypeId netDeviceType,
+ StackHelper::NetDeviceFaceCreateCallback callback)
{
- m_netDeviceCallbacks.push_back (std::make_pair (netDeviceType, callback));
+ m_netDeviceCallbacks.push_back(std::make_pair(netDeviceType, callback));
}
void
-StackHelper::UpdateNetDeviceFaceCreateCallback (TypeId netDeviceType, NetDeviceFaceCreateCallback callback)
+StackHelper::UpdateNetDeviceFaceCreateCallback(TypeId netDeviceType,
+ NetDeviceFaceCreateCallback callback)
{
- for (NetDeviceCallbackList::iterator i = m_netDeviceCallbacks.begin (); i != m_netDeviceCallbacks.end (); i++)
- {
- if (i->first == netDeviceType)
- {
- i->second = callback;
- return;
- }
+ for (NetDeviceCallbackList::iterator i = m_netDeviceCallbacks.begin();
+ i != m_netDeviceCallbacks.end(); i++) {
+ if (i->first == netDeviceType) {
+ i->second = callback;
+ return;
}
+ }
}
void
-StackHelper::RemoveNetDeviceFaceCreateCallback (TypeId netDeviceType, NetDeviceFaceCreateCallback callback)
+StackHelper::RemoveNetDeviceFaceCreateCallback(TypeId netDeviceType,
+ NetDeviceFaceCreateCallback callback)
{
- for (NetDeviceCallbackList::iterator i = m_netDeviceCallbacks.begin (); i != m_netDeviceCallbacks.end (); i++)
- {
- if (i->first == netDeviceType)
- {
- m_netDeviceCallbacks.erase (i);
- return;
- }
+ for (NetDeviceCallbackList::iterator i = m_netDeviceCallbacks.begin();
+ i != m_netDeviceCallbacks.end(); i++) {
+ if (i->first == netDeviceType) {
+ m_netDeviceCallbacks.erase(i);
+ return;
}
+ }
}
Ptr<NetDeviceFace>
-StackHelper::DefaultNetDeviceCallback (Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> netDevice) const
+StackHelper::DefaultNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn,
+ Ptr<NetDevice> netDevice) const
{
- NS_LOG_DEBUG ("Creating default NetDeviceFace on node " << node->GetId ());
+ NS_LOG_DEBUG("Creating default NetDeviceFace on node " << node->GetId());
- Ptr<NetDeviceFace> face = CreateObject<NetDeviceFace> (node, netDevice);
+ Ptr<NetDeviceFace> face = CreateObject<NetDeviceFace>(node, netDevice);
- ndn->AddFace (face);
- NS_LOG_LOGIC ("Node " << node->GetId () << ": added NetDeviceFace as face #" << *face);
+ ndn->AddFace(face);
+ NS_LOG_LOGIC("Node " << node->GetId() << ": added NetDeviceFace as face #" << *face);
return face;
}
Ptr<NetDeviceFace>
-StackHelper::PointToPointNetDeviceCallback (Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> device) const
+StackHelper::PointToPointNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn,
+ Ptr<NetDevice> device) const
{
- NS_LOG_DEBUG ("Creating point-to-point NetDeviceFace on node " << node->GetId ());
+ NS_LOG_DEBUG("Creating point-to-point NetDeviceFace on node " << node->GetId());
- Ptr<NetDeviceFace> face = CreateObject<NetDeviceFace> (node, device);
+ Ptr<NetDeviceFace> face = CreateObject<NetDeviceFace>(node, device);
- ndn->AddFace (face);
- NS_LOG_LOGIC ("Node " << node->GetId () << ": added NetDeviceFace as face #" << *face);
+ ndn->AddFace(face);
+ NS_LOG_LOGIC("Node " << node->GetId() << ": added NetDeviceFace as face #" << *face);
- if (m_limitsEnabled)
- {
- Ptr<Limits> limits = face->GetObject<Limits> ();
- if (limits == 0)
- {
- NS_FATAL_ERROR ("Limits are enabled, but the selected forwarding strategy does not support limits. Please revise your scenario");
- exit (1);
- }
-
- NS_LOG_INFO ("Limits are enabled");
- Ptr<PointToPointNetDevice> p2p = DynamicCast<PointToPointNetDevice> (device);
- if (p2p != 0)
- {
- // Setup bucket filtering
- // Assume that we know average data packet size, and this size is equal default size
- // Set maximum buckets (averaging over 1 second)
-
- DataRateValue dataRate; device->GetAttribute ("DataRate", dataRate);
- TimeValue linkDelay; device->GetChannel ()->GetAttribute ("Delay", linkDelay);
-
- NS_LOG_INFO("DataRate for this link is " << dataRate.Get());
-
- double maxInterestPackets = 1.0 * dataRate.Get ().GetBitRate () / 8.0 / (m_avgDataSize + m_avgInterestSize);
- // NS_LOG_INFO ("Max packets per second: " << maxInterestPackets);
- // NS_LOG_INFO ("Max burst: " << m_avgRtt.ToDouble (Time::S) * maxInterestPackets);
- NS_LOG_INFO ("MaxLimit: " << (int)(m_avgRtt.ToDouble (Time::S) * maxInterestPackets));
-
- // Set max to BDP
- limits->SetLimits (maxInterestPackets, m_avgRtt.ToDouble (Time::S));
- limits->SetLinkDelay (linkDelay.Get ().ToDouble (Time::S));
- }
+ if (m_limitsEnabled) {
+ Ptr<Limits> limits = face->GetObject<Limits>();
+ if (limits == 0) {
+ NS_FATAL_ERROR("Limits are enabled, but the selected forwarding strategy does not support "
+ "limits. Please revise your scenario");
+ exit(1);
}
+ NS_LOG_INFO("Limits are enabled");
+ Ptr<PointToPointNetDevice> p2p = DynamicCast<PointToPointNetDevice>(device);
+ if (p2p != 0) {
+ // Setup bucket filtering
+ // Assume that we know average data packet size, and this size is equal default size
+ // Set maximum buckets (averaging over 1 second)
+
+ DataRateValue dataRate;
+ device->GetAttribute("DataRate", dataRate);
+ TimeValue linkDelay;
+ device->GetChannel()->GetAttribute("Delay", linkDelay);
+
+ NS_LOG_INFO("DataRate for this link is " << dataRate.Get());
+
+ double maxInterestPackets =
+ 1.0 * dataRate.Get().GetBitRate() / 8.0 / (m_avgDataSize + m_avgInterestSize);
+ // NS_LOG_INFO ("Max packets per second: " << maxInterestPackets);
+ // NS_LOG_INFO ("Max burst: " << m_avgRtt.ToDouble (Time::S) * maxInterestPackets);
+ NS_LOG_INFO("MaxLimit: " << (int)(m_avgRtt.ToDouble(Time::S) * maxInterestPackets));
+
+ // Set max to BDP
+ limits->SetLimits(maxInterestPackets, m_avgRtt.ToDouble(Time::S));
+ limits->SetLinkDelay(linkDelay.Get().ToDouble(Time::S));
+ }
+ }
+
return face;
}
-
Ptr<FaceContainer>
-StackHelper::Install (const std::string &nodeName) const
+StackHelper::Install(const std::string& nodeName) const
{
- Ptr<Node> node = Names::Find<Node> (nodeName);
- return Install (node);
+ Ptr<Node> node = Names::Find<Node>(nodeName);
+ return Install(node);
}
-
void
-StackHelper::AddRoute (Ptr<Node> node, const std::string &prefix, Ptr<Face> face, int32_t metric)
+StackHelper::AddRoute(Ptr<Node> node, const std::string& prefix, Ptr<Face> face, int32_t metric)
{
- NS_LOG_LOGIC ("[" << node->GetId () << "]$ route add " << prefix << " via " << *face << " metric " << metric);
+ NS_LOG_LOGIC("[" << node->GetId() << "]$ route add " << prefix << " via " << *face << " metric "
+ << metric);
- Ptr<Fib> fib = node->GetObject<Fib> ();
+ Ptr<Fib> fib = node->GetObject<Fib>();
NameValue prefixValue;
- prefixValue.DeserializeFromString (prefix, MakeNameChecker ());
- fib->Add (prefixValue.Get (), face, metric);
+ prefixValue.DeserializeFromString(prefix, MakeNameChecker());
+ fib->Add(prefixValue.Get(), face, metric);
}
void
-StackHelper::AddRoute (Ptr<Node> node, const std::string &prefix, uint32_t faceId, int32_t metric)
+StackHelper::AddRoute(Ptr<Node> node, const std::string& prefix, uint32_t faceId, int32_t metric)
{
- Ptr<L3Protocol> ndn = node->GetObject<L3Protocol> ();
- NS_ASSERT_MSG (ndn != 0, "Ndn stack should be installed on the node");
+ Ptr<L3Protocol> ndn = node->GetObject<L3Protocol>();
+ NS_ASSERT_MSG(ndn != 0, "Ndn stack should be installed on the node");
- Ptr<Face> face = ndn->GetFace (faceId);
- NS_ASSERT_MSG (face != 0, "Face with ID [" << faceId << "] does not exist on node [" << node->GetId () << "]");
+ Ptr<Face> face = ndn->GetFace(faceId);
+ NS_ASSERT_MSG(face != 0, "Face with ID [" << faceId << "] does not exist on node ["
+ << node->GetId() << "]");
- AddRoute (node, prefix, face, metric);
+ AddRoute(node, prefix, face, metric);
}
void
-StackHelper::AddRoute (const std::string &nodeName, const std::string &prefix, uint32_t faceId, int32_t metric)
+StackHelper::AddRoute(const std::string& nodeName, const std::string& prefix, uint32_t faceId,
+ int32_t metric)
{
- Ptr<Node> node = Names::Find<Node> (nodeName);
- NS_ASSERT_MSG (node != 0, "Node [" << nodeName << "] does not exist");
+ Ptr<Node> node = Names::Find<Node>(nodeName);
+ NS_ASSERT_MSG(node != 0, "Node [" << nodeName << "] does not exist");
- Ptr<L3Protocol> ndn = node->GetObject<L3Protocol> ();
- NS_ASSERT_MSG (ndn != 0, "Ndn stack should be installed on the node");
+ Ptr<L3Protocol> ndn = node->GetObject<L3Protocol>();
+ NS_ASSERT_MSG(ndn != 0, "Ndn stack should be installed on the node");
- Ptr<Face> face = ndn->GetFace (faceId);
- NS_ASSERT_MSG (face != 0, "Face with ID [" << faceId << "] does not exist on node [" << nodeName << "]");
+ Ptr<Face> face = ndn->GetFace(faceId);
+ NS_ASSERT_MSG(face != 0, "Face with ID [" << faceId << "] does not exist on node [" << nodeName
+ << "]");
- AddRoute (node, prefix, face, metric);
+ AddRoute(node, prefix, face, metric);
}
void
-StackHelper::AddRoute (Ptr<Node> node, const std::string &prefix, Ptr<Node> otherNode, int32_t metric)
+StackHelper::AddRoute(Ptr<Node> node, const std::string& prefix, Ptr<Node> otherNode,
+ int32_t metric)
{
- for (uint32_t deviceId = 0; deviceId < node->GetNDevices (); deviceId ++)
- {
- Ptr<PointToPointNetDevice> netDevice = DynamicCast<PointToPointNetDevice> (node->GetDevice (deviceId));
- if (netDevice == 0)
- continue;
+ for (uint32_t deviceId = 0; deviceId < node->GetNDevices(); deviceId++) {
+ Ptr<PointToPointNetDevice> netDevice =
+ DynamicCast<PointToPointNetDevice>(node->GetDevice(deviceId));
+ if (netDevice == 0)
+ continue;
- Ptr<Channel> channel = netDevice->GetChannel ();
- if (channel == 0)
- continue;
+ Ptr<Channel> channel = netDevice->GetChannel();
+ if (channel == 0)
+ continue;
- if (channel->GetDevice (0)->GetNode () == otherNode ||
- channel->GetDevice (1)->GetNode () == otherNode)
- {
- Ptr<L3Protocol> ndn = node->GetObject<L3Protocol> ();
- NS_ASSERT_MSG (ndn != 0, "Ndn stack should be installed on the node");
+ if (channel->GetDevice(0)->GetNode() == otherNode
+ || channel->GetDevice(1)->GetNode() == otherNode) {
+ Ptr<L3Protocol> ndn = node->GetObject<L3Protocol>();
+ NS_ASSERT_MSG(ndn != 0, "Ndn stack should be installed on the node");
- Ptr<Face> face = ndn->GetFaceByNetDevice (netDevice);
- NS_ASSERT_MSG (face != 0, "There is no face associated with the p2p link");
+ Ptr<Face> face = ndn->GetFaceByNetDevice(netDevice);
+ NS_ASSERT_MSG(face != 0, "There is no face associated with the p2p link");
- AddRoute (node, prefix, face, metric);
+ AddRoute(node, prefix, face, metric);
- return;
- }
+ return;
}
+ }
- NS_FATAL_ERROR ("Cannot add route: Node# " << node->GetId () << " and Node# " << otherNode->GetId () << " are not connected");
+ NS_FATAL_ERROR("Cannot add route: Node# " << node->GetId() << " and Node# " << otherNode->GetId()
+ << " are not connected");
}
void
-StackHelper::AddRoute (const std::string &nodeName, const std::string &prefix, const std::string &otherNodeName, int32_t metric)
+StackHelper::AddRoute(const std::string& nodeName, const std::string& prefix,
+ const std::string& otherNodeName, int32_t metric)
{
- Ptr<Node> node = Names::Find<Node> (nodeName);
- NS_ASSERT_MSG (node != 0, "Node [" << nodeName << "] does not exist");
+ Ptr<Node> node = Names::Find<Node>(nodeName);
+ NS_ASSERT_MSG(node != 0, "Node [" << nodeName << "] does not exist");
- Ptr<Node> otherNode = Names::Find<Node> (otherNodeName);
- NS_ASSERT_MSG (otherNode != 0, "Node [" << otherNodeName << "] does not exist");
+ Ptr<Node> otherNode = Names::Find<Node>(otherNodeName);
+ NS_ASSERT_MSG(otherNode != 0, "Node [" << otherNodeName << "] does not exist");
- AddRoute (node, prefix, otherNode, metric);
+ AddRoute(node, prefix, otherNode, metric);
}
-
} // namespace ndn
} // namespace ns3
diff --git a/helper/ndn-stack-helper.hpp b/helper/ndn-stack-helper.hpp
index dc11bcf..155c22d 100644
--- a/helper/ndn-stack-helper.hpp
+++ b/helper/ndn-stack-helper.hpp
@@ -59,8 +59,7 @@
* attribute or a set of functionality that may be of interest to many other
* classes.
*/
-class StackHelper
-{
+class StackHelper {
public:
/**
* \brief Create a new NdnStackHelper with a default NDN_FLOODING forwarding stategy
@@ -70,17 +69,16 @@
/**
* \brief Destroy the NdnStackHelper
*/
- virtual ~StackHelper ();
+ virtual ~StackHelper();
/**
* @brief Set parameters of NdnL3Protocol
*/
void
- SetStackAttributes (const std::string &attr1 = "", const std::string &value1 = "",
- const std::string &attr2 = "", const std::string &value2 = "",
- const std::string &attr3 = "", const std::string &value3 = "",
- const std::string &attr4 = "", const std::string &value4 = "");
-
+ SetStackAttributes(const std::string& attr1 = "", const std::string& value1 = "",
+ const std::string& attr2 = "", const std::string& value2 = "",
+ const std::string& attr3 = "", const std::string& value3 = "",
+ const std::string& attr4 = "", const std::string& value4 = "");
/**
* @brief Set forwarding strategy class and its attributes
@@ -91,75 +89,79 @@
* Other strategies can be implemented, inheriting ns3::NdnForwardingStrategy class
*/
void
- SetForwardingStrategy (const std::string &forwardingStrategyClass,
- const std::string &attr1 = "", const std::string &value1 = "",
- const std::string &attr2 = "", const std::string &value2 = "",
- const std::string &attr3 = "", const std::string &value3 = "",
- const std::string &attr4 = "", const std::string &value4 = "");
+ SetForwardingStrategy(const std::string& forwardingStrategyClass, const std::string& attr1 = "",
+ const std::string& value1 = "", const std::string& attr2 = "",
+ const std::string& value2 = "", const std::string& attr3 = "",
+ const std::string& value3 = "", const std::string& attr4 = "",
+ const std::string& value4 = "");
/**
* @brief Set content store class and its attributes
* @param contentStoreClass string, representing class of the content store
*/
void
- SetContentStore (const std::string &contentStoreClass,
- const std::string &attr1 = "", const std::string &value1 = "",
- const std::string &attr2 = "", const std::string &value2 = "",
- const std::string &attr3 = "", const std::string &value3 = "",
- const std::string &attr4 = "", const std::string &value4 = "");
+ SetContentStore(const std::string& contentStoreClass, const std::string& attr1 = "",
+ const std::string& value1 = "", const std::string& attr2 = "",
+ const std::string& value2 = "", const std::string& attr3 = "",
+ const std::string& value3 = "", const std::string& attr4 = "",
+ const std::string& value4 = "");
/**
* @brief Set PIT class and its attributes
* @param pitClass string, representing class of PIT
*/
void
- SetPit (const std::string &pitClass,
- const std::string &attr1 = "", const std::string &value1 = "",
- const std::string &attr2 = "", const std::string &value2 = "",
- const std::string &attr3 = "", const std::string &value3 = "",
- const std::string &attr4 = "", const std::string &value4 = "");
+ SetPit(const std::string& pitClass, const std::string& attr1 = "", const std::string& value1 = "",
+ const std::string& attr2 = "", const std::string& value2 = "",
+ const std::string& attr3 = "", const std::string& value3 = "",
+ const std::string& attr4 = "", const std::string& value4 = "");
/**
* @brief Set FIB class and its attributes
* @param pitClass string, representing class of FIB
*/
void
- SetFib (const std::string &fibClass,
- const std::string &attr1 = "", const std::string &value1 = "",
- const std::string &attr2 = "", const std::string &value2 = "",
- const std::string &attr3 = "", const std::string &value3 = "",
- const std::string &attr4 = "", const std::string &value4 = "");
+ SetFib(const std::string& fibClass, const std::string& attr1 = "", const std::string& value1 = "",
+ const std::string& attr2 = "", const std::string& value2 = "",
+ const std::string& attr3 = "", const std::string& value3 = "",
+ const std::string& attr4 = "", const std::string& value4 = "");
- typedef Callback< Ptr<NetDeviceFace>, Ptr<Node>, Ptr<L3Protocol>, Ptr<NetDevice> > NetDeviceFaceCreateCallback;
+ typedef Callback<Ptr<NetDeviceFace>, Ptr<Node>, Ptr<L3Protocol>, Ptr<NetDevice>>
+ NetDeviceFaceCreateCallback;
/**
- * @brief Add callback to create and configure instance of the face, based on supplied Ptr<Node> and Ptr<NetDevice>
+ * @brief Add callback to create and configure instance of the face, based on supplied Ptr<Node>
+ *and Ptr<NetDevice>
*
* It is possible to set up several callbacks for different NetDevice types.
*
- * Currently, there is only one specialized callback for PointToPointNetDevice, which creates face and sets limits (if enabled)
+ * Currently, there is only one specialized callback for PointToPointNetDevice, which creates face
+ *and sets limits (if enabled)
* based on PointToPoint link parameters
*
- * If none of the callbacks fit the TypeId of NetDevice, a default callback is used (DefaultNetDeviceCallback)
+ * If none of the callbacks fit the TypeId of NetDevice, a default callback is used
+ *(DefaultNetDeviceCallback)
*/
void
- AddNetDeviceFaceCreateCallback (TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
+ AddNetDeviceFaceCreateCallback(TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
/**
- * @brief Update callback to create and configure instance of the face, based on supplied Ptr<Node> and Ptr<NetDevice>
+ * @brief Update callback to create and configure instance of the face, based on supplied
+ *Ptr<Node> and Ptr<NetDevice>
*
* It is possible to set up several callbacks for different NetDevice types.
*
* Using this method, it is possible to override Face creation for PointToPointNetDevices
*/
void
- UpdateNetDeviceFaceCreateCallback (TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
+ UpdateNetDeviceFaceCreateCallback(TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
/**
- * @brief Remove callback to create and configure instance of the face, based on supplied Ptr<Node> and Ptr<NetDevice>
+ * @brief Remove callback to create and configure instance of the face, based on supplied
+ * Ptr<Node> and Ptr<NetDevice>
*/
void
- RemoveNetDeviceFaceCreateCallback (TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
+ RemoveNetDeviceFaceCreateCallback(TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
/**
* @brief Enable Interest limits (disabled by default)
@@ -170,7 +172,8 @@
* @param avgInterest Average size of interest packets (including all headers)
*/
void
- EnableLimits (bool enable = true, Time avgRtt=Seconds(0.1), uint32_t avgData=1100, uint32_t avgInterest=40);
+ EnableLimits(bool enable = true, Time avgRtt = Seconds(0.1), uint32_t avgData = 1100,
+ uint32_t avgInterest = 40);
/**
* \brief Install Ndn stack on the node
@@ -184,7 +187,7 @@
* to NdnFaceContainer object
*/
Ptr<FaceContainer>
- Install (const std::string &nodeName) const;
+ Install(const std::string& nodeName) const;
/**
* \brief Install Ndn stack on the node
@@ -198,7 +201,7 @@
* to FaceContainer object
*/
Ptr<FaceContainer>
- Install (Ptr<Node> node) const;
+ Install(Ptr<Node> node) const;
/**
* \brief Install Ndn stack on each node in the input container
@@ -213,7 +216,7 @@
* to FaceContainer object
*/
Ptr<FaceContainer>
- Install (const NodeContainer &c) const;
+ Install(const NodeContainer& c) const;
/**
* \brief Install Ndn stack on all nodes in the simulation
@@ -222,7 +225,7 @@
* to FaceContainer object
*/
Ptr<FaceContainer>
- InstallAll () const;
+ InstallAll() const;
/**
* \brief Add forwarding entry to FIB
@@ -233,7 +236,7 @@
* \param metric Routing metric
*/
static void
- AddRoute (const std::string &nodeName, const std::string &prefix, uint32_t faceId, int32_t metric);
+ AddRoute(const std::string& nodeName, const std::string& prefix, uint32_t faceId, int32_t metric);
/**
* \brief Add forwarding entry to FIB
@@ -244,7 +247,7 @@
* \param metric Routing metric
*/
static void
- AddRoute (Ptr<Node> node, const std::string &prefix, uint32_t faceId, int32_t metric);
+ AddRoute(Ptr<Node> node, const std::string& prefix, uint32_t faceId, int32_t metric);
/**
* \brief Add forwarding entry to FIB
@@ -255,7 +258,7 @@
* \param metric Routing metric
*/
static void
- AddRoute (Ptr<Node> node, const std::string &prefix, Ptr<Face> face, int32_t metric);
+ AddRoute(Ptr<Node> node, const std::string& prefix, Ptr<Face> face, int32_t metric);
/**
* @brief Add forwarding entry to FIB (work only with point-to-point links)
@@ -266,35 +269,39 @@
* \param metric Routing metric
*/
static void
- AddRoute (Ptr<Node> node, const std::string &prefix, Ptr<Node> otherNode, int32_t metric);
+ AddRoute(Ptr<Node> node, const std::string& prefix, Ptr<Node> otherNode, int32_t metric);
/**
* @brief Add forwarding entry to FIB (work only with point-to-point links)
*
* \param nodeName Node name (refer to ns3::Names)
* \param prefix Routing prefix
- * \param otherNode The other node name, to which interests (will be used to infer face id (refer to ns3::Names)
+ * \param otherNode The other node name, to which interests (will be used to infer face id (refer
+ *to ns3::Names)
* \param metric Routing metric
*/
static void
- AddRoute (const std::string &nodeName, const std::string &prefix, const std::string &otherNodeName, int32_t metric);
+ AddRoute(const std::string& nodeName, const std::string& prefix, const std::string& otherNodeName,
+ int32_t metric);
/**
* \brief Set flag indicating necessity to install default routes in FIB
*/
void
- SetDefaultRoutes (bool needSet);
+ SetDefaultRoutes(bool needSet);
private:
Ptr<NetDeviceFace>
- DefaultNetDeviceCallback (Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> netDevice) const;
+ DefaultNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> netDevice) const;
Ptr<NetDeviceFace>
- PointToPointNetDeviceCallback (Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> netDevice) const;
+ PointToPointNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn,
+ Ptr<NetDevice> netDevice) const;
private:
- StackHelper (const StackHelper &);
- StackHelper &operator = (const StackHelper &o);
+ StackHelper(const StackHelper&);
+ StackHelper&
+ operator=(const StackHelper& o);
private:
ObjectFactory m_ndnFactory;
@@ -303,13 +310,13 @@
ObjectFactory m_pitFactory;
ObjectFactory m_fibFactory;
- bool m_limitsEnabled;
- Time m_avgRtt;
+ bool m_limitsEnabled;
+ Time m_avgRtt;
uint32_t m_avgDataSize;
uint32_t m_avgInterestSize;
- bool m_needSetDefaultRoutes;
+ bool m_needSetDefaultRoutes;
- typedef std::list< std::pair<TypeId, NetDeviceFaceCreateCallback> > NetDeviceCallbackList;
+ typedef std::list<std::pair<TypeId, NetDeviceFaceCreateCallback>> NetDeviceCallbackList;
NetDeviceCallbackList m_netDeviceCallbacks;
};