Another set of refactoring
diff --git a/model/pit/ndn-pit-entry-impl.h b/model/pit/ndn-pit-entry-impl.h
index 13cceb5..85c94f1 100644
--- a/model/pit/ndn-pit-entry-impl.h
+++ b/model/pit/ndn-pit-entry-impl.h
@@ -22,29 +22,30 @@
#define _NDN_PIT_ENTRY_IMPL_H_
namespace ns3 {
+namespace ndn {
-class NdnPit;
-class NdnInterestHeader;
-class NdnFibEntry;
+class Pit;
+
+namespace pit {
template<class Pit>
-class NdnPitEntryImpl : public NdnPitEntry
+class EntryImpl : public Entry
{
- typedef NdnPitEntry super;
+ typedef Entry super;
#define CONTAINER static_cast<Pit&> (m_container)
public:
- NdnPitEntryImpl (NdnPit &pit,
- Ptr<const NdnInterestHeader> header,
- Ptr<NdnFibEntry> fibEntry)
- : NdnPitEntry (pit, header, fibEntry)
+ EntryImpl (Pit &pit,
+ Ptr<const InterestHeader> header,
+ Ptr<fib::Entry> fibEntry)
+ : Entry (pit, header, fibEntry)
, item_ (0)
{
CONTAINER.i_time.insert (*this);
CONTAINER.RescheduleCleaning ();
}
- virtual ~NdnPitEntryImpl ()
+ virtual ~EntryImpl ()
{
CONTAINER.i_time.erase (Pit::time_index::s_iterator_to (*this));
@@ -86,6 +87,8 @@
}
};
-} // ns3
+} // namespace pit
+} // namespace ndn
+} // namespace ns3
#endif
diff --git a/model/pit/ndn-pit-entry-incoming-face.cc b/model/pit/ndn-pit-entry-incoming-face.cc
index 28408ed..5a7f518 100644
--- a/model/pit/ndn-pit-entry-incoming-face.cc
+++ b/model/pit/ndn-pit-entry-incoming-face.cc
@@ -23,15 +23,17 @@
#include "ns3/simulator.h"
namespace ns3 {
+namespace ndn {
+namespace pit {
-NdnPitEntryIncomingFace::NdnPitEntryIncomingFace (Ptr<NdnFace> face)
+IncomingFace::IncomingFace (Ptr<Face> face)
: m_face (face)
, m_arrivalTime (Simulator::Now ())
// , m_nonce (nonce)
{
}
-NdnPitEntryIncomingFace::NdnPitEntryIncomingFace ()
+IncomingFace::IncomingFace ()
: m_face (0)
, m_arrivalTime (0)
{
@@ -40,12 +42,14 @@
/**
* @brie Copy operator
*/
-NdnPitEntryIncomingFace &
-NdnPitEntryIncomingFace::operator = (NdnPitEntryIncomingFace &other)
+IncomingFace &
+IncomingFace::operator = (IncomingFace &other)
{
m_face = other.m_face;
m_arrivalTime = other.m_arrivalTime;
return *this;
}
+} // namespace pit
+} // namespace ndn
} // namespace ns3
diff --git a/model/pit/ndn-pit-entry-incoming-face.h b/model/pit/ndn-pit-entry-incoming-face.h
index 947271b..8ff7947 100644
--- a/model/pit/ndn-pit-entry-incoming-face.h
+++ b/model/pit/ndn-pit-entry-incoming-face.h
@@ -25,17 +25,18 @@
#include "ns3/ptr.h"
#include "ns3/ndn-face.h"
-// #include <iostream>
namespace ns3 {
+namespace ndn {
+namespace pit {
/**
* \ingroup ndn
* \brief PIT state component for each incoming interest (not including duplicates)
*/
-struct NdnPitEntryIncomingFace
+struct IncomingFace
{
- Ptr<NdnFace> m_face; ///< \brief face of the incoming Interest
+ Ptr< Face > m_face; ///< \brief face of the incoming Interest
Time m_arrivalTime; ///< \brief arrival time of the incoming Interest
public:
@@ -44,36 +45,37 @@
* \param face face of the incoming interest
* \param lifetime lifetime of the incoming interest
*/
- NdnPitEntryIncomingFace (Ptr<NdnFace> face);
+ IncomingFace (Ptr<Face> face);
/**
* @brief Default constructor, necessary for Python bindings, but should not be used anywhere else.
*/
- NdnPitEntryIncomingFace ();
+ IncomingFace ();
/**
* @brie Copy operator
*/
- NdnPitEntryIncomingFace &
- operator = (NdnPitEntryIncomingFace &other);
+ IncomingFace &
+ operator = (IncomingFace &other);
/**
- * @brief Compare two NdnPitEntryIncomingFace
+ * @brief Compare two PitEntryIncomingFace
*/
- bool operator== (const NdnPitEntryIncomingFace &dst) { return *m_face==*(dst.m_face); }
+ bool operator== (const IncomingFace &dst) { return *m_face==*(dst.m_face); }
/**
- * @brief Compare NdnPitEntryIncomingFace with NdnFace
+ * @brief Compare PitEntryIncomingFace with Face
*/
- bool operator== (Ptr<NdnFace> face) { return *m_face==*face; }
+ bool operator== (Ptr<Face> face) { return *m_face==*face; }
/**
* \brief Comparison operator used by boost::multi_index::identity<>
*/
bool
- operator< (const NdnPitEntryIncomingFace &m) const { return *m_face < *(m.m_face); } // return identity of the face
+ operator< (const IncomingFace &m) const { return *m_face < *(m.m_face); } // return identity of the face
};
-
+} // namespace pit
+} // namespace ndn
} // namespace ns3
#endif /* NDN_PIT_ENTRY_INCOMING_FACE_H */
diff --git a/model/pit/ndn-pit-entry-outgoing-face.cc b/model/pit/ndn-pit-entry-outgoing-face.cc
index 9829eaa..265529c 100644
--- a/model/pit/ndn-pit-entry-outgoing-face.cc
+++ b/model/pit/ndn-pit-entry-outgoing-face.cc
@@ -23,8 +23,10 @@
#include "ns3/simulator.h"
namespace ns3 {
+namespace ndn {
+namespace pit {
-NdnPitEntryOutgoingFace::NdnPitEntryOutgoingFace (Ptr<NdnFace> face)
+OutgoingFace::OutgoingFace (Ptr<Face> face)
: m_face (face)
, m_sendTime (Simulator::Now ())
, m_retxCount (0)
@@ -33,11 +35,13 @@
}
void
-NdnPitEntryOutgoingFace::UpdateOnRetransmit ()
+OutgoingFace::UpdateOnRetransmit ()
{
m_sendTime = Simulator::Now ();
m_retxCount++;
m_waitingInVain = false;
}
+} // namespace pit
+} // namespace ndn
} // namespace ns3
diff --git a/model/pit/ndn-pit-entry-outgoing-face.h b/model/pit/ndn-pit-entry-outgoing-face.h
index c9d1357..1a4d8b5 100644
--- a/model/pit/ndn-pit-entry-outgoing-face.h
+++ b/model/pit/ndn-pit-entry-outgoing-face.h
@@ -27,14 +27,16 @@
#include "ns3/ndn-face.h"
namespace ns3 {
+namespace ndn {
+namespace pit {
/**
* \ingroup ndn
* \brief PIT state component for each outgoing interest
*/
-struct NdnPitEntryOutgoingFace
+struct OutgoingFace
{
- Ptr<NdnFace> m_face; ///< \brief face of the outgoing Interest
+ Ptr<Face> m_face; ///< \brief face of the outgoing Interest
Time m_sendTime; ///< \brief time when the first outgoing interest is sent (for RTT measurements)
///< \todo handle problem of retransmitted interests... Probably, we should include something similar
///< to TimeStamp TCP option for retransmitted (i.e., only lost interests will suffer)
@@ -43,10 +45,10 @@
public:
/**
- * @brief Constructor to create NdnPitEntryOutgoingFace
+ * @brief Constructor to create PitEntryOutgoingFace
* \param face face of the outgoing interest
*/
- NdnPitEntryOutgoingFace (Ptr<NdnFace> face);
+ OutgoingFace (Ptr<Face> face);
/**
* @brief Update outgoing entry upon retransmission
@@ -55,23 +57,24 @@
UpdateOnRetransmit ();
/**
- * @brief Compare to NdnPitEntryOutgoingFace
+ * @brief Compare to PitEntryOutgoingFace
*/
- bool operator== (const NdnPitEntryOutgoingFace &dst) { return *m_face==*dst.m_face; }
+ bool operator== (const OutgoingFace &dst) { return *m_face==*dst.m_face; }
/**
- * @brief Compare NdnPitEntryOutgoingFace with NdnFace
+ * @brief Compare PitEntryOutgoingFace with Face
*/
- bool operator== (Ptr<NdnFace> face) { return *m_face==*face; }
+ bool operator== (Ptr<Face> face) { return *m_face==*face; }
/**
* \brief Comparison operator used by boost::multi_index::identity<>
*/
bool
- operator< (const NdnPitEntryOutgoingFace &m) const { return *m_face < *(m.m_face); } // return identity of the face
+ operator< (const OutgoingFace &m) const { return *m_face < *(m.m_face); } // return identity of the face
};
-
+} // namespace pit
+} // namespace ndn
} // namespace ns3
#endif /* NDN_PIT_ENTRY_OUTGOING_FACE_H */
diff --git a/model/pit/ndn-pit-entry.cc b/model/pit/ndn-pit-entry.cc
index bc6ca0e..b578c0e 100644
--- a/model/pit/ndn-pit-entry.cc
+++ b/model/pit/ndn-pit-entry.cc
@@ -32,14 +32,15 @@
#include <boost/foreach.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("NdnPitEntry");
+NS_LOG_COMPONENT_DEFINE ("ndn.pit.Entry");
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
+namespace pit {
-NdnPitEntry::NdnPitEntry (NdnPit &container,
- Ptr<const NdnInterestHeader> header,
- Ptr<NdnFibEntry> fibEntry)
+Entry::Entry (Pit &container,
+ Ptr<const InterestHeader> header,
+ Ptr<fib::Entry> fibEntry)
: m_container (container)
, m_prefix (header->GetNamePtr ())
, m_fibEntry (fibEntry)
@@ -52,7 +53,7 @@
}
void
-NdnPitEntry::UpdateLifetime (const Time &offsetTime)
+Entry::UpdateLifetime (const Time &offsetTime)
{
NS_LOG_FUNCTION (offsetTime.ToDouble (Time::S));
@@ -63,11 +64,11 @@
NS_LOG_INFO ("Updated lifetime to " << m_expireTime.ToDouble (Time::S));
}
-NdnPitEntry::in_iterator
-NdnPitEntry::AddIncoming (Ptr<NdnFace> face)
+Entry::in_iterator
+Entry::AddIncoming (Ptr<Face> face)
{
std::pair<in_iterator,bool> ret =
- m_incoming.insert (NdnPitEntryIncomingFace (face));
+ m_incoming.insert (IncomingFace (face));
// NS_ASSERT_MSG (ret.second, "Something is wrong");
@@ -75,29 +76,29 @@
}
void
-NdnPitEntry::RemoveIncoming (Ptr<NdnFace> face)
+Entry::RemoveIncoming (Ptr<Face> face)
{
m_incoming.erase (face);
}
-NdnPitEntry::out_iterator
-NdnPitEntry::AddOutgoing (Ptr<NdnFace> face)
+Entry::out_iterator
+Entry::AddOutgoing (Ptr<Face> face)
{
std::pair<out_iterator,bool> ret =
- m_outgoing.insert (NdnPitEntryOutgoingFace (face));
+ m_outgoing.insert (OutgoingFace (face));
if (!ret.second)
{ // outgoing face already exists
m_outgoing.modify (ret.first,
- ll::bind (&NdnPitEntryOutgoingFace::UpdateOnRetransmit, ll::_1));
+ ll::bind (&OutgoingFace::UpdateOnRetransmit, ll::_1));
}
return ret.first;
}
void
-NdnPitEntry::RemoveAllReferencesToFace (Ptr<NdnFace> face)
+Entry::RemoveAllReferencesToFace (Ptr<Face> face)
{
in_iterator incoming = m_incoming.find (face);
@@ -112,16 +113,16 @@
}
// void
-// NdnPitEntry::SetWaitingInVain (NdnPitEntry::out_iterator face)
+// Entry::SetWaitingInVain (Entry::out_iterator face)
// {
// NS_LOG_DEBUG (boost::cref (*face->m_face));
// m_outgoing.modify (face,
-// (&ll::_1)->*&NdnPitEntryOutgoingFace::m_waitingInVain = true);
+// (&ll::_1)->*&EntryOutgoingFace::m_waitingInVain = true);
// }
void
-NdnPitEntry::SetWaitingInVain (Ptr<NdnFace> face)
+Entry::SetWaitingInVain (Ptr<Face> face)
{
// NS_LOG_DEBUG (boost::cref (*face->m_face));
@@ -130,37 +131,37 @@
return;
m_outgoing.modify (item,
- (&ll::_1)->*&NdnPitEntryOutgoingFace::m_waitingInVain = true);
+ (&ll::_1)->*&OutgoingFace::m_waitingInVain = true);
}
bool
-NdnPitEntry::AreAllOutgoingInVain () const
+Entry::AreAllOutgoingInVain () const
{
NS_LOG_DEBUG (m_outgoing.size ());
bool inVain = true;
std::for_each (m_outgoing.begin (), m_outgoing.end (),
- ll::var(inVain) &= (&ll::_1)->*&NdnPitEntryOutgoingFace::m_waitingInVain);
+ ll::var(inVain) &= (&ll::_1)->*&OutgoingFace::m_waitingInVain);
NS_LOG_DEBUG ("inVain " << inVain);
return inVain;
}
bool
-NdnPitEntry::AreTherePromisingOutgoingFacesExcept (Ptr<NdnFace> face) const
+Entry::AreTherePromisingOutgoingFacesExcept (Ptr<Face> face) const
{
bool inVain = true;
std::for_each (m_outgoing.begin (), m_outgoing.end (),
ll::var(inVain) &=
- ((&ll::_1)->*&NdnPitEntryOutgoingFace::m_face == face ||
- (&ll::_1)->*&NdnPitEntryOutgoingFace::m_waitingInVain));
+ ((&ll::_1)->*&OutgoingFace::m_face == face ||
+ (&ll::_1)->*&OutgoingFace::m_waitingInVain));
return !inVain;
}
void
-NdnPitEntry::IncreaseAllowedRetxCount ()
+Entry::IncreaseAllowedRetxCount ()
{
NS_LOG_ERROR (this);
if (Simulator::Now () - m_lastRetransmission >= MilliSeconds (100))
@@ -172,12 +173,12 @@
}
}
-std::ostream& operator<< (std::ostream& os, const NdnPitEntry &entry)
+std::ostream& operator<< (std::ostream& os, const Entry &entry)
{
os << "Prefix: " << *entry.m_prefix << "\n";
os << "In: ";
bool first = true;
- BOOST_FOREACH (const NdnPitEntryIncomingFace &face, entry.m_incoming)
+ BOOST_FOREACH (const IncomingFace &face, entry.m_incoming)
{
if (!first)
os << ",";
@@ -189,7 +190,7 @@
os << "\nOut: ";
first = true;
- BOOST_FOREACH (const NdnPitEntryOutgoingFace &face, entry.m_outgoing)
+ BOOST_FOREACH (const OutgoingFace &face, entry.m_outgoing)
{
if (!first)
os << ",";
@@ -214,4 +215,6 @@
}
-}
+} // namespace pit
+} // namespace ndn
+} // namespace ns3
diff --git a/model/pit/ndn-pit-entry.h b/model/pit/ndn-pit-entry.h
index c14b93c..8dc5d24 100644
--- a/model/pit/ndn-pit-entry.h
+++ b/model/pit/ndn-pit-entry.h
@@ -25,8 +25,9 @@
#include "ns3/simple-ref-count.h"
#include "ns3/ndn-fib.h"
-#include "ndn-pit-entry-incoming-face.h"
-#include "ndn-pit-entry-outgoing-face.h"
+
+#include "ns3/ndn-pit-entry-incoming-face.h"
+#include "ns3/ndn-pit-entry-outgoing-face.h"
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/tag.hpp>
@@ -38,39 +39,38 @@
#include <set>
namespace ns3 {
+namespace ndn {
-class NdnFace;
-class NdnNameComponents;
-class NdnPit;
+class Pit;
+
+namespace pit {
/// @cond include_hidden
-namespace __ndn_private
-{
+class i_face {};
class i_retx {};
-}
/// @endcond
/**
* \ingroup ndn
- * \brief Typedef for indexed face container of NdnPitEntryOutgoingFace
+ * \brief Typedef for indexed face container of PitEntryOutgoingFace
*
* Indexes:
* - by face (may be it will be possible to replace with just the std::map)
*/
-struct NdnPitEntryOutgoingFaceContainer
+struct OutgoingFaceContainer
{
/// @cond include_hidden
typedef boost::multi_index::multi_index_container<
- NdnPitEntryOutgoingFace,
+ OutgoingFace,
boost::multi_index::indexed_by<
// For fast access to elements using NdnFace
boost::multi_index::ordered_unique<
- boost::multi_index::tag<__ndn_private::i_face>,
- boost::multi_index::member<NdnPitEntryOutgoingFace, Ptr<NdnFace>, &NdnPitEntryOutgoingFace::m_face>
+ boost::multi_index::tag<i_face>,
+ boost::multi_index::member<OutgoingFace, Ptr<Face>, &OutgoingFace::m_face>
>,
boost::multi_index::ordered_non_unique<
- boost::multi_index::tag<__ndn_private::i_retx>,
- boost::multi_index::member<NdnPitEntryOutgoingFace, uint32_t, &NdnPitEntryOutgoingFace::m_retxCount>
+ boost::multi_index::tag<i_retx>,
+ boost::multi_index::member<OutgoingFace, uint32_t, &OutgoingFace::m_retxCount>
>
>
> type;
@@ -84,13 +84,13 @@
*
* All set-methods are virtual, in case index rearrangement is necessary in the derived classes
*/
-class NdnPitEntry : public SimpleRefCount<NdnPitEntry>
+class Entry : public SimpleRefCount<Entry>
{
public:
- typedef std::set< NdnPitEntryIncomingFace > in_container; ///< @brief incoming faces container type
+ typedef std::set< IncomingFace > in_container; ///< @brief incoming faces container type
typedef in_container::iterator in_iterator; ///< @brief iterator to incoming faces
- typedef NdnPitEntryOutgoingFaceContainer::type out_container; ///< @brief outgoing faces container type
+ typedef OutgoingFaceContainer::type out_container; ///< @brief outgoing faces container type
typedef out_container::iterator out_iterator; ///< @brief iterator to outgoing faces
typedef std::set< uint32_t > nonce_container; ///< @brief nonce container type
@@ -101,12 +101,12 @@
* \param offsetTime Relative time to the current moment, representing PIT entry lifetime
* \param fibEntry A FIB entry associated with the PIT entry
*/
- NdnPitEntry (NdnPit &container, Ptr<const NdnInterestHeader> header, Ptr<NdnFibEntry> fibEntry);
+ Entry (Pit &container, Ptr<const InterestHeader> header, Ptr<fib::Entry> fibEntry);
/**
* @brief Virtual destructor
*/
- virtual ~NdnPitEntry () {}
+ virtual ~Entry () {}
/**
* @brief Update lifetime of PIT entry
@@ -122,7 +122,7 @@
/**
* @brief Get prefix of the PIT entry
*/
- const NdnNameComponents &
+ const NameComponents &
GetPrefix () const
{ return *m_prefix; }
@@ -162,13 +162,13 @@
* @returns iterator to the added entry
*/
virtual in_iterator
- AddIncoming (Ptr<NdnFace> face);
+ AddIncoming (Ptr<Face> face);
/**
* @brief Remove incoming entry for face `face`
*/
virtual void
- RemoveIncoming (Ptr<NdnFace> face);
+ RemoveIncoming (Ptr<Face> face);
/**
* @brief Clear all incoming faces either after all of them were satisfied or NACKed
@@ -184,7 +184,7 @@
* @returns iterator to the added entry
*/
virtual out_iterator
- AddOutgoing (Ptr<NdnFace> face);
+ AddOutgoing (Ptr<Face> face);
/**
* @brief Clear all incoming faces either after all of them were satisfied or NACKed
@@ -200,7 +200,7 @@
* Face is removed from the lists of incoming and outgoing faces
*/
virtual void
- RemoveAllReferencesToFace (Ptr<NdnFace> face);
+ RemoveAllReferencesToFace (Ptr<Face> face);
/**
* @brief Flag outgoing face as hopeless
@@ -208,7 +208,7 @@
// virtual void
// SetWaitingInVain (out_iterator face);
virtual void
- SetWaitingInVain (Ptr<NdnFace> face);
+ SetWaitingInVain (Ptr<Face> face);
/**
* @brief Check if all outgoing faces are NACKed
@@ -221,7 +221,7 @@
* \see AreAllOutgoingInVain
**/
bool
- AreTherePromisingOutgoingFacesExcept (Ptr<NdnFace> face) const;
+ AreTherePromisingOutgoingFacesExcept (Ptr<Face> face) const;
/**
* @brief Increase maximum limit of allowed retransmission per outgoing face
@@ -229,7 +229,7 @@
virtual void
IncreaseAllowedRetxCount ();
- Ptr<NdnFibEntry>
+ Ptr<fib::Entry>
GetFibEntry () { return m_fibEntry; };
const in_container &
@@ -242,13 +242,13 @@
GetMaxRetxCount () const { return m_maxRetxCount; }
private:
- friend std::ostream& operator<< (std::ostream& os, const NdnPitEntry &entry);
+ friend std::ostream& operator<< (std::ostream& os, const Entry &entry);
protected:
- NdnPit &m_container; ///< @brief Reference to the container (to rearrange indexes, if necessary)
+ Pit &m_container; ///< @brief Reference to the container (to rearrange indexes, if necessary)
- Ptr<const NdnNameComponents> m_prefix; ///< \brief Prefix of the PIT entry
- Ptr<NdnFibEntry> m_fibEntry; ///< \brief FIB entry related to this prefix
+ Ptr<const NameComponents> m_prefix; ///< \brief Prefix of the PIT entry
+ Ptr<fib::Entry> m_fibEntry; ///< \brief FIB entry related to this prefix
nonce_container m_seenNonces; ///< \brief map of nonces that were seen for this prefix
in_container m_incoming; ///< \brief container for incoming interests
@@ -260,8 +260,10 @@
uint32_t m_maxRetxCount; ///< @brief Maximum allowed number of retransmissions via outgoing faces
};
-std::ostream& operator<< (std::ostream& os, const NdnPitEntry &entry);
+std::ostream& operator<< (std::ostream& os, const Entry &entry);
+} // namespace pit
+} // namespace ndn
} // namespace ns3
#endif // _NDN_PIT_ENTRY_H_
diff --git a/model/pit/ndn-pit-impl.cc b/model/pit/ndn-pit-impl.cc
index 090f1d6..bb8e42a 100644
--- a/model/pit/ndn-pit-impl.cc
+++ b/model/pit/ndn-pit-impl.cc
@@ -37,7 +37,7 @@
#include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>
-NS_LOG_COMPONENT_DEFINE ("NdnPitImpl");
+NS_LOG_COMPONENT_DEFINE ("ndn.pit.PitImpl");
using namespace boost::tuples;
using namespace boost;
@@ -53,23 +53,24 @@
} x_ ## type ## templ ## RegistrationVariable
namespace ns3 {
+namespace ndn {
+namespace pit {
using namespace ndnSIM;
-
template<>
TypeId
-NdnPitImpl<persistent_policy_traits>::GetTypeId ()
+PitImpl<persistent_policy_traits>::GetTypeId ()
{
- static TypeId tid = TypeId ("ns3::NdnPit")
+ static TypeId tid = TypeId ("ns3::ndn::pit::Persistent")
.SetGroupName ("Ndn")
- .SetParent<NdnPit> ()
- .AddConstructor< NdnPitImpl< persistent_policy_traits > > ()
+ .SetParent<Pit> ()
+ .AddConstructor< PitImpl< persistent_policy_traits > > ()
.AddAttribute ("MaxSize",
"Set maximum number of entries in PIT. If 0, limit is not enforced",
StringValue ("0"),
- MakeUintegerAccessor (&NdnPitImpl< persistent_policy_traits >::GetMaxSize,
- &NdnPitImpl< persistent_policy_traits >::SetMaxSize),
+ MakeUintegerAccessor (&PitImpl< persistent_policy_traits >::GetMaxSize,
+ &PitImpl< persistent_policy_traits >::SetMaxSize),
MakeUintegerChecker<uint32_t> ())
;
@@ -78,17 +79,17 @@
template<>
TypeId
-NdnPitImpl<random_policy_traits>::GetTypeId ()
+PitImpl<random_policy_traits>::GetTypeId ()
{
- static TypeId tid = TypeId ("ns3::NdnPitRandom")
+ static TypeId tid = TypeId ("ns3::ndn::pit::Random")
.SetGroupName ("Ndn")
- .SetParent<NdnPit> ()
- .AddConstructor< NdnPitImpl< random_policy_traits > > ()
+ .SetParent<Pit> ()
+ .AddConstructor< PitImpl< random_policy_traits > > ()
.AddAttribute ("MaxSize",
"Set maximum number of entries in PIT. If 0, limit is not enforced",
StringValue ("0"),
- MakeUintegerAccessor (&NdnPitImpl< random_policy_traits >::GetMaxSize,
- &NdnPitImpl< random_policy_traits >::SetMaxSize),
+ MakeUintegerAccessor (&PitImpl< random_policy_traits >::GetMaxSize,
+ &PitImpl< random_policy_traits >::SetMaxSize),
MakeUintegerChecker<uint32_t> ())
;
@@ -97,17 +98,17 @@
template<>
TypeId
-NdnPitImpl<lru_policy_traits>::GetTypeId ()
+PitImpl<lru_policy_traits>::GetTypeId ()
{
- static TypeId tid = TypeId ("ns3::NdnPitLru")
+ static TypeId tid = TypeId ("ns3::ndn::pit::Lru")
.SetGroupName ("Ndn")
- .SetParent<NdnPit> ()
- .AddConstructor< NdnPitImpl< lru_policy_traits > > ()
+ .SetParent<Pit> ()
+ .AddConstructor< PitImpl< lru_policy_traits > > ()
.AddAttribute ("MaxSize",
"Set maximum number of entries in PIT. If 0, limit is not enforced",
StringValue ("0"),
- MakeUintegerAccessor (&NdnPitImpl< lru_policy_traits >::GetMaxSize,
- &NdnPitImpl< lru_policy_traits >::SetMaxSize),
+ MakeUintegerAccessor (&PitImpl< lru_policy_traits >::GetMaxSize,
+ &PitImpl< lru_policy_traits >::SetMaxSize),
MakeUintegerChecker<uint32_t> ())
;
@@ -115,60 +116,60 @@
}
template<class Policy>
-NdnPitImpl<Policy>::NdnPitImpl ()
+PitImpl<Policy>::PitImpl ()
{
}
template<class Policy>
-NdnPitImpl<Policy>::~NdnPitImpl ()
+PitImpl<Policy>::~PitImpl ()
{
}
template<class Policy>
uint32_t
-NdnPitImpl<Policy>::GetMaxSize () const
+PitImpl<Policy>::GetMaxSize () const
{
return super::getPolicy ().get_max_size ();
}
template<class Policy>
void
-NdnPitImpl<Policy>::SetMaxSize (uint32_t maxSize)
+PitImpl<Policy>::SetMaxSize (uint32_t maxSize)
{
super::getPolicy ().set_max_size (maxSize);
}
template<class Policy>
void
-NdnPitImpl<Policy>::NotifyNewAggregate ()
+PitImpl<Policy>::NotifyNewAggregate ()
{
if (m_fib == 0)
{
- m_fib = GetObject<NdnFib> ();
+ m_fib = GetObject<Fib> ();
}
if (m_forwardingStrategy == 0)
{
- m_forwardingStrategy = GetObject<NdnForwardingStrategy> ();
+ m_forwardingStrategy = GetObject<ForwardingStrategy> ();
}
- NdnPit::NotifyNewAggregate ();
+ Pit::NotifyNewAggregate ();
}
template<class Policy>
void
-NdnPitImpl<Policy>::DoDispose ()
+PitImpl<Policy>::DoDispose ()
{
super::clear ();
m_forwardingStrategy = 0;
m_fib = 0;
- NdnPit::DoDispose ();
+ Pit::DoDispose ();
}
template<class Policy>
void
-NdnPitImpl<Policy>::RescheduleCleaning ()
+PitImpl<Policy>::RescheduleCleaning ()
{
m_cleanEvent.Cancel ();
if (i_time.empty ())
@@ -185,12 +186,12 @@
// i_time.begin ()->GetExpireTime () << "s abs time");
m_cleanEvent = Simulator::Schedule (nextEvent,
- &NdnPitImpl<Policy>::CleanExpired, this);
+ &PitImpl<Policy>::CleanExpired, this);
}
template<class Policy>
void
-NdnPitImpl<Policy>::CleanExpired ()
+PitImpl<Policy>::CleanExpired ()
{
NS_LOG_LOGIC ("Cleaning PIT. Total: " << i_time.size ());
Time now = Simulator::Now ();
@@ -218,8 +219,8 @@
}
template<class Policy>
-Ptr<NdnPitEntry>
-NdnPitImpl<Policy>::Lookup (const NdnContentObjectHeader &header)
+Ptr<Entry>
+PitImpl<Policy>::Lookup (const ContentObjectHeader &header)
{
/// @todo use predicate to search with exclude filters
typename super::iterator item = super::longest_prefix_match (header.GetName ());
@@ -231,8 +232,8 @@
}
template<class Policy>
-Ptr<NdnPitEntry>
-NdnPitImpl<Policy>::Lookup (const NdnInterestHeader &header)
+Ptr<Entry>
+PitImpl<Policy>::Lookup (const InterestHeader &header)
{
// NS_LOG_FUNCTION (header.GetName ());
NS_ASSERT_MSG (m_fib != 0, "FIB should be set");
@@ -249,10 +250,10 @@
}
template<class Policy>
-Ptr<NdnPitEntry>
-NdnPitImpl<Policy>::Create (Ptr<const NdnInterestHeader> header)
+Ptr<Entry>
+PitImpl<Policy>::Create (Ptr<const InterestHeader> header)
{
- Ptr<NdnFibEntry> fibEntry = m_fib->LongestPrefixMatch (*header);
+ Ptr<fib::Entry> fibEntry = m_fib->LongestPrefixMatch (*header);
if (fibEntry == 0)
return 0;
@@ -283,7 +284,7 @@
template<class Policy>
void
-NdnPitImpl<Policy>::MarkErased (Ptr<NdnPitEntry> item)
+PitImpl<Policy>::MarkErased (Ptr<Entry> item)
{
// entry->SetExpireTime (Simulator::Now () + m_PitEntryPruningTimout);
super::erase (StaticCast< entry > (item)->to_iterator ());
@@ -292,7 +293,7 @@
template<class Policy>
void
-NdnPitImpl<Policy>::Print (std::ostream& os) const
+PitImpl<Policy>::Print (std::ostream& os) const
{
// !!! unordered_set imposes "random" order of item in the same level !!!
typename super::parent_trie::const_recursive_iterator item (super::getTrie ()), end (0);
@@ -306,14 +307,14 @@
template<class Policy>
uint32_t
-NdnPitImpl<Policy>::GetSize () const
+PitImpl<Policy>::GetSize () const
{
return super::getPolicy ().size ();
}
template<class Policy>
-Ptr<NdnPitEntry>
-NdnPitImpl<Policy>::Begin ()
+Ptr<Entry>
+PitImpl<Policy>::Begin ()
{
typename super::parent_trie::recursive_iterator item (super::getTrie ()), end (0);
for (; item != end; item++)
@@ -329,15 +330,15 @@
}
template<class Policy>
-Ptr<NdnPitEntry>
-NdnPitImpl<Policy>::End ()
+Ptr<Entry>
+PitImpl<Policy>::End ()
{
return 0;
}
template<class Policy>
-Ptr<NdnPitEntry>
-NdnPitImpl<Policy>::Next (Ptr<NdnPitEntry> from)
+Ptr<Entry>
+PitImpl<Policy>::Next (Ptr<Entry> from)
{
if (from == 0) return 0;
@@ -359,13 +360,14 @@
// explicit instantiation and registering
-template class NdnPitImpl<persistent_policy_traits>;
-template class NdnPitImpl<random_policy_traits>;
-template class NdnPitImpl<lru_policy_traits>;
+template class PitImpl<persistent_policy_traits>;
+template class PitImpl<random_policy_traits>;
+template class PitImpl<lru_policy_traits>;
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(NdnPitImpl, persistent_policy_traits);
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(NdnPitImpl, random_policy_traits);
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(NdnPitImpl, lru_policy_traits);
+NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, persistent_policy_traits);
+NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, random_policy_traits);
+NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, lru_policy_traits);
-
+} // namespace pit
+} // namespace ndn
} // namespace ns3
diff --git a/model/pit/ndn-pit-impl.h b/model/pit/ndn-pit-impl.h
index 4673bdb..64e1fc0 100644
--- a/model/pit/ndn-pit-impl.h
+++ b/model/pit/ndn-pit-impl.h
@@ -30,26 +30,31 @@
#include "ns3/ndn-name-components.h"
namespace ns3 {
+namespace ndn {
+
+class ForwardingStrategy;
+
+namespace pit {
/**
* \ingroup ndn
* \brief Class implementing Pending Interests Table
*/
template<class Policy>
-class NdnPitImpl : public NdnPit
- , protected ndnSIM::trie_with_policy<NdnNameComponents,
- ndnSIM::smart_pointer_payload_traits<NdnPitEntryImpl< NdnPitImpl< Policy > > >,
- // ndnSIM::persistent_policy_traits
- Policy
- >
+class PitImpl : public Pit
+ , protected ndnSIM::trie_with_policy<NameComponents,
+ ndnSIM::smart_pointer_payload_traits< EntryImpl< PitImpl< Policy > > >,
+ // ndnSIM::persistent_policy_traits
+ Policy
+ >
{
public:
- typedef ndnSIM::trie_with_policy<NdnNameComponents,
- ndnSIM::smart_pointer_payload_traits<NdnPitEntryImpl< NdnPitImpl< Policy > > >,
+ typedef ndnSIM::trie_with_policy<NameComponents,
+ ndnSIM::smart_pointer_payload_traits< EntryImpl< PitImpl< Policy > > >,
// ndnSIM::persistent_policy_traits
Policy
> super;
- typedef NdnPitEntryImpl< NdnPitImpl< Policy > > entry;
+ typedef EntryImpl< PitImpl< Policy > > entry;
/**
* \brief Interface ID
@@ -61,25 +66,25 @@
/**
* \brief PIT constructor
*/
- NdnPitImpl ();
+ PitImpl ();
/**
* \brief Destructor
*/
- virtual ~NdnPitImpl ();
+ virtual ~PitImpl ();
- // inherited from NdnPit
- virtual Ptr<NdnPitEntry>
- Lookup (const NdnContentObjectHeader &header);
+ // inherited from Pit
+ virtual Ptr<Entry>
+ Lookup (const ContentObjectHeader &header);
- virtual Ptr<NdnPitEntry>
- Lookup (const NdnInterestHeader &header);
+ virtual Ptr<Entry>
+ Lookup (const InterestHeader &header);
- virtual Ptr<NdnPitEntry>
- Create (Ptr<const NdnInterestHeader> header);
+ virtual Ptr<Entry>
+ Create (Ptr<const InterestHeader> header);
virtual void
- MarkErased (Ptr<NdnPitEntry> entry);
+ MarkErased (Ptr<Entry> entry);
virtual void
Print (std::ostream &os) const;
@@ -87,14 +92,14 @@
virtual uint32_t
GetSize () const;
- virtual Ptr<NdnPitEntry>
+ virtual Ptr<Entry>
Begin ();
- virtual Ptr<NdnPitEntry>
+ virtual Ptr<Entry>
End ();
- virtual Ptr<NdnPitEntry>
- Next (Ptr<NdnPitEntry>);
+ virtual Ptr<Entry>
+ Next (Ptr<Entry>);
protected:
void RescheduleCleaning ();
@@ -113,8 +118,8 @@
private:
EventId m_cleanEvent;
- Ptr<NdnFib> m_fib; ///< \brief Link to FIB table
- Ptr<NdnForwardingStrategy> m_forwardingStrategy;
+ Ptr<Fib> m_fib; ///< \brief Link to FIB table
+ Ptr<ForwardingStrategy> m_forwardingStrategy;
// indexes
typedef
@@ -126,9 +131,11 @@
> time_index;
time_index i_time;
- friend class NdnPitEntryImpl< NdnPitImpl >;
+ friend class EntryImpl< PitImpl >;
};
+} // namespace pit
+} // namespace ndn
} // namespace ns3
#endif /* NDN_PIT_IMPL_H */
diff --git a/model/pit/ndn-pit.cc b/model/pit/ndn-pit.cc
index 1f1bcde..48a1747 100644
--- a/model/pit/ndn-pit.cc
+++ b/model/pit/ndn-pit.cc
@@ -31,37 +31,37 @@
#include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>
-NS_LOG_COMPONENT_DEFINE ("NdnPit");
+NS_LOG_COMPONENT_DEFINE ("ndn.Pit");
namespace ns3 {
+namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (NdnPit);
-
-using namespace __ndn_private;
+NS_OBJECT_ENSURE_REGISTERED (Pit);
TypeId
-NdnPit::GetTypeId ()
+Pit::GetTypeId ()
{
- static TypeId tid = TypeId ("ns3::private::NdnPit")
+ static TypeId tid = TypeId ("ns3::ndn::Pit")
.SetGroupName ("Ndn")
.SetParent<Object> ()
.AddAttribute ("PitEntryPruningTimout",
"Timeout for PIT entry to live after being satisfied. To make sure recently satisfied interest will not be satisfied again",
StringValue ("100ms"),
- MakeTimeAccessor (&NdnPit::m_PitEntryPruningTimout),
+ MakeTimeAccessor (&Pit::m_PitEntryPruningTimout),
MakeTimeChecker ())
;
return tid;
}
-NdnPit::NdnPit ()
+Pit::Pit ()
{
}
-NdnPit::~NdnPit ()
+Pit::~Pit ()
{
}
+} // namespace ndn
} // namespace ns3
diff --git a/model/pit/ndn-pit.h b/model/pit/ndn-pit.h
index 6a0556b..f8eeafb 100644
--- a/model/pit/ndn-pit.h
+++ b/model/pit/ndn-pit.h
@@ -28,11 +28,12 @@
#include "ndn-pit-entry.h"
namespace ns3 {
+namespace ndn {
-class Ndn;
-class NdnFace;
-class NdnContentObjectHeader;
-class NdnInterestHeader;
+class L3Protocol;
+class Face;
+class ContentObjectHeader;
+class InterestHeader;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
@@ -41,7 +42,7 @@
* \ingroup ndn
* \brief Class implementing Pending Interests Table
*/
-class NdnPit : public Object
+class Pit : public Object
{
public:
/**
@@ -54,12 +55,12 @@
/**
* \brief PIT constructor
*/
- NdnPit ();
+ Pit ();
/**
* \brief Destructor
*/
- virtual ~NdnPit ();
+ virtual ~Pit ();
/**
* \brief Find corresponding PIT entry for the given content name
@@ -72,8 +73,8 @@
* \returns smart pointer to PIT entry. If record not found,
* returns 0
*/
- virtual Ptr<NdnPitEntry>
- Lookup (const NdnContentObjectHeader &header) = 0;
+ virtual Ptr<pit::Entry>
+ Lookup (const ContentObjectHeader &header) = 0;
/**
* \brief Find a PIT entry for the given content interest
@@ -81,8 +82,8 @@
* \returns iterator to Pit entry. If record not found,
* return end() iterator
*/
- virtual Ptr<NdnPitEntry>
- Lookup (const NdnInterestHeader &header) = 0;
+ virtual Ptr<pit::Entry>
+ Lookup (const InterestHeader &header) = 0;
/**
* @brief Creates a PIT entry for the given interest
@@ -92,8 +93,8 @@
*
* Note. This call assumes that the entry does not exist (i.e., there was a Lookup call before)
*/
- virtual Ptr<NdnPitEntry>
- Create (Ptr<const NdnInterestHeader> header) = 0;
+ virtual Ptr<pit::Entry>
+ Create (Ptr<const InterestHeader> header) = 0;
/**
* @brief Mark PIT entry deleted
@@ -103,7 +104,7 @@
* lifetime +m_PitEntryDefaultLifetime from Now ()
*/
virtual void
- MarkErased (Ptr<NdnPitEntry> entry) = 0;
+ MarkErased (Ptr<pit::Entry> entry) = 0;
/**
* @brief Print out PIT contents for debugging purposes
@@ -122,20 +123,20 @@
/**
* @brief Return first element of FIB (no order guaranteed)
*/
- virtual Ptr<NdnPitEntry>
+ virtual Ptr<pit::Entry>
Begin () = 0;
/**
* @brief Return item next after last (no order guaranteed)
*/
- virtual Ptr<NdnPitEntry>
+ virtual Ptr<pit::Entry>
End () = 0;
/**
* @brief Advance the iterator
*/
- virtual Ptr<NdnPitEntry>
- Next (Ptr<NdnPitEntry>) = 0;
+ virtual Ptr<pit::Entry>
+ Next (Ptr<pit::Entry>) = 0;
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
@@ -144,8 +145,8 @@
/**
* @brief Static call to cheat python bindings
*/
- static inline Ptr<NdnPit>
- GetNdnPit (Ptr<Object> node);
+ static inline Ptr<Pit>
+ GetPit (Ptr<Object> node);
protected:
// configuration variables. Check implementation of GetTypeId for more details
@@ -156,19 +157,19 @@
///////////////////////////////////////////////////////////////////////////////
inline std::ostream&
-operator<< (std::ostream& os, const NdnPit &pit)
+operator<< (std::ostream& os, const Pit &pit)
{
pit.Print (os);
return os;
}
-inline Ptr<NdnPit>
-NdnPit::GetNdnPit (Ptr<Object> node)
+inline Ptr<Pit>
+Pit::GetPit (Ptr<Object> node)
{
- return node->GetObject<NdnPit> ();
+ return node->GetObject<Pit> ();
}
-
+} // namespace ndn
} // namespace ns3
#endif /* NDN_PIT_H */