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/model/cs/content-store-impl.cpp b/model/cs/content-store-impl.cpp
index 225d137..b4d2eae 100644
--- a/model/cs/content-store-impl.cpp
+++ b/model/cs/content-store-impl.cpp
@@ -27,14 +27,14 @@
#include "../../utils/trie/multi-policy.hpp"
#include "../../utils/trie/aggregate-stats-policy.hpp"
-#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
- static struct X ## type ## templ ## RegistrationClass \
- { \
- X ## type ## templ ## RegistrationClass () { \
- ns3::TypeId tid = type<templ>::GetTypeId (); \
- tid.GetParent (); \
- } \
- } x_ ## type ## templ ## RegistrationVariable
+#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
+ static struct X##type##templ##RegistrationClass { \
+ X##type##templ##RegistrationClass() \
+ { \
+ ns3::TypeId tid = type<templ>::GetTypeId(); \
+ tid.GetParent(); \
+ } \
+ } x_##type##templ##RegistrationVariable
namespace ns3 {
namespace ndn {
@@ -69,15 +69,15 @@
NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, fifo_policy_traits);
NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, lfu_policy_traits);
-
-typedef multi_policy_traits< boost::mpl::vector2< lru_policy_traits,
- aggregate_stats_policy_traits > > LruWithCountsTraits;
-typedef multi_policy_traits< boost::mpl::vector2< random_policy_traits,
- aggregate_stats_policy_traits > > RandomWithCountsTraits;
-typedef multi_policy_traits< boost::mpl::vector2< fifo_policy_traits,
- aggregate_stats_policy_traits > > FifoWithCountsTraits;
-typedef multi_policy_traits< boost::mpl::vector2< lfu_policy_traits,
- aggregate_stats_policy_traits > > LfuWithCountsTraits;
+typedef multi_policy_traits<boost::mpl::vector2<lru_policy_traits, aggregate_stats_policy_traits>>
+ LruWithCountsTraits;
+typedef multi_policy_traits<boost::mpl::vector2<random_policy_traits,
+ aggregate_stats_policy_traits>>
+ RandomWithCountsTraits;
+typedef multi_policy_traits<boost::mpl::vector2<fifo_policy_traits, aggregate_stats_policy_traits>>
+ FifoWithCountsTraits;
+typedef multi_policy_traits<boost::mpl::vector2<lfu_policy_traits, aggregate_stats_policy_traits>>
+ LfuWithCountsTraits;
template class ContentStoreImpl<LruWithCountsTraits>;
NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, LruWithCountsTraits);
@@ -95,25 +95,28 @@
// /**
// * \brief Content Store implementing LRU cache replacement policy
// */
-class Lru : public ContentStoreImpl<lru_policy_traits> { };
+class Lru : public ContentStoreImpl<lru_policy_traits> {
+};
/**
* \brief Content Store implementing FIFO cache replacement policy
*/
-class Fifo : public ContentStoreImpl<fifo_policy_traits> { };
+class Fifo : public ContentStoreImpl<fifo_policy_traits> {
+};
/**
* \brief Content Store implementing Random cache replacement policy
*/
-class Random : public ContentStoreImpl<random_policy_traits> { };
+class Random : public ContentStoreImpl<random_policy_traits> {
+};
/**
* \brief Content Store implementing Least Frequently Used cache replacement policy
*/
-class Lfu : public ContentStoreImpl<lfu_policy_traits> { };
+class Lfu : public ContentStoreImpl<lfu_policy_traits> {
+};
#endif
-
} // namespace cs
} // namespace ndn
} // namespace ns3
diff --git a/model/cs/content-store-impl.hpp b/model/cs/content-store-impl.hpp
index 1254bb2..b35fdb4 100644
--- a/model/cs/content-store-impl.hpp
+++ b/model/cs/content-store-impl.hpp
@@ -43,292 +43,293 @@
* @brief Cache entry implementation with additional references to the base container
*/
template<class CS>
-class EntryImpl : public Entry
-{
+class EntryImpl : public Entry {
public:
typedef Entry base_type;
public:
- EntryImpl (Ptr<ContentStore> cs, Ptr<const Data> data)
- : Entry (cs, data)
- , item_ (0)
+ EntryImpl(Ptr<ContentStore> cs, Ptr<const Data> data)
+ : Entry(cs, data)
+ , item_(0)
{
}
void
- SetTrie (typename CS::super::iterator item)
+ SetTrie(typename CS::super::iterator item)
{
item_ = item;
}
- typename CS::super::iterator to_iterator () { return item_; }
- typename CS::super::const_iterator to_iterator () const { return item_; }
+ typename CS::super::iterator
+ to_iterator()
+ {
+ return item_;
+ }
+ typename CS::super::const_iterator
+ to_iterator() const
+ {
+ return item_;
+ }
private:
typename CS::super::iterator item_;
};
-
-
/**
* @ingroup ndn-cs
* @brief Base implementation of NDN content store
*/
template<class Policy>
-class ContentStoreImpl : public ContentStore,
- protected ndnSIM::trie_with_policy< Name,
- ndnSIM::smart_pointer_payload_traits< EntryImpl< ContentStoreImpl< Policy > >, Entry >,
- Policy >
-{
+class ContentStoreImpl
+ : public ContentStore,
+ protected ndnSIM::
+ trie_with_policy<Name,
+ ndnSIM::smart_pointer_payload_traits<EntryImpl<ContentStoreImpl<Policy>>,
+ Entry>,
+ Policy> {
public:
- typedef ndnSIM::trie_with_policy< Name,
- ndnSIM::smart_pointer_payload_traits< EntryImpl< ContentStoreImpl< Policy > >, Entry >,
- Policy > super;
+ typedef ndnSIM::
+ trie_with_policy<Name, ndnSIM::smart_pointer_payload_traits<EntryImpl<ContentStoreImpl<Policy>>,
+ Entry>,
+ Policy> super;
- typedef EntryImpl< ContentStoreImpl< Policy > > entry;
+ typedef EntryImpl<ContentStoreImpl<Policy>> entry;
static TypeId
- GetTypeId ();
+ GetTypeId();
- ContentStoreImpl () { };
- virtual ~ContentStoreImpl () { };
+ ContentStoreImpl(){};
+ virtual ~ContentStoreImpl(){};
// from ContentStore
virtual inline Ptr<Data>
- Lookup (Ptr<const Interest> interest);
+ Lookup(Ptr<const Interest> interest);
virtual inline bool
- Add (Ptr<const Data> data);
+ Add(Ptr<const Data> data);
// virtual bool
// Remove (Ptr<Interest> header);
virtual inline void
- Print (std::ostream &os) const;
+ Print(std::ostream& os) const;
virtual uint32_t
- GetSize () const;
+ GetSize() const;
virtual Ptr<Entry>
- Begin ();
+ Begin();
virtual Ptr<Entry>
- End ();
+ End();
- virtual Ptr<Entry>
- Next (Ptr<Entry>);
+ virtual Ptr<Entry> Next(Ptr<Entry>);
- const typename super::policy_container &
- GetPolicy () const { return super::getPolicy (); }
+ const typename super::policy_container&
+ GetPolicy() const
+ {
+ return super::getPolicy();
+ }
- typename super::policy_container &
- GetPolicy () { return super::getPolicy (); }
-
+ typename super::policy_container&
+ GetPolicy()
+ {
+ return super::getPolicy();
+ }
+
private:
void
- SetMaxSize (uint32_t maxSize);
+ SetMaxSize(uint32_t maxSize);
uint32_t
- GetMaxSize () const;
+ GetMaxSize() const;
private:
static LogComponent g_log; ///< @brief Logging variable
- /// @brief trace of for entry additions (fired every time entry is successfully added to the cache): first parameter is pointer to the CS entry
- TracedCallback< Ptr<const Entry> > m_didAddEntry;
+ /// @brief trace of for entry additions (fired every time entry is successfully added to the
+ /// cache): first parameter is pointer to the CS entry
+ TracedCallback<Ptr<const Entry>> m_didAddEntry;
};
//////////////////////////////////////////
////////// Implementation ////////////////
//////////////////////////////////////////
-
template<class Policy>
-LogComponent ContentStoreImpl< Policy >::g_log = LogComponent (("ndn.cs." + Policy::GetName ()).c_str ());
-
+LogComponent
+ ContentStoreImpl<Policy>::g_log = LogComponent(("ndn.cs." + Policy::GetName()).c_str());
template<class Policy>
TypeId
-ContentStoreImpl< Policy >::GetTypeId ()
+ContentStoreImpl<Policy>::GetTypeId()
{
- static TypeId tid = TypeId (("ns3::ndn::cs::"+Policy::GetName ()).c_str ())
- .SetGroupName ("Ndn")
- .SetParent<ContentStore> ()
- .AddConstructor< ContentStoreImpl< Policy > > ()
- .AddAttribute ("MaxSize",
- "Set maximum number of entries in ContentStore. If 0, limit is not enforced",
- StringValue ("100"),
- MakeUintegerAccessor (&ContentStoreImpl< Policy >::GetMaxSize,
- &ContentStoreImpl< Policy >::SetMaxSize),
- MakeUintegerChecker<uint32_t> ())
+ static TypeId tid =
+ TypeId(("ns3::ndn::cs::" + Policy::GetName()).c_str())
+ .SetGroupName("Ndn")
+ .SetParent<ContentStore>()
+ .AddConstructor<ContentStoreImpl<Policy>>()
+ .AddAttribute("MaxSize",
+ "Set maximum number of entries in ContentStore. If 0, limit is not enforced",
+ StringValue("100"), MakeUintegerAccessor(&ContentStoreImpl<Policy>::GetMaxSize,
+ &ContentStoreImpl<Policy>::SetMaxSize),
+ MakeUintegerChecker<uint32_t>())
- .AddTraceSource ("DidAddEntry", "Trace fired every time entry is successfully added to the cache",
- MakeTraceSourceAccessor (&ContentStoreImpl< Policy >::m_didAddEntry))
- ;
+ .AddTraceSource("DidAddEntry",
+ "Trace fired every time entry is successfully added to the cache",
+ MakeTraceSourceAccessor(&ContentStoreImpl<Policy>::m_didAddEntry));
return tid;
}
-struct isNotExcluded
-{
- inline
- isNotExcluded (const Exclude &exclude)
- : m_exclude (exclude)
+struct isNotExcluded {
+ inline isNotExcluded(const Exclude& exclude)
+ : m_exclude(exclude)
{
}
-
+
bool
- operator () (const name::Component &comp) const
+ operator()(const name::Component& comp) const
{
- return !m_exclude.isExcluded (comp);
+ return !m_exclude.isExcluded(comp);
}
private:
- const Exclude &m_exclude;
+ const Exclude& m_exclude;
};
template<class Policy>
Ptr<Data>
-ContentStoreImpl<Policy>::Lookup (Ptr<const Interest> interest)
+ContentStoreImpl<Policy>::Lookup(Ptr<const Interest> interest)
{
- NS_LOG_FUNCTION (this << interest->GetName ());
+ NS_LOG_FUNCTION(this << interest->GetName());
typename super::const_iterator node;
- if (interest->GetExclude () == 0)
- {
- node = this->deepest_prefix_match (interest->GetName ());
- }
- else
- {
- node = this->deepest_prefix_match_if_next_level (interest->GetName (),
- isNotExcluded (*interest->GetExclude ()));
- }
+ if (interest->GetExclude() == 0) {
+ node = this->deepest_prefix_match(interest->GetName());
+ }
+ else {
+ node = this->deepest_prefix_match_if_next_level(interest->GetName(),
+ isNotExcluded(*interest->GetExclude()));
+ }
- if (node != this->end ())
- {
- this->m_cacheHitsTrace (interest, node->payload ()->GetData ());
+ if (node != this->end()) {
+ this->m_cacheHitsTrace(interest, node->payload()->GetData());
- Ptr<Data> copy = Create<Data> (*node->payload ()->GetData ());
- ConstCast<Packet> (copy->GetPayload ())->RemoveAllPacketTags ();
- return copy;
- }
- else
- {
- this->m_cacheMissesTrace (interest);
- return 0;
- }
+ Ptr<Data> copy = Create<Data>(*node->payload()->GetData());
+ ConstCast<Packet>(copy->GetPayload())->RemoveAllPacketTags();
+ return copy;
+ }
+ else {
+ this->m_cacheMissesTrace(interest);
+ return 0;
+ }
}
template<class Policy>
bool
-ContentStoreImpl<Policy>::Add (Ptr<const Data> data)
+ContentStoreImpl<Policy>::Add(Ptr<const Data> data)
{
- NS_LOG_FUNCTION (this << data->GetName ());
+ NS_LOG_FUNCTION(this << data->GetName());
- Ptr< entry > newEntry = Create< entry > (this, data);
- std::pair< typename super::iterator, bool > result = super::insert (data->GetName (), newEntry);
+ Ptr<entry> newEntry = Create<entry>(this, data);
+ std::pair<typename super::iterator, bool> result = super::insert(data->GetName(), newEntry);
- if (result.first != super::end ())
- {
- if (result.second)
- {
- newEntry->SetTrie (result.first);
+ if (result.first != super::end()) {
+ if (result.second) {
+ newEntry->SetTrie(result.first);
- m_didAddEntry (newEntry);
- return true;
- }
- else
- {
- // should we do anything?
- // update payload? add new payload?
- return false;
- }
+ m_didAddEntry(newEntry);
+ return true;
}
+ else {
+ // should we do anything?
+ // update payload? add new payload?
+ return false;
+ }
+ }
else
return false; // cannot insert entry
}
template<class Policy>
void
-ContentStoreImpl<Policy>::Print (std::ostream &os) const
+ContentStoreImpl<Policy>::Print(std::ostream& os) const
{
- for (typename super::policy_container::const_iterator item = this->getPolicy ().begin ();
- item != this->getPolicy ().end ();
- item++)
- {
- os << item->payload ()->GetName () << std::endl;
- }
+ for (typename super::policy_container::const_iterator item = this->getPolicy().begin();
+ item != this->getPolicy().end(); item++) {
+ os << item->payload()->GetName() << std::endl;
+ }
}
template<class Policy>
void
-ContentStoreImpl<Policy>::SetMaxSize (uint32_t maxSize)
+ContentStoreImpl<Policy>::SetMaxSize(uint32_t maxSize)
{
- this->getPolicy ().set_max_size (maxSize);
+ this->getPolicy().set_max_size(maxSize);
}
template<class Policy>
uint32_t
-ContentStoreImpl<Policy>::GetMaxSize () const
+ContentStoreImpl<Policy>::GetMaxSize() const
{
- return this->getPolicy ().get_max_size ();
+ return this->getPolicy().get_max_size();
}
template<class Policy>
uint32_t
-ContentStoreImpl<Policy>::GetSize () const
+ContentStoreImpl<Policy>::GetSize() const
{
- return this->getPolicy ().size ();
+ return this->getPolicy().size();
}
template<class Policy>
Ptr<Entry>
-ContentStoreImpl<Policy>::Begin ()
+ContentStoreImpl<Policy>::Begin()
{
- typename super::parent_trie::recursive_iterator item (super::getTrie ()), end (0);
- for (; item != end; item++)
- {
- if (item->payload () == 0) continue;
- break;
- }
+ typename super::parent_trie::recursive_iterator item(super::getTrie()), end(0);
+ for (; item != end; item++) {
+ if (item->payload() == 0)
+ continue;
+ break;
+ }
if (item == end)
- return End ();
+ return End();
else
- return item->payload ();
+ return item->payload();
}
template<class Policy>
Ptr<Entry>
-ContentStoreImpl<Policy>::End ()
+ContentStoreImpl<Policy>::End()
{
return 0;
}
template<class Policy>
Ptr<Entry>
-ContentStoreImpl<Policy>::Next (Ptr<Entry> from)
+ContentStoreImpl<Policy>::Next(Ptr<Entry> from)
{
- if (from == 0) return 0;
+ if (from == 0)
+ return 0;
- typename super::parent_trie::recursive_iterator
- item (*StaticCast< entry > (from)->to_iterator ()),
- end (0);
+ typename super::parent_trie::recursive_iterator item(*StaticCast<entry>(from)->to_iterator()),
+ end(0);
- for (item++; item != end; item++)
- {
- if (item->payload () == 0) continue;
- break;
- }
+ for (item++; item != end; item++) {
+ if (item->payload() == 0)
+ continue;
+ break;
+ }
if (item == end)
- return End ();
+ return End();
else
- return item->payload ();
+ return item->payload();
}
-
} // namespace cs
} // namespace ndn
} // namespace ns3
diff --git a/model/cs/content-store-nocache.cpp b/model/cs/content-store-nocache.cpp
index 61515c1..85505d1 100644
--- a/model/cs/content-store-nocache.cpp
+++ b/model/cs/content-store-nocache.cpp
@@ -17,7 +17,7 @@
*
* Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Ilya Moiseenko <iliamo@cs.ucla.edu>
- *
+ *
*/
#include "content-store-nocache.hpp"
@@ -25,72 +25,70 @@
#include "ns3/log.h"
#include "ns3/packet.h"
-NS_LOG_COMPONENT_DEFINE ("ndn.cs.Nocache");
+NS_LOG_COMPONENT_DEFINE("ndn.cs.Nocache");
namespace ns3 {
namespace ndn {
namespace cs {
-NS_OBJECT_ENSURE_REGISTERED (Nocache);
+NS_OBJECT_ENSURE_REGISTERED(Nocache);
-TypeId
-Nocache::GetTypeId (void)
+TypeId
+Nocache::GetTypeId(void)
{
- static TypeId tid = TypeId ("ns3::ndn::cs::Nocache")
- .SetGroupName ("Ndn")
- .SetParent<ContentStore> ()
- .AddConstructor< Nocache > ()
- ;
+ static TypeId tid = TypeId("ns3::ndn::cs::Nocache")
+ .SetGroupName("Ndn")
+ .SetParent<ContentStore>()
+ .AddConstructor<Nocache>();
return tid;
}
-Nocache::Nocache ()
+Nocache::Nocache()
{
}
-Nocache::~Nocache ()
+Nocache::~Nocache()
{
}
Ptr<Data>
-Nocache::Lookup (Ptr<const Interest> interest)
+Nocache::Lookup(Ptr<const Interest> interest)
{
- this->m_cacheMissesTrace (interest);
+ this->m_cacheMissesTrace(interest);
return 0;
}
bool
-Nocache::Add (Ptr<const Data> data)
+Nocache::Add(Ptr<const Data> data)
{
return false;
}
void
-Nocache::Print (std::ostream &os) const
+Nocache::Print(std::ostream& os) const
{
}
uint32_t
-Nocache::GetSize () const
+Nocache::GetSize() const
{
return 0;
}
Ptr<cs::Entry>
-Nocache::Begin ()
+Nocache::Begin()
{
return 0;
}
Ptr<cs::Entry>
-Nocache::End ()
+Nocache::End()
{
return 0;
}
-Ptr<cs::Entry>
-Nocache::Next (Ptr<cs::Entry>)
+Ptr<cs::Entry> Nocache::Next(Ptr<cs::Entry>)
{
return 0;
}
diff --git a/model/cs/content-store-nocache.hpp b/model/cs/content-store-nocache.hpp
index ac7ced7..5745821 100644
--- a/model/cs/content-store-nocache.hpp
+++ b/model/cs/content-store-nocache.hpp
@@ -20,7 +20,7 @@
*/
#ifndef NDN_CONTENT_STORE_NOCACHE_H
-#define NDN_CONTENT_STORE_NOCACHE_H
+#define NDN_CONTENT_STORE_NOCACHE_H
#include "ns3/ndnSIM/model/cs/ndn-content-store.hpp"
@@ -32,49 +32,45 @@
* @ingroup ndn-cs
* @brief Implementation of ContentStore that completely disables caching
*/
-class Nocache : public ContentStore
-{
+class Nocache : public ContentStore {
public:
/**
* \brief Interface ID
*
* \return interface ID
*/
- static
- TypeId GetTypeId ();
+ static TypeId
+ GetTypeId();
/**
* @brief Default constructor
*/
- Nocache ();
-
+ Nocache();
+
/**
* @brief Virtual destructor
*/
- virtual
- ~Nocache ();
+ virtual ~Nocache();
virtual Ptr<Data>
- Lookup (Ptr<const Interest> interest);
+ Lookup(Ptr<const Interest> interest);
virtual bool
- Add (Ptr<const Data> data);
+ Add(Ptr<const Data> data);
virtual void
- Print (std::ostream &os) const;
+ Print(std::ostream& os) const;
virtual uint32_t
- GetSize () const;
+ GetSize() const;
virtual Ptr<cs::Entry>
- Begin ();
+ Begin();
virtual Ptr<cs::Entry>
- End ();
+ End();
- virtual Ptr<cs::Entry>
- Next (Ptr<cs::Entry>);
-
+ virtual Ptr<cs::Entry> Next(Ptr<cs::Entry>);
};
} // namespace cs
diff --git a/model/cs/content-store-with-freshness.cpp b/model/cs/content-store-with-freshness.cpp
index e132a78..3fa39b9 100644
--- a/model/cs/content-store-with-freshness.cpp
+++ b/model/cs/content-store-with-freshness.cpp
@@ -25,14 +25,14 @@
#include "../../utils/trie/fifo-policy.hpp"
#include "../../utils/trie/lfu-policy.hpp"
-#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
- static struct X ## type ## templ ## RegistrationClass \
- { \
- X ## type ## templ ## RegistrationClass () { \
- ns3::TypeId tid = type<templ>::GetTypeId (); \
- tid.GetParent (); \
- } \
- } x_ ## type ## templ ## RegistrationVariable
+#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
+ static struct X##type##templ##RegistrationClass { \
+ X##type##templ##RegistrationClass() \
+ { \
+ ns3::TypeId tid = type<templ>::GetTypeId(); \
+ tid.GetParent(); \
+ } \
+ } x_##type##templ##RegistrationVariable
namespace ns3 {
namespace ndn {
@@ -62,7 +62,6 @@
**/
template class ContentStoreWithFreshness<lfu_policy_traits>;
-
NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithFreshness, lru_policy_traits);
NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithFreshness, random_policy_traits);
NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithFreshness, fifo_policy_traits);
@@ -73,26 +72,29 @@
// /**
// * \brief Content Store with freshness implementing LRU cache replacement policy
// */
-class Freshness::Lru : public ContentStoreWithFreshness<lru_policy_traits> { };
+class Freshness::Lru : public ContentStoreWithFreshness<lru_policy_traits> {
+};
/**
* \brief Content Store with freshness implementing FIFO cache replacement policy
*/
-class Freshness::Fifo : public ContentStoreWithFreshness<fifo_policy_traits> { };
+class Freshness::Fifo : public ContentStoreWithFreshness<fifo_policy_traits> {
+};
/**
* \brief Content Store with freshness implementing Random cache replacement policy
*/
-class Freshness::Random : public ContentStoreWithFreshness<random_policy_traits> { };
+class Freshness::Random : public ContentStoreWithFreshness<random_policy_traits> {
+};
/**
* \brief Content Store with freshness implementing Least Frequently Used cache replacement policy
*/
-class Freshness::Lfu : public ContentStoreWithFreshness<lfu_policy_traits> { };
+class Freshness::Lfu : public ContentStoreWithFreshness<lfu_policy_traits> {
+};
#endif
-
} // namespace cs
} // namespace ndn
} // namespace ns3
diff --git a/model/cs/content-store-with-freshness.hpp b/model/cs/content-store-with-freshness.hpp
index 2bd74de..07aa56f 100644
--- a/model/cs/content-store-with-freshness.hpp
+++ b/model/cs/content-store-with-freshness.hpp
@@ -37,29 +37,34 @@
* @brief Special content store realization that honors Freshness parameter in Data packets
*/
template<class Policy>
-class ContentStoreWithFreshness :
- public ContentStoreImpl< ndnSIM::multi_policy_traits< boost::mpl::vector2< Policy, ndnSIM::freshness_policy_traits > > >
-{
+class ContentStoreWithFreshness
+ : public ContentStoreImpl<ndnSIM::
+ multi_policy_traits<boost::mpl::
+ vector2<Policy,
+ ndnSIM::freshness_policy_traits>>> {
public:
- typedef ContentStoreImpl< ndnSIM::multi_policy_traits< boost::mpl::vector2< Policy, ndnSIM::freshness_policy_traits > > > super;
+ typedef ContentStoreImpl<ndnSIM::multi_policy_traits<boost::mpl::
+ vector2<Policy,
+ ndnSIM::freshness_policy_traits>>>
+ super;
typedef typename super::policy_container::template index<1>::type freshness_policy_container;
static TypeId
- GetTypeId ();
+ GetTypeId();
virtual inline void
- Print (std::ostream &os) const;
+ Print(std::ostream& os) const;
virtual inline bool
- Add (Ptr<const Data> data);
+ Add(Ptr<const Data> data);
private:
inline void
- CleanExpired ();
+ CleanExpired();
inline void
- RescheduleCleaning ();
+ RescheduleCleaning();
private:
static LogComponent g_log; ///< @brief Logging variable
@@ -72,20 +77,18 @@
////////// Implementation ////////////////
//////////////////////////////////////////
-
template<class Policy>
-LogComponent
-ContentStoreWithFreshness< Policy >::g_log = LogComponent (("ndn.cs.Freshness." + Policy::GetName ()).c_str ());
-
+LogComponent ContentStoreWithFreshness<Policy>::g_log = LogComponent(("ndn.cs.Freshness."
+ + Policy::GetName()).c_str());
template<class Policy>
TypeId
-ContentStoreWithFreshness< Policy >::GetTypeId ()
+ContentStoreWithFreshness<Policy>::GetTypeId()
{
- static TypeId tid = TypeId (("ns3::ndn::cs::Freshness::"+Policy::GetName ()).c_str ())
- .SetGroupName ("Ndn")
- .SetParent<super> ()
- .template AddConstructor< ContentStoreWithFreshness< Policy > > ()
+ static TypeId tid = TypeId(("ns3::ndn::cs::Freshness::" + Policy::GetName()).c_str())
+ .SetGroupName("Ndn")
+ .SetParent<super>()
+ .template AddConstructor<ContentStoreWithFreshness<Policy>>()
// trace stuff here
;
@@ -93,95 +96,93 @@
return tid;
}
-
template<class Policy>
inline bool
-ContentStoreWithFreshness< Policy >::Add (Ptr<const Data> data)
+ContentStoreWithFreshness<Policy>::Add(Ptr<const Data> data)
{
- bool ok = super::Add (data);
- if (!ok) return false;
+ bool ok = super::Add(data);
+ if (!ok)
+ return false;
- NS_LOG_DEBUG (data->GetName () << " added to cache");
- RescheduleCleaning ();
+ NS_LOG_DEBUG(data->GetName() << " added to cache");
+ RescheduleCleaning();
return true;
}
template<class Policy>
inline void
-ContentStoreWithFreshness< Policy >::RescheduleCleaning ()
+ContentStoreWithFreshness<Policy>::RescheduleCleaning()
{
- const freshness_policy_container &freshness = this->getPolicy ().template get<freshness_policy_container> ();
+ const freshness_policy_container& freshness =
+ this->getPolicy().template get<freshness_policy_container>();
- if (freshness.size () > 0)
+ if (freshness.size() > 0) {
+ Time nextStateTime =
+ freshness_policy_container::policy_base::get_freshness(&(*freshness.begin()));
+
+ if (m_scheduledCleaningTime.IsZero() || // if not yet scheduled
+ m_scheduledCleaningTime > nextStateTime) // if new item expire sooner than already scheduled
{
- Time nextStateTime = freshness_policy_container::policy_base::get_freshness (&(*freshness.begin ()));
+ if (m_cleanEvent.IsRunning()) {
+ Simulator::Remove(m_cleanEvent); // just canceling would not clean up list of events
+ }
- if (m_scheduledCleaningTime.IsZero () || // if not yet scheduled
- m_scheduledCleaningTime > nextStateTime) // if new item expire sooner than already scheduled
- {
- if (m_cleanEvent.IsRunning ())
- {
- Simulator::Remove (m_cleanEvent); // just canceling would not clean up list of events
- }
-
- // NS_LOG_DEBUG ("Next event in: " << (nextStateTime - Now ()).ToDouble (Time::S) << "s");
- m_cleanEvent = Simulator::Schedule (nextStateTime - Now (), &ContentStoreWithFreshness< Policy >::CleanExpired, this);
- m_scheduledCleaningTime = nextStateTime;
- }
+ // NS_LOG_DEBUG ("Next event in: " << (nextStateTime - Now ()).ToDouble (Time::S) << "s");
+ m_cleanEvent = Simulator::Schedule(nextStateTime - Now(),
+ &ContentStoreWithFreshness<Policy>::CleanExpired, this);
+ m_scheduledCleaningTime = nextStateTime;
}
- else
- {
- if (m_cleanEvent.IsRunning ())
- {
- Simulator::Remove (m_cleanEvent); // just canceling would not clean up list of events
- }
+ }
+ else {
+ if (m_cleanEvent.IsRunning()) {
+ Simulator::Remove(m_cleanEvent); // just canceling would not clean up list of events
}
+ }
}
-
template<class Policy>
inline void
-ContentStoreWithFreshness< Policy >::CleanExpired ()
+ContentStoreWithFreshness<Policy>::CleanExpired()
{
- freshness_policy_container &freshness = this->getPolicy ().template get<freshness_policy_container> ();
+ freshness_policy_container& freshness =
+ this->getPolicy().template get<freshness_policy_container>();
- // NS_LOG_LOGIC (">> Cleaning: Total number of items:" << this->getPolicy ().size () << ", items with freshness: " << freshness.size ());
- Time now = Simulator::Now ();
+ // NS_LOG_LOGIC (">> Cleaning: Total number of items:" << this->getPolicy ().size () << ", items
+ // with freshness: " << freshness.size ());
+ Time now = Simulator::Now();
- while (!freshness.empty ())
+ while (!freshness.empty()) {
+ typename freshness_policy_container::iterator entry = freshness.begin();
+
+ if (freshness_policy_container::policy_base::get_freshness(&(*entry))
+ <= now) // is the record stale?
{
- typename freshness_policy_container::iterator entry = freshness.begin ();
-
- if (freshness_policy_container::policy_base::get_freshness (&(*entry)) <= now) // is the record stale?
- {
- super::erase (&(*entry));
- }
- else
- break; // nothing else to do. All later records will not be stale
+ super::erase(&(*entry));
}
- // NS_LOG_LOGIC ("<< Cleaning: Total number of items:" << this->getPolicy ().size () << ", items with freshness: " << freshness.size ());
+ else
+ break; // nothing else to do. All later records will not be stale
+ }
+ // NS_LOG_LOGIC ("<< Cleaning: Total number of items:" << this->getPolicy ().size () << ", items
+ // with freshness: " << freshness.size ());
- m_scheduledCleaningTime = Time ();
- RescheduleCleaning ();
+ m_scheduledCleaningTime = Time();
+ RescheduleCleaning();
}
template<class Policy>
void
-ContentStoreWithFreshness< Policy >::Print (std::ostream &os) const
+ContentStoreWithFreshness<Policy>::Print(std::ostream& os) const
{
- // const freshness_policy_container &freshness = this->getPolicy ().template get<freshness_policy_container> ();
+ // const freshness_policy_container &freshness = this->getPolicy ().template
+ // get<freshness_policy_container> ();
- for (typename super::policy_container::const_iterator item = this->getPolicy ().begin ();
- item != this->getPolicy ().end ();
- item++)
- {
- Time ttl = freshness_policy_container::policy_base::get_freshness (&(*item)) - Simulator::Now ();
- os << item->payload ()->GetName () << "(left: " << ttl.ToDouble (Time::S) << "s)" << std::endl;
- }
+ for (typename super::policy_container::const_iterator item = this->getPolicy().begin();
+ item != this->getPolicy().end(); item++) {
+ Time ttl = freshness_policy_container::policy_base::get_freshness(&(*item)) - Simulator::Now();
+ os << item->payload()->GetName() << "(left: " << ttl.ToDouble(Time::S) << "s)" << std::endl;
+ }
}
-
-
} // namespace cs
} // namespace ndn
} // namespace ns3
diff --git a/model/cs/content-store-with-probability.cpp b/model/cs/content-store-with-probability.cpp
index bf5c181..313cb36 100644
--- a/model/cs/content-store-with-probability.cpp
+++ b/model/cs/content-store-with-probability.cpp
@@ -25,14 +25,14 @@
#include "../../utils/trie/fifo-policy.hpp"
#include "../../utils/trie/lfu-policy.hpp"
-#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
- static struct X ## type ## templ ## RegistrationClass \
- { \
- X ## type ## templ ## RegistrationClass () { \
- ns3::TypeId tid = type<templ>::GetTypeId (); \
- tid.GetParent (); \
- } \
- } x_ ## type ## templ ## RegistrationVariable
+#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
+ static struct X##type##templ##RegistrationClass { \
+ X##type##templ##RegistrationClass() \
+ { \
+ ns3::TypeId tid = type<templ>::GetTypeId(); \
+ tid.GetParent(); \
+ } \
+ } x_##type##templ##RegistrationVariable
namespace ns3 {
namespace ndn {
@@ -62,7 +62,6 @@
**/
template class ContentStoreWithProbability<lfu_policy_traits>;
-
NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithProbability, lru_policy_traits);
NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithProbability, random_policy_traits);
NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithProbability, fifo_policy_traits);
@@ -73,26 +72,29 @@
// /**
// * \brief Content Store with freshness implementing LRU cache replacement policy
// */
-class Probability::Lru : public ContentStoreWithProbability<lru_policy_traits> { };
+class Probability::Lru : public ContentStoreWithProbability<lru_policy_traits> {
+};
/**
* \brief Content Store with freshness implementing FIFO cache replacement policy
*/
-class Probability::Fifo : public ContentStoreWithProbability<fifo_policy_traits> { };
+class Probability::Fifo : public ContentStoreWithProbability<fifo_policy_traits> {
+};
/**
* \brief Content Store with freshness implementing Random cache replacement policy
*/
-class Probability::Random : public ContentStoreWithProbability<random_policy_traits> { };
+class Probability::Random : public ContentStoreWithProbability<random_policy_traits> {
+};
/**
* \brief Content Store with freshness implementing Least Frequently Used cache replacement policy
*/
-class Probability::Lfu : public ContentStoreWithProbability<lfu_policy_traits> { };
+class Probability::Lfu : public ContentStoreWithProbability<lfu_policy_traits> {
+};
#endif
-
} // namespace cs
} // namespace ndn
} // namespace ns3
diff --git a/model/cs/content-store-with-probability.hpp b/model/cs/content-store-with-probability.hpp
index 55266e8..cca50c1 100644
--- a/model/cs/content-store-with-probability.hpp
+++ b/model/cs/content-store-with-probability.hpp
@@ -39,34 +39,33 @@
* @brief Special content store realization that honors Freshness parameter in Data packets
*/
template<class Policy>
-class ContentStoreWithProbability :
- public ContentStoreImpl< ndnSIM::multi_policy_traits< boost::mpl::vector2< ndnSIM::probability_policy_traits, Policy > > >
-{
+class ContentStoreWithProbability
+ : public ContentStoreImpl<ndnSIM::multi_policy_traits<boost::mpl::
+ vector2<ndnSIM::probability_policy_traits,
+ Policy>>> {
public:
- typedef ContentStoreImpl< ndnSIM::multi_policy_traits< boost::mpl::vector2< ndnSIM::probability_policy_traits, Policy > > > super;
+ typedef ContentStoreImpl<ndnSIM::multi_policy_traits<boost::mpl::
+ vector2<ndnSIM::probability_policy_traits,
+ Policy>>> super;
typedef typename super::policy_container::template index<0>::type probability_policy_container;
- ContentStoreWithProbability () {};
-
- static TypeId
- GetTypeId ();
-private:
+ ContentStoreWithProbability(){};
- void SetCacheProbability (double probability)
+ static TypeId
+ GetTypeId();
+
+private:
+ void
+ SetCacheProbability(double probability)
{
- this->getPolicy ()
- .template get<probability_policy_container> ()
- .set_probability (probability);
+ this->getPolicy().template get<probability_policy_container>().set_probability(probability);
}
double
- GetCacheProbability () const
+ GetCacheProbability() const
{
- return
- this->getPolicy ()
- .template get<probability_policy_container> ()
- .get_probability ();
+ return this->getPolicy().template get<probability_policy_container>().get_probability();
}
};
@@ -76,26 +75,25 @@
template<class Policy>
TypeId
-ContentStoreWithProbability< Policy >::GetTypeId ()
+ContentStoreWithProbability<Policy>::GetTypeId()
{
- static TypeId tid = TypeId (("ns3::ndn::cs::Probability::"+Policy::GetName ()).c_str ())
- .SetGroupName ("Ndn")
- .SetParent<super> ()
- .template AddConstructor< ContentStoreWithProbability< Policy > > ()
+ static TypeId tid =
+ TypeId(("ns3::ndn::cs::Probability::" + Policy::GetName()).c_str())
+ .SetGroupName("Ndn")
+ .SetParent<super>()
+ .template AddConstructor<ContentStoreWithProbability<Policy>>()
- .AddAttribute ("CacheProbability",
- "Set probability of caching in ContentStore. "
- "If 1, every content is cached. If 0, no content is cached.",
- DoubleValue (1.0),//(+)
- MakeDoubleAccessor (&ContentStoreWithProbability< Policy >::GetCacheProbability,
- &ContentStoreWithProbability< Policy >::SetCacheProbability),
- MakeDoubleChecker<double> ())
- ;
+ .AddAttribute("CacheProbability",
+ "Set probability of caching in ContentStore. "
+ "If 1, every content is cached. If 0, no content is cached.",
+ DoubleValue(1.0), //(+)
+ MakeDoubleAccessor(&ContentStoreWithProbability<Policy>::GetCacheProbability,
+ &ContentStoreWithProbability<Policy>::SetCacheProbability),
+ MakeDoubleChecker<double>());
return tid;
}
-
} // namespace cs
} // namespace ndn
} // namespace ns3
diff --git a/model/cs/content-store-with-stats.cpp b/model/cs/content-store-with-stats.cpp
index 7d6e567..1a44e37 100644
--- a/model/cs/content-store-with-stats.cpp
+++ b/model/cs/content-store-with-stats.cpp
@@ -25,14 +25,14 @@
#include "../../utils/trie/fifo-policy.hpp"
#include "../../utils/trie/lfu-policy.hpp"
-#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
- static struct X ## type ## templ ## RegistrationClass \
- { \
- X ## type ## templ ## RegistrationClass () { \
- ns3::TypeId tid = type<templ>::GetTypeId (); \
- tid.GetParent (); \
- } \
- } x_ ## type ## templ ## RegistrationVariable
+#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
+ static struct X##type##templ##RegistrationClass { \
+ X##type##templ##RegistrationClass() \
+ { \
+ ns3::TypeId tid = type<templ>::GetTypeId(); \
+ tid.GetParent(); \
+ } \
+ } x_##type##templ##RegistrationVariable
namespace ns3 {
namespace ndn {
@@ -68,31 +68,33 @@
NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithStats, lfu_policy_traits);
-
#ifdef DOXYGEN
// /**
// * \brief Content Store with stats implementing LRU cache replacement policy
// */
-class Stats::Lru : public ContentStoreWithStats<lru_policy_traits> { };
+class Stats::Lru : public ContentStoreWithStats<lru_policy_traits> {
+};
/**
* \brief Content Store with stats implementing FIFO cache replacement policy
*/
-class Stats::Fifo : public ContentStoreWithStats<fifo_policy_traits> { };
+class Stats::Fifo : public ContentStoreWithStats<fifo_policy_traits> {
+};
/**
* \brief Content Store with stats implementing Random cache replacement policy
*/
-class Stats::Random : public ContentStoreWithStats<random_policy_traits> { };
+class Stats::Random : public ContentStoreWithStats<random_policy_traits> {
+};
/**
* \brief Content Store with stats implementing Least Frequently Used cache replacement policy
*/
-class Stats::Lfu : public ContentStoreWithStats<lfu_policy_traits> { };
+class Stats::Lfu : public ContentStoreWithStats<lfu_policy_traits> {
+};
#endif
-
} // namespace cs
} // namespace ndn
} // namespace ns3
diff --git a/model/cs/content-store-with-stats.hpp b/model/cs/content-store-with-stats.hpp
index 542b88c..b5f7540 100644
--- a/model/cs/content-store-with-stats.hpp
+++ b/model/cs/content-store-with-stats.hpp
@@ -37,54 +37,62 @@
* @brief Special content store realization that provides ability to track stats of CS operations
*/
template<class Policy>
-class ContentStoreWithStats :
- public ContentStoreImpl< ndnSIM::multi_policy_traits< boost::mpl::vector2< Policy, ndnSIM::lifetime_stats_policy_traits > > >
-{
+class ContentStoreWithStats
+ : public ContentStoreImpl<ndnSIM::
+ multi_policy_traits<boost::mpl::
+ vector2<Policy,
+ ndnSIM::
+ lifetime_stats_policy_traits>>> {
public:
- typedef ContentStoreImpl< ndnSIM::multi_policy_traits< boost::mpl::vector2< Policy, ndnSIM::lifetime_stats_policy_traits > > > super;
+ typedef ContentStoreImpl<ndnSIM::
+ multi_policy_traits<boost::mpl::
+ vector2<Policy,
+ ndnSIM::lifetime_stats_policy_traits>>>
+ super;
typedef typename super::policy_container::template index<1>::type lifetime_stats_container;
- ContentStoreWithStats ()
+ ContentStoreWithStats()
{
// connect traceback to the policy
- super::getPolicy ().template get<1> ().set_traced_callback (&m_willRemoveEntry);
+ super::getPolicy().template get<1>().set_traced_callback(&m_willRemoveEntry);
}
static TypeId
- GetTypeId ();
+ GetTypeId();
virtual inline void
- Print (std::ostream &os) const;
+ Print(std::ostream& os) const;
private:
static LogComponent g_log; ///< @brief Logging variable
- /// @brief trace of for entry removal: first parameter is pointer to the CS entry, second is how long entry was in the cache
- TracedCallback< Ptr<const Entry>, Time > m_willRemoveEntry;
+ /// @brief trace of for entry removal: first parameter is pointer to the CS entry, second is how
+ /// long entry was in the cache
+ TracedCallback<Ptr<const Entry>, Time> m_willRemoveEntry;
};
//////////////////////////////////////////
////////// Implementation ////////////////
//////////////////////////////////////////
-
template<class Policy>
-LogComponent
-ContentStoreWithStats< Policy >::g_log = LogComponent (("ndn.cs.Stats." + Policy::GetName ()).c_str ());
-
+LogComponent ContentStoreWithStats<Policy>::g_log = LogComponent(("ndn.cs.Stats."
+ + Policy::GetName()).c_str());
template<class Policy>
TypeId
-ContentStoreWithStats< Policy >::GetTypeId ()
+ContentStoreWithStats<Policy>::GetTypeId()
{
- static TypeId tid = TypeId (("ns3::ndn::cs::Stats::"+Policy::GetName ()).c_str ())
- .SetGroupName ("Ndn")
- .SetParent<super> ()
- .template AddConstructor< ContentStoreWithStats< Policy > > ()
+ static TypeId tid =
+ TypeId(("ns3::ndn::cs::Stats::" + Policy::GetName()).c_str())
+ .SetGroupName("Ndn")
+ .SetParent<super>()
+ .template AddConstructor<ContentStoreWithStats<Policy>>()
- .AddTraceSource ("WillRemoveEntry", "Trace called just before content store entry will be removed",
- MakeTraceSourceAccessor (&ContentStoreWithStats< Policy >::m_willRemoveEntry))
+ .AddTraceSource("WillRemoveEntry",
+ "Trace called just before content store entry will be removed",
+ MakeTraceSourceAccessor(&ContentStoreWithStats<Policy>::m_willRemoveEntry))
// trace stuff here
;
@@ -94,21 +102,18 @@
template<class Policy>
void
-ContentStoreWithStats< Policy >::Print (std::ostream &os) const
+ContentStoreWithStats<Policy>::Print(std::ostream& os) const
{
- // const freshness_policy_container &freshness = this->getPolicy ().template get<freshness_policy_container> ();
+ // const freshness_policy_container &freshness = this->getPolicy ().template
+ // get<freshness_policy_container> ();
- for (typename super::policy_container::const_iterator item = this->getPolicy ().begin ();
- item != this->getPolicy ().end ();
- item++)
- {
- Time alive = lifetime_stats_container::policy_base::get_time (&(*item)) - Simulator::Now ();
- os << item->payload ()->GetName () << "(alive: " << alive.ToDouble (Time::S) << "s)" << std::endl;
- }
+ for (typename super::policy_container::const_iterator item = this->getPolicy().begin();
+ item != this->getPolicy().end(); item++) {
+ Time alive = lifetime_stats_container::policy_base::get_time(&(*item)) - Simulator::Now();
+ os << item->payload()->GetName() << "(alive: " << alive.ToDouble(Time::S) << "s)" << std::endl;
+ }
}
-
-
} // namespace cs
} // namespace ndn
} // namespace ns3
diff --git a/model/cs/custom-policies/freshness-policy.hpp b/model/cs/custom-policies/freshness-policy.hpp
index b85635e..999c61d 100644
--- a/model/cs/custom-policies/freshness-policy.hpp
+++ b/model/cs/custom-policies/freshness-policy.hpp
@@ -35,126 +35,127 @@
/**
* @brief Traits for freshness policy
*/
-struct freshness_policy_traits
-{
+struct freshness_policy_traits {
/// @brief Name that can be used to identify the policy (for NS-3 object model and logging)
- static std::string GetName () { return "Freshness"; }
-
- struct policy_hook_type : public boost::intrusive::set_member_hook<> { Time timeWhenShouldExpire; };
-
- template<class Container>
- struct container_hook
+ static std::string
+ GetName()
{
- typedef boost::intrusive::member_hook< Container,
- policy_hook_type,
- &Container::policy_hook_ > type;
+ return "Freshness";
+ }
+
+ struct policy_hook_type : public boost::intrusive::set_member_hook<> {
+ Time timeWhenShouldExpire;
};
- template<class Base,
- class Container,
- class Hook>
- struct policy
- {
- static Time& get_freshness (typename Container::iterator item)
+ template<class Container>
+ struct container_hook {
+ typedef boost::intrusive::member_hook<Container, policy_hook_type, &Container::policy_hook_>
+ type;
+ };
+
+ template<class Base, class Container, class Hook>
+ struct policy {
+ static Time&
+ get_freshness(typename Container::iterator item)
{
- return static_cast<typename policy_container::value_traits::hook_type*>
- (policy_container::value_traits::to_node_ptr(*item))->timeWhenShouldExpire;
+ return static_cast<typename policy_container::value_traits::hook_type*>(
+ policy_container::value_traits::to_node_ptr(*item))->timeWhenShouldExpire;
}
- static const Time& get_freshness (typename Container::const_iterator item)
+ static const Time&
+ get_freshness(typename Container::const_iterator item)
{
- return static_cast<const typename policy_container::value_traits::hook_type*>
- (policy_container::value_traits::to_node_ptr(*item))->timeWhenShouldExpire;
+ return static_cast<const typename policy_container::value_traits::hook_type*>(
+ policy_container::value_traits::to_node_ptr(*item))->timeWhenShouldExpire;
}
template<class Key>
- struct MemberHookLess
- {
- bool operator () (const Key &a, const Key &b) const
+ struct MemberHookLess {
+ bool
+ operator()(const Key& a, const Key& b) const
{
- return get_freshness (&a) < get_freshness (&b);
+ return get_freshness(&a) < get_freshness(&b);
}
};
- typedef boost::intrusive::multiset< Container,
- boost::intrusive::compare< MemberHookLess< Container > >,
- Hook > policy_container;
+ typedef boost::intrusive::multiset<Container,
+ boost::intrusive::compare<MemberHookLess<Container>>,
+ Hook> policy_container;
-
- class type : public policy_container
- {
+ class type : public policy_container {
public:
typedef policy policy_base; // to get access to get_freshness methods from outside
typedef Container parent_trie;
- type (Base &base)
- : base_ (base)
- , max_size_ (100)
+ type(Base& base)
+ : base_(base)
+ , max_size_(100)
{
}
inline void
- update (typename parent_trie::iterator item)
+ update(typename parent_trie::iterator item)
{
// do nothing
}
inline bool
- insert (typename parent_trie::iterator item)
+ insert(typename parent_trie::iterator item)
{
// get_time (item) = Simulator::Now ();
- Time freshness = item->payload ()->GetData ()->GetFreshness ();
- if (!freshness.IsZero ())
- {
- get_freshness (item) = Simulator::Now () + freshness;
+ Time freshness = item->payload()->GetData()->GetFreshness();
+ if (!freshness.IsZero()) {
+ get_freshness(item) = Simulator::Now() + freshness;
- // push item only if freshness is non zero. otherwise, this payload is not controlled by the policy
- // note that .size() on this policy would return only number of items with non-infinite freshness policy
- policy_container::insert (*item);
- }
+ // push item only if freshness is non zero. otherwise, this payload is not controlled by
+ // the policy
+ // note that .size() on this policy would return only number of items with non-infinite
+ // freshness policy
+ policy_container::insert(*item);
+ }
return true;
}
inline void
- lookup (typename parent_trie::iterator item)
+ lookup(typename parent_trie::iterator item)
{
// do nothing. it's random policy
}
inline void
- erase (typename parent_trie::iterator item)
+ erase(typename parent_trie::iterator item)
{
- if (!item->payload ()->GetData ()->GetFreshness ().IsZero ())
- {
- // erase only if freshness is non zero (otherwise an item is not in the policy
- policy_container::erase (policy_container::s_iterator_to (*item));
- }
+ if (!item->payload()->GetData()->GetFreshness().IsZero()) {
+ // erase only if freshness is non zero (otherwise an item is not in the policy
+ policy_container::erase(policy_container::s_iterator_to(*item));
+ }
}
inline void
- clear ()
+ clear()
{
- policy_container::clear ();
+ policy_container::clear();
}
inline void
- set_max_size (size_t max_size)
+ set_max_size(size_t max_size)
{
max_size_ = max_size;
}
inline size_t
- get_max_size () const
+ get_max_size() const
{
return max_size_;
}
private:
- type () : base_(*((Base*)0)) { };
+ type()
+ : base_(*((Base*)0)){};
private:
- Base &base_;
+ Base& base_;
size_t max_size_;
};
};
diff --git a/model/cs/custom-policies/lifetime-stats-policy.hpp b/model/cs/custom-policies/lifetime-stats-policy.hpp
index 905f532..1102ef1 100644
--- a/model/cs/custom-policies/lifetime-stats-policy.hpp
+++ b/model/cs/custom-policies/lifetime-stats-policy.hpp
@@ -35,119 +35,122 @@
/**
* @brief Traits for lifetime stats policy
*/
-struct lifetime_stats_policy_traits
-{
+struct lifetime_stats_policy_traits {
/// @brief Name that can be used to identify the policy (for NS-3 object model and logging)
- static std::string GetName () { return "LifetimeStats"; }
-
- struct policy_hook_type : public boost::intrusive::list_member_hook<> { Time timeWhenAdded; };
-
- template<class Container>
- struct container_hook
+ static std::string
+ GetName()
{
- typedef boost::intrusive::member_hook< Container,
- policy_hook_type,
- &Container::policy_hook_ > type;
+ return "LifetimeStats";
+ }
+
+ struct policy_hook_type : public boost::intrusive::list_member_hook<> {
+ Time timeWhenAdded;
};
- template<class Base,
- class Container,
- class Hook>
- struct policy
- {
- typedef typename boost::intrusive::list< Container, Hook > policy_container;
-
- static Time& get_time (typename Container::iterator item)
+ template<class Container>
+ struct container_hook {
+ typedef boost::intrusive::member_hook<Container, policy_hook_type, &Container::policy_hook_>
+ type;
+ };
+
+ template<class Base, class Container, class Hook>
+ struct policy {
+ typedef typename boost::intrusive::list<Container, Hook> policy_container;
+
+ static Time&
+ get_time(typename Container::iterator item)
{
- return static_cast<typename policy_container::value_traits::hook_type*>
- (policy_container::value_traits::to_node_ptr(*item))->timeWhenAdded;
- }
-
- static const Time& get_time (typename Container::const_iterator item)
- {
- return static_cast<const typename policy_container::value_traits::hook_type*>
- (policy_container::value_traits::to_node_ptr(*item))->timeWhenAdded;
+ return static_cast<typename policy_container::value_traits::hook_type*>(
+ policy_container::value_traits::to_node_ptr(*item))->timeWhenAdded;
}
- class type : public policy_container
+ static const Time&
+ get_time(typename Container::const_iterator item)
{
+ return static_cast<const typename policy_container::value_traits::hook_type*>(
+ policy_container::value_traits::to_node_ptr(*item))->timeWhenAdded;
+ }
+
+ class type : public policy_container {
public:
typedef policy policy_base; // to get access to get_time methods from outside
typedef Container parent_trie;
- type (Base &base)
- : base_ (base)
- , max_size_ (100)
- , m_willRemoveEntry (0)
+ type(Base& base)
+ : base_(base)
+ , max_size_(100)
+ , m_willRemoveEntry(0)
{
}
inline void
- update (typename parent_trie::iterator item)
+ update(typename parent_trie::iterator item)
{
// do nothing. it's random policy
}
-
- inline bool
- insert (typename parent_trie::iterator item)
- {
- get_time (item) = Simulator::Now ();
- policy_container::push_back (*item);
+ inline bool
+ insert(typename parent_trie::iterator item)
+ {
+ get_time(item) = Simulator::Now();
+
+ policy_container::push_back(*item);
return true;
}
-
+
inline void
- lookup (typename parent_trie::iterator item)
+ lookup(typename parent_trie::iterator item)
{
// do nothing. it's random policy
}
-
- inline void
- erase (typename parent_trie::iterator item)
- {
- Time lifetime = Simulator::Now () - get_time (item);
- if (m_willRemoveEntry != 0)
- {
- (*m_willRemoveEntry) (item->payload (), lifetime);
- }
-
- policy_container::erase (policy_container::s_iterator_to (*item));
+ inline void
+ erase(typename parent_trie::iterator item)
+ {
+ Time lifetime = Simulator::Now() - get_time(item);
+
+ if (m_willRemoveEntry != 0) {
+ (*m_willRemoveEntry)(item->payload(), lifetime);
+ }
+
+ policy_container::erase(policy_container::s_iterator_to(*item));
}
inline void
- clear ()
+ clear()
{
- policy_container::clear ();
+ policy_container::clear();
}
inline void
- set_max_size (size_t max_size)
+ set_max_size(size_t max_size)
{
max_size_ = max_size;
}
inline size_t
- get_max_size () const
+ get_max_size() const
{
return max_size_;
}
void
- set_traced_callback (TracedCallback< typename parent_trie::payload_traits::const_base_type, Time > *callback)
+ set_traced_callback(
+ TracedCallback<typename parent_trie::payload_traits::const_base_type, Time>* callback)
{
m_willRemoveEntry = callback;
}
-
+
private:
- type () : base_(*((Base*)0)) { };
-
+ type()
+ : base_(*((Base*)0)){};
+
private:
- Base &base_;
+ Base& base_;
size_t max_size_;
- TracedCallback< typename parent_trie::payload_traits::const_base_type, Time > *m_willRemoveEntry;
+ TracedCallback<typename parent_trie::payload_traits::const_base_type, Time>*
+ m_willRemoveEntry;
};
};
};
diff --git a/model/cs/custom-policies/probability-policy.hpp b/model/cs/custom-policies/probability-policy.hpp
index 0c3088c..57d6835 100644
--- a/model/cs/custom-policies/probability-policy.hpp
+++ b/model/cs/custom-policies/probability-policy.hpp
@@ -33,109 +33,106 @@
/**
* @brief Traits for freshness policy
*/
-struct probability_policy_traits
-{
- static std::string GetName () { return "ProbabilityImpl"; }
-
- struct policy_hook_type : public boost::intrusive::list_member_hook<> {};
-
- template<class Container>
- struct container_hook
+struct probability_policy_traits {
+ static std::string
+ GetName()
{
- typedef boost::intrusive::member_hook< Container,
- policy_hook_type,
- &Container::policy_hook_ > type;
+ return "ProbabilityImpl";
+ }
+
+ struct policy_hook_type : public boost::intrusive::list_member_hook<> {
};
- template<class Base,
- class Container,
- class Hook>
- struct policy
- {
- typedef typename boost::intrusive::list< Container, Hook > policy_container;
-
- class type : public policy_container
- {
+ template<class Container>
+ struct container_hook {
+ typedef boost::intrusive::member_hook<Container, policy_hook_type, &Container::policy_hook_>
+ type;
+ };
+
+ template<class Base, class Container, class Hook>
+ struct policy {
+ typedef typename boost::intrusive::list<Container, Hook> policy_container;
+
+ class type : public policy_container {
public:
typedef policy policy_base; // to get access to get_freshness methods from outside
typedef Container parent_trie;
- type (Base &base)
- : base_ (base)
- , max_size_ (100)
- , probability_ (1.0)
+ type(Base& base)
+ : base_(base)
+ , max_size_(100)
+ , probability_(1.0)
{
}
inline void
- update (typename parent_trie::iterator item)
+ update(typename parent_trie::iterator item)
{
}
inline bool
- insert (typename parent_trie::iterator item)
+ insert(typename parent_trie::iterator item)
{
- if (ns3_rand_.GetValue () < probability_)
- {
- policy_container::push_back (*item);
+ if (ns3_rand_.GetValue() < probability_) {
+ policy_container::push_back(*item);
- // allow caching
- return true;
- }
- else
- {
- // don't allow caching
- return false;
- }
+ // allow caching
+ return true;
+ }
+ else {
+ // don't allow caching
+ return false;
+ }
}
inline void
- lookup (typename parent_trie::iterator item)
+ lookup(typename parent_trie::iterator item)
{
// do nothing. it's random policy
}
inline void
- erase (typename parent_trie::iterator item)
+ erase(typename parent_trie::iterator item)
{
- policy_container::erase (policy_container::s_iterator_to (*item));
+ policy_container::erase(policy_container::s_iterator_to(*item));
}
inline void
- clear ()
+ clear()
{
- policy_container::clear ();
+ policy_container::clear();
}
inline void
- set_max_size (size_t max_size)
+ set_max_size(size_t max_size)
{
max_size_ = max_size;
}
inline size_t
- get_max_size () const
+ get_max_size() const
{
return max_size_;
}
inline void
- set_probability (double probability)
+ set_probability(double probability)
{
probability_ = probability;
}
inline double
- get_probability () const
+ get_probability() const
{
return probability_;
- }
+ }
private:
- type () : base_(*((Base*)0)) { };
+ type()
+ : base_(*((Base*)0)){};
private:
- Base &base_;
+ Base& base_;
size_t max_size_;
double probability_;
UniformVariable ns3_rand_;
diff --git a/model/cs/ndn-content-store.cpp b/model/cs/ndn-content-store.cpp
index 4d3bb65..3588eb9 100644
--- a/model/cs/ndn-content-store.cpp
+++ b/model/cs/ndn-content-store.cpp
@@ -17,7 +17,7 @@
*
* Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Ilya Moiseenko <iliamo@cs.ucla.edu>
- *
+ *
*/
#include "ndn-content-store.hpp"
@@ -25,32 +25,31 @@
#include "ns3/log.h"
#include "ns3/packet.h"
-NS_LOG_COMPONENT_DEFINE ("ndn.cs.ContentStore");
+NS_LOG_COMPONENT_DEFINE("ndn.cs.ContentStore");
namespace ns3 {
namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (ContentStore);
+NS_OBJECT_ENSURE_REGISTERED(ContentStore);
TypeId
-ContentStore::GetTypeId (void)
+ContentStore::GetTypeId(void)
{
- static TypeId tid = TypeId ("ns3::ndn::ContentStore")
- .SetGroupName ("Ndn")
- .SetParent<Object> ()
+ static TypeId tid =
+ TypeId("ns3::ndn::ContentStore")
+ .SetGroupName("Ndn")
+ .SetParent<Object>()
- .AddTraceSource ("CacheHits", "Trace called every time there is a cache hit",
- MakeTraceSourceAccessor (&ContentStore::m_cacheHitsTrace))
+ .AddTraceSource("CacheHits", "Trace called every time there is a cache hit",
+ MakeTraceSourceAccessor(&ContentStore::m_cacheHitsTrace))
- .AddTraceSource ("CacheMisses", "Trace called every time there is a cache miss",
- MakeTraceSourceAccessor (&ContentStore::m_cacheMissesTrace))
- ;
+ .AddTraceSource("CacheMisses", "Trace called every time there is a cache miss",
+ MakeTraceSourceAccessor(&ContentStore::m_cacheMissesTrace));
return tid;
}
-
-ContentStore::~ContentStore ()
+ContentStore::~ContentStore()
{
}
@@ -58,31 +57,30 @@
//////////////////////////////////////////////////////////////////////
-Entry::Entry (Ptr<ContentStore> cs, Ptr<const Data> data)
- : m_cs (cs)
- , m_data (data)
+Entry::Entry(Ptr<ContentStore> cs, Ptr<const Data> data)
+ : m_cs(cs)
+ , m_data(data)
{
}
const Name&
-Entry::GetName () const
+Entry::GetName() const
{
- return m_data->GetName ();
+ return m_data->GetName();
}
Ptr<const Data>
-Entry::GetData () const
+Entry::GetData() const
{
return m_data;
}
Ptr<ContentStore>
-Entry::GetContentStore ()
+Entry::GetContentStore()
{
return m_cs;
}
-
} // namespace cs
} // namespace ndn
} // namespace ns3
diff --git a/model/cs/ndn-content-store.hpp b/model/cs/ndn-content-store.hpp
index ae7c059..23266c4 100644
--- a/model/cs/ndn-content-store.hpp
+++ b/model/cs/ndn-content-store.hpp
@@ -20,7 +20,7 @@
*/
#ifndef NDN_CONTENT_STORE_H
-#define NDN_CONTENT_STORE_H
+#define NDN_CONTENT_STORE_H
#include "ns3/object.h"
#include "ns3/ptr.h"
@@ -54,8 +54,7 @@
* @ingroup ndn-cs
* @brief NDN content store entry
*/
-class Entry : public SimpleRefCount<Entry>
-{
+class Entry : public SimpleRefCount<Entry> {
public:
/**
* \brief Construct content store entry
@@ -66,27 +65,27 @@
* The constructor will make a copy of the supplied packet and calls
* RemoveHeader and RemoveTail on the copy.
*/
- Entry (Ptr<ContentStore> cs, Ptr<const Data> data);
+ Entry(Ptr<ContentStore> cs, Ptr<const Data> data);
/**
* \brief Get prefix of the stored entry
* \returns prefix of the stored entry
*/
const Name&
- GetName () const;
+ GetName() const;
/**
* \brief Get Data of the stored entry
* \returns Data of the stored entry
*/
Ptr<const Data>
- GetData () const;
+ GetData() const;
/**
* @brief Get pointer to access store, to which this entry is added
*/
Ptr<ContentStore>
- GetContentStore ();
+ GetContentStore();
private:
Ptr<ContentStore> m_cs; ///< \brief content store to which entry is added
@@ -95,29 +94,26 @@
} // namespace cs
-
/**
* @ingroup ndn-cs
* \brief Base class for NDN content store
*
* Particular implementations should implement Lookup, Add, and Print methods
*/
-class ContentStore : public Object
-{
+class ContentStore : public Object {
public:
/**
* \brief Interface ID
*
* \return interface ID
*/
- static
- TypeId GetTypeId ();
+ static TypeId
+ GetTypeId();
/**
* @brief Virtual destructor
*/
- virtual
- ~ContentStore ();
+ virtual ~ContentStore();
/**
* \brief Find corresponding CS entry for the given interest
@@ -129,7 +125,7 @@
* used entries index, \see m_contentStore
*/
virtual Ptr<Data>
- Lookup (Ptr<const Interest> interest) = 0;
+ Lookup(Ptr<const Interest> interest) = 0;
/**
* \brief Add a new content to the content store.
@@ -140,7 +136,7 @@
* @returns true if an existing entry was updated, false otherwise
*/
virtual bool
- Add (Ptr<const Data> data) = 0;
+ Add(Ptr<const Data> data) = 0;
// /*
// * \brief Add a new content to the content store.
@@ -155,32 +151,30 @@
* \brief Print out content store entries
*/
virtual void
- Print (std::ostream &os) const = 0;
-
+ Print(std::ostream& os) const = 0;
/**
* @brief Get number of entries in content store
*/
virtual uint32_t
- GetSize () const = 0;
+ GetSize() const = 0;
/**
* @brief Return first element of content store (no order guaranteed)
*/
virtual Ptr<cs::Entry>
- Begin () = 0;
+ Begin() = 0;
/**
* @brief Return item next after last (no order guaranteed)
*/
virtual Ptr<cs::Entry>
- End () = 0;
+ End() = 0;
/**
* @brief Advance the iterator
*/
- virtual Ptr<cs::Entry>
- Next (Ptr<cs::Entry>) = 0;
+ virtual Ptr<cs::Entry> Next(Ptr<cs::Entry>) = 0;
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
@@ -190,29 +184,28 @@
* @brief Static call to cheat python bindings
*/
static inline Ptr<ContentStore>
- GetContentStore (Ptr<Object> node);
+ GetContentStore(Ptr<Object> node);
protected:
TracedCallback<Ptr<const Interest>,
- Ptr<const Data> > m_cacheHitsTrace; ///< @brief trace of cache hits
+ Ptr<const Data>> m_cacheHitsTrace; ///< @brief trace of cache hits
- TracedCallback<Ptr<const Interest> > m_cacheMissesTrace; ///< @brief trace of cache misses
+ TracedCallback<Ptr<const Interest>> m_cacheMissesTrace; ///< @brief trace of cache misses
};
inline std::ostream&
-operator<< (std::ostream &os, const ContentStore &cs)
+operator<<(std::ostream& os, const ContentStore& cs)
{
- cs.Print (os);
+ cs.Print(os);
return os;
}
inline Ptr<ContentStore>
-ContentStore::GetContentStore (Ptr<Object> node)
+ContentStore::GetContentStore(Ptr<Object> node)
{
- return node->GetObject<ContentStore> ();
+ return node->GetObject<ContentStore>();
}
-
} // namespace ndn
} // namespace ns3
diff --git a/model/ndn-app-face.cpp b/model/ndn-app-face.cpp
index 9125e2c..d267f6b 100644
--- a/model/ndn-app-face.cpp
+++ b/model/ndn-app-face.cpp
@@ -34,45 +34,42 @@
#include "ndn-interest.hpp"
#include "ndn-data.hpp"
-NS_LOG_COMPONENT_DEFINE ("ndn.AppFace");
+NS_LOG_COMPONENT_DEFINE("ndn.AppFace");
namespace ns3 {
namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (AppFace);
+NS_OBJECT_ENSURE_REGISTERED(AppFace);
TypeId
-AppFace::GetTypeId ()
+AppFace::GetTypeId()
{
- static TypeId tid = TypeId ("ns3::ndn::AppFace")
- .SetParent<Face> ()
- .SetGroupName ("Ndn")
- ;
+ static TypeId tid = TypeId("ns3::ndn::AppFace").SetParent<Face>().SetGroupName("Ndn");
return tid;
}
-AppFace::AppFace (Ptr<App> app)
- : Face (app->GetNode ())
- , m_app (app)
+AppFace::AppFace(Ptr<App> app)
+ : Face(app->GetNode())
+ , m_app(app)
{
- NS_LOG_FUNCTION (this << app);
-
- NS_ASSERT (m_app != 0);
- SetFlags (Face::APPLICATION);
+ NS_LOG_FUNCTION(this << app);
+
+ NS_ASSERT(m_app != 0);
+ SetFlags(Face::APPLICATION);
}
-AppFace::~AppFace ()
+AppFace::~AppFace()
{
- NS_LOG_FUNCTION_NOARGS ();
+ NS_LOG_FUNCTION_NOARGS();
}
-AppFace::AppFace ()
- : Face (0)
+AppFace::AppFace()
+ : Face(0)
{
}
-AppFace::AppFace (const AppFace &)
- : Face (0)
+AppFace::AppFace(const AppFace&)
+ : Face(0)
{
}
@@ -83,39 +80,37 @@
}
bool
-AppFace::SendInterest (Ptr<const Interest> interest)
+AppFace::SendInterest(Ptr<const Interest> interest)
{
- NS_LOG_FUNCTION (this << interest);
+ NS_LOG_FUNCTION(this << interest);
- if (!IsUp ())
- {
- return false;
- }
+ if (!IsUp()) {
+ return false;
+ }
- if (interest->GetNack () > 0)
- m_app->OnNack (interest);
+ if (interest->GetNack() > 0)
+ m_app->OnNack(interest);
else
- m_app->OnInterest (interest);
-
+ m_app->OnInterest(interest);
+
return true;
}
bool
-AppFace::SendData (Ptr<const Data> data)
+AppFace::SendData(Ptr<const Data> data)
{
- NS_LOG_FUNCTION (this << data);
+ NS_LOG_FUNCTION(this << data);
- if (!IsUp ())
- {
- return false;
- }
+ if (!IsUp()) {
+ return false;
+ }
- m_app->OnData (data);
+ m_app->OnData(data);
return true;
}
std::ostream&
-AppFace::Print (std::ostream& os) const
+AppFace::Print(std::ostream& os) const
{
os << "dev=local(" << GetId() << ")";
return os;
@@ -123,4 +118,3 @@
} // namespace ndn
} // namespace ns3
-
diff --git a/model/ndn-app-face.hpp b/model/ndn-app-face.hpp
index 3663be0..6d8be19 100644
--- a/model/ndn-app-face.hpp
+++ b/model/ndn-app-face.hpp
@@ -49,35 +49,35 @@
*
* \see AppFace, NdnNetDeviceFace, NdnIpv4Face, NdnUdpFace
*/
-class AppFace : public Face
-{
+class AppFace : public Face {
public:
static TypeId
- GetTypeId ();
+ GetTypeId();
/**
* \brief Default constructor
*/
- AppFace (Ptr<App> app);
+ AppFace(Ptr<App> app);
virtual ~AppFace();
-
+
////////////////////////////////////////////////////////////////////
// methods overloaded from Face
virtual bool
- SendInterest (Ptr<const Interest> interest);
+ SendInterest(Ptr<const Interest> interest);
virtual bool
- SendData (Ptr<const Data> data);
+ SendData(Ptr<const Data> data);
public:
virtual std::ostream&
- Print (std::ostream &os) const;
+ Print(std::ostream& os) const;
////////////////////////////////////////////////////////////////////
-
+
private:
- AppFace ();
- AppFace (const AppFace &); ///< \brief Disabled copy constructor
- AppFace& operator= (const AppFace &); ///< \brief Disabled copy operator
+ AppFace();
+ AppFace(const AppFace&); ///< \brief Disabled copy constructor
+ AppFace&
+ operator=(const AppFace&); ///< \brief Disabled copy operator
private:
Ptr<App> m_app;
diff --git a/model/ndn-common.hpp b/model/ndn-common.hpp
index 8bfc4f9..f5da38b 100644
--- a/model/ndn-common.hpp
+++ b/model/ndn-common.hpp
@@ -1,10 +1,10 @@
/** -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
+/*
* Copyright (c) 2013, Regents of the University of California
* Alexander Afanasyev
- *
+ *
* BSD license, See the doc/LICENSE file for more information
- *
+ *
* Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
@@ -16,8 +16,12 @@
#define NDNSIM_MODE 1
-#define NDN_NAMESPACE_BEGIN namespace ns3 { namespace ndn {
-#define NDN_NAMESPACE_END } /*ndn*/ } /*ns3*/
+#define NDN_NAMESPACE_BEGIN \
+ namespace ns3 { \
+ namespace ndn {
+#define NDN_NAMESPACE_END \
+ } /*ndn*/ \
+ } /*ns3*/
/**
* @brief NS-3 namespace
@@ -29,22 +33,19 @@
*/
namespace ndn {
}
-
}
NDN_NAMESPACE_BEGIN
typedef Time TimeInterval;
-namespace time
-{
+namespace time {
inline Time
-NowUnixTimestamp ()
+NowUnixTimestamp()
{
- return Simulator::Now ();
+ return Simulator::Now();
}
-
}
NDN_NAMESPACE_END
diff --git a/model/ndn-face.cpp b/model/ndn-face.cpp
index 6b23dd7..505c2b4 100644
--- a/model/ndn-face.cpp
+++ b/model/ndn-face.cpp
@@ -39,25 +39,24 @@
#include <boost/ref.hpp>
-NS_LOG_COMPONENT_DEFINE ("ndn.Face");
+NS_LOG_COMPONENT_DEFINE("ndn.Face");
namespace ns3 {
namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (Face);
+NS_OBJECT_ENSURE_REGISTERED(Face);
TypeId
-Face::GetTypeId ()
+Face::GetTypeId()
{
- static TypeId tid = TypeId ("ns3::ndn::Face")
- .SetParent<Object> ()
- .SetGroupName ("Ndn")
- .AddAttribute ("Id", "Face id (unique integer for the Ndn stack on this node)",
- TypeId::ATTR_GET, // allow only getting it.
- UintegerValue (0),
- MakeUintegerAccessor (&Face::m_id),
- MakeUintegerChecker<uint32_t> ())
- ;
+ static TypeId tid =
+ TypeId("ns3::ndn::Face")
+ .SetParent<Object>()
+ .SetGroupName("Ndn")
+ .AddAttribute("Id", "Face id (unique integer for the Ndn stack on this node)",
+ TypeId::ATTR_GET, // allow only getting it.
+ UintegerValue(0), MakeUintegerAccessor(&Face::m_id),
+ MakeUintegerChecker<uint32_t>());
return tid;
}
@@ -66,26 +65,26 @@
* with no IP addresses. Before becoming useable, the user must
* invoke SetUp on them once an Ndn address and mask have been set.
*/
-Face::Face (Ptr<Node> node)
- : m_node (node)
- , m_upstreamInterestHandler (MakeNullCallback< void, Ptr<Face>, Ptr<Interest> > ())
- , m_upstreamDataHandler (MakeNullCallback< void, Ptr<Face>, Ptr<Data> > ())
- , m_ifup (false)
- , m_id ((uint32_t)-1)
- , m_metric (0)
- , m_flags (0)
+Face::Face(Ptr<Node> node)
+ : m_node(node)
+ , m_upstreamInterestHandler(MakeNullCallback<void, Ptr<Face>, Ptr<Interest>>())
+ , m_upstreamDataHandler(MakeNullCallback<void, Ptr<Face>, Ptr<Data>>())
+ , m_ifup(false)
+ , m_id((uint32_t)-1)
+ , m_metric(0)
+ , m_flags(0)
{
- NS_LOG_FUNCTION (this << node);
+ NS_LOG_FUNCTION(this << node);
- NS_ASSERT_MSG (node != 0, "node cannot be NULL. Check the code");
+ NS_ASSERT_MSG(node != 0, "node cannot be NULL. Check the code");
}
-Face::~Face ()
+Face::~Face()
{
- NS_LOG_FUNCTION_NOARGS ();
+ NS_LOG_FUNCTION_NOARGS();
}
-Face::Face (const Face &)
+Face::Face(const Face&)
{
}
@@ -95,152 +94,146 @@
}
Ptr<Node>
-Face::GetNode () const
+Face::GetNode() const
{
return m_node;
}
void
-Face::RegisterProtocolHandlers (const InterestHandler &interestHandler, const DataHandler &dataHandler)
+Face::RegisterProtocolHandlers(const InterestHandler& interestHandler,
+ const DataHandler& dataHandler)
{
- NS_LOG_FUNCTION_NOARGS ();
+ NS_LOG_FUNCTION_NOARGS();
m_upstreamInterestHandler = interestHandler;
m_upstreamDataHandler = dataHandler;
}
void
-Face::UnRegisterProtocolHandlers ()
+Face::UnRegisterProtocolHandlers()
{
- NS_LOG_FUNCTION_NOARGS ();
+ NS_LOG_FUNCTION_NOARGS();
- m_upstreamInterestHandler = MakeNullCallback< void, Ptr<Face>, Ptr<Interest> > ();
- m_upstreamDataHandler = MakeNullCallback< void, Ptr<Face>, Ptr<Data> > ();
-}
-
-
-bool
-Face::SendInterest (Ptr<const Interest> interest)
-{
- NS_LOG_FUNCTION (this << boost::cref (*this) << interest->GetName ());
-
- if (!IsUp ())
- {
- return false;
- }
-
- return Send (Wire::FromInterest (interest));
+ m_upstreamInterestHandler = MakeNullCallback<void, Ptr<Face>, Ptr<Interest>>();
+ m_upstreamDataHandler = MakeNullCallback<void, Ptr<Face>, Ptr<Data>>();
}
bool
-Face::SendData (Ptr<const Data> data)
+Face::SendInterest(Ptr<const Interest> interest)
{
- NS_LOG_FUNCTION (this << data);
+ NS_LOG_FUNCTION(this << boost::cref(*this) << interest->GetName());
- if (!IsUp ())
- {
- return false;
- }
+ if (!IsUp()) {
+ return false;
+ }
- return Send (Wire::FromData (data));
+ return Send(Wire::FromInterest(interest));
}
bool
-Face::Send (Ptr<Packet> packet)
+Face::SendData(Ptr<const Data> data)
+{
+ NS_LOG_FUNCTION(this << data);
+
+ if (!IsUp()) {
+ return false;
+ }
+
+ return Send(Wire::FromData(data));
+}
+
+bool
+Face::Send(Ptr<Packet> packet)
{
FwHopCountTag hopCount;
- bool tagExists = packet->RemovePacketTag (hopCount);
- if (tagExists)
- {
- hopCount.Increment ();
- packet->AddPacketTag (hopCount);
- }
+ bool tagExists = packet->RemovePacketTag(hopCount);
+ if (tagExists) {
+ hopCount.Increment();
+ packet->AddPacketTag(hopCount);
+ }
return true;
}
bool
-Face::Receive (Ptr<const Packet> p)
+Face::Receive(Ptr<const Packet> p)
{
- NS_LOG_FUNCTION (this << p << p->GetSize ());
+ NS_LOG_FUNCTION(this << p << p->GetSize());
- if (!IsUp ())
- {
- // no tracing here. If we were off while receiving, we shouldn't even know that something was there
+ if (!IsUp()) {
+ // no tracing here. If we were off while receiving, we shouldn't even know that something was
+ // there
+ return false;
+ }
+
+ Ptr<Packet> packet = p->Copy(); // give upper layers a rw copy of the packet
+ try {
+ HeaderHelper::Type type = HeaderHelper::GetNdnHeaderType(packet);
+ switch (type) {
+ case HeaderHelper::INTEREST_NDNSIM:
+ return ReceiveInterest(Wire::ToInterest(packet, Wire::WIRE_FORMAT_NDNSIM));
+ case HeaderHelper::INTEREST_CCNB:
+ return ReceiveInterest(Wire::ToInterest(packet, Wire::WIRE_FORMAT_CCNB));
+ case HeaderHelper::CONTENT_OBJECT_NDNSIM:
+ return ReceiveData(Wire::ToData(packet, Wire::WIRE_FORMAT_NDNSIM));
+ case HeaderHelper::CONTENT_OBJECT_CCNB:
+ return ReceiveData(Wire::ToData(packet, Wire::WIRE_FORMAT_CCNB));
+ default:
+ NS_FATAL_ERROR("Not supported NDN header");
return false;
}
- Ptr<Packet> packet = p->Copy (); // give upper layers a rw copy of the packet
- try
- {
- HeaderHelper::Type type = HeaderHelper::GetNdnHeaderType (packet);
- switch (type)
- {
- case HeaderHelper::INTEREST_NDNSIM:
- return ReceiveInterest (Wire::ToInterest (packet, Wire::WIRE_FORMAT_NDNSIM));
- case HeaderHelper::INTEREST_CCNB:
- return ReceiveInterest (Wire::ToInterest (packet, Wire::WIRE_FORMAT_CCNB));
- case HeaderHelper::CONTENT_OBJECT_NDNSIM:
- return ReceiveData (Wire::ToData (packet, Wire::WIRE_FORMAT_NDNSIM));
- case HeaderHelper::CONTENT_OBJECT_CCNB:
- return ReceiveData (Wire::ToData (packet, Wire::WIRE_FORMAT_CCNB));
- default:
- NS_FATAL_ERROR ("Not supported NDN header");
- return false;
- }
-
- // exception will be thrown if packet is not recognized
- }
- catch (UnknownHeaderException)
- {
- NS_FATAL_ERROR ("Unknown NDN header. Should not happen");
- return false;
- }
+ // exception will be thrown if packet is not recognized
+ }
+ catch (UnknownHeaderException) {
+ NS_FATAL_ERROR("Unknown NDN header. Should not happen");
+ return false;
+ }
return false;
}
bool
-Face::ReceiveInterest (Ptr<Interest> interest)
+Face::ReceiveInterest(Ptr<Interest> interest)
{
- if (!IsUp ())
- {
- // no tracing here. If we were off while receiving, we shouldn't even know that something was there
- return false;
- }
+ if (!IsUp()) {
+ // no tracing here. If we were off while receiving, we shouldn't even know that something was
+ // there
+ return false;
+ }
- m_upstreamInterestHandler (this, interest);
+ m_upstreamInterestHandler(this, interest);
return true;
}
bool
-Face::ReceiveData (Ptr<Data> data)
+Face::ReceiveData(Ptr<Data> data)
{
- if (!IsUp ())
- {
- // no tracing here. If we were off while receiving, we shouldn't even know that something was there
- return false;
- }
+ if (!IsUp()) {
+ // no tracing here. If we were off while receiving, we shouldn't even know that something was
+ // there
+ return false;
+ }
- m_upstreamDataHandler (this, data);
+ m_upstreamDataHandler(this, data);
return true;
}
void
-Face::SetMetric (uint16_t metric)
+Face::SetMetric(uint16_t metric)
{
- NS_LOG_FUNCTION (metric);
+ NS_LOG_FUNCTION(metric);
m_metric = metric;
}
uint16_t
-Face::GetMetric (void) const
+Face::GetMetric(void) const
{
return m_metric;
}
void
-Face::SetFlags (uint32_t flags)
+Face::SetFlags(uint32_t flags)
{
m_flags = flags;
}
@@ -248,8 +241,9 @@
bool
Face::operator== (const Face &face) const
{
- NS_ASSERT_MSG (m_node->GetId () == face.m_node->GetId (),
- "Faces of different nodes should not be compared to each other: " << *this << " == " << face);
+ NS_ASSERT_MSG(m_node->GetId() == face.m_node->GetId(),
+ "Faces of different nodes should not be compared to each other: " << *this << " == "
+ << face);
return (m_id == face.m_id);
}
@@ -257,26 +251,26 @@
bool
Face::operator< (const Face &face) const
{
- NS_ASSERT_MSG (m_node->GetId () == face.m_node->GetId (),
- "Faces of different nodes should not be compared to each other: " << *this << " == " << face);
+ NS_ASSERT_MSG(m_node->GetId() == face.m_node->GetId(),
+ "Faces of different nodes should not be compared to each other: " << *this << " == "
+ << face);
return (m_id < face.m_id);
}
std::ostream&
-Face::Print (std::ostream &os) const
+Face::Print(std::ostream& os) const
{
- os << "id=" << GetId ();
+ os << "id=" << GetId();
return os;
}
std::ostream&
-operator<< (std::ostream& os, const Face &face)
+operator<<(std::ostream& os, const Face& face)
{
- face.Print (os);
+ face.Print(os);
return os;
}
} // namespace ndn
} // namespace ns3
-
diff --git a/model/ndn-face.hpp b/model/ndn-face.hpp
index bf0a9b2..b8cd098 100644
--- a/model/ndn-face.hpp
+++ b/model/ndn-face.hpp
@@ -55,12 +55,10 @@
*
* \see ndn::AppFace, ndn::NetDeviceFace
*/
-class Face :
- public Object
-{
+class Face : public Object {
public:
static TypeId
- GetTypeId ();
+ GetTypeId();
/**
* \brief NDN protocol handlers
@@ -68,20 +66,20 @@
* \param face Face from which packet has been received
* \param packet Original packet
*/
- typedef Callback<void, Ptr<Face>, Ptr<Interest> > InterestHandler;
- typedef Callback<void, Ptr<Face>, Ptr<Data> > DataHandler;
+ typedef Callback<void, Ptr<Face>, Ptr<Interest>> InterestHandler;
+ typedef Callback<void, Ptr<Face>, Ptr<Data>> DataHandler;
/**
* \brief Default constructor
*/
- Face (Ptr<Node> node);
+ Face(Ptr<Node> node);
virtual ~Face();
/**
* @brief Get node to which this face is associated
*/
Ptr<Node>
- GetNode () const;
+ GetNode() const;
////////////////////////////////////////////////////////////////////
@@ -91,7 +89,7 @@
* This method should call protocol-dependent registration function
*/
virtual void
- RegisterProtocolHandlers (const InterestHandler &interestHandler, const DataHandler &dataHandler);
+ RegisterProtocolHandlers(const InterestHandler& interestHandler, const DataHandler& dataHandler);
/**
* \brief Un-Register callback to call when new packet arrives on the face
@@ -99,7 +97,7 @@
* This method should call protocol-dependent registration function
*/
virtual void
- UnRegisterProtocolHandlers ();
+ UnRegisterProtocolHandlers();
/**
* @brief Send out interest through the face
@@ -109,7 +107,7 @@
* @returns true if interest is considered to be send out (enqueued)
*/
virtual bool
- SendInterest (Ptr<const Interest> interest);
+ SendInterest(Ptr<const Interest> interest);
/**
* @brief Send out Dat packet through the face
@@ -119,7 +117,7 @@
* @returns true if Data packet is considered to be send out (enqueued)
*/
virtual bool
- SendData (Ptr<const Data> data);
+ SendData(Ptr<const Data> data);
/**
* \brief Receive interest from application or another node and forward it up to the NDN stack
@@ -127,7 +125,7 @@
* By default it is called from inside Receive method, but can be used directly, if appropriate
*/
virtual bool
- ReceiveInterest (Ptr<Interest> interest);
+ ReceiveInterest(Ptr<Interest> interest);
/**
* \brief Receive Data packet from application or another node and forward it up to the NDN stack
@@ -135,7 +133,7 @@
* By default it is called from inside Receive method, but can be used directly, if appropriate
*/
virtual bool
- ReceiveData (Ptr<Data> data);
+ ReceiveData(Ptr<Data> data);
////////////////////////////////////////////////////////////////////
/**
@@ -144,7 +142,7 @@
* \param metric configured routing metric (cost) of this face
*/
virtual void
- SetMetric (uint16_t metric);
+ SetMetric(uint16_t metric);
/**
* \brief Get routing/forwarding metric assigned to the face
@@ -152,7 +150,7 @@
* \returns configured routing/forwarding metric (cost) of this face
*/
virtual uint16_t
- GetMetric (void) const;
+ GetMetric(void) const;
/**
* These are face states and may be distinct from actual lower-layer
@@ -164,39 +162,39 @@
* \brief Enable or disable this face
*/
inline void
- SetUp (bool up = true);
+ SetUp(bool up = true);
/**
* \brief Returns true if this face is enabled, false otherwise.
*/
inline bool
- IsUp () const;
+ IsUp() const;
/**
* @brief Get face flags
*
- * Face flags may indicate various properties of the face. For example, if the face is an application face,
+ * Face flags may indicate various properties of the face. For example, if the face is an
+ *application face,
* than the returned flags have Face::APPLICATION bit set.
*
* @see ndn::Face::Flags for the list of currently defined face flags
*/
inline uint32_t
- GetFlags () const;
+ GetFlags() const;
/**
* @brief List of currently defined face flags
*/
- enum Flags
- {
- APPLICATION = 1 ///< @brief An application face
- };
+ enum Flags {
+ APPLICATION = 1 ///< @brief An application face
+ };
/**
* @brief Print information about the face into the stream
* @param os stream to write information to
*/
virtual std::ostream&
- Print (std::ostream &os) const;
+ Print(std::ostream& os) const;
/**
* \brief Set face Id
@@ -206,7 +204,7 @@
* \param id id to set
*/
inline void
- SetId (uint32_t id);
+ SetId(uint32_t id);
/**
* \brief Get face Id
@@ -216,7 +214,7 @@
* \returns id id to set
*/
inline uint32_t
- GetId () const;
+ GetId() const;
/**
* \brief Compare two faces. Only two faces on the same node could be compared.
@@ -224,7 +222,7 @@
* Internal index is used for comparison.
*/
bool
- operator== (const Face &face) const;
+ operator==(const Face& face) const;
/**
* \brief Compare two faces. Only two faces on the same node could be compared.
@@ -232,7 +230,7 @@
* Internal index is used for comparison.
*/
inline bool
- operator!= (const Face &face) const;
+ operator!=(const Face& face) const;
/**
* \brief Compare two faces. Only two faces on the same node could be compared.
@@ -240,30 +238,31 @@
* Internal index is used for comparison.
*/
bool
- operator< (const Face &face) const;
+ operator<(const Face& face) const;
protected:
/**
* @brief Send packet down to the stack (towards app or network)
*/
virtual bool
- Send (Ptr<Packet> packet);
+ Send(Ptr<Packet> packet);
/**
* @brief Send packet up to the stack (towards forwarding strategy)
*/
virtual bool
- Receive (Ptr<const Packet> p);
+ Receive(Ptr<const Packet> p);
/**
* @brief Set face flags
*/
void
- SetFlags (uint32_t flags);
+ SetFlags(uint32_t flags);
private:
- Face (const Face &); ///< \brief Disabled copy constructor
- Face& operator= (const Face &); ///< \brief Disabled copy operator
+ Face(const Face&); ///< \brief Disabled copy constructor
+ Face&
+ operator=(const Face&); ///< \brief Disabled copy operator
protected:
Ptr<Node> m_node; ///< \brief Smart pointer to Node
@@ -272,46 +271,46 @@
InterestHandler m_upstreamInterestHandler;
DataHandler m_upstreamDataHandler;
bool m_ifup;
- uint32_t m_id; ///< \brief id of the interface in NDN stack (per-node uniqueness)
+ uint32_t m_id; ///< \brief id of the interface in NDN stack (per-node uniqueness)
uint16_t m_metric; ///< \brief metric of the face
- uint32_t m_flags; ///< @brief faces flags (e.g., APPLICATION)
+ uint32_t m_flags; ///< @brief faces flags (e.g., APPLICATION)
};
std::ostream&
-operator<< (std::ostream& os, const Face &face);
+operator<<(std::ostream& os, const Face& face);
inline bool
-Face::IsUp (void) const
+Face::IsUp(void) const
{
return m_ifup;
}
inline void
-Face::SetUp (bool up/* = true*/)
+Face::SetUp(bool up /* = true*/)
{
m_ifup = up;
}
inline uint32_t
-Face::GetFlags () const
+Face::GetFlags() const
{
return m_flags;
}
inline bool
-operator < (const Ptr<Face> &lhs, const Ptr<Face> &rhs)
+operator<(const Ptr<Face>& lhs, const Ptr<Face>& rhs)
{
return *lhs < *rhs;
}
void
-Face::SetId (uint32_t id)
+Face::SetId(uint32_t id)
{
m_id = id;
}
uint32_t
-Face::GetId () const
+Face::GetId() const
{
return m_id;
}
diff --git a/model/ndn-global-router.cpp b/model/ndn-global-router.cpp
index e29c055..f44a088 100644
--- a/model/ndn-global-router.cpp
+++ b/model/ndn-global-router.cpp
@@ -33,66 +33,62 @@
uint32_t GlobalRouter::m_idCounter = 0;
-NS_OBJECT_ENSURE_REGISTERED (GlobalRouter);
+NS_OBJECT_ENSURE_REGISTERED(GlobalRouter);
-TypeId
-GlobalRouter::GetTypeId ()
+TypeId
+GlobalRouter::GetTypeId()
{
- static TypeId tid = TypeId ("ns3::ndn::GlobalRouter")
- .SetGroupName ("Ndn")
- .SetParent<Object> ()
- ;
+ static TypeId tid = TypeId("ns3::ndn::GlobalRouter").SetGroupName("Ndn").SetParent<Object>();
return tid;
}
-GlobalRouter::GlobalRouter ()
+GlobalRouter::GlobalRouter()
{
m_id = m_idCounter;
- m_idCounter ++;
+ m_idCounter++;
}
void
-GlobalRouter::NotifyNewAggregate ()
+GlobalRouter::NotifyNewAggregate()
{
- if (m_ndn == 0)
- {
- m_ndn = GetObject<L3Protocol> ();
- }
- Object::NotifyNewAggregate ();
+ if (m_ndn == 0) {
+ m_ndn = GetObject<L3Protocol>();
+ }
+ Object::NotifyNewAggregate();
}
uint32_t
-GlobalRouter::GetId () const
+GlobalRouter::GetId() const
{
return m_id;
}
Ptr<L3Protocol>
-GlobalRouter::GetL3Protocol () const
+GlobalRouter::GetL3Protocol() const
{
return m_ndn;
}
void
-GlobalRouter::AddLocalPrefix (Ptr< Name > prefix)
+GlobalRouter::AddLocalPrefix(Ptr<Name> prefix)
{
- m_localPrefixes.push_back (prefix);
+ m_localPrefixes.push_back(prefix);
}
void
-GlobalRouter::AddIncidency (Ptr< Face > face, Ptr< GlobalRouter > gr)
+GlobalRouter::AddIncidency(Ptr<Face> face, Ptr<GlobalRouter> gr)
{
- m_incidencies.push_back (make_tuple (this, face, gr));
+ m_incidencies.push_back(make_tuple(this, face, gr));
}
-GlobalRouter::IncidencyList &
-GlobalRouter::GetIncidencies ()
+GlobalRouter::IncidencyList&
+GlobalRouter::GetIncidencies()
{
return m_incidencies;
}
-const GlobalRouter::LocalPrefixList &
-GlobalRouter::GetLocalPrefixes () const
+const GlobalRouter::LocalPrefixList&
+GlobalRouter::GetLocalPrefixes() const
{
return m_localPrefixes;
}
diff --git a/model/ndn-global-router.hpp b/model/ndn-global-router.hpp
index dad2180..f680db7 100644
--- a/model/ndn-global-router.hpp
+++ b/model/ndn-global-router.hpp
@@ -43,53 +43,52 @@
* @ingroup ndn
* @brief Class representing global router interface for ndnSIM
*/
-class GlobalRouter : public Object
-{
+class GlobalRouter : public Object {
public:
/**
* @brief Graph edge
*/
- typedef boost::tuple< Ptr< GlobalRouter >, Ptr< Face >, Ptr< GlobalRouter > > Incidency;
+ typedef boost::tuple<Ptr<GlobalRouter>, Ptr<Face>, Ptr<GlobalRouter>> Incidency;
/**
* @brief List of graph edges
*/
- typedef std::list< Incidency > IncidencyList;
+ typedef std::list<Incidency> IncidencyList;
/**
* @brief List of locally exported prefixes
*/
- typedef std::list< Ptr<Name> > LocalPrefixList;
-
+ typedef std::list<Ptr<Name>> LocalPrefixList;
+
/**
* \brief Interface ID
*
* \return interface ID
*/
static TypeId
- GetTypeId ();
+ GetTypeId();
/**
* @brief Default constructor
*/
- GlobalRouter ();
+ GlobalRouter();
/**
* @brief Get numeric ID of the node (internally assigned)
*/
uint32_t
- GetId () const;
+ GetId() const;
/**
* @brief Helper function to get smart pointer to ndn::L3Protocol object (basically, self)
*/
Ptr<L3Protocol>
- GetL3Protocol () const;
+ GetL3Protocol() const;
/**
* @brief Add new locally exported prefix
* @param prefix Prefix
*/
void
- AddLocalPrefix (Ptr< Name > prefix);
+ AddLocalPrefix(Ptr<Name> prefix);
/**
* @brief Add edge to the node
@@ -97,28 +96,29 @@
* @param ndn GlobalRouter of another node
*/
void
- AddIncidency (Ptr< Face > face, Ptr< GlobalRouter > ndn);
+ AddIncidency(Ptr<Face> face, Ptr<GlobalRouter> ndn);
/**
* @brief Get list of edges that are connected to this node
*/
- IncidencyList &
- GetIncidencies ();
+ IncidencyList&
+ GetIncidencies();
/**
* @brief Get list of locally exported prefixes
*/
- const LocalPrefixList &
- GetLocalPrefixes () const;
+ const LocalPrefixList&
+ GetLocalPrefixes() const;
// ??
protected:
virtual void
- NotifyNewAggregate (); ///< @brief Notify when the object is aggregated to another object (e.g., Node)
-
+ NotifyNewAggregate(); ///< @brief Notify when the object is aggregated to another object (e.g.,
+ /// Node)
+
private:
uint32_t m_id;
-
+
Ptr<L3Protocol> m_ndn;
LocalPrefixList m_localPrefixes;
IncidencyList m_incidencies;
@@ -127,19 +127,15 @@
};
inline bool
-operator == (const GlobalRouter::Incidency &a,
- const GlobalRouter::Incidency &b)
+operator==(const GlobalRouter::Incidency& a, const GlobalRouter::Incidency& b)
{
- return a.get<0> () == b.get<0> () &&
- a.get<1> () == b.get<1> () &&
- a.get<2> () == b.get<2> ();
+ return a.get<0>() == b.get<0>() && a.get<1>() == b.get<1>() && a.get<2>() == b.get<2>();
}
inline bool
-operator != (const GlobalRouter::Incidency &a,
- const GlobalRouter::Incidency &b)
+operator!=(const GlobalRouter::Incidency& a, const GlobalRouter::Incidency& b)
{
- return ! (a == b);
+ return !(a == b);
}
} // namespace ndn
diff --git a/model/ndn-l3-protocol.cpp b/model/ndn-l3-protocol.cpp
index 5ab8cba..d7505e7 100644
--- a/model/ndn-l3-protocol.cpp
+++ b/model/ndn-l3-protocol.cpp
@@ -43,7 +43,7 @@
#include <boost/foreach.hpp>
-NS_LOG_COMPONENT_DEFINE ("ndn.L3Protocol");
+NS_LOG_COMPONENT_DEFINE("ndn.L3Protocol");
namespace ns3 {
namespace ndn {
@@ -51,32 +51,31 @@
const uint16_t L3Protocol::ETHERNET_FRAME_TYPE = 0x7777;
const uint16_t L3Protocol::IP_STACK_PORT = 9695;
-NS_OBJECT_ENSURE_REGISTERED (L3Protocol);
+NS_OBJECT_ENSURE_REGISTERED(L3Protocol);
TypeId
-L3Protocol::GetTypeId (void)
+L3Protocol::GetTypeId(void)
{
- static TypeId tid = TypeId ("ns3::ndn::L3Protocol")
- .SetGroupName ("ndn")
- .SetParent<Object> ()
- .AddConstructor<L3Protocol> ()
- .AddAttribute ("FaceList", "List of faces associated with ndn stack",
- ObjectVectorValue (),
- MakeObjectVectorAccessor (&L3Protocol::m_faces),
- MakeObjectVectorChecker<Face> ())
- ;
+ static TypeId tid =
+ TypeId("ns3::ndn::L3Protocol")
+ .SetGroupName("ndn")
+ .SetParent<Object>()
+ .AddConstructor<L3Protocol>()
+ .AddAttribute("FaceList", "List of faces associated with ndn stack", ObjectVectorValue(),
+ MakeObjectVectorAccessor(&L3Protocol::m_faces),
+ MakeObjectVectorChecker<Face>());
return tid;
}
-L3Protocol::L3Protocol ()
-: m_faceCounter (0)
+L3Protocol::L3Protocol()
+ : m_faceCounter(0)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION(this);
}
-L3Protocol::~L3Protocol ()
+L3Protocol::~L3Protocol()
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION(this);
}
/*
@@ -84,137 +83,135 @@
* by setting the node in the ndn stack
*/
void
-L3Protocol::NotifyNewAggregate ()
+L3Protocol::NotifyNewAggregate()
{
// not really efficient, but this will work only once
- if (m_node == 0)
- {
- m_node = GetObject<Node> ();
- if (m_node != 0)
- {
- NS_ASSERT_MSG (m_forwardingStrategy != 0,
- "Forwarding strategy should be aggregated before L3Protocol");
- }
+ if (m_node == 0) {
+ m_node = GetObject<Node>();
+ if (m_node != 0) {
+ NS_ASSERT_MSG(m_forwardingStrategy != 0,
+ "Forwarding strategy should be aggregated before L3Protocol");
}
- if (m_forwardingStrategy == 0)
- {
- m_forwardingStrategy = GetObject<ForwardingStrategy> ();
- }
+ }
+ if (m_forwardingStrategy == 0) {
+ m_forwardingStrategy = GetObject<ForwardingStrategy>();
+ }
- Object::NotifyNewAggregate ();
+ Object::NotifyNewAggregate();
}
void
-L3Protocol::DoDispose (void)
+L3Protocol::DoDispose(void)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION(this);
// for (FaceList::iterator i = m_faces.begin (); i != m_faces.end (); ++i)
// {
// *i = 0;
// }
- m_faces.clear ();
+ m_faces.clear();
m_node = 0;
// Force delete on objects
m_forwardingStrategy = 0; // there is a reference to PIT stored in here
- Object::DoDispose ();
+ Object::DoDispose();
}
uint32_t
-L3Protocol::AddFace (const Ptr<Face> &face)
+L3Protocol::AddFace(const Ptr<Face>& face)
{
- NS_LOG_FUNCTION (this << &face);
+ NS_LOG_FUNCTION(this << &face);
- face->SetId (m_faceCounter); // sets a unique ID of the face. This ID serves only informational purposes
+ face->SetId(
+ m_faceCounter); // sets a unique ID of the face. This ID serves only informational purposes
// ask face to register in lower-layer stack
- face->RegisterProtocolHandlers (MakeCallback (&ForwardingStrategy::OnInterest, m_forwardingStrategy),
- MakeCallback (&ForwardingStrategy::OnData, m_forwardingStrategy));
+ face->RegisterProtocolHandlers(MakeCallback(&ForwardingStrategy::OnInterest,
+ m_forwardingStrategy),
+ MakeCallback(&ForwardingStrategy::OnData, m_forwardingStrategy));
- m_faces.push_back (face);
+ m_faces.push_back(face);
m_faceCounter++;
- m_forwardingStrategy->AddFace (face); // notify that face is added
- return face->GetId ();
+ m_forwardingStrategy->AddFace(face); // notify that face is added
+ return face->GetId();
}
void
-L3Protocol::RemoveFace (Ptr<Face> face)
+L3Protocol::RemoveFace(Ptr<Face> face)
{
- NS_LOG_FUNCTION (this << boost::cref (*face));
+ NS_LOG_FUNCTION(this << boost::cref(*face));
// ask face to register in lower-layer stack
- face->UnRegisterProtocolHandlers ();
- Ptr<Pit> pit = GetObject<Pit> ();
+ face->UnRegisterProtocolHandlers();
+ Ptr<Pit> pit = GetObject<Pit>();
// just to be on a safe side. Do the process in two steps
- std::list< Ptr<pit::Entry> > entriesToRemoves;
- for (Ptr<pit::Entry> pitEntry = pit->Begin (); pitEntry != 0; pitEntry = pit->Next (pitEntry))
- {
- pitEntry->RemoveAllReferencesToFace (face);
+ std::list<Ptr<pit::Entry>> entriesToRemoves;
+ for (Ptr<pit::Entry> pitEntry = pit->Begin(); pitEntry != 0; pitEntry = pit->Next(pitEntry)) {
+ pitEntry->RemoveAllReferencesToFace(face);
- // If this face is the only for the associated FIB entry, then FIB entry will be removed soon.
- // Thus, we have to remove the whole PIT entry
- if (pitEntry->GetFibEntry ()->m_faces.size () == 1 &&
- pitEntry->GetFibEntry ()->m_faces.begin ()->GetFace () == face)
- {
- entriesToRemoves.push_back (pitEntry);
- }
+ // If this face is the only for the associated FIB entry, then FIB entry will be removed soon.
+ // Thus, we have to remove the whole PIT entry
+ if (pitEntry->GetFibEntry()->m_faces.size() == 1
+ && pitEntry->GetFibEntry()->m_faces.begin()->GetFace() == face) {
+ entriesToRemoves.push_back(pitEntry);
}
- BOOST_FOREACH (Ptr<pit::Entry> removedEntry, entriesToRemoves)
- {
- pit->MarkErased (removedEntry);
- }
+ }
+ BOOST_FOREACH (Ptr<pit::Entry> removedEntry, entriesToRemoves) {
+ pit->MarkErased(removedEntry);
+ }
- FaceList::iterator face_it = find (m_faces.begin(), m_faces.end(), face);
- if (face_it == m_faces.end ())
- {
- return;
- }
- m_faces.erase (face_it);
+ FaceList::iterator face_it = find(m_faces.begin(), m_faces.end(), face);
+ if (face_it == m_faces.end()) {
+ return;
+ }
+ m_faces.erase(face_it);
- GetObject<Fib> ()->RemoveFromAll (face);
- m_forwardingStrategy->RemoveFace (face); // notify that face is removed
+ GetObject<Fib>()->RemoveFromAll(face);
+ m_forwardingStrategy->RemoveFace(face); // notify that face is removed
}
Ptr<Face>
-L3Protocol::GetFace (uint32_t index) const
+L3Protocol::GetFace(uint32_t index) const
{
- NS_ASSERT (0 <= index && index < m_faces.size ());
+ NS_ASSERT(0 <= index && index < m_faces.size());
return m_faces[index];
}
Ptr<Face>
-L3Protocol::GetFaceById (uint32_t index) const
+L3Protocol::GetFaceById(uint32_t index) const
{
- BOOST_FOREACH (const Ptr<Face> &face, m_faces) // this function is not supposed to be called often, so linear search is fine
- {
- if (face->GetId () == index)
- return face;
- }
+ BOOST_FOREACH (const Ptr<Face>& face, m_faces) // this function is not supposed to be called
+ // often, so linear search is fine
+ {
+ if (face->GetId() == index)
+ return face;
+ }
return 0;
}
Ptr<Face>
-L3Protocol::GetFaceByNetDevice (Ptr<NetDevice> netDevice) const
+L3Protocol::GetFaceByNetDevice(Ptr<NetDevice> netDevice) const
{
- BOOST_FOREACH (const Ptr<Face> &face, m_faces) // this function is not supposed to be called often, so linear search is fine
- {
- Ptr<NetDeviceFace> netDeviceFace = DynamicCast<NetDeviceFace> (face);
- if (netDeviceFace == 0) continue;
+ BOOST_FOREACH (const Ptr<Face>& face, m_faces) // this function is not supposed to be called
+ // often, so linear search is fine
+ {
+ Ptr<NetDeviceFace> netDeviceFace = DynamicCast<NetDeviceFace>(face);
+ if (netDeviceFace == 0)
+ continue;
- if (netDeviceFace->GetNetDevice () == netDevice)
- return face;
- }
+ if (netDeviceFace->GetNetDevice() == netDevice)
+ return face;
+ }
return 0;
}
uint32_t
-L3Protocol::GetNFaces (void) const
+L3Protocol::GetNFaces(void) const
{
- return m_faces.size ();
+ return m_faces.size();
}
-} //namespace ndn
-} //namespace ns3
+} // namespace ndn
+} // namespace ns3
diff --git a/model/ndn-l3-protocol.hpp b/model/ndn-l3-protocol.hpp
index 552bd19..5b71e3a 100644
--- a/model/ndn-l3-protocol.hpp
+++ b/model/ndn-l3-protocol.hpp
@@ -53,7 +53,7 @@
* the NDN stack implementation:
* -# register a face (Face-derived object) for use by the NDN
* layer
- *
+ *
* Each Face-derived object has conceptually a single NDN
* interface associated with it.
*
@@ -61,18 +61,17 @@
*
* \see Face, ForwardingStrategy
*/
-class L3Protocol :
- public Object
-{
+class L3Protocol : public Object {
public:
- typedef std::vector<Ptr<Face> > FaceList;
+ typedef std::vector<Ptr<Face>> FaceList;
/**
* \brief Interface ID
*
* \return interface ID
*/
- static TypeId GetTypeId ();
+ static TypeId
+ GetTypeId();
static const uint16_t ETHERNET_FRAME_TYPE; ///< @brief Ethernet Frame Type of Ndn
static const uint16_t IP_STACK_PORT; ///< @brief TCP/UDP port for NDN stack
@@ -82,7 +81,7 @@
* \brief Default constructor. Creates an empty stack without forwarding strategy set
*/
L3Protocol();
- virtual ~L3Protocol ();
+ virtual ~L3Protocol();
/**
* \brief Add face to Ndn stack
@@ -90,19 +89,19 @@
* \param face smart pointer to NdnFace-derived object
* (NdnLocalFace, NdnNetDeviceFace, NdnUdpFace) \returns the
* index of the Ndn interface added.
- *
+ *
* \see NdnLocalFace, NdnNetDeviceFace, NdnUdpFace
*/
virtual uint32_t
- AddFace (const Ptr<Face> &face);
-
+ AddFace(const Ptr<Face>& face);
+
/**
* \brief Get current number of faces added to Ndn stack
*
* \returns the number of faces
*/
virtual uint32_t
- GetNFaces () const;
+ GetNFaces() const;
/**
* \brief Get face by face index
@@ -110,48 +109,55 @@
* \returns The NdnFace associated with the Ndn face number.
*/
virtual Ptr<Face>
- GetFace (uint32_t face) const;
-
+ GetFace(uint32_t face) const;
+
/**
* \brief Get face by face ID
* \param face The face ID number
* \returns The NdnFace associated with the Ndn face number.
*/
virtual Ptr<Face>
- GetFaceById (uint32_t face) const;
+ GetFaceById(uint32_t face) const;
/**
* \brief Remove face from ndn stack (remove callbacks)
*/
virtual void
- RemoveFace (Ptr<Face> face);
+ RemoveFace(Ptr<Face> face);
/**
* \brief Get face for NetDevice
*/
virtual Ptr<Face>
- GetFaceByNetDevice (Ptr<NetDevice> netDevice) const;
+ GetFaceByNetDevice(Ptr<NetDevice> netDevice) const;
protected:
- virtual void DoDispose (void); ///< @brief Do cleanup
+ virtual void
+ DoDispose(void); ///< @brief Do cleanup
/**
- * This function will notify other components connected to the node that a new stack member is now connected
- * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
+ * This function will notify other components connected to the node that a new stack member is now
+ * connected
+ * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them
+ * together.
*/
- virtual void NotifyNewAggregate ();
+ virtual void
+ NotifyNewAggregate();
private:
- L3Protocol(const L3Protocol &); ///< copy constructor is disabled
- L3Protocol &operator = (const L3Protocol &); ///< copy operator is disabled
-
+ L3Protocol(const L3Protocol&); ///< copy constructor is disabled
+ L3Protocol&
+ operator=(const L3Protocol&); ///< copy operator is disabled
+
private:
- uint32_t m_faceCounter; ///< \brief counter of faces. Increased every time a new face is added to the stack
+ uint32_t m_faceCounter; ///< \brief counter of faces. Increased every time a new face is added to
+ /// the stack
FaceList m_faces; ///< \brief list of faces that belongs to ndn stack on this node
// These objects are aggregated, but for optimization, get them here
Ptr<Node> m_node; ///< \brief node on which ndn stack is installed
- Ptr<ForwardingStrategy> m_forwardingStrategy; ///< \brief smart pointer to the selected forwarding strategy
+ Ptr<ForwardingStrategy>
+ m_forwardingStrategy; ///< \brief smart pointer to the selected forwarding strategy
};
} // namespace ndn
diff --git a/model/ndn-net-device-face.cpp b/model/ndn-net-device-face.cpp
index af4baa0..31d57fc 100644
--- a/model/ndn-net-device-face.cpp
+++ b/model/ndn-net-device-face.cpp
@@ -33,20 +33,17 @@
#include "ns3/channel.h"
#include "ns3/ndn-name.hpp"
-NS_LOG_COMPONENT_DEFINE ("ndn.NetDeviceFace");
+NS_LOG_COMPONENT_DEFINE("ndn.NetDeviceFace");
namespace ns3 {
namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (NetDeviceFace);
+NS_OBJECT_ENSURE_REGISTERED(NetDeviceFace);
TypeId
-NetDeviceFace::GetTypeId ()
+NetDeviceFace::GetTypeId()
{
- static TypeId tid = TypeId ("ns3::ndn::NetDeviceFace")
- .SetParent<Face> ()
- .SetGroupName ("Ndn")
- ;
+ static TypeId tid = TypeId("ns3::ndn::NetDeviceFace").SetParent<Face>().SetGroupName("Ndn");
return tid;
}
@@ -54,20 +51,20 @@
* By default, Ndn face are created in the "down" state. Before
* becoming useable, the user must invoke SetUp on the face
*/
-NetDeviceFace::NetDeviceFace (Ptr<Node> node, const Ptr<NetDevice> &netDevice)
- : Face (node)
- , m_netDevice (netDevice)
+NetDeviceFace::NetDeviceFace(Ptr<Node> node, const Ptr<NetDevice>& netDevice)
+ : Face(node)
+ , m_netDevice(netDevice)
{
- NS_LOG_FUNCTION (this << netDevice);
+ NS_LOG_FUNCTION(this << netDevice);
- SetMetric (1); // default metric
+ SetMetric(1); // default metric
- NS_ASSERT_MSG (m_netDevice != 0, "NetDeviceFace needs to be assigned a valid NetDevice");
+ NS_ASSERT_MSG(m_netDevice != 0, "NetDeviceFace needs to be assigned a valid NetDevice");
}
-NetDeviceFace::~NetDeviceFace ()
+NetDeviceFace::~NetDeviceFace()
{
- NS_LOG_FUNCTION_NOARGS ();
+ NS_LOG_FUNCTION_NOARGS();
}
NetDeviceFace& NetDeviceFace::operator= (const NetDeviceFace &)
@@ -76,84 +73,85 @@
}
Ptr<NetDevice>
-NetDeviceFace::GetNetDevice () const
+NetDeviceFace::GetNetDevice() const
{
return m_netDevice;
}
void
-NetDeviceFace::RegisterProtocolHandlers (const InterestHandler &interestHandler, const DataHandler &dataHandler)
+NetDeviceFace::RegisterProtocolHandlers(const InterestHandler& interestHandler,
+ const DataHandler& dataHandler)
{
- NS_LOG_FUNCTION (this);
+ NS_LOG_FUNCTION(this);
- Face::RegisterProtocolHandlers (interestHandler, dataHandler);
+ Face::RegisterProtocolHandlers(interestHandler, dataHandler);
- m_node->RegisterProtocolHandler (MakeCallback (&NetDeviceFace::ReceiveFromNetDevice, this),
- L3Protocol::ETHERNET_FRAME_TYPE, m_netDevice, true/*promiscuous mode*/);
+ m_node->RegisterProtocolHandler(MakeCallback(&NetDeviceFace::ReceiveFromNetDevice, this),
+ L3Protocol::ETHERNET_FRAME_TYPE, m_netDevice,
+ true /*promiscuous mode*/);
}
void
-NetDeviceFace:: UnRegisterProtocolHandlers ()
+NetDeviceFace::UnRegisterProtocolHandlers()
{
- m_node->UnregisterProtocolHandler (MakeCallback (&NetDeviceFace::ReceiveFromNetDevice, this));
- Face::UnRegisterProtocolHandlers ();
+ m_node->UnregisterProtocolHandler(MakeCallback(&NetDeviceFace::ReceiveFromNetDevice, this));
+ Face::UnRegisterProtocolHandlers();
}
bool
-NetDeviceFace::Send (Ptr<Packet> packet)
+NetDeviceFace::Send(Ptr<Packet> packet)
{
- if (!Face::Send (packet))
- {
- return false;
- }
-
- NS_LOG_FUNCTION (this << packet);
+ if (!Face::Send(packet)) {
+ return false;
+ }
- NS_ASSERT_MSG (packet->GetSize () <= m_netDevice->GetMtu (),
- "Packet size " << packet->GetSize () << " exceeds device MTU "
- << m_netDevice->GetMtu ()
- << " for Ndn; fragmentation not supported");
+ NS_LOG_FUNCTION(this << packet);
- bool ok = m_netDevice->Send (packet, m_netDevice->GetBroadcast (),
- L3Protocol::ETHERNET_FRAME_TYPE);
+ NS_ASSERT_MSG(packet->GetSize() <= m_netDevice->GetMtu(),
+ "Packet size " << packet->GetSize() << " exceeds device MTU "
+ << m_netDevice->GetMtu() << " for Ndn; fragmentation not supported");
+
+ bool ok = m_netDevice->Send(packet, m_netDevice->GetBroadcast(), L3Protocol::ETHERNET_FRAME_TYPE);
return ok;
}
// callback
void
-NetDeviceFace::ReceiveFromNetDevice (Ptr<NetDevice> device,
- Ptr<const Packet> p,
- uint16_t protocol,
- const Address &from,
- const Address &to,
- NetDevice::PacketType packetType)
+NetDeviceFace::ReceiveFromNetDevice(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol,
+ const Address& from, const Address& to,
+ NetDevice::PacketType packetType)
{
- NS_LOG_FUNCTION (device << p << protocol << from << to << packetType);
- Receive (p);
+ NS_LOG_FUNCTION(device << p << protocol << from << to << packetType);
+ Receive(p);
}
-
std::ostream&
-NetDeviceFace::Print (std::ostream& os) const
+NetDeviceFace::Print(std::ostream& os) const
{
#ifdef NS3_LOG_ENABLE
- os << "dev[" << GetNode ()->GetId () << "]=net(" << GetId ();
+ os << "dev[" << GetNode()->GetId() << "]=net(" << GetId();
- if (DynamicCast<PointToPointNetDevice> (m_netDevice))
- {
- // extra debugging information which available ONLY for PointToPointNetDevice's
- os << ",";
- os << DynamicCast<PointToPointNetDevice> (m_netDevice)->GetChannel ()->GetDevice (0)->GetNode ()->GetId ();
- os << "-";
- os << DynamicCast<PointToPointNetDevice> (m_netDevice)->GetChannel ()->GetDevice (1)->GetNode ()->GetId ();
- }
+ if (DynamicCast<PointToPointNetDevice>(m_netDevice)) {
+ // extra debugging information which available ONLY for PointToPointNetDevice's
+ os << ",";
+ os << DynamicCast<PointToPointNetDevice>(m_netDevice)
+ ->GetChannel()
+ ->GetDevice(0)
+ ->GetNode()
+ ->GetId();
+ os << "-";
+ os << DynamicCast<PointToPointNetDevice>(m_netDevice)
+ ->GetChannel()
+ ->GetDevice(1)
+ ->GetNode()
+ ->GetId();
+ }
os << ")";
#else
- os << "dev=net(" << GetId () << ")";
+ os << "dev=net(" << GetId() << ")";
#endif
return os;
}
} // namespace ndnsim
} // namespace ns3
-
diff --git a/model/ndn-net-device-face.hpp b/model/ndn-net-device-face.hpp
index 6bf231c..5bc8e3a 100644
--- a/model/ndn-net-device-face.hpp
+++ b/model/ndn-net-device-face.hpp
@@ -26,7 +26,7 @@
namespace ns3 {
namespace ndn {
-
+
/**
* \ingroup ndn-face
* \brief Implementation of layer-2 (Ethernet) Ndn face
@@ -41,11 +41,10 @@
*
* \see NdnAppFace, NdnNetDeviceFace, NdnIpv4Face, NdnUdpFace
*/
-class NetDeviceFace : public Face
-{
+class NetDeviceFace : public Face {
public:
static TypeId
- GetTypeId ();
+ GetTypeId();
/**
* \brief Constructor
@@ -54,27 +53,27 @@
* @param netDevice a smart pointer to NetDevice object to which
* this face will be associate
*/
- NetDeviceFace (Ptr<Node> node, const Ptr<NetDevice> &netDevice);
+ NetDeviceFace(Ptr<Node> node, const Ptr<NetDevice>& netDevice);
virtual ~NetDeviceFace();
////////////////////////////////////////////////////////////////////
// methods overloaded from NdnFace
virtual void
- RegisterProtocolHandlers (const InterestHandler &interestHandler, const DataHandler &dataHandler);
+ RegisterProtocolHandlers(const InterestHandler& interestHandler, const DataHandler& dataHandler);
virtual void
- UnRegisterProtocolHandlers ();
-
+ UnRegisterProtocolHandlers();
+
protected:
virtual bool
- Send (Ptr<Packet> p);
+ Send(Ptr<Packet> p);
public:
/**
* @brief Print out name of the NdnFace to the stream
*/
virtual std::ostream&
- Print (std::ostream &os) const;
+ Print(std::ostream& os) const;
////////////////////////////////////////////////////////////////////
/**
@@ -82,19 +81,18 @@
*
* \returns smart pointer to NetDevice associated with the face
*/
- Ptr<NetDevice> GetNetDevice () const;
+ Ptr<NetDevice>
+ GetNetDevice() const;
private:
- NetDeviceFace (const NetDeviceFace &); ///< \brief Disabled copy constructor
- NetDeviceFace& operator= (const NetDeviceFace &); ///< \brief Disabled copy operator
+ NetDeviceFace(const NetDeviceFace&); ///< \brief Disabled copy constructor
+ NetDeviceFace&
+ operator=(const NetDeviceFace&); ///< \brief Disabled copy operator
/// \brief callback from lower layers
- void ReceiveFromNetDevice (Ptr<NetDevice> device,
- Ptr<const Packet> p,
- uint16_t protocol,
- const Address &from,
- const Address &to,
- NetDevice::PacketType packetType);
+ void
+ ReceiveFromNetDevice(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol,
+ const Address& from, const Address& to, NetDevice::PacketType packetType);
private:
Ptr<NetDevice> m_netDevice; ///< \brief Smart pointer to NetDevice
@@ -103,4 +101,4 @@
} // namespace ndn
} // namespace ns3
-#endif //NDN_NET_DEVICE_FACE_H
+#endif // NDN_NET_DEVICE_FACE_H