Another set of refactoring
diff --git a/model/content-store/ndn-content-store-impl.h b/model/content-store/ndn-content-store-impl.h
deleted file mode 100644
index 0140f58..0000000
--- a/model/content-store/ndn-content-store-impl.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_CONTENT_STORE_IMPL_H_
-#define NDN_CONTENT_STORE_IMPL_H_
-
-#include "ndn-content-store.h"
-#include "ns3/packet.h"
-#include "ns3/ndn-interest-header.h"
-#include "ns3/ndn-content-object-header.h"
-#include <boost/foreach.hpp>
-
-namespace ns3
-{
-
-template<class Container>
-class NdnContentStoreImpl : public NdnContentStore,
- protected Container
-{
-public:
- // from NdnContentStore
-
- virtual inline boost::tuple<Ptr<Packet>, Ptr<const NdnContentObjectHeader>, Ptr<const Packet> >
- Lookup (Ptr<const NdnInterestHeader> interest);
-
- virtual inline bool
- Add (Ptr<const NdnContentObjectHeader> header, Ptr<const Packet> packet);
-
- // virtual bool
- // Remove (Ptr<NdnInterestHeader> header);
-
- virtual inline void
- Print (std::ostream &os) const;
-};
-
-
-template<class Container>
-boost::tuple<Ptr<Packet>, Ptr<const NdnContentObjectHeader>, Ptr<const Packet> >
-NdnContentStoreImpl<Container>::Lookup (Ptr<const NdnInterestHeader> interest)
-{
- // NS_LOG_FUNCTION (this << interest->GetName ());
-
- /// @todo Change to search with predicate
- typename Container::const_iterator node = this->deepest_prefix_match (interest->GetName ());
-
- if (node != this->end ())
- {
- this->m_cacheHitsTrace (interest, node->payload ()->GetHeader ());
-
- // NS_LOG_DEBUG ("cache hit with " << node->payload ()->GetHeader ()->GetName ());
- return boost::make_tuple (node->payload ()->GetFullyFormedNdnPacket (),
- node->payload ()->GetHeader (),
- node->payload ()->GetPacket ());
- }
- else
- {
- // NS_LOG_DEBUG ("cache miss for " << interest->GetName ());
- this->m_cacheMissesTrace (interest);
- return boost::tuple<Ptr<Packet>, Ptr<NdnContentObjectHeader>, Ptr<Packet> > (0, 0, 0);
- }
-}
-
-template<class Container>
-bool
-NdnContentStoreImpl<Container>::Add (Ptr<const NdnContentObjectHeader> header, Ptr<const Packet> packet)
-{
- // NS_LOG_FUNCTION (this << header->GetName ());
-
- return
- this->insert (header->GetName (), Create<NdnContentStoreEntry> (header, packet))
- .second;
-}
-
-template<class Container>
-void
-NdnContentStoreImpl<Container>::Print (std::ostream &os) const
-{
- for (typename Container::policy_container::const_iterator item = this->getPolicy ().begin ();
- item != this->getPolicy ().end ();
- item++)
- // BOOST_FOREACH (const typename Container::parent_trie &item, this->getPolicy ())
- {
- os << item->payload ()->GetName () << std::endl;
- }
-}
-
-
-} // namespace ns3
-
-#endif // NDN_CONTENT_STORE_IMPL_H_
diff --git a/model/content-store/ndn-content-store-policies.cc b/model/content-store/ndn-content-store-policies.cc
deleted file mode 100644
index a474461..0000000
--- a/model/content-store/ndn-content-store-policies.cc
+++ /dev/null
@@ -1,173 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-content-store-policies.h"
-#include "ns3/log.h"
-#include "ns3/uinteger.h"
-
-NS_LOG_COMPONENT_DEFINE ("NdnContentStorePolicies");
-
-namespace ns3
-{
-
-////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////
-// LRU policy
-////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////
-
-NS_OBJECT_ENSURE_REGISTERED (NdnContentStoreLru);
-
-TypeId
-NdnContentStoreLru::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::NdnContentStoreLru")
- .SetGroupName ("Ndn")
- .SetParent< NdnContentStore > ()
- .AddConstructor<NdnContentStoreLru> ()
- .AddAttribute ("Size",
- "Maximum number of packets that content storage can hold",
- UintegerValue (100),
- MakeUintegerAccessor (&NdnContentStoreLru::SetMaxSize,
- &NdnContentStoreLru::GetMaxSize),
- MakeUintegerChecker<uint32_t> ())
- ;
-
- return tid;
-}
-
-void
-NdnContentStoreLru::SetMaxSize (uint32_t maxSize)
-{
- getPolicy ().set_max_size (maxSize);
-}
-
-uint32_t
-NdnContentStoreLru::GetMaxSize () const
-{
- return getPolicy ().get_max_size ();
-}
-
-NdnContentStoreLru::NdnContentStoreLru ()
-{
-}
-
-NdnContentStoreLru::~NdnContentStoreLru ()
-{
-}
-
-////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////
-// RANDOM policy
-////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////
-
-NS_OBJECT_ENSURE_REGISTERED (NdnContentStoreRandom);
-
-TypeId
-NdnContentStoreRandom::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::NdnContentStoreRandom")
- .SetGroupName ("Ndn")
- .SetParent< NdnContentStore > ()
- .AddConstructor<NdnContentStoreRandom> ()
-
- .AddAttribute ("Size",
- "Maximum number of packets that content storage can hold",
- UintegerValue (100),
- MakeUintegerAccessor (&NdnContentStoreRandom::SetMaxSize,
- &NdnContentStoreRandom::GetMaxSize),
- MakeUintegerChecker<uint32_t> ())
- ;
-
- return tid;
-}
-
-void
-NdnContentStoreRandom::SetMaxSize (uint32_t maxSize)
-{
- getPolicy ().set_max_size (maxSize);
-}
-
-uint32_t
-NdnContentStoreRandom::GetMaxSize () const
-{
- return getPolicy ().get_max_size ();
-}
-
-NdnContentStoreRandom::NdnContentStoreRandom ()
-{
-}
-
-NdnContentStoreRandom::~NdnContentStoreRandom ()
-{
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////
-// FIFO policy
-////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////
-
-NS_OBJECT_ENSURE_REGISTERED (NdnContentStoreFifo);
-
-TypeId
-NdnContentStoreFifo::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::NdnContentStoreFifo")
- .SetGroupName ("Ndn")
- .SetParent< NdnContentStore > ()
- .AddConstructor<NdnContentStoreFifo> ()
-
- .AddAttribute ("Size",
- "Maximum number of packets that content storage can hold",
- UintegerValue (100),
- MakeUintegerAccessor (&NdnContentStoreFifo::SetMaxSize,
- &NdnContentStoreFifo::GetMaxSize),
- MakeUintegerChecker<uint32_t> ())
- ;
-
- return tid;
-}
-
-void
-NdnContentStoreFifo::SetMaxSize (uint32_t maxSize)
-{
- getPolicy ().set_max_size (maxSize);
-}
-
-uint32_t
-NdnContentStoreFifo::GetMaxSize () const
-{
- return getPolicy ().get_max_size ();
-}
-
-NdnContentStoreFifo::NdnContentStoreFifo ()
-{
-}
-
-NdnContentStoreFifo::~NdnContentStoreFifo ()
-{
-}
-
-
-} // namespace ns3
-
diff --git a/model/content-store/ndn-content-store-policies.h b/model/content-store/ndn-content-store-policies.h
deleted file mode 100644
index 506dc72..0000000
--- a/model/content-store/ndn-content-store-policies.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#ifndef NDN_CONTENT_STORE_POLICIES_H
-#define NDN_CONTENT_STORE_POLICIES_H
-
-// #include "ns3/ndn.h"
-
-#include "ndn-content-store-impl.h"
-
-#include "../../utils/trie.h"
-#include "../../utils/trie-with-policy.h"
-
-#include "../../utils/lru-policy.h"
-#include "../../utils/random-policy.h"
-#include "../../utils/fifo-policy.h"
-
-namespace ns3
-{
-
-/**
- * \ingroup ndn
- * \brief Content Store with LRU replacement policy
- */
-class NdnContentStoreLru :
- public NdnContentStoreImpl<
- ndnSIM::trie_with_policy<NdnNameComponents,
- ndnSIM::smart_pointer_payload_traits<NdnContentStoreEntry>,
- ndnSIM::lru_policy_traits >
- >
-{
-public:
- /**
- * \brief Interface ID
- *
- * \return interface ID
- */
- static TypeId GetTypeId ();
-
- /**
- * Default constructor
- */
- NdnContentStoreLru ();
- virtual ~NdnContentStoreLru ();
-
-private:
- void
- SetMaxSize (uint32_t maxSize);
-
- uint32_t
- GetMaxSize () const;
-};
-
-
-/**
- * \ingroup ndn
- * \brief Content Store with RANDOM replacement policy
- */
-class NdnContentStoreRandom :
- public NdnContentStoreImpl<
- ndnSIM::trie_with_policy<NdnNameComponents,
- ndnSIM::smart_pointer_payload_traits<NdnContentStoreEntry>,
- ndnSIM::random_policy_traits >
- >
-{
-public:
- /**
- * \brief Interface ID
- *
- * \return interface ID
- */
- static TypeId GetTypeId ();
-
- /**
- * Default constructor
- */
- NdnContentStoreRandom ();
- virtual ~NdnContentStoreRandom ();
-
-private:
- void
- SetMaxSize (uint32_t maxSize);
-
- uint32_t
- GetMaxSize () const;
-};
-
-/**
- * \ingroup ndn
- * \brief Content Store with FIFO replacement policy
- */
-class NdnContentStoreFifo :
- public NdnContentStoreImpl<
- ndnSIM::trie_with_policy<NdnNameComponents,
- ndnSIM::smart_pointer_payload_traits<NdnContentStoreEntry>,
- ndnSIM::fifo_policy_traits >
- >
-{
-public:
- /**
- * \brief Interface ID
- *
- * \return interface ID
- */
- static TypeId GetTypeId ();
-
- /**
- * Default constructor
- */
- NdnContentStoreFifo ();
- virtual ~NdnContentStoreFifo ();
-
-private:
- void
- SetMaxSize (uint32_t maxSize);
-
- uint32_t
- GetMaxSize () const;
-};
-
-
-} //namespace ns3
-
-#endif // NDN_CONTENT_STORE_POLICIES_H
diff --git a/model/cs/content-store-impl.cc b/model/cs/content-store-impl.cc
new file mode 100644
index 0000000..fe6346b
--- /dev/null
+++ b/model/cs/content-store-impl.cc
@@ -0,0 +1,188 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "content-store-impl.h"
+#include "ns3/log.h"
+#include "ns3/uinteger.h"
+#include "ns3/string.h"
+
+#include "../../utils/random-policy.h"
+#include "../../utils/lru-policy.h"
+#include "../../utils/fifo-policy.h"
+
+NS_LOG_COMPONENT_DEFINE ("ndn.cs.ContentStoreImpl");
+
+#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 {
+
+using namespace ndnSIM;
+
+namespace cs {
+
+
+template<>
+TypeId
+ContentStoreImpl< lru_policy_traits >::GetTypeId ()
+{
+ static TypeId tid = TypeId ("ns3::ndn::cs::Lru")
+ .SetGroupName ("Ndn")
+ .SetParent<ContentStore> ()
+ .AddConstructor< ContentStoreImpl< lru_policy_traits > > ()
+ .AddAttribute ("MaxSize",
+ "Set maximum number of entries in ContentStore. If 0, limit is not enforced",
+ StringValue ("100"),
+ MakeUintegerAccessor (&ContentStoreImpl< lru_policy_traits >::GetMaxSize,
+ &ContentStoreImpl< lru_policy_traits >::SetMaxSize),
+ MakeUintegerChecker<uint32_t> ())
+ ;
+
+ return tid;
+}
+
+template<>
+TypeId
+ContentStoreImpl< random_policy_traits >::GetTypeId ()
+{
+ static TypeId tid = TypeId ("ns3::ndn::cs::Random")
+ .SetGroupName ("Ndn")
+ .SetParent<ContentStore> ()
+ .AddConstructor< ContentStoreImpl< random_policy_traits > > ()
+ .AddAttribute ("MaxSize",
+ "Set maximum number of entries in ContentStore. If 0, limit is not enforced",
+ StringValue ("100"),
+ MakeUintegerAccessor (&ContentStoreImpl< random_policy_traits >::GetMaxSize,
+ &ContentStoreImpl< random_policy_traits >::SetMaxSize),
+ MakeUintegerChecker<uint32_t> ())
+ ;
+
+ return tid;
+}
+
+template<>
+TypeId
+ContentStoreImpl< fifo_policy_traits >::GetTypeId ()
+{
+ static TypeId tid = TypeId ("ns3::ndn::cs::Fifo")
+ .SetGroupName ("Ndn")
+ .SetParent<ContentStore> ()
+ .AddConstructor< ContentStoreImpl< fifo_policy_traits > > ()
+ .AddAttribute ("MaxSize",
+ "Set maximum number of entries in ContentStore. If 0, limit is not enforced",
+ StringValue ("100"),
+ MakeUintegerAccessor (&ContentStoreImpl< fifo_policy_traits >::GetMaxSize,
+ &ContentStoreImpl< fifo_policy_traits >::SetMaxSize),
+ MakeUintegerChecker<uint32_t> ())
+ ;
+
+ return tid;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////
+
+template<class Policy>
+boost::tuple<Ptr<Packet>, Ptr<const ContentObjectHeader>, Ptr<const Packet> >
+ContentStoreImpl<Policy>::Lookup (Ptr<const InterestHeader> interest)
+{
+ // NS_LOG_FUNCTION (this << interest->GetName ());
+
+ /// @todo Change to search with predicate
+ typename super::const_iterator node = this->deepest_prefix_match (interest->GetName ());
+
+ if (node != this->end ())
+ {
+ this->m_cacheHitsTrace (interest, node->payload ()->GetHeader ());
+
+ // NS_LOG_DEBUG ("cache hit with " << node->payload ()->GetHeader ()->GetName ());
+ return boost::make_tuple (node->payload ()->GetFullyFormedNdnPacket (),
+ node->payload ()->GetHeader (),
+ node->payload ()->GetPacket ());
+ }
+ else
+ {
+ // NS_LOG_DEBUG ("cache miss for " << interest->GetName ());
+ this->m_cacheMissesTrace (interest);
+ return boost::tuple<Ptr<Packet>, Ptr<ContentObjectHeader>, Ptr<Packet> > (0, 0, 0);
+ }
+}
+
+template<class Policy>
+bool
+ContentStoreImpl<Policy>::Add (Ptr<const ContentObjectHeader> header, Ptr<const Packet> packet)
+{
+ // NS_LOG_FUNCTION (this << header->GetName ());
+
+ return
+ this->insert (header->GetName (), Create<Entry> (header, packet))
+ .second;
+}
+
+template<class Policy>
+void
+ContentStoreImpl<Policy>::Print (std::ostream &os) const
+{
+ for (typename super::policy_container::const_iterator item = this->getPolicy ().begin ();
+ item != this->getPolicy ().end ();
+ item++)
+ // BOOST_FOREACH (const typename super::parent_trie &item, this->getPolicy ())
+ {
+ os << item->payload ()->GetName () << std::endl;
+ }
+}
+
+template<class Policy>
+void
+ContentStoreImpl<Policy>::SetMaxSize (uint32_t maxSize)
+{
+ this->getPolicy ().set_max_size (maxSize);
+}
+
+template<class Policy>
+uint32_t
+ContentStoreImpl<Policy>::GetMaxSize () const
+{
+ return this->getPolicy ().get_max_size ();
+}
+
+////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////
+
+// explicit instantiation and registering
+template class ContentStoreImpl<lru_policy_traits>;
+template class ContentStoreImpl<random_policy_traits>;
+template class ContentStoreImpl<fifo_policy_traits>;
+
+NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, lru_policy_traits);
+NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, random_policy_traits);
+NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, fifo_policy_traits);
+
+
+} // namespace cs
+} // namespace ndn
+} // namespace ns3
diff --git a/model/cs/content-store-impl.h b/model/cs/content-store-impl.h
new file mode 100644
index 0000000..9ba1af5
--- /dev/null
+++ b/model/cs/content-store-impl.h
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef NDN_CONTENT_STORE_IMPL_H_
+#define NDN_CONTENT_STORE_IMPL_H_
+
+#include "ndn-content-store.h"
+#include "ns3/packet.h"
+#include "ns3/ndn-interest-header.h"
+#include "ns3/ndn-content-object-header.h"
+#include <boost/foreach.hpp>
+
+#include "../../utils/trie-with-policy.h"
+
+namespace ns3 {
+namespace ndn {
+namespace cs {
+
+
+template<class Policy>
+class ContentStoreImpl : public ContentStore,
+ protected ndnSIM::trie_with_policy< NameComponents,
+ ndnSIM::smart_pointer_payload_traits< Entry >,
+ Policy >
+{
+private:
+ typedef ndnSIM::trie_with_policy< NameComponents,
+ ndnSIM::smart_pointer_payload_traits< Entry >,
+ Policy > super;
+
+public:
+ static TypeId
+ GetTypeId ();
+
+ ContentStoreImpl () { };
+ virtual ~ContentStoreImpl () { };
+
+ // from ContentStore
+
+ virtual inline boost::tuple<Ptr<Packet>, Ptr<const ContentObjectHeader>, Ptr<const Packet> >
+ Lookup (Ptr<const InterestHeader> interest);
+
+ virtual inline bool
+ Add (Ptr<const ContentObjectHeader> header, Ptr<const Packet> packet);
+
+ // virtual bool
+ // Remove (Ptr<InterestHeader> header);
+
+ virtual inline void
+ Print (std::ostream &os) const;
+
+private:
+ void
+ SetMaxSize (uint32_t maxSize);
+
+ uint32_t
+ GetMaxSize () const;
+};
+
+} // namespace cs
+} // namespace ndn
+} // namespace ns3
+
+#endif // NDN_CONTENT_STORE_IMPL_H_
diff --git a/model/content-store/ndn-content-store.cc b/model/cs/ndn-content-store.cc
similarity index 68%
rename from model/content-store/ndn-content-store.cc
rename to model/cs/ndn-content-store.cc
index 75e9373..bfd4926 100644
--- a/model/content-store/ndn-content-store.cc
+++ b/model/cs/ndn-content-store.cc
@@ -27,47 +27,49 @@
#include "ns3/ndn-interest-header.h"
#include "ns3/ndn-content-object-header.h"
-NS_LOG_COMPONENT_DEFINE ("NdnContentStore");
+NS_LOG_COMPONENT_DEFINE ("ndn.cs.ContentStore");
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (NdnContentStore);
+NS_OBJECT_ENSURE_REGISTERED (ContentStore);
TypeId
-NdnContentStore::GetTypeId (void)
+ContentStore::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::NdnContentStore")
+ static TypeId tid = TypeId ("ns3::ndn::ContentStore")
.SetGroupName ("Ndn")
.SetParent<Object> ()
.AddTraceSource ("CacheHits", "Trace called every time there is a cache hit",
- MakeTraceSourceAccessor (&NdnContentStore::m_cacheHitsTrace))
+ MakeTraceSourceAccessor (&ContentStore::m_cacheHitsTrace))
.AddTraceSource ("CacheMisses", "Trace called every time there is a cache miss",
- MakeTraceSourceAccessor (&NdnContentStore::m_cacheMissesTrace))
+ MakeTraceSourceAccessor (&ContentStore::m_cacheMissesTrace))
;
return tid;
}
-NdnContentStore::~NdnContentStore ()
+ContentStore::~ContentStore ()
{
}
+namespace cs {
+
//////////////////////////////////////////////////////////////////////
-NdnContentStoreEntry::NdnContentStoreEntry (Ptr<const NdnContentObjectHeader> header, Ptr<const Packet> packet)
+Entry::Entry (Ptr<const ContentObjectHeader> header, Ptr<const Packet> packet)
: m_header (header)
, m_packet (packet->Copy ())
{
}
Ptr<Packet>
-NdnContentStoreEntry::GetFullyFormedNdnPacket () const
+Entry::GetFullyFormedNdnPacket () const
{
- static NdnContentObjectTail tail; ///< \internal for optimization purposes
+ static ContentObjectTail tail; ///< \internal for optimization purposes
Ptr<Packet> packet = m_packet->Copy ();
packet->AddHeader (*m_header);
@@ -75,22 +77,24 @@
return packet;
}
-const NdnNameComponents&
-NdnContentStoreEntry::GetName () const
+const NameComponents&
+Entry::GetName () const
{
return m_header->GetName ();
}
-Ptr<const NdnContentObjectHeader>
-NdnContentStoreEntry::GetHeader () const
+Ptr<const ContentObjectHeader>
+Entry::GetHeader () const
{
return m_header;
}
Ptr<const Packet>
-NdnContentStoreEntry::GetPacket () const
+Entry::GetPacket () const
{
return m_packet;
}
+} // namespace cs
+} // namespace ndn
} // namespace ns3
diff --git a/model/content-store/ndn-content-store.h b/model/cs/ndn-content-store.h
similarity index 70%
rename from model/content-store/ndn-content-store.h
rename to model/cs/ndn-content-store.h
index 2d4ada6..963c7bc 100644
--- a/model/content-store/ndn-content-store.h
+++ b/model/cs/ndn-content-store.h
@@ -28,13 +28,17 @@
#include <boost/tuple/tuple.hpp>
-namespace ns3
-{
+namespace ns3 {
class Packet;
-class NdnContentObjectHeader;
-class NdnInterestHeader;
-class NdnNameComponents;
+
+namespace ndn {
+
+class ContentObjectHeader;
+class InterestHeader;
+class NameComponents;
+
+namespace cs {
/**
* \ingroup ndn
@@ -42,37 +46,37 @@
*
* Content store entry stores separately pseudo header and content of
* ContentObject packet. It is responsibility of the caller to
- * construct a fully formed NdnPacket by calling Copy(), AddHeader(),
+ * construct a fully formed NDN Packet by calling Copy(), AddHeader(),
* AddTail() on the packet received by GetPacket() method.
*
* GetFullyFormedNdnPacket method provided as a convenience
*/
-class NdnContentStoreEntry : public SimpleRefCount<NdnContentStoreEntry>
+class Entry : public SimpleRefCount<Entry>
{
public:
/**
* \brief Construct content store entry
*
- * \param header Parsed NdnContentObject header
+ * \param header Parsed ContentObject header
* \param packet Original Ndn packet
*
* The constructor will make a copy of the supplied packet and calls
* RemoveHeader and RemoveTail on the copy.
*/
- NdnContentStoreEntry (Ptr<const NdnContentObjectHeader> header, Ptr<const Packet> packet);
+ Entry (Ptr<const ContentObjectHeader> header, Ptr<const Packet> packet);
/**
* \brief Get prefix of the stored entry
* \returns prefix of the stored entry
*/
- const NdnNameComponents&
+ const NameComponents&
GetName () const;
/**
- * \brief Get NdnContentObjectHeader of the stored entry
- * \returns NdnContentObjectHeader of the stored entry
+ * \brief Get ContentObjectHeader of the stored entry
+ * \returns ContentObjectHeader of the stored entry
*/
- Ptr<const NdnContentObjectHeader>
+ Ptr<const ContentObjectHeader>
GetHeader () const;
/**
@@ -84,16 +88,18 @@
/**
* \brief Convenience method to create a fully formed Ndn packet from stored header and content
- * \returns A read-write copy of the packet with NdnContentObjectHeader and CcxnContentObjectTail
+ * \returns A read-write copy of the packet with ContentObjectHeader and ContentObjectTail
*/
Ptr<Packet>
GetFullyFormedNdnPacket () const;
private:
- Ptr<const NdnContentObjectHeader> m_header; ///< \brief non-modifiable NdnContentObjectHeader
+ Ptr<const ContentObjectHeader> m_header; ///< \brief non-modifiable ContentObjectHeader
Ptr<Packet> m_packet; ///< \brief non-modifiable content of the ContentObject packet
};
+} // namespace cs
+
/**
* \ingroup ndn
@@ -101,7 +107,7 @@
*
* Particular implementations should implement Lookup, Add, and Print methods
*/
-class NdnContentStore : public Object
+class ContentStore : public Object
{
public:
/**
@@ -115,7 +121,8 @@
/**
* @brief Virtual destructor
*/
- virtual ~NdnContentStore ();
+ virtual
+ ~ContentStore ();
/**
* \brief Find corresponding CS entry for the given interest
@@ -126,19 +133,19 @@
* If an entry is found, it is promoted to the top of most recent
* used entries index, \see m_contentStore
*/
- virtual boost::tuple<Ptr<Packet>, Ptr<const NdnContentObjectHeader>, Ptr<const Packet> >
- Lookup (Ptr<const NdnInterestHeader> interest) = 0;
+ virtual boost::tuple<Ptr<Packet>, Ptr<const ContentObjectHeader>, Ptr<const Packet> >
+ Lookup (Ptr<const InterestHeader> interest) = 0;
/**
* \brief Add a new content to the content store.
*
- * \param header Fully parsed NdnContentObjectHeader
+ * \param header Fully parsed ContentObjectHeader
* \param packet Fully formed Ndn packet to add to content store
* (will be copied and stripped down of headers)
* @returns true if an existing entry was updated, false otherwise
*/
virtual bool
- Add (Ptr<const NdnContentObjectHeader> header, Ptr<const Packet> packet) = 0;
+ Add (Ptr<const ContentObjectHeader> header, Ptr<const Packet> packet) = 0;
// /**
// * \brief Add a new content to the content store.
@@ -147,7 +154,7 @@
// * @returns true if an existing entry was removed, false otherwise
// */
// virtual bool
- // Remove (Ptr<NdnInterestHeader> header) = 0;
+ // Remove (Ptr<InterestHeader> header) = 0;
/**
* \brief Print out content store entries
@@ -156,19 +163,20 @@
Print (std::ostream &os) const = 0;
protected:
- TracedCallback<Ptr<const NdnInterestHeader>,
- Ptr<const NdnContentObjectHeader> > m_cacheHitsTrace; ///< @brief trace of cache hits
+ TracedCallback<Ptr<const InterestHeader>,
+ Ptr<const ContentObjectHeader> > m_cacheHitsTrace; ///< @brief trace of cache hits
- TracedCallback<Ptr<const NdnInterestHeader> > m_cacheMissesTrace; ///< @brief trace of cache misses
+ TracedCallback<Ptr<const InterestHeader> > m_cacheMissesTrace; ///< @brief trace of cache misses
};
inline std::ostream&
-operator<< (std::ostream &os, const NdnContentStore &cs)
+operator<< (std::ostream &os, const ContentStore &cs)
{
cs.Print (os);
return os;
}
+} // namespace ndn
} // namespace ns3
#endif // NDN_CONTENT_STORE_H
diff --git a/model/fib/ndn-fib-entry.cc b/model/fib/ndn-fib-entry.cc
index 965886f..01e2970 100644
--- a/model/fib/ndn-fib-entry.cc
+++ b/model/fib/ndn-fib-entry.cc
@@ -32,30 +32,25 @@
#include <boost/lambda/bind.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("NdnFibEntry");
+NS_LOG_COMPONENT_DEFINE ("ndn.fib.Entry");
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
+namespace fib {
//////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////
-namespace __ndn_private {
-struct NdnFibFaceMetricByFace
+struct FaceMetricByFace
{
- typedef NdnFibFaceMetricContainer::type::index<i_face>::type
+ typedef FaceMetricContainer::type::index<i_face>::type
type;
};
-}
-//////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////
-
-using namespace __ndn_private;
void
-NdnFibFaceMetric::UpdateRtt (const Time &rttSample)
+FaceMetric::UpdateRtt (const Time &rttSample)
{
// const Time & this->m_rttSample
@@ -78,56 +73,56 @@
/////////////////////////////////////////////////////////////////////
void
-NdnFibEntry::UpdateFaceRtt (Ptr<NdnFace> face, const Time &sample)
+Entry::UpdateFaceRtt (Ptr<Face> face, const Time &sample)
{
- NdnFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
+ FaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
NS_ASSERT_MSG (record != m_faces.get<i_face> ().end (),
"Update status can be performed only on existing faces of CcxnFibEntry");
m_faces.modify (record,
- ll::bind (&NdnFibFaceMetric::UpdateRtt, ll::_1, sample));
+ ll::bind (&FaceMetric::UpdateRtt, ll::_1, sample));
// reordering random access index same way as by metric index
m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
}
void
-NdnFibEntry::UpdateStatus (Ptr<NdnFace> face, NdnFibFaceMetric::Status status)
+Entry::UpdateStatus (Ptr<Face> face, FaceMetric::Status status)
{
NS_LOG_FUNCTION (this << boost::cref(*face) << status);
- NdnFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
+ FaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
NS_ASSERT_MSG (record != m_faces.get<i_face> ().end (),
"Update status can be performed only on existing faces of CcxnFibEntry");
m_faces.modify (record,
- (&ll::_1)->*&NdnFibFaceMetric::m_status = status);
+ (&ll::_1)->*&FaceMetric::m_status = status);
// reordering random access index same way as by metric index
m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
}
void
-NdnFibEntry::AddOrUpdateRoutingMetric (Ptr<NdnFace> face, int32_t metric)
+Entry::AddOrUpdateRoutingMetric (Ptr<Face> face, int32_t metric)
{
NS_LOG_FUNCTION (this);
NS_ASSERT_MSG (face != NULL, "Trying to Add or Update NULL face");
- NdnFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
+ FaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
if (record == m_faces.get<i_face> ().end ())
{
- m_faces.insert (NdnFibFaceMetric (face, metric));
+ m_faces.insert (FaceMetric (face, metric));
}
else
{
// don't update metric to higher value
- if (record->m_routingCost > metric || record->m_status == NdnFibFaceMetric::NDN_FIB_RED)
+ if (record->m_routingCost > metric || record->m_status == FaceMetric::NDN_FIB_RED)
{
m_faces.modify (record,
- (&ll::_1)->*&NdnFibFaceMetric::m_routingCost = metric);
+ (&ll::_1)->*&FaceMetric::m_routingCost = metric);
m_faces.modify (record,
- (&ll::_1)->*&NdnFibFaceMetric::m_status = NdnFibFaceMetric::NDN_FIB_YELLOW);
+ (&ll::_1)->*&FaceMetric::m_status = FaceMetric::NDN_FIB_YELLOW);
}
}
@@ -136,31 +131,31 @@
}
void
-NdnFibEntry::Invalidate ()
+Entry::Invalidate ()
{
- for (NdnFibFaceMetricByFace::type::iterator face = m_faces.begin ();
+ for (FaceMetricByFace::type::iterator face = m_faces.begin ();
face != m_faces.end ();
face++)
{
m_faces.modify (face,
- (&ll::_1)->*&NdnFibFaceMetric::m_routingCost = std::numeric_limits<uint16_t>::max ());
+ (&ll::_1)->*&FaceMetric::m_routingCost = std::numeric_limits<uint16_t>::max ());
m_faces.modify (face,
- (&ll::_1)->*&NdnFibFaceMetric::m_status = NdnFibFaceMetric::NDN_FIB_RED);
+ (&ll::_1)->*&FaceMetric::m_status = FaceMetric::NDN_FIB_RED);
}
}
-const NdnFibFaceMetric &
-NdnFibEntry::FindBestCandidate (uint32_t skip/* = 0*/) const
+const FaceMetric &
+Entry::FindBestCandidate (uint32_t skip/* = 0*/) const
{
- if (m_faces.size () == 0) throw NdnFibEntry::NoFaces ();
+ if (m_faces.size () == 0) throw Entry::NoFaces ();
skip = skip % m_faces.size();
return m_faces.get<i_nth> () [skip];
}
-std::ostream& operator<< (std::ostream& os, const NdnFibEntry &entry)
+std::ostream& operator<< (std::ostream& os, const Entry &entry)
{
- for (NdnFibFaceMetricContainer::type::index<i_nth>::type::iterator metric =
+ for (FaceMetricContainer::type::index<i_nth>::type::iterator metric =
entry.m_faces.get<i_nth> ().begin ();
metric != entry.m_faces.get<i_nth> ().end ();
metric++)
@@ -173,7 +168,7 @@
return os;
}
-std::ostream& operator<< (std::ostream& os, const NdnFibFaceMetric &metric)
+std::ostream& operator<< (std::ostream& os, const FaceMetric &metric)
{
static const std::string statusString[] = {"","g","y","r"};
@@ -181,5 +176,6 @@
return os;
}
-
-} // ns3
+} // namespace fib
+} // namespace ndn
+} // namespace ns3
diff --git a/model/fib/ndn-fib-entry.h b/model/fib/ndn-fib-entry.h
index cf8cbe6..532120f 100644
--- a/model/fib/ndn-fib-entry.h
+++ b/model/fib/ndn-fib-entry.h
@@ -23,8 +23,8 @@
#include "ns3/ptr.h"
#include "ns3/nstime.h"
-#include "ns3/ndn.h"
#include "ns3/ndn-face.h"
+#include "ns3/ndn-name-components.h"
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/tag.hpp>
@@ -35,16 +35,18 @@
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/mem_fun.hpp>
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
-class NdnNameComponents;
+class NameComponents;
+
+namespace fib {
/**
* \ingroup ndn
* \brief Structure holding various parameters associated with a (FibEntry, Face) tuple
*/
-class NdnFibFaceMetric
+class FaceMetric
{
public:
/**
@@ -60,7 +62,7 @@
* \param face Face for which metric
* \param cost Initial value for routing cost
*/
- NdnFibFaceMetric (Ptr<NdnFace> face, int32_t cost)
+ FaceMetric (Ptr<Face> face, int32_t cost)
: m_face (face)
, m_status (NDN_FIB_YELLOW)
, m_routingCost (cost)
@@ -72,18 +74,18 @@
* \brief Comparison operator used by boost::multi_index::identity<>
*/
bool
- operator< (const NdnFibFaceMetric &fm) const { return *m_face < *fm.m_face; } // return identity of the face
+ operator< (const FaceMetric &fm) const { return *m_face < *fm.m_face; } // return identity of the face
/**
- * @brief Comparison between NdnFibFaceMetric and NdnFace
+ * @brief Comparison between FaceMetric and Face
*/
bool
- operator< (const Ptr<NdnFace> &face) const { return *m_face < *face; }
+ operator< (const Ptr<Face> &face) const { return *m_face < *face; }
/**
- * @brief Return NdnFace associated with NdnFibFaceMetric
+ * @brief Return Face associated with FaceMetric
*/
- Ptr<NdnFace>
+ Ptr<Face>
GetFace () const { return m_face; }
/**
@@ -94,9 +96,9 @@
UpdateRtt (const Time &rttSample);
private:
- friend std::ostream& operator<< (std::ostream& os, const NdnFibFaceMetric &metric);
+ friend std::ostream& operator<< (std::ostream& os, const FaceMetric &metric);
public:
- Ptr<NdnFace> m_face; ///< Face
+ Ptr<Face> m_face; ///< Face
Status m_status; ///< \brief Status of the next hop:
///< - NDN_FIB_GREEN
@@ -109,9 +111,16 @@
Time m_rttVar; ///< \brief round-trip time variation
};
+/// @cond include_hidden
+class i_face {};
+class i_metric {};
+class i_nth {};
+/// @endcond
+
+
/**
* \ingroup ndn
- * \brief Typedef for indexed face container of NdnFibEntry
+ * \brief Typedef for indexed face container of Entry
*
* Currently, there are 2 indexes:
* - by face (used to find record and update metric)
@@ -119,31 +128,31 @@
* - random access index (for fast lookup on nth face). Order is
* maintained manually to be equal to the 'by metric' order
*/
-struct NdnFibFaceMetricContainer
+struct FaceMetricContainer
{
/// @cond include_hidden
typedef boost::multi_index::multi_index_container<
- NdnFibFaceMetric,
+ FaceMetric,
boost::multi_index::indexed_by<
- // For fast access to elements using NdnFace
+ // For fast access to elements using Face
boost::multi_index::ordered_unique<
- boost::multi_index::tag<__ndn_private::i_face>,
- boost::multi_index::member<NdnFibFaceMetric,Ptr<NdnFace>,&NdnFibFaceMetric::m_face>
+ boost::multi_index::tag<i_face>,
+ boost::multi_index::member<FaceMetric,Ptr<Face>,&FaceMetric::m_face>
>,
// List of available faces ordered by (status, m_routingCost)
boost::multi_index::ordered_non_unique<
- boost::multi_index::tag<__ndn_private::i_metric>,
+ boost::multi_index::tag<i_metric>,
boost::multi_index::composite_key<
- NdnFibFaceMetric,
- boost::multi_index::member<NdnFibFaceMetric,NdnFibFaceMetric::Status,&NdnFibFaceMetric::m_status>,
- boost::multi_index::member<NdnFibFaceMetric,int32_t,&NdnFibFaceMetric::m_routingCost>
+ FaceMetric,
+ boost::multi_index::member<FaceMetric,FaceMetric::Status,&FaceMetric::m_status>,
+ boost::multi_index::member<FaceMetric,int32_t,&FaceMetric::m_routingCost>
>
>,
// To optimize nth candidate selection (sacrifice a little bit space to gain speed)
boost::multi_index::random_access<
- boost::multi_index::tag<__ndn_private::i_nth>
+ boost::multi_index::tag<i_nth>
>
>
> type;
@@ -155,7 +164,7 @@
* \brief Structure for FIB table entry, holding indexed list of
* available faces and their respective metrics
*/
-class NdnFibEntry : public SimpleRefCount<NdnFibEntry>
+class Entry : public SimpleRefCount<Entry>
{
public:
class NoFaces {}; ///< @brief Exception class for the case when FIB entry is not found
@@ -164,7 +173,7 @@
* \brief Constructor
* \param prefix smart pointer to the prefix for the FIB entry
*/
- NdnFibEntry (const Ptr<const NdnNameComponents> &prefix)
+ Entry (const Ptr<const NameComponents> &prefix)
: m_prefix (prefix)
, m_needsProbing (false)
{ }
@@ -173,14 +182,14 @@
* \brief Update status of FIB next hop
* \param status Status to set on the FIB entry
*/
- void UpdateStatus (Ptr<NdnFace> face, NdnFibFaceMetric::Status status);
+ void UpdateStatus (Ptr<Face> face, FaceMetric::Status status);
/**
* \brief Add or update routing metric of FIB next hop
*
* Initial status of the next hop is set to YELLOW
*/
- void AddOrUpdateRoutingMetric (Ptr<NdnFace> face, int32_t metric);
+ void AddOrUpdateRoutingMetric (Ptr<Face> face, int32_t metric);
/**
* @brief Invalidate face
@@ -194,44 +203,46 @@
* @brief Update RTT averages for the face
*/
void
- UpdateFaceRtt (Ptr<NdnFace> face, const Time &sample);
+ UpdateFaceRtt (Ptr<Face> face, const Time &sample);
/**
* \brief Get prefix for the FIB entry
*/
- const NdnNameComponents&
+ const NameComponents&
GetPrefix () const { return *m_prefix; }
/**
* \brief Find "best route" candidate, skipping `skip' first candidates (modulo # of faces)
*
- * throws NdnFibEntry::NoFaces if m_faces.size()==0
+ * throws Entry::NoFaces if m_faces.size()==0
*/
- const NdnFibFaceMetric &
+ const FaceMetric &
FindBestCandidate (uint32_t skip = 0) const;
/**
* @brief Remove record associated with `face`
*/
void
- RemoveFace (const Ptr<NdnFace> &face)
+ RemoveFace (const Ptr<Face> &face)
{
m_faces.erase (face);
}
private:
- friend std::ostream& operator<< (std::ostream& os, const NdnFibEntry &entry);
+ friend std::ostream& operator<< (std::ostream& os, const Entry &entry);
public:
- Ptr<const NdnNameComponents> m_prefix; ///< \brief Prefix of the FIB entry
- NdnFibFaceMetricContainer::type m_faces; ///< \brief Indexed list of faces
+ Ptr<const NameComponents> m_prefix; ///< \brief Prefix of the FIB entry
+ FaceMetricContainer::type m_faces; ///< \brief Indexed list of faces
bool m_needsProbing; ///< \brief flag indicating that probing should be performed
};
-std::ostream& operator<< (std::ostream& os, const NdnFibEntry &entry);
-std::ostream& operator<< (std::ostream& os, const NdnFibFaceMetric &metric);
+std::ostream& operator<< (std::ostream& os, const Entry &entry);
+std::ostream& operator<< (std::ostream& os, const FaceMetric &metric);
-} // ns3
+} // namespace fib
+} // namespace ndn
+} // namespace ns3
#endif // _NDN_FIB_ENTRY_H_
diff --git a/model/fib/ndn-fib-impl.cc b/model/fib/ndn-fib-impl.cc
index 747c689..a55e9fd 100644
--- a/model/fib/ndn-fib-impl.cc
+++ b/model/fib/ndn-fib-impl.cc
@@ -34,43 +34,45 @@
#include <boost/lambda/bind.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("NdnFibImpl");
+NS_LOG_COMPONENT_DEFINE ("ndn.fib.FibImpl");
namespace ns3 {
+namespace ndn {
+namespace fib {
-NS_OBJECT_ENSURE_REGISTERED (NdnFibImpl);
+NS_OBJECT_ENSURE_REGISTERED (FibImpl);
TypeId
-NdnFibImpl::GetTypeId (void)
+FibImpl::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::NdnFib") // cheating ns3 object system
- .SetParent<NdnFib> ()
+ static TypeId tid = TypeId ("ns3::ndn::fib::Default") // cheating ns3 object system
+ .SetParent<Fib> ()
.SetGroupName ("Ndn")
- .AddConstructor<NdnFibImpl> ()
+ .AddConstructor<FibImpl> ()
;
return tid;
}
-NdnFibImpl::NdnFibImpl ()
+FibImpl::FibImpl ()
{
}
void
-NdnFibImpl::NotifyNewAggregate ()
+FibImpl::NotifyNewAggregate ()
{
Object::NotifyNewAggregate ();
}
void
-NdnFibImpl::DoDispose (void)
+FibImpl::DoDispose (void)
{
clear ();
Object::DoDispose ();
}
-Ptr<NdnFibEntry>
-NdnFibImpl::LongestPrefixMatch (const NdnInterestHeader &interest)
+Ptr<Entry>
+FibImpl::LongestPrefixMatch (const InterestHeader &interest)
{
super::iterator item = super::longest_prefix_match (interest.GetName ());
// @todo use predicate to search with exclude filters
@@ -82,14 +84,14 @@
}
-Ptr<NdnFibEntry>
-NdnFibImpl::Add (const NdnNameComponents &prefix, Ptr<NdnFace> face, int32_t metric)
+Ptr<Entry>
+FibImpl::Add (const NameComponents &prefix, Ptr<Face> face, int32_t metric)
{
- return Add (Create<NdnNameComponents> (prefix), face, metric);
+ return Add (Create<NameComponents> (prefix), face, metric);
}
-Ptr<NdnFibEntry>
-NdnFibImpl::Add (const Ptr<const NdnNameComponents> &prefix, Ptr<NdnFace> face, int32_t metric)
+Ptr<Entry>
+FibImpl::Add (const Ptr<const NameComponents> &prefix, Ptr<Face> face, int32_t metric)
{
NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix) << boost::cref(*face) << metric);
@@ -99,13 +101,13 @@
{
if (result.second)
{
- Ptr<NdnFibEntryImpl> newEntry = Create<NdnFibEntryImpl> (prefix);
+ Ptr<EntryImpl> newEntry = Create<EntryImpl> (prefix);
newEntry->SetTrie (result.first);
result.first->set_payload (newEntry);
}
super::modify (result.first,
- ll::bind (&NdnFibEntry::AddOrUpdateRoutingMetric, ll::_1, face, metric));
+ ll::bind (&Entry::AddOrUpdateRoutingMetric, ll::_1, face, metric));
return result.first->payload ();
}
@@ -114,7 +116,7 @@
}
void
-NdnFibImpl::Remove (const Ptr<const NdnNameComponents> &prefix)
+FibImpl::Remove (const Ptr<const NameComponents> &prefix)
{
NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix));
@@ -122,7 +124,7 @@
}
// void
-// NdnFibImpl::Invalidate (const Ptr<const NdnNameComponents> &prefix)
+// FibImpl::Invalidate (const Ptr<const NameComponents> &prefix)
// {
// NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix));
@@ -134,11 +136,11 @@
// return; // nothing to invalidate
// super::modify (lastItem,
-// ll::bind (&NdnFibEntry::Invalidate, ll::_1));
+// ll::bind (&Entry::Invalidate, ll::_1));
// }
void
-NdnFibImpl::InvalidateAll ()
+FibImpl::InvalidateAll ()
{
NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId ());
@@ -149,28 +151,28 @@
if (item->payload () == 0) continue;
super::modify (&(*item),
- ll::bind (&NdnFibEntry::Invalidate, ll::_1));
+ ll::bind (&Entry::Invalidate, ll::_1));
}
}
void
-NdnFibImpl::RemoveFace (super::parent_trie &item, Ptr<NdnFace> face)
+FibImpl::RemoveFace (super::parent_trie &item, Ptr<Face> face)
{
if (item.payload () == 0) return;
NS_LOG_FUNCTION (this);
super::modify (&item,
- ll::bind (&NdnFibEntry::RemoveFace, ll::_1, face));
+ ll::bind (&Entry::RemoveFace, ll::_1, face));
}
void
-NdnFibImpl::RemoveFromAll (Ptr<NdnFace> face)
+FibImpl::RemoveFromAll (Ptr<Face> face)
{
NS_LOG_FUNCTION (this);
std::for_each (super::parent_trie::recursive_iterator (super::getTrie ()),
super::parent_trie::recursive_iterator (0),
- ll::bind (&NdnFibImpl::RemoveFace,
+ ll::bind (&FibImpl::RemoveFace,
this, ll::_1, face));
super::parent_trie::recursive_iterator trieNode (super::getTrie ());
@@ -187,7 +189,7 @@
}
void
-NdnFibImpl::Print (std::ostream &os) const
+FibImpl::Print (std::ostream &os) const
{
// !!! unordered_set imposes "random" order of item in the same level !!!
super::parent_trie::const_recursive_iterator item (super::getTrie ());
@@ -201,13 +203,13 @@
}
uint32_t
-NdnFibImpl::GetSize () const
+FibImpl::GetSize () const
{
return super::getPolicy ().size ();
}
-Ptr<const NdnFibEntry>
-NdnFibImpl::Begin ()
+Ptr<const Entry>
+FibImpl::Begin ()
{
super::parent_trie::const_recursive_iterator item (super::getTrie ());
super::parent_trie::const_recursive_iterator end (0);
@@ -223,18 +225,18 @@
return item->payload ();
}
-Ptr<const NdnFibEntry>
-NdnFibImpl::End ()
+Ptr<const Entry>
+FibImpl::End ()
{
return 0;
}
-Ptr<const NdnFibEntry>
-NdnFibImpl::Next (Ptr<const NdnFibEntry> from)
+Ptr<const Entry>
+FibImpl::Next (Ptr<const Entry> from)
{
if (from == 0) return 0;
- super::parent_trie::const_recursive_iterator item (*StaticCast<const NdnFibEntryImpl> (from)->to_iterator ());
+ super::parent_trie::const_recursive_iterator item (*StaticCast<const EntryImpl> (from)->to_iterator ());
super::parent_trie::const_recursive_iterator end (0);
for (item++; item != end; item++)
{
@@ -248,5 +250,6 @@
return item->payload ();
}
-
+} // namespace fib
+} // namespace ndn
} // namespace ns3
diff --git a/model/fib/ndn-fib-impl.h b/model/fib/ndn-fib-impl.h
index 562f06e..4c78997 100644
--- a/model/fib/ndn-fib-impl.h
+++ b/model/fib/ndn-fib-impl.h
@@ -28,18 +28,20 @@
#include "../../utils/counting-policy.h"
namespace ns3 {
+namespace ndn {
+namespace fib {
-class NdnFibEntryImpl : public NdnFibEntry
+class EntryImpl : public Entry
{
public:
typedef ndnSIM::trie_with_policy<
- NdnNameComponents,
- ndnSIM::smart_pointer_payload_traits<NdnFibEntryImpl>,
+ NameComponents,
+ ndnSIM::smart_pointer_payload_traits<EntryImpl>,
ndnSIM::counting_policy_traits
> trie;
- NdnFibEntryImpl (const Ptr<const NdnNameComponents> &prefix)
- : NdnFibEntry (prefix)
+ EntryImpl (const Ptr<const NameComponents> &prefix)
+ : Entry (prefix)
, item_ (0)
{
}
@@ -57,24 +59,19 @@
trie::iterator item_;
};
-struct NdnFibEntryContainer
-{
- typedef ndnSIM::trie_with_policy<
- NdnNameComponents,
- ndnSIM::smart_pointer_payload_traits<NdnFibEntryImpl>,
- ndnSIM::counting_policy_traits
- > type;
-};
-
/**
* \ingroup ndn
* \brief Class implementing FIB functionality
*/
-class NdnFibImpl : public NdnFib,
- private NdnFibEntryContainer::type
+class FibImpl : public Fib,
+ protected ndnSIM::trie_with_policy< NameComponents,
+ ndnSIM::smart_pointer_payload_traits< EntryImpl >,
+ ndnSIM::counting_policy_traits >
{
public:
- typedef NdnFibEntryContainer::type super;
+ typedef ndnSIM::trie_with_policy< NameComponents,
+ ndnSIM::smart_pointer_payload_traits<EntryImpl>,
+ ndnSIM::counting_policy_traits > super;
/**
* \brief Interface ID
@@ -86,25 +83,25 @@
/**
* \brief Constructor
*/
- NdnFibImpl ();
+ FibImpl ();
- virtual Ptr<NdnFibEntry>
- LongestPrefixMatch (const NdnInterestHeader &interest);
+ virtual Ptr<Entry>
+ LongestPrefixMatch (const InterestHeader &interest);
- virtual Ptr<NdnFibEntry>
- Add (const NdnNameComponents &prefix, Ptr<NdnFace> face, int32_t metric);
+ virtual Ptr<Entry>
+ Add (const NameComponents &prefix, Ptr<Face> face, int32_t metric);
- virtual Ptr<NdnFibEntry>
- Add (const Ptr<const NdnNameComponents> &prefix, Ptr<NdnFace> face, int32_t metric);
+ virtual Ptr<Entry>
+ Add (const Ptr<const NameComponents> &prefix, Ptr<Face> face, int32_t metric);
virtual void
- Remove (const Ptr<const NdnNameComponents> &prefix);
+ Remove (const Ptr<const NameComponents> &prefix);
virtual void
InvalidateAll ();
virtual void
- RemoveFromAll (Ptr<NdnFace> face);
+ RemoveFromAll (Ptr<Face> face);
virtual void
Print (std::ostream &os) const;
@@ -112,24 +109,14 @@
virtual uint32_t
GetSize () const;
- virtual Ptr<const NdnFibEntry>
+ virtual Ptr<const Entry>
Begin ();
- virtual Ptr<const NdnFibEntry>
+ virtual Ptr<const Entry>
End ();
- virtual Ptr<const NdnFibEntry>
- Next (Ptr<const NdnFibEntry> item);
-
- // /**
- // * @brief Modify element in container
- // */
- // template<typename Modifier>
- // bool
- // modify (Ptr<NdnFibEntry> item, Modifier mod)
- // {
- // return super::modify (StaticCast<NdnFibEntryImpl> (item)->to_iterator (), mod);
- // }
+ virtual Ptr<const Entry>
+ Next (Ptr<const Entry> item);
protected:
// inherited from Object class
@@ -142,12 +129,14 @@
* entry will be removed
*/
void
- RemoveFace (super::parent_trie &item, Ptr<NdnFace> face);
+ RemoveFace (super::parent_trie &item, Ptr<Face> face);
private:
Ptr<Node> m_node;
};
-
+
+} // namespace fib
+} // namespace ndn
} // namespace ns3
#endif /* _NDN_FIB_IMPL_H_ */
diff --git a/model/fib/ndn-fib.cc b/model/fib/ndn-fib.cc
index 7046634..f63dadf 100644
--- a/model/fib/ndn-fib.cc
+++ b/model/fib/ndn-fib.cc
@@ -20,36 +20,24 @@
#include "ndn-fib.h"
-#include "ndn-fib-impl.h"
-
-#include "ns3/ndn.h"
-#include "ns3/ndn-face.h"
-#include "ns3/ndn-interest-header.h"
-#include "ns3/ndn-name-components.h"
-
#include "ns3/node.h"
#include "ns3/names.h"
-#include <boost/ref.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-namespace ll = boost::lambda;
-
namespace ns3 {
-
-using namespace __ndn_private;
+namespace ndn {
TypeId
-NdnFib::GetTypeId (void)
+Fib::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::private::NdnFib") // cheating ns3 object system
+ static TypeId tid = TypeId ("ns3::ndn::Fib") // cheating ns3 object system
.SetParent<Object> ()
.SetGroupName ("Ndn")
;
return tid;
}
-std::ostream& operator<< (std::ostream& os, const NdnFib &fib)
+std::ostream&
+operator<< (std::ostream& os, const Fib &fib)
{
os << "Node " << Names::FindName (fib.GetObject<Node>()) << "\n";
os << " Dest prefix Interfaces(Costs) \n";
@@ -59,4 +47,5 @@
return os;
}
+} // namespace ndn
} // namespace ns3
diff --git a/model/fib/ndn-fib.h b/model/fib/ndn-fib.h
index 12a6148..b1b4be7 100644
--- a/model/fib/ndn-fib.h
+++ b/model/fib/ndn-fib.h
@@ -27,14 +27,15 @@
#include "ns3/ndn-fib-entry.h"
namespace ns3 {
+namespace ndn {
-class NdnInterestHeader;
+class InterestHeader;
/**
* \ingroup ndn
* \brief Class implementing FIB functionality
*/
-class NdnFib : public Object
+class Fib : public Object
{
public:
/**
@@ -46,12 +47,12 @@
/**
* @brief Default constructor
*/
- NdnFib () {}
+ Fib () {}
/**
* @brief Virtual destructor
*/
- virtual ~NdnFib () { };
+ virtual ~Fib () { };
/**
* \brief Perform longest prefix match
@@ -61,8 +62,8 @@
* \param interest Interest packet header
* \returns If entry found a valid iterator will be returned, otherwise end ()
*/
- virtual Ptr<NdnFibEntry>
- LongestPrefixMatch (const NdnInterestHeader &interest) = 0;
+ virtual Ptr<fib::Entry>
+ LongestPrefixMatch (const InterestHeader &interest) = 0;
/**
* \brief Add or update FIB entry
@@ -75,8 +76,8 @@
* @param face Forwarding face
* @param metric Routing metric
*/
- virtual Ptr<NdnFibEntry>
- Add (const NdnNameComponents &prefix, Ptr<NdnFace> face, int32_t metric) = 0;
+ virtual Ptr<fib::Entry>
+ Add (const NameComponents &prefix, Ptr<Face> face, int32_t metric) = 0;
/**
* \brief Add or update FIB entry using smart pointer to prefix
@@ -89,8 +90,8 @@
* @param face Forwarding face
* @param metric Routing metric
*/
- virtual Ptr<NdnFibEntry>
- Add (const Ptr<const NdnNameComponents> &prefix, Ptr<NdnFace> face, int32_t metric) = 0;
+ virtual Ptr<fib::Entry>
+ Add (const Ptr<const NameComponents> &prefix, Ptr<Face> face, int32_t metric) = 0;
/**
* @brief Remove FIB entry
@@ -101,7 +102,7 @@
* @param name Smart pointer to prefix
*/
virtual void
- Remove (const Ptr<const NdnNameComponents> &prefix) = 0;
+ Remove (const Ptr<const NameComponents> &prefix) = 0;
// /**
// * @brief Invalidate FIB entry ("Safe" version of Remove)
@@ -110,7 +111,7 @@
// * @param name Smart pointer to prefix
// */
// virtual void
- // Invalidate (const Ptr<const NdnNameComponents> &prefix) = 0;
+ // Invalidate (const Ptr<const NameComponents> &prefix) = 0;
/**
* @brief Invalidate all FIB entries
@@ -123,7 +124,7 @@
* this FIB entry will be removed.
*/
virtual void
- RemoveFromAll (Ptr<NdnFace> face) = 0;
+ RemoveFromAll (Ptr<Face> face) = 0;
/**
* @brief Print out entries in FIB
@@ -140,20 +141,20 @@
/**
* @brief Return first element of FIB (no order guaranteed)
*/
- virtual Ptr<const NdnFibEntry>
+ virtual Ptr<const fib::Entry>
Begin () = 0;
/**
* @brief Return item next after last (no order guaranteed)
*/
- virtual Ptr<const NdnFibEntry>
+ virtual Ptr<const fib::Entry>
End () = 0;
/**
* @brief Advance the iterator
*/
- virtual Ptr<const NdnFibEntry>
- Next (Ptr<const NdnFibEntry>) = 0;
+ virtual Ptr<const fib::Entry>
+ Next (Ptr<const fib::Entry>) = 0;
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
@@ -162,28 +163,29 @@
/**
* @brief Static call to cheat python bindings
*/
- static inline Ptr<NdnFib>
- GetNdnFib (Ptr<Object> node);
+ static inline Ptr<Fib>
+ GetFib (Ptr<Object> node);
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
private:
- NdnFib(const NdnFib&) {} ; ///< \brief copy constructor is disabled
+ Fib (const Fib&) {} ; ///< \brief copy constructor is disabled
};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-std::ostream& operator<< (std::ostream& os, const NdnFib &fib);
+std::ostream& operator<< (std::ostream& os, const Fib &fib);
-Ptr<NdnFib>
-NdnFib::GetNdnFib (Ptr<Object> node)
+Ptr<Fib>
+Fib::GetFib (Ptr<Object> node)
{
- return node->GetObject<NdnFib> ();
+ return node->GetObject<Fib> ();
}
+} // namespace ndn
} // namespace ns3
#endif // _NDN_FIB_H_
diff --git a/model/forwarding-strategy/ndn-forwarding-strategy.h b/model/forwarding-strategy/ndn-forwarding-strategy.h
deleted file mode 100644
index c2fa296..0000000
--- a/model/forwarding-strategy/ndn-forwarding-strategy.h
+++ /dev/null
@@ -1,235 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-#ifndef NDN_FORWARDING_STRATEGY_H
-#define NDN_FORWARDING_STRATEGY_H
-
-#include "ns3/packet.h"
-#include "ns3/callback.h"
-#include "ns3/object.h"
-#include "ns3/traced-callback.h"
-
-namespace ns3 {
-
-class NdnFace;
-class NdnInterestHeader;
-class NdnContentObjectHeader;
-class NdnPit;
-class NdnPitEntry;
-class NdnFibFaceMetric;
-class NdnFib;
-class NdnContentStore;
-
-/**
- * \ingroup ndn
- * \brief Abstract base class for Ndn forwarding strategies
- */
-class NdnForwardingStrategy :
- public Object
-{
-public:
- static TypeId GetTypeId (void);
-
- /**
- * @brief Default constructor
- */
- NdnForwardingStrategy ();
- virtual ~NdnForwardingStrategy ();
-
- /**
- * \brief Actual processing of incoming Ndn interests. Note, interests do not have payload
- *
- * Processing Interest packets
- * @param face incoming face
- * @param header deserialized Interest header
- * @param packet original packet
- */
- virtual void
- OnInterest (const Ptr<NdnFace> &face,
- Ptr<NdnInterestHeader> &header,
- const Ptr<const Packet> &p);
-
- /**
- * \brief Actual processing of incoming Ndn content objects
- *
- * Processing ContentObject packets
- * @param face incoming face
- * @param header deserialized ContentObject header
- * @param payload data packet payload
- * @param packet original packet
- */
- virtual void
- OnData (const Ptr<NdnFace> &face,
- Ptr<NdnContentObjectHeader> &header,
- Ptr<Packet> &payload,
- const Ptr<const Packet> &packet);
-
- virtual void
- WillErasePendingInterest (Ptr<NdnPitEntry> pitEntry);
-
- virtual void
- RemoveFace (Ptr<NdnFace> face);
-
-protected:
- // events
- virtual void
- DidReceiveDuplicateInterest (const Ptr<NdnFace> &face,
- Ptr<NdnInterestHeader> &header,
- const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry);
-
- virtual void
- DidExhaustForwardingOptions (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
- const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry);
-
- virtual void
- FailedToCreatePitEntry (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
- const Ptr<const Packet> &packet);
-
- virtual void
- DidCreatePitEntry (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
- const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry);
-
- virtual bool
- DetectRetransmittedInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnPitEntry> pitEntry);
-
- // makes sense only for data received from network
- // When Interest is satisfied from the cache, incoming face is 0
- virtual void
- WillSatisfyPendingInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnPitEntry> pitEntry);
-
- // for data received both from network and cache
- virtual void
- SatisfyPendingInterest (const Ptr<NdnFace> &incomingFace, // 0 allowed (from cache)
- Ptr<const NdnContentObjectHeader> header,
- Ptr<const Packet> payload,
- const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry);
-
- virtual void
- DidSendOutData (const Ptr<NdnFace> &face,
- Ptr<const NdnContentObjectHeader> header,
- Ptr<const Packet> payload,
- const Ptr<const Packet> &packet);
-
- virtual void
- DidReceiveUnsolicitedData (const Ptr<NdnFace> &incomingFace,
- Ptr<const NdnContentObjectHeader> header,
- Ptr<const Packet> payload);
-
- virtual bool
- ShouldSuppressIncomingInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnPitEntry> pitEntry);
-
- /**
- * @brief Event fired before actually sending out an interest
- *
- * If event returns false, then there is some kind of a problem (e.g., per-face limit reached)
- */
- virtual bool
- WillSendOutInterest (const Ptr<NdnFace> &outgoingFace,
- Ptr<NdnInterestHeader> header,
- Ptr<NdnPitEntry> pitEntry);
-
- /**
- * @brief Event fired just after sending out an interest
- */
- virtual void
- DidSendOutInterest (const Ptr<NdnFace> &outgoingFace,
- Ptr<NdnInterestHeader> header,
- const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry);
-
- virtual void
- PropagateInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
- const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry);
-
- /**
- * @brief Base method to propagate the interest according to the forwarding strategy
- *
- * @param pitEntry Reference to PIT entry (reference to corresponding FIB entry inside)
- * @param incomingFace Incoming face
- * @param header NdnInterestHeader
- * @param packet Original Interest packet
- * @param sendCallback Send callback
- *
- * @return true if interest was successfully propagated, false if all options have failed
- */
- virtual bool
- DoPropagateInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
- const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry) = 0;
-
-
- // virtual void
- // OnDataDelayed (Ptr<const NdnContentObjectHeader> header,
- // Ptr<const Packet> payload,
- // const Ptr<const Packet> &packet);
-
-protected:
- // inherited from Object class
- virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object
- virtual void DoDispose (); ///< @brief Do cleanup
-
-protected:
- Ptr<NdnPit> m_pit; ///< \brief Reference to PIT to which this forwarding strategy is associated
- Ptr<NdnFib> m_fib; ///< \brief FIB
- Ptr<NdnContentStore> m_contentStore; ///< \brief Content store (for caching purposes only)
-
- bool m_cacheUnsolicitedData;
- bool m_detectRetransmissions;
-
- TracedCallback<Ptr<const NdnInterestHeader>,
- Ptr<const NdnFace> > m_outInterests; ///< @brief Transmitted interests trace
-
- TracedCallback<Ptr<const NdnInterestHeader>,
- Ptr<const NdnFace> > m_inInterests; ///< @brief trace of incoming Interests
-
- TracedCallback<Ptr<const NdnInterestHeader>,
- Ptr<const NdnFace> > m_dropInterests; ///< @brief trace of dropped Interests
-
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
-
- TracedCallback<Ptr<const NdnContentObjectHeader>, Ptr<const Packet>,
- bool /*from cache*/,
- Ptr<const NdnFace> > m_outData; ///< @brief trace of outgoing Data
-
- TracedCallback<Ptr<const NdnContentObjectHeader>, Ptr<const Packet>,
- Ptr<const NdnFace> > m_inData; ///< @brief trace of incoming Data
-
- TracedCallback<Ptr<const NdnContentObjectHeader>, Ptr<const Packet>,
- Ptr<const NdnFace> > m_dropData; ///< @brief trace of dropped Data
-};
-
-} //namespace ns3
-
-#endif /* NDN_FORWARDING_STRATEGY_H */
diff --git a/model/forwarding-strategy/best-route.cc b/model/fw/best-route.cc
similarity index 81%
rename from model/forwarding-strategy/best-route.cc
rename to model/fw/best-route.cc
index ba56979..84e74fe 100644
--- a/model/forwarding-strategy/best-route.cc
+++ b/model/fw/best-route.cc
@@ -33,19 +33,18 @@
#include <boost/lambda/bind.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("NdnSimBestRoute");
+NS_LOG_COMPONENT_DEFINE ("ndn.fw.BestRoute");
namespace ns3 {
-namespace ndnSIM {
-
-using namespace __ndn_private;
+namespace ndn {
+namespace fw {
NS_OBJECT_ENSURE_REGISTERED (BestRoute);
TypeId
BestRoute::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::ndnSIM::BestRoute")
+ static TypeId tid = TypeId ("ns3::ndn::fw::BestRoute")
.SetGroupName ("Ndn")
.SetParent <GreenYellowRed> ()
.AddConstructor <BestRoute> ()
@@ -58,10 +57,10 @@
}
bool
-BestRoute::DoPropagateInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+BestRoute::DoPropagateInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
NS_LOG_FUNCTION (this);
@@ -72,10 +71,9 @@
return true;
int propagatedCount = 0;
-
- BOOST_FOREACH (const NdnFibFaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<i_metric> ())
+ BOOST_FOREACH (const fib::FaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<fib::i_metric> ())
{
- if (metricFace.m_status == NdnFibFaceMetric::NDN_FIB_RED) // all non-read faces are in front
+ if (metricFace.m_status == fib::FaceMetric::NDN_FIB_RED) // all non-read faces are in front
break;
if (metricFace.m_face == incomingFace)
@@ -103,5 +101,6 @@
return propagatedCount > 0;
}
-} // namespace ndnSIM
+} // namespace fw
+} // namespace ndn
} // namespace ns3
diff --git a/model/forwarding-strategy/best-route.h b/model/fw/best-route.h
similarity index 85%
rename from model/forwarding-strategy/best-route.h
rename to model/fw/best-route.h
index ec86914..7326b5b 100644
--- a/model/forwarding-strategy/best-route.h
+++ b/model/fw/best-route.h
@@ -26,7 +26,8 @@
#include "green-yellow-red.h"
namespace ns3 {
-namespace ndnSIM {
+namespace ndn {
+namespace fw {
/**
* \ingroup ndn
@@ -37,7 +38,7 @@
{
public:
static TypeId
- GetTypeId (void);
+ GetTypeId ();
/**
* @brief Default constructor
@@ -46,16 +47,17 @@
// inherited from NdnForwardingStrategy
virtual bool
- DoPropagateInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+ DoPropagateInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry);
+ Ptr<pit::Entry> pitEntry);
private:
typedef GreenYellowRed super;
};
-} // namespace ndnSIM
+} // namespace fw
+} // namespace ndn
} // namespace ns3
#endif // NDNSIM_BEST_ROUTE_H
diff --git a/model/forwarding-strategy/flooding.cc b/model/fw/flooding.cc
similarity index 78%
rename from model/forwarding-strategy/flooding.cc
rename to model/fw/flooding.cc
index b20854f..be969be 100644
--- a/model/forwarding-strategy/flooding.cc
+++ b/model/fw/flooding.cc
@@ -36,18 +36,17 @@
#include <boost/lambda/bind.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("NdnSimFlooding");
+NS_LOG_COMPONENT_DEFINE ("ndn.fw.Flooding");
namespace ns3 {
-namespace ndnSIM {
-
-using namespace __ndn_private;
+namespace ndn {
+namespace fw {
NS_OBJECT_ENSURE_REGISTERED (Flooding);
-TypeId Flooding::GetTypeId (void)
+TypeId Flooding::GetTypeId ()
{
- static TypeId tid = TypeId ("ns3::ndnSIM::Flooding")
+ static TypeId tid = TypeId ("ns3::ndn::fw::Flooding")
.SetGroupName ("Ndn")
.SetParent <Nacks> ()
.AddConstructor <Flooding> ()
@@ -60,19 +59,19 @@
}
bool
-Flooding::DoPropagateInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+Flooding::DoPropagateInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
NS_LOG_FUNCTION (this);
int propagatedCount = 0;
- BOOST_FOREACH (const NdnFibFaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<i_metric> ())
+ BOOST_FOREACH (const fib::FaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<fib::i_metric> ())
{
NS_LOG_DEBUG ("Trying " << boost::cref(metricFace));
- if (metricFace.m_status == NdnFibFaceMetric::NDN_FIB_RED) // all non-read faces are in the front of the list
+ if (metricFace.m_status == fib::FaceMetric::NDN_FIB_RED) // all non-read faces are in the front of the list
break;
if (metricFace.m_face == incomingFace)
@@ -99,5 +98,6 @@
return propagatedCount > 0;
}
-} // namespace ndnSIM
+} // namespace fw
+} // namespace ndn
} // namespace ns3
diff --git a/model/forwarding-strategy/flooding.h b/model/fw/flooding.h
similarity index 81%
rename from model/forwarding-strategy/flooding.h
rename to model/fw/flooding.h
index 32fa7ae..d6a83e0 100644
--- a/model/forwarding-strategy/flooding.h
+++ b/model/fw/flooding.h
@@ -25,7 +25,8 @@
#include "nacks.h"
namespace ns3 {
-namespace ndnSIM {
+namespace ndn {
+namespace fw {
/**
* \ingroup ndn
@@ -37,7 +38,7 @@
public Nacks
{
public:
- static TypeId GetTypeId (void);
+ static TypeId GetTypeId ();
/**
* @brief Default constructor
@@ -45,18 +46,19 @@
Flooding ();
protected:
- // inherited from Nacks/NdnForwardingStrategy
+ // inherited from Nacks/ForwardingStrategy
virtual bool
- DoPropagateInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+ DoPropagateInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry);
+ Ptr<pit::Entry> pitEntry);
private:
typedef Nacks super;
};
-} // namespace ndnSIM
+} // namespace fw
+} // namespace ndn
} // namespace ns3
#endif // NDNSIM_FLOODING
diff --git a/model/forwarding-strategy/fw-stats.cc b/model/fw/fw-stats.cc
similarity index 78%
rename from model/forwarding-strategy/fw-stats.cc
rename to model/fw/fw-stats.cc
index af344e4..de30473 100644
--- a/model/forwarding-strategy/fw-stats.cc
+++ b/model/fw/fw-stats.cc
@@ -36,17 +36,21 @@
#include <boost/lambda/bind.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("NdnSimFwStats");
+NS_LOG_COMPONENT_DEFINE ("ndn.fw.Stats");
namespace ns3 {
-namespace ndnSIM {
+namespace ndn {
+
+using namespace ndnSIM;
+
+namespace fw {
NS_OBJECT_ENSURE_REGISTERED (FwStats);
TypeId
FwStats::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::ndnSIM::FwStats")
+ static TypeId tid = TypeId ("ns3::ndn::fw::Stats")
.SetGroupName ("Ndn")
.SetParent <BestRoute> ()
.AddConstructor <FwStats> ()
@@ -69,8 +73,8 @@
}
void
-FwStats::OnInterest (const Ptr<NdnFace> &face,
- Ptr<NdnInterestHeader> &header,
+FwStats::OnInterest (const Ptr<Face> &face,
+ Ptr<InterestHeader> &header,
const Ptr<const Packet> &packet)
{
super::OnInterest (face, header, packet);
@@ -81,8 +85,8 @@
}
void
-FwStats::OnData (const Ptr<NdnFace> &face,
- Ptr<NdnContentObjectHeader> &header,
+FwStats::OnData (const Ptr<Face> &face,
+ Ptr<ContentObjectHeader> &header,
Ptr<Packet> &payload,
const Ptr<const Packet> &packet)
{
@@ -95,8 +99,8 @@
void
-FwStats::FailedToCreatePitEntry (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+FwStats::FailedToCreatePitEntry (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet)
{
super::FailedToCreatePitEntry (incomingFace, header, packet);
@@ -110,10 +114,10 @@
}
void
-FwStats::DidCreatePitEntry (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+FwStats::DidCreatePitEntry (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
super::DidCreatePitEntry (incomingFace, header, packet, pitEntry);
@@ -124,8 +128,8 @@
}
void
-FwStats::WillSatisfyPendingInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnPitEntry> pitEntry)
+FwStats::WillSatisfyPendingInterest (const Ptr<Face> &incomingFace,
+ Ptr<pit::Entry> pitEntry)
{
super::WillSatisfyPendingInterest (incomingFace, pitEntry);
@@ -135,10 +139,10 @@
}
void
-FwStats::DidSendOutInterest (const Ptr<NdnFace> &outgoingFace,
- Ptr<NdnInterestHeader> header,
+FwStats::DidSendOutInterest (const Ptr<Face> &outgoingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
super::DidSendOutInterest (outgoingFace, header, packet, pitEntry);
@@ -149,8 +153,8 @@
}
void
-FwStats::DidSendOutData (const Ptr<NdnFace> &face,
- Ptr<const NdnContentObjectHeader> header,
+FwStats::DidSendOutData (const Ptr<Face> &face,
+ Ptr<const ContentObjectHeader> header,
Ptr<const Packet> payload,
const Ptr<const Packet> &packet)
{
@@ -163,7 +167,7 @@
void
-FwStats::WillErasePendingInterest (Ptr<NdnPitEntry> pitEntry)
+FwStats::WillErasePendingInterest (Ptr<pit::Entry> pitEntry)
{
super::WillErasePendingInterest (pitEntry);
@@ -194,7 +198,7 @@
}
void
-FwStats::RemoveFace (Ptr<NdnFace> face)
+FwStats::RemoveFace (Ptr<Face> face)
{
m_stats.RemoveFace (face);
@@ -202,5 +206,6 @@
}
-} // namespace ndnSIM
+} // namespace fw
+} // namespace ndn
} // namespace ns3
diff --git a/model/forwarding-strategy/fw-stats.h b/model/fw/fw-stats.h
similarity index 64%
rename from model/forwarding-strategy/fw-stats.h
rename to model/fw/fw-stats.h
index 2b1d337..2b8cae9 100644
--- a/model/forwarding-strategy/fw-stats.h
+++ b/model/fw/fw-stats.h
@@ -28,7 +28,8 @@
#include "../../utils/stats-tree.h"
namespace ns3 {
-namespace ndnSIM {
+namespace ndn {
+namespace fw {
/**
* \ingroup ndn
@@ -39,7 +40,7 @@
{
public:
static TypeId
- GetTypeId (void);
+ GetTypeId ();
/**
* @brief Default constructor
@@ -47,53 +48,53 @@
FwStats ();
inline
- const StatsTree &
+ const ndnSIM::StatsTree &
GetStatsTree () const;
virtual void
- OnInterest (const Ptr<NdnFace> &face,
- Ptr<NdnInterestHeader> &header,
+ OnInterest (const Ptr<Face> &face,
+ Ptr<InterestHeader> &header,
const Ptr<const Packet> &p);
virtual void
- OnData (const Ptr<NdnFace> &face,
- Ptr<NdnContentObjectHeader> &header,
+ OnData (const Ptr<Face> &face,
+ Ptr<ContentObjectHeader> &header,
Ptr<Packet> &payload,
const Ptr<const Packet> &packet);
virtual void
- RemoveFace (Ptr<NdnFace> face);
+ RemoveFace (Ptr<Face> face);
protected:
virtual void
- DidCreatePitEntry (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+ DidCreatePitEntry (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry);
+ Ptr<pit::Entry> pitEntry);
virtual void
- FailedToCreatePitEntry (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+ FailedToCreatePitEntry (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet);
virtual void
- WillSatisfyPendingInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnPitEntry> pitEntry);
+ WillSatisfyPendingInterest (const Ptr<Face> &incomingFace,
+ Ptr<pit::Entry> pitEntry);
virtual void
- DidSendOutInterest (const Ptr<NdnFace> &outgoingFace,
- Ptr<NdnInterestHeader> header,
+ DidSendOutInterest (const Ptr<Face> &outgoingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry);
+ Ptr<pit::Entry> pitEntry);
virtual void
- DidSendOutData (const Ptr<NdnFace> &face,
- Ptr<const NdnContentObjectHeader> header,
+ DidSendOutData (const Ptr<Face> &face,
+ Ptr<const ContentObjectHeader> header,
Ptr<const Packet> payload,
const Ptr<const Packet> &packet);
virtual void
- WillErasePendingInterest (Ptr<NdnPitEntry> pitEntry);
+ WillErasePendingInterest (Ptr<pit::Entry> pitEntry);
// from Object
void
@@ -107,22 +108,23 @@
ScheduleRefreshingIfNecessary ();
private:
- StatsTree m_stats;
+ ndnSIM::StatsTree m_stats;
EventId m_statsRefreshEvent;
- TracedCallback< Ptr<NdnForwardingStrategy>,
- const StatsTree & > m_statsTrace;
+ TracedCallback< Ptr<ForwardingStrategy>,
+ const ndnSIM::StatsTree & > m_statsTrace;
typedef BestRoute super;
};
-const StatsTree &
+const ndnSIM::StatsTree &
FwStats::GetStatsTree () const
{
return m_stats;
}
-} // namespace ndnSIM
+} // namespace fw
+} // namespace ndn
} // namespace ns3
#endif // NDNSIM_FW_STATS_H
diff --git a/model/forwarding-strategy/green-yellow-red.cc b/model/fw/green-yellow-red.cc
similarity index 71%
rename from model/forwarding-strategy/green-yellow-red.cc
rename to model/fw/green-yellow-red.cc
index 5d497a6..3f0653f 100644
--- a/model/forwarding-strategy/green-yellow-red.cc
+++ b/model/fw/green-yellow-red.cc
@@ -43,20 +43,18 @@
#include <boost/tuple/tuple.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("NdnSimGreenYellowRed");
+NS_LOG_COMPONENT_DEFINE ("ndn.fw.GreenYellowRed");
namespace ns3 {
-
-using namespace __ndn_private;
-
-namespace ndnSIM {
+namespace ndn {
+namespace fw {
NS_OBJECT_ENSURE_REGISTERED (GreenYellowRed);
TypeId
GreenYellowRed::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::ndnSIM::GreenYellowRed")
+ static TypeId tid = TypeId ("ns3::ndn::fw::GreenYellowRed")
.SetGroupName ("Ndn")
.SetParent<Nacks> ()
@@ -65,20 +63,20 @@
}
bool
-GreenYellowRed::DoPropagateInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+GreenYellowRed::DoPropagateInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
NS_LOG_FUNCTION (this);
NS_ASSERT_MSG (m_pit != 0, "PIT should be aggregated with forwarding strategy");
int propagatedCount = 0;
- BOOST_FOREACH (const NdnFibFaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<i_metric> ())
+ BOOST_FOREACH (const fib::FaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<fib::i_metric> ())
{
- if (metricFace.m_status == NdnFibFaceMetric::NDN_FIB_RED ||
- metricFace.m_status == NdnFibFaceMetric::NDN_FIB_YELLOW)
+ if (metricFace.m_status == fib::FaceMetric::NDN_FIB_RED ||
+ metricFace.m_status == fib::FaceMetric::NDN_FIB_YELLOW)
break; //propagate only to green faces
if (pitEntry->GetIncoming ().find (metricFace.m_face) != pitEntry->GetIncoming ().end ())
@@ -103,32 +101,33 @@
}
void
-GreenYellowRed::WillSatisfyPendingInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnPitEntry> pitEntry)
+GreenYellowRed::WillSatisfyPendingInterest (const Ptr<Face> &incomingFace,
+ Ptr<pit::Entry> pitEntry)
{
if (incomingFace != 0)
{
// Update metric status for the incoming interface in the corresponding FIB entry
- pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, NdnFibFaceMetric::NDN_FIB_GREEN);
+ pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, fib::FaceMetric::NDN_FIB_GREEN);
}
super::WillSatisfyPendingInterest (incomingFace, pitEntry);
}
void
-GreenYellowRed::DidReceiveValidNack (const Ptr<NdnFace> &incomingFace,
+GreenYellowRed::DidReceiveValidNack (const Ptr<Face> &incomingFace,
uint32_t nackCode,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
super::DidReceiveValidNack (incomingFace, nackCode, pitEntry);
if (incomingFace != 0 &&
- nackCode != NdnInterestHeader::NACK_LOOP)
+ nackCode != InterestHeader::NACK_LOOP)
{
- pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, NdnFibFaceMetric::NDN_FIB_YELLOW);
+ pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, fib::FaceMetric::NDN_FIB_YELLOW);
}
}
-} // namespace ndnSIM
+} // namespace fw
+} // namespace ndn
} // namespace ns3
diff --git a/model/forwarding-strategy/green-yellow-red.h b/model/fw/green-yellow-red.h
similarity index 75%
rename from model/forwarding-strategy/green-yellow-red.h
rename to model/fw/green-yellow-red.h
index 67263ee..f324376 100644
--- a/model/forwarding-strategy/green-yellow-red.h
+++ b/model/fw/green-yellow-red.h
@@ -24,7 +24,8 @@
#include "nacks.h"
namespace ns3 {
-namespace ndnSIM {
+namespace ndn {
+namespace fw {
/**
* \ingroup ndn
@@ -37,24 +38,25 @@
protected:
virtual void
- WillSatisfyPendingInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnPitEntry> pitEntry);
+ WillSatisfyPendingInterest (const Ptr<Face> &incomingFace,
+ Ptr<pit::Entry> pitEntry);
virtual bool
- DoPropagateInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+ DoPropagateInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry);
+ Ptr<pit::Entry> pitEntry);
virtual void
- DidReceiveValidNack (const Ptr<NdnFace> &incomingFace,
+ DidReceiveValidNack (const Ptr<Face> &incomingFace,
uint32_t nackCode,
- Ptr<NdnPitEntry> pitEntry);
+ Ptr<pit::Entry> pitEntry);
private:
typedef Nacks super;
};
-} // namespace ndnSIM
+} // namespace fw
+} // namespace ndn
} // namespace ns3
#endif // NDNSIM_GREEN_YELLOW_RED
diff --git a/model/forwarding-strategy/nacks.cc b/model/fw/nacks.cc
similarity index 79%
rename from model/forwarding-strategy/nacks.cc
rename to model/fw/nacks.cc
index 4cc8287..a148794 100644
--- a/model/forwarding-strategy/nacks.cc
+++ b/model/fw/nacks.cc
@@ -42,19 +42,20 @@
#include <boost/tuple/tuple.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("NdnSimNacks");
+NS_LOG_COMPONENT_DEFINE ("ndn.fw.Nacks");
namespace ns3 {
-namespace ndnSIM {
+namespace ndn {
+namespace fw {
NS_OBJECT_ENSURE_REGISTERED (Nacks);
TypeId
Nacks::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::ndnSIM::Nacks")
+ static TypeId tid = TypeId ("ns3::ndn::fw::Nacks")
.SetGroupName ("Ndn")
- .SetParent<NdnForwardingStrategy> ()
+ .SetParent<ForwardingStrategy> ()
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
@@ -72,8 +73,8 @@
}
void
-Nacks::OnInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> &header,
+Nacks::OnInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> &header,
const Ptr<const Packet> &packet)
{
if (header->GetNack () > 0)
@@ -83,8 +84,8 @@
}
void
-Nacks::OnNack (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> &header,
+Nacks::OnNack (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> &header,
const Ptr<const Packet> &packet)
{
NS_ASSERT (m_nacksEnabled);
@@ -92,7 +93,7 @@
// NS_LOG_FUNCTION (incomingFace << header << packet);
m_inNacks (header, incomingFace);
- Ptr<NdnPitEntry> pitEntry = m_pit->Lookup (*header);
+ Ptr<pit::Entry> pitEntry = m_pit->Lookup (*header);
if (pitEntry == 0)
{
// somebody is doing something bad
@@ -119,7 +120,7 @@
}
Ptr<Packet> nonNackInterest = Create<Packet> ();
- header->SetNack (NdnInterestHeader::NORMAL_INTEREST);
+ header->SetNack (InterestHeader::NORMAL_INTEREST);
nonNackInterest->AddHeader (*header);
bool propagated = DoPropagateInterest (incomingFace, header, nonNackInterest, pitEntry);
@@ -130,17 +131,17 @@
}
void
-Nacks::DidReceiveDuplicateInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> &header,
+Nacks::DidReceiveDuplicateInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> &header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
super::DidReceiveDuplicateInterest (incomingFace, header, packet, pitEntry);
if (m_nacksEnabled)
{
NS_LOG_DEBUG ("Sending NACK_LOOP");
- header->SetNack (NdnInterestHeader::NACK_LOOP);
+ header->SetNack (InterestHeader::NACK_LOOP);
Ptr<Packet> nack = Create<Packet> ();
nack->AddHeader (*header);
@@ -150,20 +151,20 @@
}
void
-Nacks::DidExhaustForwardingOptions (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+Nacks::DidExhaustForwardingOptions (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
super::DidExhaustForwardingOptions (incomingFace, header, packet, pitEntry);
if (m_nacksEnabled)
{
Ptr<Packet> packet = Create<Packet> ();
- header->SetNack (NdnInterestHeader::NACK_GIVEUP_PIT);
+ header->SetNack (InterestHeader::NACK_GIVEUP_PIT);
packet->AddHeader (*header);
- BOOST_FOREACH (const NdnPitEntryIncomingFace &incoming, pitEntry->GetIncoming ())
+ BOOST_FOREACH (const pit::IncomingFace &incoming, pitEntry->GetIncoming ())
{
NS_LOG_DEBUG ("Send NACK for " << boost::cref (header->GetName ()) << " to " << boost::cref (*incoming.m_face));
incoming.m_face->Send (packet->Copy ());
@@ -183,19 +184,20 @@
}
void
-Nacks::DidReceiveValidNack (const Ptr<NdnFace> &incomingFace,
+Nacks::DidReceiveValidNack (const Ptr<Face> &incomingFace,
uint32_t nackCode,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
// If NACK is NACK_GIVEUP_PIT, then neighbor gave up trying to and removed it's PIT entry.
// So, if we had an incoming entry to this neighbor, then we can remove it now
- if (nackCode == NdnInterestHeader::NACK_GIVEUP_PIT)
+ if (nackCode == InterestHeader::NACK_GIVEUP_PIT)
{
pitEntry->RemoveIncoming (incomingFace);
}
- pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, NdnFibFaceMetric::NDN_FIB_YELLOW);
+ pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, fib::FaceMetric::NDN_FIB_YELLOW);
}
-} // namespace ndnSIM
+} // namespace fw
+} // namespace ndn
} // namespace ns3
diff --git a/model/forwarding-strategy/nacks.h b/model/fw/nacks.h
similarity index 61%
rename from model/forwarding-strategy/nacks.h
rename to model/fw/nacks.h
index 074f5ab..e9226ad 100644
--- a/model/forwarding-strategy/nacks.h
+++ b/model/fw/nacks.h
@@ -23,19 +23,19 @@
#include "ns3/ndn-forwarding-strategy.h"
namespace ns3 {
-
-namespace ndnSIM {
+namespace ndn {
+namespace fw {
/**
* \ingroup ndn
* \brief Abstract base class for Ndn forwarding strategies
*/
class Nacks :
- public NdnForwardingStrategy
+ public ForwardingStrategy
{
public:
static TypeId
- GetTypeId (void);
+ GetTypeId ();
/**
* \brief Actual processing of incoming Ndn interests. Note, interests do not have payload
@@ -46,52 +46,53 @@
* @param packet original packet
*/
virtual void
- OnInterest (const Ptr<NdnFace> &face,
- Ptr<NdnInterestHeader> &header,
+ OnInterest (const Ptr<Face> &face,
+ Ptr<InterestHeader> &header,
const Ptr<const Packet> &p);
protected:
// using NdnForwardingStrategy::PropagateInterest; // some strange c++ cheating
virtual void
- DidReceiveDuplicateInterest (const Ptr<NdnFace> &face,
- Ptr<NdnInterestHeader> &header,
+ DidReceiveDuplicateInterest (const Ptr<Face> &face,
+ Ptr<InterestHeader> &header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry);
+ Ptr<pit::Entry> pitEntry);
virtual void
- DidExhaustForwardingOptions (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+ DidExhaustForwardingOptions (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry);
+ Ptr<pit::Entry> pitEntry);
virtual void
- OnNack (const Ptr<NdnFace> &face,
- Ptr<NdnInterestHeader> &header,
+ OnNack (const Ptr<Face> &face,
+ Ptr<InterestHeader> &header,
const Ptr<const Packet> &p);
virtual void
- DidReceiveValidNack (const Ptr<NdnFace> &incomingFace,
+ DidReceiveValidNack (const Ptr<Face> &incomingFace,
uint32_t nackCode,
- Ptr<NdnPitEntry> pitEntry);
+ Ptr<pit::Entry> pitEntry);
protected:
bool m_nacksEnabled;
- TracedCallback<Ptr<const NdnInterestHeader>,
- Ptr<const NdnFace> > m_outNacks; ///< @brief trace of outgoing NACKs
+ TracedCallback<Ptr<const InterestHeader>,
+ Ptr<const Face> > m_outNacks; ///< @brief trace of outgoing NACKs
- TracedCallback<Ptr<const NdnInterestHeader>,
- Ptr<const NdnFace> > m_inNacks; ///< @brief trace of incoming NACKs
+ TracedCallback<Ptr<const InterestHeader>,
+ Ptr<const Face> > m_inNacks; ///< @brief trace of incoming NACKs
- TracedCallback<Ptr<const NdnInterestHeader>,
- Ptr<const NdnFace> > m_dropNacks; ///< @brief trace of dropped NACKs
+ TracedCallback<Ptr<const InterestHeader>,
+ Ptr<const Face> > m_dropNacks; ///< @brief trace of dropped NACKs
private:
- typedef NdnForwardingStrategy super;
+ typedef ForwardingStrategy super;
};
-} // namespace ndnSIM
+} // namespace fw
+} // namespace ndn
} // namespace ns3
#endif // NDNSIM_NACKS
diff --git a/model/forwarding-strategy/ndn-forwarding-strategy.cc b/model/fw/ndn-forwarding-strategy.cc
similarity index 71%
rename from model/forwarding-strategy/ndn-forwarding-strategy.cc
rename to model/fw/ndn-forwarding-strategy.cc
index dedd60f..f1c92bd 100644
--- a/model/forwarding-strategy/ndn-forwarding-strategy.cc
+++ b/model/fw/ndn-forwarding-strategy.cc
@@ -44,77 +44,76 @@
#include <boost/tuple/tuple.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("NdnForwardingStrategy");
+NS_LOG_COMPONENT_DEFINE ("ndn.ForwardingStrategy");
namespace ns3 {
+namespace ndn {
-using namespace __ndn_private;
+NS_OBJECT_ENSURE_REGISTERED (ForwardingStrategy);
-NS_OBJECT_ENSURE_REGISTERED (NdnForwardingStrategy);
-
-TypeId NdnForwardingStrategy::GetTypeId (void)
+TypeId ForwardingStrategy::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::NdnForwardingStrategy")
+ static TypeId tid = TypeId ("ns3::ndn::ForwardingStrategy")
.SetGroupName ("Ndn")
.SetParent<Object> ()
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
- .AddTraceSource ("OutInterests", "OutInterests", MakeTraceSourceAccessor (&NdnForwardingStrategy::m_outInterests))
- .AddTraceSource ("InInterests", "InInterests", MakeTraceSourceAccessor (&NdnForwardingStrategy::m_inInterests))
- .AddTraceSource ("DropInterests", "DropInterests", MakeTraceSourceAccessor (&NdnForwardingStrategy::m_dropInterests))
+ .AddTraceSource ("OutInterests", "OutInterests", MakeTraceSourceAccessor (&ForwardingStrategy::m_outInterests))
+ .AddTraceSource ("InInterests", "InInterests", MakeTraceSourceAccessor (&ForwardingStrategy::m_inInterests))
+ .AddTraceSource ("DropInterests", "DropInterests", MakeTraceSourceAccessor (&ForwardingStrategy::m_dropInterests))
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
- .AddTraceSource ("OutData", "OutData", MakeTraceSourceAccessor (&NdnForwardingStrategy::m_outData))
- .AddTraceSource ("InData", "InData", MakeTraceSourceAccessor (&NdnForwardingStrategy::m_inData))
- .AddTraceSource ("DropData", "DropData", MakeTraceSourceAccessor (&NdnForwardingStrategy::m_dropData))
+ .AddTraceSource ("OutData", "OutData", MakeTraceSourceAccessor (&ForwardingStrategy::m_outData))
+ .AddTraceSource ("InData", "InData", MakeTraceSourceAccessor (&ForwardingStrategy::m_inData))
+ .AddTraceSource ("DropData", "DropData", MakeTraceSourceAccessor (&ForwardingStrategy::m_dropData))
.AddAttribute ("CacheUnsolicitedData", "Cache overheard data that have not been requested",
BooleanValue (false),
- MakeBooleanAccessor (&NdnForwardingStrategy::m_cacheUnsolicitedData),
+ MakeBooleanAccessor (&ForwardingStrategy::m_cacheUnsolicitedData),
MakeBooleanChecker ())
.AddAttribute ("DetectRetransmissions", "If non-duplicate interest is received on the same face more than once, "
"it is considered a retransmission",
BooleanValue (true),
- MakeBooleanAccessor (&NdnForwardingStrategy::m_detectRetransmissions),
+ MakeBooleanAccessor (&ForwardingStrategy::m_detectRetransmissions),
MakeBooleanChecker ())
;
return tid;
}
-NdnForwardingStrategy::NdnForwardingStrategy ()
+ForwardingStrategy::ForwardingStrategy ()
{
}
-NdnForwardingStrategy::~NdnForwardingStrategy ()
+ForwardingStrategy::~ForwardingStrategy ()
{
}
void
-NdnForwardingStrategy::NotifyNewAggregate ()
+ForwardingStrategy::NotifyNewAggregate ()
{
if (m_pit == 0)
{
- m_pit = GetObject<NdnPit> ();
+ m_pit = GetObject<Pit> ();
}
if (m_fib == 0)
{
- m_fib = GetObject<NdnFib> ();
+ m_fib = GetObject<Fib> ();
}
if (m_contentStore == 0)
{
- m_contentStore = GetObject<NdnContentStore> ();
+ m_contentStore = GetObject<ContentStore> ();
}
Object::NotifyNewAggregate ();
}
void
-NdnForwardingStrategy::DoDispose ()
+ForwardingStrategy::DoDispose ()
{
m_pit = 0;
m_contentStore = 0;
@@ -124,13 +123,13 @@
}
void
-NdnForwardingStrategy::OnInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> &header,
+ForwardingStrategy::OnInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> &header,
const Ptr<const Packet> &packet)
{
m_inInterests (header, incomingFace);
- Ptr<NdnPitEntry> pitEntry = m_pit->Lookup (*header);
+ Ptr<pit::Entry> pitEntry = m_pit->Lookup (*header);
if (pitEntry == 0)
{
pitEntry = m_pit->Create (header);
@@ -159,7 +158,7 @@
}
Ptr<Packet> contentObject;
- Ptr<const NdnContentObjectHeader> contentObjectHeader; // used for tracing
+ Ptr<const ContentObjectHeader> contentObjectHeader; // used for tracing
Ptr<const Packet> payload; // used for tracing
boost::tie (contentObject, contentObjectHeader, payload) = m_contentStore->Lookup (header);
if (contentObject != 0)
@@ -192,8 +191,8 @@
}
void
-NdnForwardingStrategy::OnData (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnContentObjectHeader> &header,
+ForwardingStrategy::OnData (const Ptr<Face> &incomingFace,
+ Ptr<ContentObjectHeader> &header,
Ptr<Packet> &payload,
const Ptr<const Packet> &packet)
{
@@ -201,7 +200,7 @@
m_inData (header, payload, incomingFace);
// Lookup PIT entry
- Ptr<NdnPitEntry> pitEntry = m_pit->Lookup (*header);
+ Ptr<pit::Entry> pitEntry = m_pit->Lookup (*header);
if (pitEntry == 0)
{
DidReceiveUnsolicitedData (incomingFace, header, payload);
@@ -228,10 +227,10 @@
void
-NdnForwardingStrategy::DidReceiveDuplicateInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> &header,
+ForwardingStrategy::DidReceiveDuplicateInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> &header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
NS_LOG_FUNCTION (this << boost::cref (*incomingFace));
/////////////////////////////////////////////////////////////////////////////////////////
@@ -244,18 +243,18 @@
}
void
-NdnForwardingStrategy::DidExhaustForwardingOptions (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+ForwardingStrategy::DidExhaustForwardingOptions (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
NS_LOG_FUNCTION (this << boost::cref (*incomingFace));
m_dropInterests (header, incomingFace);
}
void
-NdnForwardingStrategy::FailedToCreatePitEntry (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+ForwardingStrategy::FailedToCreatePitEntry (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet)
{
NS_LOG_FUNCTION (this);
@@ -263,18 +262,18 @@
}
void
-NdnForwardingStrategy::DidCreatePitEntry (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+ForwardingStrategy::DidCreatePitEntry (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntrypitEntry)
+ Ptr<pit::Entry> pitEntrypitEntry)
{
}
bool
-NdnForwardingStrategy::DetectRetransmittedInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnPitEntry> pitEntry)
+ForwardingStrategy::DetectRetransmittedInterest (const Ptr<Face> &incomingFace,
+ Ptr<pit::Entry> pitEntry)
{
- NdnPitEntry::in_iterator inFace = pitEntry->GetIncoming ().find (incomingFace);
+ pit::Entry::in_iterator inFace = pitEntry->GetIncoming ().find (incomingFace);
bool isRetransmitted = false;
@@ -288,17 +287,17 @@
}
void
-NdnForwardingStrategy::SatisfyPendingInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<const NdnContentObjectHeader> header,
+ForwardingStrategy::SatisfyPendingInterest (const Ptr<Face> &incomingFace,
+ Ptr<const ContentObjectHeader> header,
Ptr<const Packet> payload,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
if (incomingFace != 0)
pitEntry->RemoveIncoming (incomingFace);
//satisfy all pending incoming Interests
- BOOST_FOREACH (const NdnPitEntryIncomingFace &incoming, pitEntry->GetIncoming ())
+ BOOST_FOREACH (const pit::IncomingFace &incoming, pitEntry->GetIncoming ())
{
bool ok = incoming.m_face->Send (packet->Copy ());
if (ok)
@@ -328,8 +327,8 @@
}
void
-NdnForwardingStrategy::DidReceiveUnsolicitedData (const Ptr<NdnFace> &incomingFace,
- Ptr<const NdnContentObjectHeader> header,
+ForwardingStrategy::DidReceiveUnsolicitedData (const Ptr<Face> &incomingFace,
+ Ptr<const ContentObjectHeader> header,
Ptr<const Packet> payload)
{
if (m_cacheUnsolicitedData)
@@ -348,10 +347,10 @@
}
void
-NdnForwardingStrategy::WillSatisfyPendingInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnPitEntry> pitEntry)
+ForwardingStrategy::WillSatisfyPendingInterest (const Ptr<Face> &incomingFace,
+ Ptr<pit::Entry> pitEntry)
{
- NdnPitEntry::out_iterator out = pitEntry->GetOutgoing ().find (incomingFace);
+ pit::Entry::out_iterator out = pitEntry->GetOutgoing ().find (incomingFace);
// If we have sent interest for this data via this face, then update stats.
if (out != pitEntry->GetOutgoing ().end ())
@@ -361,8 +360,8 @@
}
bool
-NdnForwardingStrategy::ShouldSuppressIncomingInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnPitEntry> pitEntry)
+ForwardingStrategy::ShouldSuppressIncomingInterest (const Ptr<Face> &incomingFace,
+ Ptr<pit::Entry> pitEntry)
{
bool isNew = pitEntry->GetIncoming ().size () == 0 && pitEntry->GetOutgoing ().size () == 0;
@@ -382,7 +381,7 @@
// ?? not sure if we need to do that ?? ...
- // pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, NdnFibFaceMetric::NDN_FIB_YELLOW);
+ // pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, fib::FaceMetric::NDN_FIB_YELLOW);
}
else
if (!isNew && !isRetransmitted)
@@ -394,10 +393,10 @@
}
void
-NdnForwardingStrategy::PropagateInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+ForwardingStrategy::PropagateInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
bool isRetransmitted = m_detectRetransmissions && // a small guard
DetectRetransmittedInterest (incomingFace, pitEntry);
@@ -427,11 +426,11 @@
}
bool
-NdnForwardingStrategy::WillSendOutInterest (const Ptr<NdnFace> &outgoingFace,
- Ptr<NdnInterestHeader> header,
- Ptr<NdnPitEntry> pitEntry)
+ForwardingStrategy::WillSendOutInterest (const Ptr<Face> &outgoingFace,
+ Ptr<InterestHeader> header,
+ Ptr<pit::Entry> pitEntry)
{
- NdnPitEntryOutgoingFaceContainer::type::iterator outgoing =
+ pit::Entry::out_iterator outgoing =
pitEntry->GetOutgoing ().find (outgoingFace);
if (outgoing != pitEntry->GetOutgoing ().end () &&
@@ -451,33 +450,34 @@
}
void
-NdnForwardingStrategy::DidSendOutInterest (const Ptr<NdnFace> &outgoingFace,
- Ptr<NdnInterestHeader> header,
+ForwardingStrategy::DidSendOutInterest (const Ptr<Face> &outgoingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
m_outInterests (header, outgoingFace);
}
void
-NdnForwardingStrategy::DidSendOutData (const Ptr<NdnFace> &face,
- Ptr<const NdnContentObjectHeader> header,
+ForwardingStrategy::DidSendOutData (const Ptr<Face> &face,
+ Ptr<const ContentObjectHeader> header,
Ptr<const Packet> payload,
const Ptr<const Packet> &packet)
{
}
void
-NdnForwardingStrategy::WillErasePendingInterest (Ptr<NdnPitEntry> pitEntry)
+ForwardingStrategy::WillErasePendingInterest (Ptr<pit::Entry> pitEntry)
{
// do nothing for now. may be need to do some logging
}
void
-NdnForwardingStrategy::RemoveFace (Ptr<NdnFace> face)
+ForwardingStrategy::RemoveFace (Ptr<Face> face)
{
// do nothing here
}
-} //namespace ns3
+} // namespace ndn
+} // namespace ns3
diff --git a/model/fw/ndn-forwarding-strategy.h b/model/fw/ndn-forwarding-strategy.h
new file mode 100644
index 0000000..1d4111e
--- /dev/null
+++ b/model/fw/ndn-forwarding-strategy.h
@@ -0,0 +1,231 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ * Ilya Moiseenko <iliamo@cs.ucla.edu>
+ */
+#ifndef NDN_FORWARDING_STRATEGY_H
+#define NDN_FORWARDING_STRATEGY_H
+
+#include "ns3/packet.h"
+#include "ns3/callback.h"
+#include "ns3/object.h"
+#include "ns3/traced-callback.h"
+
+namespace ns3 {
+namespace ndn {
+
+class Face;
+class InterestHeader;
+class ContentObjectHeader;
+class Pit;
+namespace pit { class Entry; }
+class FibFaceMetric;
+class Fib;
+class ContentStore;
+
+/**
+ * \ingroup ndn
+ * \brief Abstract base class for Ndn forwarding strategies
+ */
+class ForwardingStrategy :
+ public Object
+{
+public:
+ static TypeId GetTypeId (void);
+
+ /**
+ * @brief Default constructor
+ */
+ ForwardingStrategy ();
+ virtual ~ForwardingStrategy ();
+
+ /**
+ * \brief Actual processing of incoming Ndn interests. Note, interests do not have payload
+ *
+ * Processing Interest packets
+ * @param face incoming face
+ * @param header deserialized Interest header
+ * @param packet original packet
+ */
+ virtual void
+ OnInterest (const Ptr<Face> &face,
+ Ptr<InterestHeader> &header,
+ const Ptr<const Packet> &p);
+
+ /**
+ * \brief Actual processing of incoming Ndn content objects
+ *
+ * Processing ContentObject packets
+ * @param face incoming face
+ * @param header deserialized ContentObject header
+ * @param payload data packet payload
+ * @param packet original packet
+ */
+ virtual void
+ OnData (const Ptr<Face> &face,
+ Ptr<ContentObjectHeader> &header,
+ Ptr<Packet> &payload,
+ const Ptr<const Packet> &packet);
+
+ virtual void
+ WillErasePendingInterest (Ptr<pit::Entry> pitEntry);
+
+ virtual void
+ RemoveFace (Ptr<Face> face);
+
+protected:
+ // events
+ virtual void
+ DidReceiveDuplicateInterest (const Ptr<Face> &face,
+ Ptr<InterestHeader> &header,
+ const Ptr<const Packet> &packet,
+ Ptr<pit::Entry> pitEntry);
+
+ virtual void
+ DidExhaustForwardingOptions (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
+ const Ptr<const Packet> &packet,
+ Ptr<pit::Entry> pitEntry);
+
+ virtual void
+ FailedToCreatePitEntry (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
+ const Ptr<const Packet> &packet);
+
+ virtual void
+ DidCreatePitEntry (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
+ const Ptr<const Packet> &packet,
+ Ptr<pit::Entry> pitEntry);
+
+ virtual bool
+ DetectRetransmittedInterest (const Ptr<Face> &incomingFace,
+ Ptr<pit::Entry> pitEntry);
+
+ // makes sense only for data received from network
+ // When Interest is satisfied from the cache, incoming face is 0
+ virtual void
+ WillSatisfyPendingInterest (const Ptr<Face> &incomingFace,
+ Ptr<pit::Entry> pitEntry);
+
+ // for data received both from network and cache
+ virtual void
+ SatisfyPendingInterest (const Ptr<Face> &incomingFace, // 0 allowed (from cache)
+ Ptr<const ContentObjectHeader> header,
+ Ptr<const Packet> payload,
+ const Ptr<const Packet> &packet,
+ Ptr<pit::Entry> pitEntry);
+
+ virtual void
+ DidSendOutData (const Ptr<Face> &face,
+ Ptr<const ContentObjectHeader> header,
+ Ptr<const Packet> payload,
+ const Ptr<const Packet> &packet);
+
+ virtual void
+ DidReceiveUnsolicitedData (const Ptr<Face> &incomingFace,
+ Ptr<const ContentObjectHeader> header,
+ Ptr<const Packet> payload);
+
+ virtual bool
+ ShouldSuppressIncomingInterest (const Ptr<Face> &incomingFace,
+ Ptr<pit::Entry> pitEntry);
+
+ /**
+ * @brief Event fired before actually sending out an interest
+ *
+ * If event returns false, then there is some kind of a problem (e.g., per-face limit reached)
+ */
+ virtual bool
+ WillSendOutInterest (const Ptr<Face> &outgoingFace,
+ Ptr<InterestHeader> header,
+ Ptr<pit::Entry> pitEntry);
+
+ /**
+ * @brief Event fired just after sending out an interest
+ */
+ virtual void
+ DidSendOutInterest (const Ptr<Face> &outgoingFace,
+ Ptr<InterestHeader> header,
+ const Ptr<const Packet> &packet,
+ Ptr<pit::Entry> pitEntry);
+
+ virtual void
+ PropagateInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
+ const Ptr<const Packet> &packet,
+ Ptr<pit::Entry> pitEntry);
+
+ /**
+ * @brief Base method to propagate the interest according to the forwarding strategy
+ *
+ * @param pitEntry Reference to PIT entry (reference to corresponding FIB entry inside)
+ * @param incomingFace Incoming face
+ * @param header InterestHeader
+ * @param packet Original Interest packet
+ * @param sendCallback Send callback
+ *
+ * @return true if interest was successfully propagated, false if all options have failed
+ */
+ virtual bool
+ DoPropagateInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
+ const Ptr<const Packet> &packet,
+ Ptr<pit::Entry> pitEntry) = 0;
+
+protected:
+ // inherited from Object class
+ virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object
+ virtual void DoDispose (); ///< @brief Do cleanup
+
+protected:
+ Ptr<Pit> m_pit; ///< \brief Reference to PIT to which this forwarding strategy is associated
+ Ptr<Fib> m_fib; ///< \brief FIB
+ Ptr<ContentStore> m_contentStore; ///< \brief Content store (for caching purposes only)
+
+ bool m_cacheUnsolicitedData;
+ bool m_detectRetransmissions;
+
+ TracedCallback<Ptr<const InterestHeader>,
+ Ptr<const Face> > m_outInterests; ///< @brief Transmitted interests trace
+
+ TracedCallback<Ptr<const InterestHeader>,
+ Ptr<const Face> > m_inInterests; ///< @brief trace of incoming Interests
+
+ TracedCallback<Ptr<const InterestHeader>,
+ Ptr<const Face> > m_dropInterests; ///< @brief trace of dropped Interests
+
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+
+ TracedCallback<Ptr<const ContentObjectHeader>, Ptr<const Packet>,
+ bool /*from cache*/,
+ Ptr<const Face> > m_outData; ///< @brief trace of outgoing Data
+
+ TracedCallback<Ptr<const ContentObjectHeader>, Ptr<const Packet>,
+ Ptr<const Face> > m_inData; ///< @brief trace of incoming Data
+
+ TracedCallback<Ptr<const ContentObjectHeader>, Ptr<const Packet>,
+ Ptr<const Face> > m_dropData; ///< @brief trace of dropped Data
+};
+
+} // namespace ndn
+} // namespace ns3
+
+#endif /* NDN_FORWARDING_STRATEGY_H */
diff --git a/model/forwarding-strategy/smart-flooding.cc b/model/fw/smart-flooding.cc
similarity index 80%
rename from model/forwarding-strategy/smart-flooding.cc
rename to model/fw/smart-flooding.cc
index 58a56a2..53272e9 100644
--- a/model/forwarding-strategy/smart-flooding.cc
+++ b/model/fw/smart-flooding.cc
@@ -35,20 +35,18 @@
#include <boost/lambda/bind.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("NdnSimSmartFlooding");
+NS_LOG_COMPONENT_DEFINE ("ndn.fw.SmartFlooding");
namespace ns3 {
-
-using namespace __ndn_private;
-
-namespace ndnSIM {
+namespace ndn {
+namespace fw {
NS_OBJECT_ENSURE_REGISTERED (SmartFlooding);
TypeId
SmartFlooding::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::ndnSIM::SmartFloodingy")
+ static TypeId tid = TypeId ("ns3::ndn::fw::SmartFlooding")
.SetGroupName ("Ndn")
.SetParent <GreenYellowRed> ()
.AddConstructor <SmartFlooding> ()
@@ -61,10 +59,10 @@
}
bool
-SmartFlooding::DoPropagateInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+SmartFlooding::DoPropagateInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry)
+ Ptr<pit::Entry> pitEntry)
{
NS_LOG_FUNCTION (this);
@@ -75,10 +73,10 @@
int propagatedCount = 0;
- BOOST_FOREACH (const NdnFibFaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<i_metric> ())
+ BOOST_FOREACH (const fib::FaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<fib::i_metric> ())
{
NS_LOG_DEBUG ("Trying " << boost::cref(metricFace));
- if (metricFace.m_status == NdnFibFaceMetric::NDN_FIB_RED) // all non-read faces are in the front of the list
+ if (metricFace.m_status == fib::FaceMetric::NDN_FIB_RED) // all non-read faces are in the front of the list
break;
if (metricFace.m_face == incomingFace)
@@ -105,5 +103,6 @@
return propagatedCount > 0;
}
-} // namespace ndnSIM
+} // namespace fw
+} // namespace ndn
} // namespace ns3
diff --git a/model/forwarding-strategy/smart-flooding.h b/model/fw/smart-flooding.h
similarity index 83%
rename from model/forwarding-strategy/smart-flooding.h
rename to model/fw/smart-flooding.h
index c939015..a228d3e 100644
--- a/model/forwarding-strategy/smart-flooding.h
+++ b/model/fw/smart-flooding.h
@@ -24,7 +24,8 @@
#include "green-yellow-red.h"
namespace ns3 {
-namespace ndnSIM {
+namespace ndn {
+namespace fw {
/**
* \ingroup ccnx
@@ -33,7 +34,7 @@
public GreenYellowRed
{
public:
- static TypeId GetTypeId (void);
+ static TypeId GetTypeId ();
/**
* @brief Default constructor
@@ -42,16 +43,17 @@
// inherited
virtual bool
- DoPropagateInterest (const Ptr<NdnFace> &incomingFace,
- Ptr<NdnInterestHeader> header,
+ DoPropagateInterest (const Ptr<Face> &incomingFace,
+ Ptr<InterestHeader> header,
const Ptr<const Packet> &packet,
- Ptr<NdnPitEntry> pitEntry);
+ Ptr<pit::Entry> pitEntry);
private:
typedef GreenYellowRed super;
};
-} // namespace ndnSIM
+} // namespace fw
+} // namespace ndn
} // namespace ns3
#endif // NDNSIM_SMART_FLOODING_H
diff --git a/model/ndn-app-face.cc b/model/ndn-app-face.cc
index 55cee9b..538b10c 100644
--- a/model/ndn-app-face.cc
+++ b/model/ndn-app-face.cc
@@ -34,25 +34,25 @@
#include "ndn-interest-header.h"
#include "ndn-content-object-header.h"
-NS_LOG_COMPONENT_DEFINE ("NdnAppFace");
+NS_LOG_COMPONENT_DEFINE ("ndn.AppFace");
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (NdnAppFace);
+NS_OBJECT_ENSURE_REGISTERED (AppFace);
TypeId
-NdnAppFace::GetTypeId ()
+AppFace::GetTypeId ()
{
- static TypeId tid = TypeId ("ns3::NdnAppFace")
- .SetParent<NdnFace> ()
+ static TypeId tid = TypeId ("ns3::ndn::AppFace")
+ .SetParent<Face> ()
.SetGroupName ("Ndn")
;
return tid;
}
-NdnAppFace::NdnAppFace (Ptr<NdnApp> app)
- : NdnFace (app->GetNode ())
+AppFace::AppFace (Ptr<App> app)
+ : Face (app->GetNode ())
, m_app (app)
{
NS_LOG_FUNCTION (this << app);
@@ -60,50 +60,50 @@
NS_ASSERT (m_app != 0);
}
-NdnAppFace::~NdnAppFace ()
+AppFace::~AppFace ()
{
NS_LOG_FUNCTION_NOARGS ();
}
-NdnAppFace::NdnAppFace ()
- : NdnFace (0)
+AppFace::AppFace ()
+ : Face (0)
{
}
-NdnAppFace::NdnAppFace (const NdnAppFace &)
- : NdnFace (0)
+AppFace::AppFace (const AppFace &)
+ : Face (0)
{
}
-NdnAppFace& NdnAppFace::operator= (const NdnAppFace &)
+AppFace& AppFace::operator= (const AppFace &)
{
- return *((NdnAppFace*)0);
+ return *((AppFace*)0);
}
void
-NdnAppFace::RegisterProtocolHandler (ProtocolHandler handler)
+AppFace::RegisterProtocolHandler (ProtocolHandler handler)
{
NS_LOG_FUNCTION (this);
- NdnFace::RegisterProtocolHandler (handler);
+ Face::RegisterProtocolHandler (handler);
- m_app->RegisterProtocolHandler (MakeCallback (&NdnFace::Receive, this));
+ m_app->RegisterProtocolHandler (MakeCallback (&Face::Receive, this));
}
bool
-NdnAppFace::SendImpl (Ptr<Packet> p)
+AppFace::SendImpl (Ptr<Packet> p)
{
NS_LOG_FUNCTION (this << p);
try
{
- NdnHeaderHelper::Type type = NdnHeaderHelper::GetNdnHeaderType (p);
+ HeaderHelper::Type type = HeaderHelper::GetNdnHeaderType (p);
switch (type)
{
- case NdnHeaderHelper::INTEREST:
+ case HeaderHelper::INTEREST:
{
- Ptr<NdnInterestHeader> header = Create<NdnInterestHeader> ();
+ Ptr<InterestHeader> header = Create<InterestHeader> ();
p->RemoveHeader (*header);
if (header->GetNack () > 0)
@@ -113,10 +113,10 @@
break;
}
- case NdnHeaderHelper::CONTENT_OBJECT:
+ case HeaderHelper::CONTENT_OBJECT:
{
- static NdnContentObjectTail tail;
- Ptr<NdnContentObjectHeader> header = Create<NdnContentObjectHeader> ();
+ static ContentObjectTail tail;
+ Ptr<ContentObjectHeader> header = Create<ContentObjectHeader> ();
p->RemoveHeader (*header);
p->RemoveTrailer (tail);
m_app->OnContentObject (header, p/*payload*/);
@@ -127,7 +127,7 @@
return true;
}
- catch (NdnUnknownHeaderException)
+ catch (UnknownHeaderException)
{
NS_LOG_ERROR ("Unknown header type");
return false;
@@ -135,11 +135,12 @@
}
std::ostream&
-NdnAppFace::Print (std::ostream& os) const
+AppFace::Print (std::ostream& os) const
{
os << "dev=local(" << GetId() << ")";
return os;
}
-}; // namespace ns3
+} // namespace ndn
+} // namespace ns3
diff --git a/model/ndn-app-face.h b/model/ndn-app-face.h
index 9a9d2c5..2e58705 100644
--- a/model/ndn-app-face.h
+++ b/model/ndn-app-face.h
@@ -25,13 +25,15 @@
#include "ndn-face.h"
#include "ns3/traced-callback.h"
-namespace ns3
-{
+namespace ns3 {
-class NdnInterestHeader;
-class NdnContentObjectHeader;
class Packet;
-class NdnApp;
+
+namespace ndn {
+
+class InterestHeader;
+class ContentObjectHeader;
+class App;
/**
* \ingroup ndn-face
@@ -41,9 +43,9 @@
* component responsible for actual delivery of data packet to and
* from Ndn stack
*
- * \see NdnAppFace, NdnNetDeviceFace, NdnIpv4Face, NdnUdpFace
+ * \see AppFace, NdnNetDeviceFace, NdnIpv4Face, NdnUdpFace
*/
-class NdnAppFace : public NdnFace
+class AppFace : public Face
{
public:
static TypeId
@@ -52,11 +54,11 @@
/**
* \brief Default constructor
*/
- NdnAppFace (Ptr<NdnApp> app);
- virtual ~NdnAppFace();
+ AppFace (Ptr<App> app);
+ virtual ~AppFace();
////////////////////////////////////////////////////////////////////
- // methods overloaded from NdnFace
+ // methods overloaded from Face
virtual void
RegisterProtocolHandler (ProtocolHandler handler);
@@ -70,14 +72,15 @@
////////////////////////////////////////////////////////////////////
private:
- NdnAppFace ();
- NdnAppFace (const NdnAppFace &); ///< \brief Disabled copy constructor
- NdnAppFace& operator= (const NdnAppFace &); ///< \brief Disabled copy operator
+ AppFace ();
+ AppFace (const AppFace &); ///< \brief Disabled copy constructor
+ AppFace& operator= (const AppFace &); ///< \brief Disabled copy operator
private:
- Ptr<NdnApp> m_app;
+ Ptr<App> m_app;
};
+} // namespace ndn
} // namespace ns3
#endif // NDN_APP_FACE_H
diff --git a/model/ndn-content-object-header.cc b/model/ndn-content-object-header.cc
index 2a480d8..1a31abb 100644
--- a/model/ndn-content-object-header.cc
+++ b/model/ndn-content-object-header.cc
@@ -25,76 +25,76 @@
#include "../helper/ndn-encoding-helper.h"
#include "../helper/ndn-decoding-helper.h"
-#include "../helper/ccnb-parser/ccnb-parser-common.h"
-#include "../helper/ccnb-parser/visitors/ccnb-parser-void-depth-first-visitor.h"
-#include "../helper/ccnb-parser/visitors/ccnb-parser-name-components-visitor.h"
-#include "../helper/ccnb-parser/visitors/ccnb-parser-non-negative-integer-visitor.h"
-#include "../helper/ccnb-parser/visitors/ccnb-parser-timestamp-visitor.h"
-#include "../helper/ccnb-parser/visitors/ccnb-parser-string-visitor.h"
-#include "../helper/ccnb-parser/visitors/ccnb-parser-uint32t-blob-visitor.h"
-#include "../helper/ccnb-parser/visitors/ccnb-parser-content-type-visitor.h"
+#include "../helper/ccnb-parser/common.h"
+#include "../helper/ccnb-parser/visitors/void-depth-first-visitor.h"
+#include "../helper/ccnb-parser/visitors/name-components-visitor.h"
+#include "../helper/ccnb-parser/visitors/non-negative-integer-visitor.h"
+#include "../helper/ccnb-parser/visitors/timestamp-visitor.h"
+#include "../helper/ccnb-parser/visitors/string-visitor.h"
+#include "../helper/ccnb-parser/visitors/uint32t-blob-visitor.h"
+#include "../helper/ccnb-parser/visitors/content-type-visitor.h"
-#include "../helper/ccnb-parser/syntax-tree/ccnb-parser-block.h"
-#include "../helper/ccnb-parser/syntax-tree/ccnb-parser-dtag.h"
+#include "../helper/ccnb-parser/syntax-tree/block.h"
+#include "../helper/ccnb-parser/syntax-tree/dtag.h"
#include <boost/foreach.hpp>
-NS_LOG_COMPONENT_DEFINE ("NdnContentObjectHeader");
+NS_LOG_COMPONENT_DEFINE ("ndn.ContentObjectHeader");
-using namespace ns3::CcnbParser;
+namespace ns3 {
+namespace ndn {
-namespace ns3
-{
+using namespace CcnbParser;
-const std::string NdnContentObjectHeader::Signature::DefaultDigestAlgorithm = "2.16.840.1.101.3.4.2.1";
+const std::string ContentObjectHeader::Signature::DefaultDigestAlgorithm = "2.16.840.1.101.3.4.2.1";
-NS_OBJECT_ENSURE_REGISTERED (NdnContentObjectHeader);
-NS_OBJECT_ENSURE_REGISTERED (NdnContentObjectTail);
+NS_OBJECT_ENSURE_REGISTERED (ContentObjectHeader);
+NS_OBJECT_ENSURE_REGISTERED (ContentObjectTail);
TypeId
-NdnContentObjectHeader::GetTypeId (void)
+ContentObjectHeader::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::NdnContentObjectHeader")
- .SetGroupName ("ndn")
+ static TypeId tid = TypeId ("ns3::ndn::ContentObjectHeader")
+ .SetGroupName ("Ndn")
.SetParent<Header> ()
- .AddConstructor<NdnContentObjectHeader> ()
+ .AddConstructor<ContentObjectHeader> ()
;
return tid;
}
-NdnContentObjectHeader::NdnContentObjectHeader ()
+ContentObjectHeader::ContentObjectHeader ()
{
}
void
-NdnContentObjectHeader::SetName (const Ptr<NdnNameComponents> &name)
+ContentObjectHeader::SetName (const Ptr<NameComponents> &name)
{
m_name = name;
}
-const NdnNameComponents&
-NdnContentObjectHeader::GetName () const
+const NameComponents&
+ContentObjectHeader::GetName () const
{
- if (m_name==0) throw NdnContentObjectHeaderException();
+ if (m_name==0) throw ContentObjectHeaderException();
return *m_name;
}
-Ptr<const NdnNameComponents>
-NdnContentObjectHeader::GetNamePtr () const
+Ptr<const NameComponents>
+ContentObjectHeader::GetNamePtr () const
{
return m_name;
}
-#define CCNB NdnEncodingHelper // just to simplify writing
+#define CCNB EncodingHelper // just to simplify writing
void
-NdnContentObjectHeader::Serialize (Buffer::Iterator start) const
+ContentObjectHeader::Serialize (Buffer::Iterator start) const
{
size_t written = 0;
- written += CCNB::AppendBlockHeader (start, CCN_DTAG_ContentObject, CcnbParser::CCN_DTAG); // <ContentObject>
+ written += CCNB::AppendBlockHeader (start, CCN_DTAG_ContentObject, CCN_DTAG); // <ContentObject>
// fake signature
- written += CCNB::AppendBlockHeader (start, CCN_DTAG_Signature, CcnbParser::CCN_DTAG); // <Signature>
+ written += CCNB::AppendBlockHeader (start, CCN_DTAG_Signature, CCN_DTAG); // <Signature>
// Signature ::= √DigestAlgorithm?
// Witness?
// √SignatureBits
@@ -159,11 +159,11 @@
written += CCNB::AppendBlockHeader (start, CCN_DTAG_Content, CCN_DTAG); // <Content>
// there are no closing tags !!!
- // The closing tag is handled by NdnContentObjectTail
+ // The closing tag is handled by ContentObjectTail
}
uint32_t
-NdnContentObjectHeader::GetSerializedSize () const
+ContentObjectHeader::GetSerializedSize () const
{
size_t written = 0;
written += CCNB::EstimateBlockHeader (CCN_DTAG_ContentObject); // <ContentObject>
@@ -232,7 +232,7 @@
written += CCNB::EstimateBlockHeader (CCN_DTAG_Content); // <Content>
// there are no closing tags !!!
- // The closing tag is handled by NdnContentObjectTail
+ // The closing tag is handled by ContentObjectTail
return written;
}
#undef CCNB
@@ -240,7 +240,7 @@
class ContentObjectVisitor : public VoidDepthFirstVisitor
{
public:
- virtual void visit (Dtag &n, boost::any param/*should be NdnContentObjectHeader* */)
+ virtual void visit (Dtag &n, boost::any param/*should be ContentObjectHeader* */)
{
// uint32_t n.m_dtag;
// std::list<Ptr<Block> > n.m_nestedBlocks;
@@ -251,7 +251,7 @@
static Uint32tBlobVisitor uint32tBlobVisitor;
static ContentTypeVisitor contentTypeVisitor;
- NdnContentObjectHeader &contentObject = *(boost::any_cast<NdnContentObjectHeader*> (param));
+ ContentObjectHeader &contentObject = *(boost::any_cast<ContentObjectHeader*> (param));
switch (n.m_dtag)
{
@@ -265,7 +265,7 @@
case CCN_DTAG_Name:
{
// process name components
- Ptr<NdnNameComponents> name = Create<NdnNameComponents> ();
+ Ptr<NameComponents> name = Create<NameComponents> ();
BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
{
@@ -337,7 +337,7 @@
throw CcnbDecodingException ();
contentObject.GetSignedInfo ().SetContentType
- (static_cast<NdnContentObjectHeader::ContentType>
+ (static_cast<ContentObjectHeader::ContentType>
(boost::any_cast<uint32_t> ((*n.m_nestedTags.begin())->accept
(contentTypeVisitor))));
break;
@@ -372,7 +372,7 @@
throw CcnbDecodingException ();
// process name components
- Ptr<NdnNameComponents> name = Create<NdnNameComponents> ();
+ Ptr<NameComponents> name = Create<NameComponents> ();
BOOST_FOREACH (Ptr<Block> block, nameTag->m_nestedTags)
{
@@ -394,25 +394,25 @@
};
uint32_t
-NdnContentObjectHeader::Deserialize (Buffer::Iterator start)
+ContentObjectHeader::Deserialize (Buffer::Iterator start)
{
static ContentObjectVisitor contentObjectVisitor;
Buffer::Iterator i = start;
- Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
+ Ptr<Block> root = Block::ParseBlock (i);
root->accept (contentObjectVisitor, this);
return i.GetDistanceFrom (start);
}
TypeId
-NdnContentObjectHeader::GetInstanceTypeId (void) const
+ContentObjectHeader::GetInstanceTypeId (void) const
{
return GetTypeId ();
}
void
-NdnContentObjectHeader::Print (std::ostream &os) const
+ContentObjectHeader::Print (std::ostream &os) const
{
os << "D: " << GetName ();
// os << "<ContentObject><Name>" << GetName () << "</Name><Content>";
@@ -420,40 +420,40 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
-NdnContentObjectTail::NdnContentObjectTail ()
+ContentObjectTail::ContentObjectTail ()
{
}
TypeId
-NdnContentObjectTail::GetTypeId (void)
+ContentObjectTail::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::NdnContentObjectTail")
+ static TypeId tid = TypeId ("ns3::ndn::ContentObjectTail")
.SetParent<Trailer> ()
- .AddConstructor<NdnContentObjectTail> ()
+ .AddConstructor<ContentObjectTail> ()
;
return tid;
}
TypeId
-NdnContentObjectTail::GetInstanceTypeId (void) const
+ContentObjectTail::GetInstanceTypeId (void) const
{
return GetTypeId ();
}
void
-NdnContentObjectTail::Print (std::ostream &os) const
+ContentObjectTail::Print (std::ostream &os) const
{
os << "</Content></ContentObject>";
}
uint32_t
-NdnContentObjectTail::GetSerializedSize (void) const
+ContentObjectTail::GetSerializedSize (void) const
{
return 2;
}
void
-NdnContentObjectTail::Serialize (Buffer::Iterator start) const
+ContentObjectTail::Serialize (Buffer::Iterator start) const
{
Buffer::Iterator i = start;
i.Prev (2); // Trailer interface requires us to go backwards
@@ -463,7 +463,7 @@
}
uint32_t
-NdnContentObjectTail::Deserialize (Buffer::Iterator start)
+ContentObjectTail::Deserialize (Buffer::Iterator start)
{
Buffer::Iterator i = start;
i.Prev (2); // Trailer interface requires us to go backwards
@@ -481,7 +481,7 @@
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
-NdnContentObjectHeader::SignedInfo::SignedInfo ()
+ContentObjectHeader::SignedInfo::SignedInfo ()
: m_publisherPublicKeyDigest (0)
// , m_timestamp
, m_type (DATA)
@@ -492,63 +492,64 @@
}
void
-NdnContentObjectHeader::SignedInfo::SetPublisherPublicKeyDigest (uint32_t digest)
+ContentObjectHeader::SignedInfo::SetPublisherPublicKeyDigest (uint32_t digest)
{
m_publisherPublicKeyDigest = digest;
}
uint32_t
-NdnContentObjectHeader::SignedInfo::GetPublisherPublicKeyDigest () const
+ContentObjectHeader::SignedInfo::GetPublisherPublicKeyDigest () const
{
return m_publisherPublicKeyDigest;
}
void
-NdnContentObjectHeader::SignedInfo::SetTimestamp (const Time ×tamp)
+ContentObjectHeader::SignedInfo::SetTimestamp (const Time ×tamp)
{
m_timestamp = timestamp;
}
Time
-NdnContentObjectHeader::SignedInfo::GetTimestamp () const
+ContentObjectHeader::SignedInfo::GetTimestamp () const
{
return m_timestamp;
}
void
-NdnContentObjectHeader::SignedInfo::SetContentType (NdnContentObjectHeader::ContentType type)
+ContentObjectHeader::SignedInfo::SetContentType (ContentObjectHeader::ContentType type)
{
m_type = type;
}
-NdnContentObjectHeader::ContentType
-NdnContentObjectHeader::SignedInfo::GetContentType () const
+ContentObjectHeader::ContentType
+ContentObjectHeader::SignedInfo::GetContentType () const
{
return m_type;
}
void
-NdnContentObjectHeader::SignedInfo::SetFreshness (const Time &freshness)
+ContentObjectHeader::SignedInfo::SetFreshness (const Time &freshness)
{
m_freshness = freshness;
}
Time
-NdnContentObjectHeader::SignedInfo::GetFreshness () const
+ContentObjectHeader::SignedInfo::GetFreshness () const
{
return m_freshness;
}
void
-NdnContentObjectHeader::SignedInfo::SetKeyLocator (Ptr<const NdnNameComponents> keyLocator)
+ContentObjectHeader::SignedInfo::SetKeyLocator (Ptr<const NameComponents> keyLocator)
{
m_keyLocator = keyLocator;
}
-Ptr<const NdnNameComponents>
-NdnContentObjectHeader::SignedInfo::GetKeyLocator () const
+Ptr<const NameComponents>
+ContentObjectHeader::SignedInfo::GetKeyLocator () const
{
return m_keyLocator;
}
+} // namespace ndn
} // namespace ns3
diff --git a/model/ndn-content-object-header.h b/model/ndn-content-object-header.h
index 0266cc9..64fc3e5 100644
--- a/model/ndn-content-object-header.h
+++ b/model/ndn-content-object-header.h
@@ -34,8 +34,8 @@
#include "ndn-name-components.h"
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
/**
* Ndn XML definition of ContentObject
@@ -51,7 +51,7 @@
* "<ContentObject><Signature>..</Signature><Name>...</Name><SignedInfo>...</SignedInfo><Content>"
*
*/
-class NdnContentObjectHeader : public SimpleRefCount<NdnContentObjectHeader,Header>
+class ContentObjectHeader : public SimpleRefCount<ContentObjectHeader,Header>
{
public:
////////////////////////////////////////////////////////////////////////////
@@ -195,14 +195,14 @@
* Note that only <KeyName> option for the key locator is supported
*/
void
- SetKeyLocator (Ptr<const NdnNameComponents> keyLocator);
+ SetKeyLocator (Ptr<const NameComponents> keyLocator);
/**
* @brief Get key locator
*
* Note that only <KeyName> option for the key locator is supported
*/
- Ptr<const NdnNameComponents>
+ Ptr<const NameComponents>
GetKeyLocator () const;
private:
@@ -211,7 +211,7 @@
ContentType m_type;
Time m_freshness;
// FinalBlockID
- Ptr<const NdnNameComponents> m_keyLocator; // support only <KeyName> option for KeyLocator
+ Ptr<const NameComponents> m_keyLocator; // support only <KeyName> option for KeyLocator
};
////////////////////////////////////////////////////////////////////////////
@@ -226,26 +226,26 @@
*
* Creates a null header
**/
- NdnContentObjectHeader ();
+ ContentObjectHeader ();
/**
* \brief Set content object name
*
- * Sets name of the content object. For example, SetName( NdnNameComponents("prefix")("postfix") );
+ * Sets name of the content object. For example, SetName( NameComponents("prefix")("postfix") );
**/
void
- SetName (const Ptr<NdnNameComponents> &name);
+ SetName (const Ptr<NameComponents> &name);
/**
* @brief Get name of the content object
*/
- const NdnNameComponents&
+ const NameComponents&
GetName () const;
/**
* @brief Get smart pointer to the interest name (to avoid extra memory usage)
*/
- Ptr<const NdnNameComponents>
+ Ptr<const NameComponents>
GetNamePtr () const;
/**
@@ -283,7 +283,7 @@
private:
Signature m_signature;
- Ptr<NdnNameComponents> m_name;
+ Ptr<NameComponents> m_name;
SignedInfo m_signedInfo;
};
@@ -291,10 +291,10 @@
* ContentObjectTail should always be 2 bytes, representing two closing tags:
* "</Content><ContentObject>"
*/
-class NdnContentObjectTail : public Trailer
+class ContentObjectTail : public Trailer
{
public:
- NdnContentObjectTail ();
+ ContentObjectTail ();
//////////////////////////////////////////////////////////////////
static TypeId GetTypeId (void); ///< @brief Get TypeId
@@ -306,66 +306,68 @@
};
-NdnContentObjectHeader::Signature::Signature ()
+ContentObjectHeader::Signature::Signature ()
: m_digestAlgorithm ("99.0")
, m_signatureBits (0)
{
}
const std::string &
-NdnContentObjectHeader::Signature::GetDigestAlgorithm () const
+ContentObjectHeader::Signature::GetDigestAlgorithm () const
{
return m_digestAlgorithm;
}
void
-NdnContentObjectHeader::Signature::SetDigestAlgorithm (const std::string &digestAlgorithm)
+ContentObjectHeader::Signature::SetDigestAlgorithm (const std::string &digestAlgorithm)
{
m_digestAlgorithm = digestAlgorithm;
}
uint32_t
-NdnContentObjectHeader::Signature::GetSignatureBits () const
+ContentObjectHeader::Signature::GetSignatureBits () const
{
return m_signatureBits;
}
inline void
-NdnContentObjectHeader::Signature::SetSignatureBits (uint32_t signature)
+ContentObjectHeader::Signature::SetSignatureBits (uint32_t signature)
{
m_signatureBits = signature;
}
-NdnContentObjectHeader::Signature &
-NdnContentObjectHeader::GetSignature ()
+ContentObjectHeader::Signature &
+ContentObjectHeader::GetSignature ()
{
return m_signature;
}
-const NdnContentObjectHeader::Signature &
-NdnContentObjectHeader::GetSignature () const
+const ContentObjectHeader::Signature &
+ContentObjectHeader::GetSignature () const
{
return m_signature;
}
-NdnContentObjectHeader::SignedInfo &
-NdnContentObjectHeader::GetSignedInfo ()
+ContentObjectHeader::SignedInfo &
+ContentObjectHeader::GetSignedInfo ()
{
return m_signedInfo;
}
-const NdnContentObjectHeader::SignedInfo &
-NdnContentObjectHeader::GetSignedInfo () const
+const ContentObjectHeader::SignedInfo &
+ContentObjectHeader::GetSignedInfo () const
{
return m_signedInfo;
}
/**
+ * @ingroup ndn-exceptions
* @brief Class for ContentObject parsing exception
*/
-class NdnContentObjectHeaderException {};
+class ContentObjectHeaderException {};
+} // namespace ndn
} // namespace ns3
#endif // _NDN_CONTENT_OBJECT_HEADER_H_
diff --git a/model/ndn-face.cc b/model/ndn-face.cc
index 316b1df..936021d 100644
--- a/model/ndn-face.cc
+++ b/model/ndn-face.cc
@@ -35,49 +35,50 @@
#include <boost/ref.hpp>
-NS_LOG_COMPONENT_DEFINE ("NdnFace");
+NS_LOG_COMPONENT_DEFINE ("ndn.Face");
namespace ns3 {
+namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (NdnFace);
+NS_OBJECT_ENSURE_REGISTERED (Face);
TypeId
-NdnFace::GetTypeId ()
+Face::GetTypeId ()
{
- static TypeId tid = TypeId ("ns3::NdnFace")
+ 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 (&NdnFace::m_id),
+ MakeUintegerAccessor (&Face::m_id),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("BucketMax", "Maximum size of leaky bucket",
DoubleValue (-1.0),
- MakeDoubleAccessor (&NdnFace::m_bucketMax),
+ MakeDoubleAccessor (&Face::m_bucketMax),
MakeDoubleChecker<double> ())
.AddAttribute ("BucketLeak", "Normalized bucket leak size",
DoubleValue (0.0),
- MakeDoubleAccessor (&NdnFace::m_bucketLeak),
+ MakeDoubleAccessor (&Face::m_bucketLeak),
MakeDoubleChecker<double> ())
.AddAttribute ("RandomizeLimitChecking", "Whether or not to randomize the limit checking procedure. false (persistent) by default",
BooleanValue (false),
- MakeBooleanAccessor (&NdnFace::m_randomizeLimitChecking),
+ MakeBooleanAccessor (&Face::m_randomizeLimitChecking),
MakeBooleanChecker ())
// .AddAttribute ("MetricTagging", "Enable metric tagging (path-stretch calculation)",
// BooleanValue (false),
- // MakeBooleanAccessor (&NdnFace::m_enableMetricTagging),
+ // MakeBooleanAccessor (&Face::m_enableMetricTagging),
// MakeBooleanChecker ())
.AddTraceSource ("NdnTx", "Transmitted packet trace",
- MakeTraceSourceAccessor (&NdnFace::m_ndnTxTrace))
+ MakeTraceSourceAccessor (&Face::m_txTrace))
.AddTraceSource ("NdnRx", "Received packet trace",
- MakeTraceSourceAccessor (&NdnFace::m_ndnRxTrace))
+ MakeTraceSourceAccessor (&Face::m_rxTrace))
.AddTraceSource ("NdnDrop", "Dropped packet trace",
- MakeTraceSourceAccessor (&NdnFace::m_ndnDropTrace))
+ MakeTraceSourceAccessor (&Face::m_dropTrace))
;
return tid;
}
@@ -87,12 +88,12 @@
* with no IP addresses. Before becoming useable, the user must
* invoke SetUp on them once an Ndn address and mask have been set.
*/
-NdnFace::NdnFace (Ptr<Node> node)
+Face::Face (Ptr<Node> node)
: m_node (node)
, m_bucket (0.0)
, m_bucketMax (-1.0)
, m_bucketLeak (0.0)
- , m_protocolHandler (MakeNullCallback<void,const Ptr<NdnFace>&,const Ptr<const Packet>&> ())
+ , m_protocolHandler (MakeNullCallback<void,const Ptr<Face>&,const Ptr<const Packet>&> ())
, m_ifup (false)
, m_id ((uint32_t)-1)
, m_lastLeakTime (0)
@@ -104,28 +105,28 @@
NS_ASSERT_MSG (node != 0, "node cannot be NULL. Check the code");
}
-NdnFace::~NdnFace ()
+Face::~Face ()
{
NS_LOG_FUNCTION_NOARGS ();
}
-NdnFace::NdnFace (const NdnFace &)
+Face::Face (const Face &)
{
}
-NdnFace& NdnFace::operator= (const NdnFace &)
+Face& Face::operator= (const Face &)
{
return *this;
}
Ptr<Node>
-NdnFace::GetNode () const
+Face::GetNode () const
{
return m_node;
}
void
-NdnFace::RegisterProtocolHandler (ProtocolHandler handler)
+Face::RegisterProtocolHandler (ProtocolHandler handler)
{
NS_LOG_FUNCTION_NOARGS ();
@@ -133,14 +134,14 @@
}
bool
-NdnFace::IsBelowLimit ()
+Face::IsBelowLimit ()
{
NS_LOG_FUNCTION_NOARGS ();
/// \todo Implement tracing, if requested
if (!IsUp ()){
- NS_LOG_INFO("NdnFace is not up.");
+ NS_LOG_INFO("Face is not up.");
return false;
}
@@ -182,14 +183,14 @@
}
bool
-NdnFace::Send (Ptr<Packet> packet)
+Face::Send (Ptr<Packet> packet)
{
NS_LOG_FUNCTION (boost::cref (*this) << packet << packet->GetSize ());
NS_LOG_DEBUG (*packet);
if (!IsUp ())
{
- m_ndnDropTrace (packet);
+ m_dropTrace (packet);
return false;
}
@@ -214,18 +215,18 @@
bool ok = SendImpl (packet);
if (ok)
{
- m_ndnTxTrace (packet);
+ m_txTrace (packet);
return true;
}
else
{
- m_ndnDropTrace (packet);
+ m_dropTrace (packet);
return false;
}
}
bool
-NdnFace::Receive (const Ptr<const Packet> &packet)
+Face::Receive (const Ptr<const Packet> &packet)
{
NS_LOG_FUNCTION (boost::cref (*this) << packet << packet->GetSize ());
@@ -235,14 +236,14 @@
return false;
}
- m_ndnRxTrace (packet);
+ m_rxTrace (packet);
m_protocolHandler (this, packet);
return true;
}
void
-NdnFace::LeakBucket ()
+Face::LeakBucket ()
{
if (m_lastLeakTime.IsZero ())
{
@@ -262,28 +263,28 @@
}
void
-NdnFace::SetBucketMax (double bucket)
+Face::SetBucketMax (double bucket)
{
NS_LOG_FUNCTION (this << bucket);
m_bucketMax = bucket;
}
void
-NdnFace::SetBucketLeak (double leak)
+Face::SetBucketLeak (double leak)
{
NS_LOG_FUNCTION (this << leak);
m_bucketLeak = leak;
}
void
-NdnFace::SetMetric (uint16_t metric)
+Face::SetMetric (uint16_t metric)
{
NS_LOG_FUNCTION (metric);
m_metric = metric;
}
uint16_t
-NdnFace::GetMetric (void) const
+Face::GetMetric (void) const
{
NS_LOG_FUNCTION_NOARGS ();
return m_metric;
@@ -296,21 +297,21 @@
*/
bool
-NdnFace::IsUp (void) const
+Face::IsUp (void) const
{
NS_LOG_FUNCTION_NOARGS ();
return m_ifup;
}
void
-NdnFace::SetUp (bool up/* = true*/)
+Face::SetUp (bool up/* = true*/)
{
NS_LOG_FUNCTION_NOARGS ();
m_ifup = up;
}
bool
-NdnFace::operator== (const NdnFace &face) const
+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");
@@ -319,7 +320,7 @@
}
bool
-NdnFace::operator< (const NdnFace &face) const
+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");
@@ -328,18 +329,19 @@
}
std::ostream&
-NdnFace::Print (std::ostream &os) const
+Face::Print (std::ostream &os) const
{
os << "id=" << GetId ();
return os;
}
std::ostream&
-operator<< (std::ostream& os, const NdnFace &face)
+operator<< (std::ostream& os, const Face &face)
{
face.Print (os);
return os;
}
-}; // namespace ns3
+} // namespace ndn
+} // namespace ns3
diff --git a/model/ndn-face.h b/model/ndn-face.h
index e785ac9..0e98905 100644
--- a/model/ndn-face.h
+++ b/model/ndn-face.h
@@ -33,22 +33,24 @@
class Packet;
class Node;
-
+
+namespace ndn {
+
/**
* \ingroup ndn
* \defgroup ndn-face Faces
*/
/**
* \ingroup ndn-face
- * \brief Virtual class defining Ndn face
+ * \brief Virtual class defining NDN face
*
- * This class defines basic functionality of Ndn face. Face is core
+ * This class defines basic functionality of NDN face. Face is core
* component responsible for actual delivery of data packet to and
- * from Ndn stack
+ * from NDN stack
*
- * \see NdnLocalFace, NdnNetDeviceFace, NdnIpv4Face, NdnUdpFace
+ * \see ndn::LocalFace, ndn::NetDeviceFace, ndn::Ipv4Face, ndn::UdpFace
*/
-class NdnFace : public Object
+class Face : public Object
{
public:
static TypeId
@@ -60,13 +62,13 @@
* \param face Face from which packet has been received
* \param packet Original packet
*/
- typedef Callback<void,const Ptr<NdnFace>&,const Ptr<const Packet>& > ProtocolHandler;
+ typedef Callback<void,const Ptr<Face>&,const Ptr<const Packet>& > ProtocolHandler;
/**
* \brief Default constructor
*/
- NdnFace (Ptr<Node> node);
- virtual ~NdnFace();
+ Face (Ptr<Node> node);
+ virtual ~Face();
/**
* @brief Get node to which this face is associated
@@ -201,7 +203,7 @@
* Internal index is used for comparison.
*/
bool
- operator== (const NdnFace &face) const;
+ operator== (const Face &face) const;
/**
* \brief Compare two faces. Only two faces on the same node could be compared.
@@ -209,7 +211,7 @@
* Internal index is used for comparison.
*/
inline bool
- operator!= (const NdnFace &face) const;
+ operator!= (const Face &face) const;
/**
* \brief Compare two faces. Only two faces on the same node could be compared.
@@ -217,7 +219,7 @@
* Internal index is used for comparison.
*/
bool
- operator< (const NdnFace &face) const;
+ operator< (const Face &face) const;
protected:
/**
@@ -229,8 +231,8 @@
SendImpl (Ptr<Packet> p) = 0;
private:
- NdnFace (const NdnFace &); ///< \brief Disabled copy constructor
- NdnFace& operator= (const NdnFace &); ///< \brief Disabled copy operator
+ Face (const Face &); ///< \brief Disabled copy constructor
+ Face& operator= (const Face &); ///< \brief Disabled copy operator
protected:
// uint16_t m_metric; ///< \brief Routing/forwarding metric
@@ -250,38 +252,38 @@
// bool m_enableMetricTagging;
- TracedCallback<Ptr<const Packet> > m_ndnTxTrace;
- TracedCallback<Ptr<const Packet> > m_ndnRxTrace;
- TracedCallback<Ptr<const Packet> > m_ndnDropTrace;
+ TracedCallback<Ptr<const Packet> > m_txTrace;
+ TracedCallback<Ptr<const Packet> > m_rxTrace;
+ TracedCallback<Ptr<const Packet> > m_dropTrace;
};
-std::ostream& operator<< (std::ostream& os, const NdnFace &face);
+std::ostream& operator<< (std::ostream& os, const Face &face);
inline bool
-operator < (const Ptr<NdnFace> &lhs, const Ptr<NdnFace> &rhs)
+operator < (const Ptr<Face> &lhs, const Ptr<Face> &rhs)
{
return *lhs < *rhs;
}
void
-NdnFace::SetId (uint32_t id)
+Face::SetId (uint32_t id)
{
m_id = id;
}
uint32_t
-NdnFace::GetId () const
+Face::GetId () const
{
return m_id;
}
inline bool
-NdnFace::operator!= (const NdnFace &face) const
+Face::operator!= (const Face &face) const
{
return !(*this == face);
}
-
+} // namespace ndn
} // namespace ns3
-#endif //NDN_FACE_H
+#endif // NDN_FACE_H
diff --git a/model/ndn-global-router.cc b/model/ndn-global-router.cc
index 816dc88..8020f43 100644
--- a/model/ndn-global-router.cc
+++ b/model/ndn-global-router.cc
@@ -20,7 +20,7 @@
#include "ndn-global-router.h"
-#include "ns3/ndn.h"
+#include "ns3/ndn-l3-protocol.h"
#include "ns3/ndn-face.h"
#include "ns3/ndn-name-components.h"
@@ -29,78 +29,79 @@
using namespace boost;
namespace ns3 {
+namespace ndn {
-uint32_t NdnGlobalRouter::m_idCounter = 0;
+uint32_t GlobalRouter::m_idCounter = 0;
-NS_OBJECT_ENSURE_REGISTERED (NdnGlobalRouter);
+NS_OBJECT_ENSURE_REGISTERED (GlobalRouter);
TypeId
-NdnGlobalRouter::GetTypeId ()
+GlobalRouter::GetTypeId ()
{
- static TypeId tid = TypeId ("ns3::NdnGlobalRouter")
+ static TypeId tid = TypeId ("ns3::ndn::GlobalRouter")
.SetGroupName ("Ndn")
.SetParent<Object> ()
;
return tid;
}
-NdnGlobalRouter::NdnGlobalRouter ()
+GlobalRouter::GlobalRouter ()
{
m_id = m_idCounter;
m_idCounter ++;
}
void
-NdnGlobalRouter::NotifyNewAggregate ()
+GlobalRouter::NotifyNewAggregate ()
{
if (m_ndn == 0)
{
- m_ndn = GetObject<Ndn> ();
+ m_ndn = GetObject<L3Protocol> ();
}
Object::NotifyNewAggregate ();
}
uint32_t
-NdnGlobalRouter::GetId () const
+GlobalRouter::GetId () const
{
return m_id;
}
-Ptr<Ndn>
-NdnGlobalRouter::GetNdn () const
+Ptr<L3Protocol>
+GlobalRouter::GetL3Protocol () const
{
return m_ndn;
}
void
-NdnGlobalRouter::AddLocalPrefix (Ptr< NdnNameComponents > prefix)
+GlobalRouter::AddLocalPrefix (Ptr< NameComponents > prefix)
{
m_localPrefixes.push_back (prefix);
}
void
-NdnGlobalRouter::AddIncidency (Ptr< NdnFace > face, Ptr< NdnGlobalRouter > gr)
+GlobalRouter::AddIncidency (Ptr< Face > face, Ptr< GlobalRouter > gr)
{
m_incidencies.push_back (make_tuple (this, face, gr));
}
-NdnGlobalRouter::IncidencyList &
-NdnGlobalRouter::GetIncidencies ()
+GlobalRouter::IncidencyList &
+GlobalRouter::GetIncidencies ()
{
return m_incidencies;
}
-const NdnGlobalRouter::LocalPrefixList &
-NdnGlobalRouter::GetLocalPrefixes () const
+const GlobalRouter::LocalPrefixList &
+GlobalRouter::GetLocalPrefixes () const
{
return m_localPrefixes;
}
// void
-// NdnGlobalRouter::AddIncidencyChannel (Ptr< NdnFace > face, Ptr< Channel > channel)
+// GlobalRouter::AddIncidencyChannel (Ptr< NdnFace > face, Ptr< Channel > channel)
// {
// m_incidenciesChannel.push_back (make_tuple (face, channel));
// }
-}
-
+} // namespace ndn
+} // namespace ns3
diff --git a/model/ndn-global-router.h b/model/ndn-global-router.h
index f1475a3..d277bb8 100644
--- a/model/ndn-global-router.h
+++ b/model/ndn-global-router.h
@@ -30,20 +30,23 @@
namespace ns3 {
class Channel;
-class Ndn;
-class NdnFace;
-class NdnNameComponents;
+
+namespace ndn {
+
+class L3Protocol;
+class Face;
+class NameComponents;
/**
* @brief Class representing global router interface for ndnSIM
*/
-class NdnGlobalRouter : public Object
+class GlobalRouter : public Object
{
public:
/**
* @brief Graph edge
*/
- typedef boost::tuple< Ptr< NdnGlobalRouter >, Ptr< NdnFace >, Ptr< NdnGlobalRouter > > Incidency;
+ typedef boost::tuple< Ptr< GlobalRouter >, Ptr< Face >, Ptr< GlobalRouter > > Incidency;
/**
* @brief List of graph edges
*/
@@ -51,7 +54,7 @@
/**
* @brief List of locally exported prefixes
*/
- typedef std::list< Ptr<NdnNameComponents> > LocalPrefixList;
+ typedef std::list< Ptr<NameComponents> > LocalPrefixList;
/**
* \brief Interface ID
@@ -64,7 +67,7 @@
/**
* @brief Default constructor
*/
- NdnGlobalRouter ();
+ GlobalRouter ();
/**
* @brief Get numeric ID of the node (internally assigned)
@@ -73,25 +76,25 @@
GetId () const;
/**
- * @brief Helper function to get smart pointer to Ndn object (basically, self)
+ * @brief Helper function to get smart pointer to ndn::L3Protocol object (basically, self)
*/
- Ptr<Ndn>
- GetNdn () const;
+ Ptr<L3Protocol>
+ GetL3Protocol () const;
/**
* @brief Add new locally exported prefix
* @param prefix Prefix
*/
void
- AddLocalPrefix (Ptr< NdnNameComponents > prefix);
+ AddLocalPrefix (Ptr< NameComponents > prefix);
/**
* @brief Add edge to the node
* @param face Face of the edge
- * @param ndn NdnGlobalRouter of another node
+ * @param ndn GlobalRouter of another node
*/
void
- AddIncidency (Ptr< NdnFace > face, Ptr< NdnGlobalRouter > ndn);
+ AddIncidency (Ptr< Face > face, Ptr< GlobalRouter > ndn);
/**
* @brief Get list of edges that are connected to this node
@@ -113,7 +116,7 @@
private:
uint32_t m_id;
- Ptr<Ndn> m_ndn;
+ Ptr<L3Protocol> m_ndn;
LocalPrefixList m_localPrefixes;
IncidencyList m_incidencies;
@@ -121,8 +124,8 @@
};
inline bool
-operator == (const NdnGlobalRouter::Incidency &a,
- const NdnGlobalRouter::Incidency &b)
+operator == (const GlobalRouter::Incidency &a,
+ const GlobalRouter::Incidency &b)
{
return a.get<0> () == b.get<0> () &&
a.get<1> () == b.get<1> () &&
@@ -130,12 +133,13 @@
}
inline bool
-operator != (const NdnGlobalRouter::Incidency &a,
- const NdnGlobalRouter::Incidency &b)
+operator != (const GlobalRouter::Incidency &a,
+ const GlobalRouter::Incidency &b)
{
return ! (a == b);
}
-}
+} // namespace ndn
+} // namespace ns3
#endif // NDN_GLOBAL_ROUTER_H
diff --git a/model/ndn-interest-header.cc b/model/ndn-interest-header.cc
index 192cae5..bb6c329 100644
--- a/model/ndn-interest-header.cc
+++ b/model/ndn-interest-header.cc
@@ -30,26 +30,26 @@
#include "../helper/ndn-encoding-helper.h"
#include "../helper/ndn-decoding-helper.h"
-NS_LOG_COMPONENT_DEFINE ("NdnInterestHeader");
+NS_LOG_COMPONENT_DEFINE ("ndn.InterestHeader");
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (NdnInterestHeader);
+NS_OBJECT_ENSURE_REGISTERED (InterestHeader);
TypeId
-NdnInterestHeader::GetTypeId (void)
+InterestHeader::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::NdnInterestHeader")
+ static TypeId tid = TypeId ("ns3::ndn::InterestHeader")
.SetGroupName ("Ndn")
.SetParent<Header> ()
- .AddConstructor<NdnInterestHeader> ()
+ .AddConstructor<InterestHeader> ()
;
return tid;
}
-NdnInterestHeader::NdnInterestHeader ()
+InterestHeader::InterestHeader ()
: m_minSuffixComponents (-1)
, m_maxSuffixComponents (-1)
, m_childSelector (false)
@@ -62,168 +62,168 @@
}
void
-NdnInterestHeader::SetName (const Ptr<NdnNameComponents> &name)
+InterestHeader::SetName (const Ptr<NameComponents> &name)
{
m_name = name;
}
-const NdnNameComponents&
-NdnInterestHeader::GetName () const
+const NameComponents&
+InterestHeader::GetName () const
{
- if (m_name==0) throw NdnInterestHeaderException();
+ if (m_name==0) throw InterestHeaderException();
return *m_name;
}
-Ptr<const NdnNameComponents>
-NdnInterestHeader::GetNamePtr () const
+Ptr<const NameComponents>
+InterestHeader::GetNamePtr () const
{
return m_name;
}
void
-NdnInterestHeader::SetMinSuffixComponents (int32_t value)
+InterestHeader::SetMinSuffixComponents (int32_t value)
{
m_minSuffixComponents = value;
}
int32_t
-NdnInterestHeader::GetMinSuffixComponents () const
+InterestHeader::GetMinSuffixComponents () const
{
return m_minSuffixComponents;
}
void
-NdnInterestHeader::SetMaxSuffixComponents (int32_t value)
+InterestHeader::SetMaxSuffixComponents (int32_t value)
{
m_maxSuffixComponents = value;
}
int32_t
-NdnInterestHeader::GetMaxSuffixComponents () const
+InterestHeader::GetMaxSuffixComponents () const
{
return m_maxSuffixComponents;
}
void
-NdnInterestHeader::SetExclude (const Ptr<NdnNameComponents> &exclude)
+InterestHeader::SetExclude (const Ptr<NameComponents> &exclude)
{
m_exclude = exclude;
}
bool
-NdnInterestHeader::IsEnabledExclude () const
+InterestHeader::IsEnabledExclude () const
{
return m_exclude!=0;
}
-const NdnNameComponents&
-NdnInterestHeader::GetExclude () const
+const NameComponents&
+InterestHeader::GetExclude () const
{
- if (m_exclude==0) throw NdnInterestHeaderException();
+ if (m_exclude==0) throw InterestHeaderException();
return *m_exclude;
}
void
-NdnInterestHeader::SetChildSelector (bool value)
+InterestHeader::SetChildSelector (bool value)
{
m_childSelector = value;
}
bool
-NdnInterestHeader::IsEnabledChildSelector () const
+InterestHeader::IsEnabledChildSelector () const
{
return m_childSelector;
}
void
-NdnInterestHeader::SetAnswerOriginKind (bool value)
+InterestHeader::SetAnswerOriginKind (bool value)
{
m_answerOriginKind = value;
}
bool
-NdnInterestHeader::IsEnabledAnswerOriginKind () const
+InterestHeader::IsEnabledAnswerOriginKind () const
{
return m_answerOriginKind;
}
void
-NdnInterestHeader::SetScope (int8_t scope)
+InterestHeader::SetScope (int8_t scope)
{
m_scope = scope;
}
int8_t
-NdnInterestHeader::GetScope () const
+InterestHeader::GetScope () const
{
return m_scope;
}
void
-NdnInterestHeader::SetInterestLifetime (Time lifetime)
+InterestHeader::SetInterestLifetime (Time lifetime)
{
m_interestLifetime = lifetime;
}
Time
-NdnInterestHeader::GetInterestLifetime () const
+InterestHeader::GetInterestLifetime () const
{
return m_interestLifetime;
}
void
-NdnInterestHeader::SetNonce (uint32_t nonce)
+InterestHeader::SetNonce (uint32_t nonce)
{
m_nonce = nonce;
}
uint32_t
-NdnInterestHeader::GetNonce () const
+InterestHeader::GetNonce () const
{
return m_nonce;
}
void
-NdnInterestHeader::SetNack (uint32_t nackType)
+InterestHeader::SetNack (uint32_t nackType)
{
m_nackType = nackType;
}
uint32_t
-NdnInterestHeader::GetNack () const
+InterestHeader::GetNack () const
{
return m_nackType;
}
uint32_t
-NdnInterestHeader::GetSerializedSize (void) const
+InterestHeader::GetSerializedSize (void) const
{
// unfortunately, we don't know exact header size in advance
- return NdnEncodingHelper::GetSerializedSize (*this);
+ return EncodingHelper::GetSerializedSize (*this);
}
void
-NdnInterestHeader::Serialize (Buffer::Iterator start) const
+InterestHeader::Serialize (Buffer::Iterator start) const
{
- size_t size = NdnEncodingHelper::Serialize (start, *this);
+ size_t size = EncodingHelper::Serialize (start, *this);
NS_UNUSED (size);
NS_LOG_INFO ("Serialize size = " << size);
}
uint32_t
-NdnInterestHeader::Deserialize (Buffer::Iterator start)
+InterestHeader::Deserialize (Buffer::Iterator start)
{
- return NdnDecodingHelper::Deserialize (start, *this); // \todo Debugging is necessary
+ return DecodingHelper::Deserialize (start, *this); // \todo Debugging is necessary
}
TypeId
-NdnInterestHeader::GetInstanceTypeId (void) const
+InterestHeader::GetInstanceTypeId (void) const
{
return GetTypeId ();
}
void
-NdnInterestHeader::Print (std::ostream &os) const
+InterestHeader::Print (std::ostream &os) const
{
os << "I: " << GetName ();
@@ -265,4 +265,6 @@
os << "</Interest>";
}
-}
+} // namespace ndn
+} // namespace ns3
+
diff --git a/model/ndn-interest-header.h b/model/ndn-interest-header.h
index 9b52ca2..c87ff32 100644
--- a/model/ndn-interest-header.h
+++ b/model/ndn-interest-header.h
@@ -33,8 +33,8 @@
#include "ndn-name-components.h"
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
/**
* Ndn XML definition of Interest
@@ -126,7 +126,7 @@
* - InterestLifetime: ?
* - Nonce: 32 bit random integer. If value is 0, will not be serialized
**/
-class NdnInterestHeader : public SimpleRefCount<NdnInterestHeader,Header>
+class InterestHeader : public SimpleRefCount<InterestHeader, Header>
{
public:
/**
@@ -134,7 +134,7 @@
*
* Creates a null header
**/
- NdnInterestHeader ();
+ InterestHeader ();
/**
* \brief Set interest name
@@ -143,7 +143,7 @@
* @param[in] name const pointer to ndnNameComponents object that contains an interest name
**/
void
- SetName (const Ptr<NdnNameComponents> &name);
+ SetName (const Ptr<NameComponents> &name);
/**
@@ -151,13 +151,13 @@
*
* Gets name of the interest.
**/
- const NdnNameComponents&
+ const NameComponents&
GetName () const;
/**
* @brief Get smart pointer to the interest name (to avoid extra memory usage)
*/
- Ptr<const NdnNameComponents>
+ Ptr<const NameComponents>
GetNamePtr () const;
/**
@@ -210,7 +210,7 @@
* @param[in] exclude const pointer to ndnNameComponents to be excluded
**/
void
- SetExclude (const Ptr<NdnNameComponents> &exclude);
+ SetExclude (const Ptr<NameComponents> &exclude);
/**
* \brief Check if interest conatins exclude filter
@@ -222,7 +222,7 @@
/**
* \brief Get exclude filter
*/
- const NdnNameComponents&
+ const NameComponents&
GetExclude () const;
/**
@@ -381,23 +381,25 @@
virtual uint32_t Deserialize (Buffer::Iterator start);
private:
- Ptr<NdnNameComponents> m_name; ///< Interest name
- int32_t m_minSuffixComponents; ///< Minimum suffix components. not used if negative
- int32_t m_maxSuffixComponents; ///< Maximum suffix components. not used if negative
- Ptr<NdnNameComponents> m_exclude; ///< Exclude filter
- bool m_childSelector; ///< Default value for ChildSelector is false
- bool m_answerOriginKind; ///< Default value for AnswerOriginKind is false
- int8_t m_scope; ///< -1 not set, 0 local scope, 1 this host, 2 immediate neighborhood
- Time m_interestLifetime; ///< InterestLifetime
- uint32_t m_nonce; ///< Nonce. not used if zero
- uint32_t m_nackType; ///< Negative Acknowledgement type
+ Ptr<NameComponents> m_name; ///< Interest name
+ int32_t m_minSuffixComponents; ///< Minimum suffix components. not used if negative
+ int32_t m_maxSuffixComponents; ///< Maximum suffix components. not used if negative
+ Ptr<NameComponents> m_exclude; ///< Exclude filter
+ bool m_childSelector; ///< Default value for ChildSelector is false
+ bool m_answerOriginKind; ///< Default value for AnswerOriginKind is false
+ int8_t m_scope; ///< -1 not set, 0 local scope, 1 this host, 2 immediate neighborhood
+ Time m_interestLifetime; ///< InterestLifetime
+ uint32_t m_nonce; ///< Nonce. not used if zero
+ uint32_t m_nackType; ///< Negative Acknowledgement type
};
/**
+ * @ingroup ndn-exceptions
* @brief Class for Interest parsing exception
*/
-class NdnInterestHeaderException {};
+class InterestHeaderException {};
+} // namespace ndn
} // namespace ns3
#endif // _NDN_INTEREST_HEADER_H_
diff --git a/model/ndn-l3-protocol.cc b/model/ndn-l3-protocol.cc
index 62c6241..315ad63 100644
--- a/model/ndn-l3-protocol.cc
+++ b/model/ndn-l3-protocol.cc
@@ -40,43 +40,41 @@
#include "ns3/ndn-face.h"
#include "ns3/ndn-forwarding-strategy.h"
-// #include "fib/ndn-fib-impl.h"
-
#include "ndn-net-device-face.h"
#include <boost/foreach.hpp>
-NS_LOG_COMPONENT_DEFINE ("NdnL3Protocol");
+NS_LOG_COMPONENT_DEFINE ("ndn.L3Protocol");
namespace ns3 {
+namespace ndn {
-const uint16_t NdnL3Protocol::ETHERNET_FRAME_TYPE = 0x7777;
+const uint16_t L3Protocol::ETHERNET_FRAME_TYPE = 0x7777;
-NS_OBJECT_ENSURE_REGISTERED (NdnL3Protocol);
+NS_OBJECT_ENSURE_REGISTERED (L3Protocol);
TypeId
-NdnL3Protocol::GetTypeId (void)
+L3Protocol::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::NdnL3Protocol")
- .SetParent<Ndn> ()
+ static TypeId tid = TypeId ("ns3::ndn::L3Protocol")
.SetGroupName ("ndn")
- .AddConstructor<NdnL3Protocol> ()
+ .AddConstructor<L3Protocol> ()
.AddAttribute ("FaceList", "List of faces associated with ndn stack",
ObjectVectorValue (),
- MakeObjectVectorAccessor (&NdnL3Protocol::m_faces),
- MakeObjectVectorChecker<NdnFace> ())
+ MakeObjectVectorAccessor (&L3Protocol::m_faces),
+ MakeObjectVectorChecker<Face> ())
;
return tid;
}
-NdnL3Protocol::NdnL3Protocol()
+L3Protocol::L3Protocol()
: m_faceCounter (0)
{
NS_LOG_FUNCTION (this);
}
-NdnL3Protocol::~NdnL3Protocol ()
+L3Protocol::~L3Protocol ()
{
NS_LOG_FUNCTION (this);
}
@@ -86,7 +84,7 @@
* by setting the node in the ndn stack
*/
void
-NdnL3Protocol::NotifyNewAggregate ()
+L3Protocol::NotifyNewAggregate ()
{
// not really efficient, but this will work only once
if (m_node == 0)
@@ -95,37 +93,37 @@
if (m_node != 0)
{
// NS_ASSERT_MSG (m_pit != 0 && m_fib != 0 && m_contentStore != 0 && m_forwardingStrategy != 0,
- // "PIT, FIB, and ContentStore should be aggregated before NdnL3Protocol");
+ // "PIT, FIB, and ContentStore should be aggregated before L3Protocol");
NS_ASSERT_MSG (m_forwardingStrategy != 0,
- "Forwarding strategy should be aggregated before NdnL3Protocol");
+ "Forwarding strategy should be aggregated before L3Protocol");
}
}
// if (m_pit == 0)
// {
- // m_pit = GetObject<NdnPit> ();
+ // m_pit = GetObject<Pit> ();
// }
// if (m_fib == 0)
// {
- // m_fib = GetObject<NdnFib> ();
+ // m_fib = GetObject<Fib> ();
// }
if (m_forwardingStrategy == 0)
{
- m_forwardingStrategy = GetObject<NdnForwardingStrategy> ();
+ m_forwardingStrategy = GetObject<ForwardingStrategy> ();
}
// if (m_contentStore == 0)
// {
- // m_contentStore = GetObject<NdnContentStore> ();
+ // m_contentStore = GetObject<ContentStore> ();
// }
- Ndn::NotifyNewAggregate ();
+ Object::NotifyNewAggregate ();
}
void
-NdnL3Protocol::DoDispose (void)
+L3Protocol::DoDispose (void)
{
NS_LOG_FUNCTION (this);
- for (NdnFaceList::iterator i = m_faces.begin (); i != m_faces.end (); ++i)
+ for (FaceList::iterator i = m_faces.begin (); i != m_faces.end (); ++i)
{
*i = 0;
}
@@ -135,18 +133,18 @@
// Force delete on objects
m_forwardingStrategy = 0; // there is a reference to PIT stored in here
- Ndn::DoDispose ();
+ Object::DoDispose ();
}
uint32_t
-NdnL3Protocol::AddFace (const Ptr<NdnFace> &face)
+L3Protocol::AddFace (const Ptr<Face> &face)
{
NS_LOG_FUNCTION (this << &face);
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->RegisterProtocolHandler (MakeCallback (&NdnL3Protocol::Receive, this));
+ face->RegisterProtocolHandler (MakeCallback (&L3Protocol::Receive, this));
m_faces.push_back (face);
m_faceCounter++;
@@ -154,15 +152,15 @@
}
void
-NdnL3Protocol::RemoveFace (Ptr<NdnFace> face)
+L3Protocol::RemoveFace (Ptr<Face> face)
{
// ask face to register in lower-layer stack
- face->RegisterProtocolHandler (MakeNullCallback<void,const Ptr<NdnFace>&,const Ptr<const Packet>&> ());
- Ptr<NdnPit> pit = GetObject<NdnPit> ();
+ face->RegisterProtocolHandler (MakeNullCallback<void,const Ptr<Face>&,const Ptr<const Packet>&> ());
+ Ptr<Pit> pit = GetObject<Pit> ();
// just to be on a safe side. Do the process in two steps
- std::list< Ptr<NdnPitEntry> > entriesToRemoves;
- for (Ptr<NdnPitEntry> pitEntry = pit->Begin (); pitEntry != 0; pitEntry = pit->Next (pitEntry))
+ std::list< Ptr<pit::Entry> > entriesToRemoves;
+ for (Ptr<pit::Entry> pitEntry = pit->Begin (); pitEntry != 0; pitEntry = pit->Next (pitEntry))
{
pitEntry->RemoveAllReferencesToFace (face);
@@ -174,20 +172,20 @@
entriesToRemoves.push_back (pitEntry);
}
}
- BOOST_FOREACH (Ptr<NdnPitEntry> removedEntry, entriesToRemoves)
+ BOOST_FOREACH (Ptr<pit::Entry> removedEntry, entriesToRemoves)
{
pit->MarkErased (removedEntry);
}
- NdnFaceList::iterator face_it = find (m_faces.begin(), m_faces.end(), face);
+ FaceList::iterator face_it = find (m_faces.begin(), m_faces.end(), face);
NS_ASSERT_MSG (face_it != m_faces.end (), "Attempt to remove face that doesn't exist");
m_faces.erase (face_it);
}
-Ptr<NdnFace>
-NdnL3Protocol::GetFace (uint32_t index) const
+Ptr<Face>
+L3Protocol::GetFace (uint32_t index) const
{
- BOOST_FOREACH (const Ptr<NdnFace> &face, m_faces) // this function is not supposed to be called often, so linear search is fine
+ 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;
@@ -195,12 +193,12 @@
return 0;
}
-Ptr<NdnFace>
-NdnL3Protocol::GetFaceByNetDevice (Ptr<NetDevice> netDevice) const
+Ptr<Face>
+L3Protocol::GetFaceByNetDevice (Ptr<NetDevice> netDevice) const
{
- BOOST_FOREACH (const Ptr<NdnFace> &face, m_faces) // this function is not supposed to be called often, so linear search is fine
+ BOOST_FOREACH (const Ptr<Face> &face, m_faces) // this function is not supposed to be called often, so linear search is fine
{
- Ptr<NdnNetDeviceFace> netDeviceFace = DynamicCast<NdnNetDeviceFace> (face);
+ Ptr<NetDeviceFace> netDeviceFace = DynamicCast<NetDeviceFace> (face);
if (netDeviceFace == 0) continue;
if (netDeviceFace->GetNetDevice () == netDevice)
@@ -210,14 +208,14 @@
}
uint32_t
-NdnL3Protocol::GetNFaces (void) const
+L3Protocol::GetNFaces (void) const
{
return m_faces.size ();
}
// Callback from lower layer
void
-NdnL3Protocol::Receive (const Ptr<NdnFace> &face, const Ptr<const Packet> &p)
+L3Protocol::Receive (const Ptr<Face> &face, const Ptr<const Packet> &p)
{
if (!face->IsUp ())
return;
@@ -229,12 +227,12 @@
Ptr<Packet> packet = p->Copy (); // give upper layers a rw copy of the packet
try
{
- NdnHeaderHelper::Type type = NdnHeaderHelper::GetNdnHeaderType (p);
+ HeaderHelper::Type type = HeaderHelper::GetNdnHeaderType (p);
switch (type)
{
- case NdnHeaderHelper::INTEREST:
+ case HeaderHelper::INTEREST:
{
- Ptr<NdnInterestHeader> header = Create<NdnInterestHeader> ();
+ Ptr<InterestHeader> header = Create<InterestHeader> ();
// Deserialization. Exception may be thrown
packet->RemoveHeader (*header);
@@ -247,11 +245,11 @@
// OnInterest (face, header, p/*original packet*/);
break;
}
- case NdnHeaderHelper::CONTENT_OBJECT:
+ case HeaderHelper::CONTENT_OBJECT:
{
- Ptr<NdnContentObjectHeader> header = Create<NdnContentObjectHeader> ();
+ Ptr<ContentObjectHeader> header = Create<ContentObjectHeader> ();
- static NdnContentObjectTail contentObjectTrailer; //there is no data in this object
+ static ContentObjectTail contentObjectTrailer; //there is no data in this object
// Deserialization. Exception may be thrown
packet->RemoveHeader (*header);
@@ -264,413 +262,14 @@
// exception will be thrown if packet is not recognized
}
- catch (NdnUnknownHeaderException)
+ catch (UnknownHeaderException)
{
- NS_ASSERT_MSG (false, "Unknown Ndn header. Should not happen");
- NS_LOG_ERROR ("Unknown Ndn header. Should not happen");
+ NS_ASSERT_MSG (false, "Unknown NDN header. Should not happen");
+ NS_LOG_ERROR ("Unknown NDN header. Should not happen");
return;
}
}
-// void
-// NdnL3Protocol::OnNack (const Ptr<NdnFace> &incomingFace,
-// Ptr<NdnInterestHeader> &header,
-// const Ptr<const Packet> &packet)
-// {
-// NS_LOG_FUNCTION (incomingFace << header << packet);
-// m_inNacks (header, incomingFace);
-// Ptr<NdnPitEntry> pitEntry = m_pit->Lookup (*header);
-// if (pitEntry == 0)
-// {
-// // somebody is doing something bad
-// m_dropNacks (header, NON_DUPLICATED, incomingFace);
-// return;
-// }
-
-// // NdnPitEntryIncomingFaceContainer::type::iterator inFace = pitEntry->GetIncoming ().find (incomingFace);
-// NdnPitEntryOutgoingFaceContainer::type::iterator outFace = pitEntry->GetOutgoing ().find (incomingFace);
-
-// if (outFace == pitEntry->GetOutgoing ().end ())
-// {
-// // NS_ASSERT_MSG (false,
-// // "Node " << GetObject<Node> ()->GetId () << ", outgoing entry should exist for face " << boost::cref(*incomingFace) << "\n" <<
-// // "size: " << pitEntry.GetOutgoing ().size ());
-
-// // m_dropNacks (header, NON_DUPLICATE, incomingFace);
-// return;
-// }
-
-// // This was done in error. Never, never do anything, except normal leakage. This way we ensure that we will not have losses,
-// // at least when there is only one client
-// //
-// // incomingFace->LeakBucketByOnePacket ();
-
-// NS_LOG_ERROR ("Nack on " << boost::cref(*incomingFace));
-
-// pitEntry->SetWaitingInVain (outFace);
-
-// // If NACK is NACK_GIVEUP_PIT, then neighbor gave up trying to and removed it's PIT entry.
-// // So, if we had an incoming entry to this neighbor, then we can remove it now
-
-// if (header->GetNack () == NdnInterestHeader::NACK_GIVEUP_PIT)
-// {
-// pitEntry->RemoveIncoming (incomingFace);
-// }
-
-// pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, NdnFibFaceMetric::NDN_FIB_YELLOW);
-// // StaticCast<NdnFibImpl> (m_fib)->modify (pitEntry->GetFibEntry (),
-// // ll::bind (&NdnFibEntry::UpdateStatus,
-// // ll::_1, incomingFace, NdnFibFaceMetric::NDN_FIB_YELLOW));
-
-// if (pitEntry->GetIncoming ().size () == 0) // interest was actually satisfied
-// {
-// // no need to do anything
-// m_dropNacks (header, AFTER_SATISFIED, incomingFace);
-// return;
-// }
-
-// if (!pitEntry->AreAllOutgoingInVain ()) // not all ougtoing are in vain
-// {
-// NS_LOG_DEBUG ("Not all outgoing are in vain");
-// // suppress
-// // Don't do anything, we are still expecting data from some other face
-// m_dropNacks (header, SUPPRESSED, incomingFace);
-// return;
-// }
-
-// Ptr<Packet> nonNackInterest = Create<Packet> ();
-// header->SetNack (NdnInterestHeader::NORMAL_INTEREST);
-// nonNackInterest->AddHeader (*header);
-
-// bool propagated = m_forwardingStrategy->
-// PropagateInterest (pitEntry, incomingFace, header, nonNackInterest);
-
-// // // ForwardingStrategy will try its best to forward packet to at least one interface.
-// // // If no interests was propagated, then there is not other option for forwarding or
-// // // ForwardingStrategy failed to find it.
-// if (!propagated)
-// {
-// m_dropNacks (header, NO_FACES, incomingFace); // this headers doesn't have NACK flag set
-// GiveUpInterest (pitEntry, header);
-// }
-// }
-
-// Processing Interests
-//
-// // !!! Key point.
-// // !!! All interests should be answerred!!! Either later with data, immediately with data, or immediately with NACK
-// void NdnL3Protocol::OnInterest (const Ptr<NdnFace> &incomingFace,
-// Ptr<NdnInterestHeader> &header,
-// const Ptr<const Packet> &packet)
-// {
-// m_inInterests (header, incomingFace);
-
-// Ptr<NdnPitEntry> pitEntry = m_pit->Lookup (*header);
-// if (pitEntry == 0)
-// {
-// pitEntry = m_pit->Create (header);
-// }
-
-// if (pitEntry == 0)
-// {
-// // if it is still not created, then give up processing
-// m_dropInterests (header, PIT_LIMIT, incomingFace);
-// return;
-// }
-
-// bool isNew = pitEntry->GetIncoming ().size () == 0 && pitEntry->GetOutgoing ().size () == 0;
-// bool isDuplicated = true;
-// if (!pitEntry->IsNonceSeen (header->GetNonce ()))
-// {
-// pitEntry->AddSeenNonce (header->GetNonce ());
-// isDuplicated = false;
-// }
-
-// NS_LOG_FUNCTION (header->GetName () << header->GetNonce () << boost::cref (*incomingFace) << isDuplicated);
-
-// /////////////////////////////////////////////////////////////////////////////////////////
-// /////////////////////////////////////////////////////////////////////////////////////////
-// /////////////////////////////////////////////////////////////////////////////////////////
-// // //
-// // !!!! IMPORTANT CHANGE !!!! Duplicate interests will create incoming face entry !!!! //
-// // //
-// /////////////////////////////////////////////////////////////////////////////////////////
-// /////////////////////////////////////////////////////////////////////////////////////////
-// /////////////////////////////////////////////////////////////////////////////////////////
-
-// // Data is not in cache
-// NdnPitEntry::in_iterator inFace = pitEntry->GetIncoming ().find (incomingFace);
-// NdnPitEntry::out_iterator outFace = pitEntry->GetOutgoing ().find (incomingFace);
-
-// bool isRetransmitted = false;
-
-// if (inFace != pitEntry->GetIncoming ().end ())
-// {
-// // NdnPitEntryIncomingFace.m_arrivalTime keeps track arrival time of the first packet... why?
-
-// isRetransmitted = true;
-// // this is almost definitely a retransmission. But should we trust the user on that?
-// }
-// else
-// {
-// inFace = pitEntry->AddIncoming (incomingFace);
-// }
-// //////////////////////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////////////////////
-
-// if (isDuplicated)
-// {
-// NS_LOG_DEBUG ("Received duplicatie interest on " << *incomingFace);
-// m_dropInterests (header, DUPLICATED, incomingFace);
-
-// /**
-// * This condition will handle "routing" loops and also recently satisfied interests.
-// * Every time interest is satisfied, PIT entry (with empty incoming and outgoing faces)
-// * is kept for another small chunk of time.
-// */
-
-// if (m_nacksEnabled)
-// {
-// NS_LOG_DEBUG ("Sending NACK_LOOP");
-// header->SetNack (NdnInterestHeader::NACK_LOOP);
-// Ptr<Packet> nack = Create<Packet> ();
-// nack->AddHeader (*header);
-
-// incomingFace->Send (nack);
-// m_outNacks (header, incomingFace);
-// }
-
-// return;
-// }
-
-// Ptr<Packet> contentObject;
-// Ptr<const NdnContentObjectHeader> contentObjectHeader; // used for tracing
-// Ptr<const Packet> payload; // used for tracing
-// tie (contentObject, contentObjectHeader, payload) = m_contentStore->Lookup (header);
-// if (contentObject != 0)
-// {
-// NS_ASSERT (contentObjectHeader != 0);
-// NS_LOG_LOGIC("Found in cache");
-
-// OnDataDelayed (contentObjectHeader, payload, contentObject);
-// return;
-// }
-
-// // update PIT entry lifetime
-// pitEntry->UpdateLifetime (header->GetInterestLifetime ());
-
-// if (outFace != pitEntry->GetOutgoing ().end ())
-// {
-// NS_LOG_DEBUG ("Non duplicate interests from the face we have sent interest to. Don't suppress");
-// // got a non-duplicate interest from the face we have sent interest to
-// // Probably, there is no point in waiting data from that face... Not sure yet
-
-// // If we're expecting data from the interface we got the interest from ("producer" asks us for "his own" data)
-// // Mark interface YELLOW, but keep a small hope that data will come eventually.
-
-// // ?? not sure if we need to do that ?? ...
-
-// pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, NdnFibFaceMetric::NDN_FIB_YELLOW);
-// // StaticCast<NdnFibImpl> (m_fib)->modify(pitEntry->GetFibEntry (),
-// // ll::bind (&NdnFibEntry::UpdateStatus,
-// // ll::_1, incomingFace, NdnFibFaceMetric::NDN_FIB_YELLOW));
-// }
-// else
-// if (!isNew && !isRetransmitted)
-// {
-// // Suppress this interest if we're still expecting data from some other face
-// NS_LOG_DEBUG ("Suppress interests");
-// m_dropInterests (header, SUPPRESSED, incomingFace);
-// return;
-// }
-
-// /////////////////////////////////////////////////////////////////////
-// // Propagate
-// /////////////////////////////////////////////////////////////////////
-
-// bool propagated = m_forwardingStrategy->
-// PropagateInterest (pitEntry, incomingFace, header, packet);
-
-// if (!propagated && isRetransmitted) //give another chance if retransmitted
-// {
-// // increase max number of allowed retransmissions
-// pitEntry->IncreaseAllowedRetxCount ();
-
-// // try again
-// propagated = m_forwardingStrategy->
-// PropagateInterest (pitEntry, incomingFace, header, packet);
-// }
-
-// // ForwardingStrategy will try its best to forward packet to at least one interface.
-// // If no interests was propagated, then there is not other option for forwarding or
-// // ForwardingStrategy failed to find it.
-// if (!propagated)
-// {
-// NS_LOG_DEBUG ("Not propagated");
-// m_dropInterests (header, NO_FACES, incomingFace);
-// GiveUpInterest (pitEntry, header);
-// }
-// }
-
-// void
-// NdnL3Protocol::OnDataDelayed (Ptr<const NdnContentObjectHeader> header,
-// Ptr<const Packet> payload,
-// const Ptr<const Packet> &packet)
-// {
-// // 1. Lookup PIT entry
-// Ptr<NdnPitEntry> pitEntry = m_pit->Lookup (*header);
-// if (pitEntry != 0)
-// {
-// //satisfy all pending incoming Interests
-// BOOST_FOREACH (const NdnPitEntryIncomingFace &incoming, pitEntry->GetIncoming ())
-// {
-// incoming.m_face->Send (packet->Copy ());
-// m_outData (header, payload, false, incoming.m_face);
-// NS_LOG_DEBUG ("Satisfy " << *incoming.m_face);
-
-// // successfull forwarded data trace
-// }
-
-// if (pitEntry->GetIncoming ().size () > 0)
-// {
-// // All incoming interests are satisfied. Remove them
-// pitEntry->ClearIncoming ();
-
-// // Remove all outgoing faces
-// pitEntry->ClearOutgoing ();
-
-// // Set pruning timout on PIT entry (instead of deleting the record)
-// m_pit->MarkErased (pitEntry);
-// }
-// }
-// else
-// {
-// NS_LOG_DEBUG ("Pit entry not found (was satisfied and removed before)");
-// return; // do not process unsoliced data packets
-// }
-// }
-
-// // Processing ContentObjects
-// void
-// NdnL3Protocol::OnData (const Ptr<NdnFace> &incomingFace,
-// Ptr<NdnContentObjectHeader> &header,
-// Ptr<Packet> &payload,
-// const Ptr<const Packet> &packet)
-// {
-
-// NS_LOG_FUNCTION (incomingFace << header->GetName () << payload << packet);
-// m_inData (header, payload, incomingFace);
-
-// // 1. Lookup PIT entry
-// Ptr<NdnPitEntry> pitEntry = m_pit->Lookup (*header);
-// if (pitEntry != 0)
-// {
-// // Note that with MultiIndex we need to modify entries indirectly
-
-// NdnPitEntry::out_iterator out = pitEntry->GetOutgoing ().find (incomingFace);
-
-// // If we have sent interest for this data via this face, then update stats.
-// if (out != pitEntry->GetOutgoing ().end ())
-// {
-// pitEntry->GetFibEntry ()->UpdateFaceRtt (incomingFace, Simulator::Now () - out->m_sendTime);
-// // StaticCast<NdnFibImpl> (m_fib)->modify (pitEntry->GetFibEntry (),
-// // ll::bind (&NdnFibEntry::UpdateFaceRtt,
-// // ll::_1,
-// // incomingFace,
-// // Simulator::Now () - out->m_sendTime));
-// }
-// else
-// {
-// // Unsolicited data, but we're interested in it... should we get it?
-// // Potential hole for attacks
-
-// if (m_cacheUnsolicitedData)
-// {
-// // Optimistically add or update entry in the content store
-// m_contentStore->Add (header, payload);
-// }
-// else
-// {
-// NS_LOG_ERROR ("Node "<< m_node->GetId() <<
-// ". PIT entry for "<< header->GetName ()<<" is valid, "
-// "but outgoing entry for interface "<< boost::cref(*incomingFace) <<" doesn't exist\n");
-// }
-// // ignore unsolicited data
-// return;
-// }
-
-// // Update metric status for the incoming interface in the corresponding FIB entry
-// pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, NdnFibFaceMetric::NDN_FIB_GREEN);
-// // StaticCast<NdnFibImpl>(m_fib)->modify (pitEntry->GetFibEntry (),
-// // ll::bind (&NdnFibEntry::UpdateStatus, ll::_1,
-// // incomingFace, NdnFibFaceMetric::NDN_FIB_GREEN));
-
-// // Add or update entry in the content store
-// m_contentStore->Add (header, payload);
-
-// pitEntry->RemoveIncoming (incomingFace);
-
-// if (pitEntry->GetIncoming ().size () == 0)
-// {
-// // Set pruning timout on PIT entry (instead of deleting the record)
-// m_pit->MarkErased (pitEntry);
-// }
-// else
-// {
-// OnDataDelayed (header, payload, packet);
-// }
-// }
-// else
-// {
-// NS_LOG_DEBUG ("Pit entry not found");
-// if (m_cacheUnsolicitedData)
-// {
-// // Optimistically add or update entry in the content store
-// m_contentStore->Add (header, payload);
-// }
-// else
-// {
-// // Drop data packet if PIT entry is not found
-// // (unsolicited data packets should not "poison" content store)
-
-// //drop dulicated or not requested data packet
-// m_dropData (header, payload, UNSOLICITED, incomingFace);
-// }
-// return; // do not process unsoliced data packets
-// }
-// }
-
-// void
-// NdnL3Protocol::GiveUpInterest (Ptr<NdnPitEntry> pitEntry,
-// Ptr<NdnInterestHeader> header)
-// {
-// NS_LOG_FUNCTION (this);
-
-// if (m_nacksEnabled)
-// {
-// Ptr<Packet> packet = Create<Packet> ();
-// header->SetNack (NdnInterestHeader::NACK_GIVEUP_PIT);
-// packet->AddHeader (*header);
-
-// BOOST_FOREACH (const NdnPitEntryIncomingFace &incoming, pitEntry->GetIncoming ())
-// {
-// NS_LOG_DEBUG ("Send NACK for " << boost::cref (header->GetName ()) << " to " << boost::cref (*incoming.m_face));
-// incoming.m_face->Send (packet->Copy ());
-
-// m_outNacks (header, incoming.m_face);
-// }
-
-// // All incoming interests cannot be satisfied. Remove them
-// pitEntry->ClearIncoming ();
-
-// // Remove also outgoing
-// pitEntry->ClearOutgoing ();
-
-// // Set pruning timout on PIT entry (instead of deleting the record)
-// m_pit->MarkErased (pitEntry);
-// }
-// }
-
+} //namespace ndn
} //namespace ns3
diff --git a/model/ndn-l3-protocol.h b/model/ndn-l3-protocol.h
index 3b1897d..372ac6a 100644
--- a/model/ndn-l3-protocol.h
+++ b/model/ndn-l3-protocol.h
@@ -28,42 +28,43 @@
#include "ns3/net-device.h"
#include "ns3/nstime.h"
-// #include "ndn-content-store.h"
-// #include "ndn-pit.h"
-// #include "ndn-fib.h"
-
-#include "ndn.h"
-
namespace ns3 {
class Packet;
class NetDevice;
class Node;
-class NdnFace;
-class NdnRoute;
-class NdnForwardingStrategy;
class Header;
-class NdnInterestHeader;
-class NdnContentObjectHeader;
-
+namespace ndn {
+
+class Face;
+class ForwardingStrategy;
+class InterestHeader;
+class ContentObjectHeader;
+
+/**
+ * \defgroup ndn ndnSIM: NDN simulation module
+ *
+ * This is a simplified modular implementation of NDN protocol
+ */
/**
* \ingroup ndn
- * \brief Actual implementation of the Ndn network layer
- *
- * \todo This description is incorrect. Should be changed accordingly
+ * \brief Implementation network-layer of NDN stack
*
- * This class contains two distinct groups of trace sources. The
- * trace sources 'Rx' and 'Tx' are called, respectively, immediately
- * after receiving from the NetDevice and immediately before sending
- * to a NetDevice for transmitting a packet. These are low level
- * trace sources that include the NdnHeader already serialized into
- * the packet. In contrast, the Drop, SendOutgoing, UnicastForward,
- * and LocalDeliver trace sources are slightly higher-level and pass
- * around the NdnHeader as an explicit parameter and not as part of
- * the packet.
+ * This class defines the API to manipulate the following aspects of
+ * 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.
+ *
+ * In addition, this class defines NDN packet coding constants
+ *
+ * \see Face, ForwardingStrategy
*/
-class NdnL3Protocol : public Ndn
+class L3Protocol :
+ public Object
{
public:
/**
@@ -80,72 +81,52 @@
/**
* \brief Default constructor. Creates an empty stack without forwarding strategy set
*/
- NdnL3Protocol();
- virtual ~NdnL3Protocol ();
+ L3Protocol();
+ virtual ~L3Protocol ();
- ////////////////////////////////////////////////////////////////////
- // functions defined in base class Ndn
-
+ /**
+ * \brief Add face to Ndn stack
+ *
+ * \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<NdnFace> &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;
- virtual Ptr<NdnFace>
+ /**
+ * \brief Get face by face index
+ * \param face The face number of an Ndn interface.
+ * \returns The NdnFace associated with the Ndn face number.
+ */
+ virtual Ptr<Face>
GetFace (uint32_t face) const;
+ /**
+ * \brief Remove face from ndn stack (remove callbacks)
+ */
virtual void
- RemoveFace (Ptr<NdnFace> face);
+ RemoveFace (Ptr<Face> face);
- virtual Ptr<NdnFace>
+ /**
+ * \brief Get face for NetDevice
+ */
+ virtual Ptr<Face>
GetFaceByNetDevice (Ptr<NetDevice> netDevice) const;
-
- // void ScheduleLeakage();
+
private:
void
- Receive (const Ptr<NdnFace> &face, const Ptr<const Packet> &p);
-
- // /**
- // * \brief Actual processing of incoming Ndn interests. Note, interests do not have payload
- // *
- // * Processing Interest packets
- // * @param face incoming face
- // * @param header deserialized Interest header
- // * @param packet original packet
- // */
- // void
- // OnInterest (const Ptr<NdnFace> &face,
- // Ptr<NdnInterestHeader> &header,
- // const Ptr<const Packet> &p);
-
- // /**
- // * \brief Processing of incoming Ndn NACKs. Note, these packets, like interests, do not have payload
- // *
- // * Processing NACK packets
- // * @param face incoming face
- // * @param header deserialized Interest header
- // * @param packet original packet
- // */
- // void
- // OnNack (const Ptr<NdnFace> &face,
- // Ptr<NdnInterestHeader> &header,
- // const Ptr<const Packet> &p);
-
- // /**
- // * \brief Actual processing of incoming Ndn content objects
- // *
- // * Processing ContentObject packets
- // * @param face incoming face
- // * @param header deserialized ContentObject header
- // * @param payload data packet payload
- // * @param packet original packet
- // */
- // void
- // OnData (const Ptr<NdnFace> &face,
- // Ptr<NdnContentObjectHeader> &header,
- // Ptr<Packet> &payload,
- // const Ptr<const Packet> &packet);
+ Receive (const Ptr<Face> &face, const Ptr<const Packet> &p);
protected:
virtual void DoDispose (void); ///< @brief Do cleanup
@@ -157,31 +138,20 @@
virtual void NotifyNewAggregate ();
private:
- NdnL3Protocol(const NdnL3Protocol &); ///< copy constructor is disabled
- NdnL3Protocol &operator = (const NdnL3Protocol &); ///< copy operator is disabled
-
- // void
- // GiveUpInterest (Ptr<NdnPitEntry> pitEntry,
- // Ptr<NdnInterestHeader> header);
-
- // void
- // OnDataDelayed (Ptr<const NdnContentObjectHeader> header,
- // Ptr<const Packet> payload,
- // const Ptr<const Packet> &packet);
+ 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
- typedef std::vector<Ptr<NdnFace> > NdnFaceList;
- NdnFaceList m_faces; ///< \brief list of faces that belongs to ndn stack on this node
+ typedef std::vector<Ptr<Face> > FaceList;
+ 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<NdnForwardingStrategy> m_forwardingStrategy; ///< \brief smart pointer to the selected forwarding strategy
-
- // bool m_nacksEnabled;
- // bool m_cacheUnsolicitedData;
+ Ptr<ForwardingStrategy> m_forwardingStrategy; ///< \brief smart pointer to the selected forwarding strategy
};
-
-} // Namespace ns3
+
+} // namespace ndn
+} // namespace ns3
#endif /* NDN_L3_PROTOCOL_H */
diff --git a/model/ndn-name-components-hash-helper.h b/model/ndn-name-components-hash-helper.h
deleted file mode 100644
index c773580..0000000
--- a/model/ndn-name-components-hash-helper.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#ifndef NDN_HASH_HELPER_H
-#define NDN_HASH_HELPER_H
-
-#include <string>
-#include <boost/foreach.hpp>
-#include "ndn-name-components.h"
-
-namespace ns3
-{
-
-/**
- * \ingroup ndn-helpers
- * \brief Helper providing hash value for the name prefix
- *
- * The whole prefix is considered as a long string with '/' delimiters
- *
- * \todo Testing is required to determine if this hash function
- * actually provides good hash results
- */
-struct NdnPrefixHash : public std::unary_function<NdnNameComponents, std::size_t>
-{
- /**
- * @brief Compute hash of the name prefix
- */
- std::size_t
- operator() (const NdnNameComponents &prefix) const
- {
- std::size_t hash = 23;
- BOOST_FOREACH (const std::string &str, prefix.GetComponents ())
- {
- hash += str.size ();
- hash = ((hash << 6) ^ (hash >> 27)) + '/';
- BOOST_FOREACH (char c, str)
- {
- hash = ((hash << 6) ^ (hash >> 27)) + c;
- }
- }
- return hash;
- }
-};
-} // namespace ns3
-
-#endif // NDN_HASH_HELPER_H
diff --git a/model/ndn-name-components.cc b/model/ndn-name-components.cc
index 96d40ec..d5ac498 100644
--- a/model/ndn-name-components.cc
+++ b/model/ndn-name-components.cc
@@ -27,17 +27,18 @@
using namespace std;
-NS_LOG_COMPONENT_DEFINE ("NdnNameComponents");
+NS_LOG_COMPONENT_DEFINE ("ndn.NameComponents");
namespace ns3 {
+namespace ndn {
-ATTRIBUTE_HELPER_CPP (NdnNameComponents);
+ATTRIBUTE_HELPER_CPP (NameComponents);
-NdnNameComponents::NdnNameComponents (/* root */)
+NameComponents::NameComponents (/* root */)
{
}
-NdnNameComponents::NdnNameComponents (const std::list<boost::reference_wrapper<const std::string> > &components)
+NameComponents::NameComponents (const std::list<boost::reference_wrapper<const std::string> > &components)
{
BOOST_FOREACH (const boost::reference_wrapper<const std::string> &component, components)
{
@@ -45,13 +46,13 @@
}
}
-NdnNameComponents::NdnNameComponents (const std::string &prefix)
+NameComponents::NameComponents (const std::string &prefix)
{
istringstream is (prefix);
is >> *this;
}
-NdnNameComponents::NdnNameComponents (const char *prefix)
+NameComponents::NameComponents (const char *prefix)
{
NS_ASSERT (prefix != 0);
@@ -60,13 +61,13 @@
}
const std::list<std::string> &
-NdnNameComponents::GetComponents () const
+NameComponents::GetComponents () const
{
return m_prefix;
}
std::string
-NdnNameComponents::GetLastComponent () const
+NameComponents::GetLastComponent () const
{
if (m_prefix.size () == 0)
{
@@ -77,7 +78,7 @@
}
std::list<boost::reference_wrapper<const std::string> >
-NdnNameComponents::GetSubComponents (size_t num) const
+NameComponents::GetSubComponents (size_t num) const
{
NS_ASSERT_MSG (0<=num && num<=m_prefix.size (), "Invalid number of subcomponents requested");
@@ -91,10 +92,10 @@
return subComponents;
}
-NdnNameComponents
-NdnNameComponents::cut (size_t minusComponents) const
+NameComponents
+NameComponents::cut (size_t minusComponents) const
{
- NdnNameComponents retval;
+ NameComponents retval;
std::list<std::string>::const_iterator component = m_prefix.begin ();
for (uint32_t i = 0; i < m_prefix.size () - minusComponents; i++, component++)
{
@@ -105,7 +106,7 @@
}
void
-NdnNameComponents::Print (std::ostream &os) const
+NameComponents::Print (std::ostream &os) const
{
for (const_iterator i=m_prefix.begin(); i!=m_prefix.end(); i++)
{
@@ -115,14 +116,14 @@
}
std::ostream &
-operator << (std::ostream &os, const NdnNameComponents &components)
+operator << (std::ostream &os, const NameComponents &components)
{
components.Print (os);
return os;
}
std::istream &
-operator >> (std::istream &is, NdnNameComponents &components)
+operator >> (std::istream &is, NameComponents &components)
{
istream_iterator<char> eos; // end of stream
@@ -148,5 +149,5 @@
return is;
}
-}
-
+} // ndn
+} // ns3
diff --git a/model/ndn-name-components.h b/model/ndn-name-components.h
index 553c140..4a479ac 100644
--- a/model/ndn-name-components.h
+++ b/model/ndn-name-components.h
@@ -34,6 +34,7 @@
#include <boost/ref.hpp>
namespace ns3 {
+namespace ndn {
/**
* \ingroup ndn
@@ -44,7 +45,7 @@
* There are no restrictions on what byte sequences may be used.
* The Name element in an Interest is often referred to with the term name prefix or simply prefix.
*/
-class NdnNameComponents : public SimpleRefCount<NdnNameComponents>
+class NameComponents : public SimpleRefCount<NameComponents>
{
public:
typedef std::list<std::string>::iterator iterator;
@@ -54,28 +55,28 @@
* \brief Constructor
* Creates a prefix with zero components (can be looked as root "/")
*/
- NdnNameComponents ();
+ NameComponents ();
/**
* \brief Constructor
* Creates a prefix from a list of strings where every string represents a prefix component
* @param[in] components A list of strings
*/
- NdnNameComponents (const std::list<boost::reference_wrapper<const std::string> > &components);
+ NameComponents (const std::list<boost::reference_wrapper<const std::string> > &components);
/**
* @brief Constructor
* Creates a prefix from the string (string is parsed using operator>>)
* @param[in] prefix A string representation of a prefix
*/
- NdnNameComponents (const std::string &prefix);
+ NameComponents (const std::string &prefix);
/**
* @brief Constructor
* Creates a prefix from the string (string is parsed using operator>>)
* @param[in] prefix A string representation of a prefix
*/
- NdnNameComponents (const char *prefix);
+ NameComponents (const char *prefix);
/**
* \brief Generic Add method
@@ -91,7 +92,7 @@
* The object of type T will be appended to the list of components
*/
template<class T>
- inline NdnNameComponents&
+ inline NameComponents&
operator () (const T &value);
/**
@@ -117,7 +118,7 @@
/**
* @brief Get prefix of the name, containing less minusComponents right components
*/
- NdnNameComponents
+ NameComponents
cut (size_t minusComponents) const;
/**
@@ -127,7 +128,7 @@
void Print (std::ostream &os) const;
/**
- * \brief Returns the size of NdnNameComponents
+ * \brief Returns the size of NameComponents
*/
inline size_t
size () const;
@@ -157,16 +158,16 @@
end () const;
/**
- * \brief Equality operator for NdnNameComponents
+ * \brief Equality operator for NameComponents
*/
inline bool
- operator== (const NdnNameComponents &prefix) const;
+ operator== (const NameComponents &prefix) const;
/**
- * \brief Less than operator for NdnNameComponents
+ * \brief Less than operator for NameComponents
*/
inline bool
- operator< (const NdnNameComponents &prefix) const;
+ operator< (const NameComponents &prefix) const;
typedef std::string partial_type;
@@ -178,26 +179,26 @@
* \brief Print out name components separated by slashes, e.g., /first/second/third
*/
std::ostream &
-operator << (std::ostream &os, const NdnNameComponents &components);
+operator << (std::ostream &os, const NameComponents &components);
/**
* \brief Read components from input and add them to components. Will read input stream till eof
* Substrings separated by slashes will become separate components
*/
std::istream &
-operator >> (std::istream &is, NdnNameComponents &components);
+operator >> (std::istream &is, NameComponents &components);
/**
- * \brief Returns the size of NdnNameComponents object
+ * \brief Returns the size of NameComponents object
*/
size_t
-NdnNameComponents::size () const
+NameComponents::size () const
{
return m_prefix.size ();
}
-NdnNameComponents::iterator
-NdnNameComponents::begin ()
+NameComponents::iterator
+NameComponents::begin ()
{
return m_prefix.begin ();
}
@@ -205,8 +206,8 @@
/**
* @brief Get read-only begin() iterator
*/
-NdnNameComponents::const_iterator
-NdnNameComponents::begin () const
+NameComponents::const_iterator
+NameComponents::begin () const
{
return m_prefix.begin ();
}
@@ -214,8 +215,8 @@
/**
* @brief Get read-write end() iterator
*/
-NdnNameComponents::iterator
-NdnNameComponents::end ()
+NameComponents::iterator
+NameComponents::end ()
{
return m_prefix.end ();
}
@@ -223,8 +224,8 @@
/**
* @brief Get read-only end() iterator
*/
-NdnNameComponents::const_iterator
-NdnNameComponents::end () const
+NameComponents::const_iterator
+NameComponents::end () const
{
return m_prefix.end ();
}
@@ -235,8 +236,8 @@
* The object of type T will be appended to the list of components
*/
template<class T>
-NdnNameComponents&
-NdnNameComponents::operator () (const T &value)
+NameComponents&
+NameComponents::operator () (const T &value)
{
Add (value);
return *this;
@@ -249,7 +250,7 @@
*/
template<class T>
void
-NdnNameComponents::Add (const T &value)
+NameComponents::Add (const T &value)
{
std::ostringstream os;
os << value;
@@ -257,10 +258,10 @@
}
/**
- * \brief Equality operator for NdnNameComponents
+ * \brief Equality operator for NameComponents
*/
bool
-NdnNameComponents::operator== (const NdnNameComponents &prefix) const
+NameComponents::operator== (const NameComponents &prefix) const
{
if (m_prefix.size () != prefix.m_prefix.size ())
return false;
@@ -269,17 +270,19 @@
}
/**
- * \brief Less than operator for NdnNameComponents
+ * \brief Less than operator for NameComponents
*/
bool
-NdnNameComponents::operator< (const NdnNameComponents &prefix) const
+NameComponents::operator< (const NameComponents &prefix) const
{
return std::lexicographical_compare (m_prefix.begin (), m_prefix.end (),
prefix.m_prefix.begin (), prefix.m_prefix.end ());
}
-ATTRIBUTE_HELPER_HEADER (NdnNameComponents);
+ATTRIBUTE_HELPER_HEADER (NameComponents);
+
+} // namespace ndn
} // namespace ns3
#endif // _NDN_NAME_COMPONENTS_H_
diff --git a/model/ndn-net-device-face.cc b/model/ndn-net-device-face.cc
index 7baa363..f5f38a0 100644
--- a/model/ndn-net-device-face.cc
+++ b/model/ndn-net-device-face.cc
@@ -28,19 +28,21 @@
#include "ns3/node.h"
#include "ns3/pointer.h"
+// #include "ns3/address.h"
#include "ns3/point-to-point-net-device.h"
#include "ns3/channel.h"
#include "ns3/ndn-name-components.h"
-NS_LOG_COMPONENT_DEFINE ("NdnNetDeviceFace");
+NS_LOG_COMPONENT_DEFINE ("ndn.NetDeviceFace");
namespace ns3 {
+namespace ndn {
TypeId
-NdnNetDeviceFace::GetTypeId ()
+NetDeviceFace::GetTypeId ()
{
- static TypeId tid = TypeId ("ns3::NdnNetDeviceFace")
- .SetParent<NdnFace> ()
+ static TypeId tid = TypeId ("ns3::ndn::NetDeviceFace")
+ .SetParent<Face> ()
.SetGroupName ("Ndn")
;
return tid;
@@ -50,46 +52,46 @@
* By default, Ndn face are created in the "down" state. Before
* becoming useable, the user must invoke SetUp on the face
*/
-NdnNetDeviceFace::NdnNetDeviceFace (Ptr<Node> node, const Ptr<NetDevice> &netDevice)
- : NdnFace (node)
+NetDeviceFace::NetDeviceFace (Ptr<Node> node, const Ptr<NetDevice> &netDevice)
+ : Face (node)
, m_netDevice (netDevice)
{
NS_LOG_FUNCTION (this << netDevice);
SetMetric (1); // default metric
- NS_ASSERT_MSG (m_netDevice != 0, "NdnNetDeviceFace needs to be assigned a valid NetDevice");
+ NS_ASSERT_MSG (m_netDevice != 0, "NetDeviceFace needs to be assigned a valid NetDevice");
}
-NdnNetDeviceFace::~NdnNetDeviceFace ()
+NetDeviceFace::~NetDeviceFace ()
{
NS_LOG_FUNCTION_NOARGS ();
}
-NdnNetDeviceFace& NdnNetDeviceFace::operator= (const NdnNetDeviceFace &)
+NetDeviceFace& NetDeviceFace::operator= (const NetDeviceFace &)
{
return *this;
}
Ptr<NetDevice>
-NdnNetDeviceFace::GetNetDevice () const
+NetDeviceFace::GetNetDevice () const
{
return m_netDevice;
}
void
-NdnNetDeviceFace::RegisterProtocolHandler (ProtocolHandler handler)
+NetDeviceFace::RegisterProtocolHandler (ProtocolHandler handler)
{
NS_LOG_FUNCTION (this);
- NdnFace::RegisterProtocolHandler (handler);
+ Face::RegisterProtocolHandler (handler);
- m_node->RegisterProtocolHandler (MakeCallback (&NdnNetDeviceFace::ReceiveFromNetDevice, this),
- NdnL3Protocol::ETHERNET_FRAME_TYPE, m_netDevice, true/*promiscuous mode*/);
+ m_node->RegisterProtocolHandler (MakeCallback (&NetDeviceFace::ReceiveFromNetDevice, this),
+ L3Protocol::ETHERNET_FRAME_TYPE, m_netDevice, true/*promiscuous mode*/);
}
bool
-NdnNetDeviceFace::SendImpl (Ptr<Packet> packet)
+NetDeviceFace::SendImpl (Ptr<Packet> packet)
{
NS_LOG_FUNCTION (this << packet);
@@ -99,18 +101,18 @@
<< " for Ndn; fragmentation not supported");
bool ok = m_netDevice->Send (packet, m_netDevice->GetBroadcast (),
- NdnL3Protocol::ETHERNET_FRAME_TYPE);
+ L3Protocol::ETHERNET_FRAME_TYPE);
return ok;
}
// callback
void
-NdnNetDeviceFace::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);
@@ -118,15 +120,20 @@
std::ostream&
-NdnNetDeviceFace::Print (std::ostream& os) const
+NetDeviceFace::Print (std::ostream& os) const
{
+#ifdef NS3_LOG_ENABLE
os << "dev[" << GetNode ()->GetId () << "]=net(" << GetId () << ",";
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 () << ")";
+#endif
return os;
}
-}; // namespace ns3
+} // namespace ndnsim
+} // namespace ns3
diff --git a/model/ndn-net-device-face.h b/model/ndn-net-device-face.h
index bc132f7..651a7ae 100644
--- a/model/ndn-net-device-face.h
+++ b/model/ndn-net-device-face.h
@@ -25,8 +25,7 @@
#include "ns3/net-device.h"
namespace ns3 {
-
-class Address;
+namespace ndn {
/**
* \ingroup ndn-face
@@ -42,7 +41,7 @@
*
* \see NdnAppFace, NdnNetDeviceFace, NdnIpv4Face, NdnUdpFace
*/
-class NdnNetDeviceFace : public NdnFace
+class NetDeviceFace : public Face
{
public:
static TypeId
@@ -55,8 +54,8 @@
* @param netDevice a smart pointer to NetDevice object to which
* this face will be associate
*/
- NdnNetDeviceFace (Ptr<Node> node, const Ptr<NetDevice> &netDevice);
- virtual ~NdnNetDeviceFace();
+ NetDeviceFace (Ptr<Node> node, const Ptr<NetDevice> &netDevice);
+ virtual ~NetDeviceFace();
////////////////////////////////////////////////////////////////////
// methods overloaded from NdnFace
@@ -84,8 +83,8 @@
Ptr<NetDevice> GetNetDevice () const;
private:
- NdnNetDeviceFace (const NdnNetDeviceFace &); ///< \brief Disabled copy constructor
- NdnNetDeviceFace& operator= (const NdnNetDeviceFace &); ///< \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,
@@ -99,6 +98,7 @@
Ptr<NetDevice> m_netDevice; ///< \brief Smart pointer to NetDevice
};
+} // namespace ndn
} // namespace ns3
#endif //NDN_NET_DEVICE_FACE_H
diff --git a/model/ndn.cc b/model/ndn.cc
deleted file mode 100644
index 1083992..0000000
--- a/model/ndn.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ns3/assert.h"
-#include "ns3/node.h"
-#include "ns3/boolean.h"
-
-#include "ndn.h"
-#include "ndn-face.h"
-#include "forwarding-strategy/ndn-forwarding-strategy.h"
-#include "ndn-interest-header.h"
-#include "ndn-content-object-header.h"
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (Ndn);
-
-TypeId
-Ndn::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::Ndn")
- .SetGroupName ("Ndn")
- .SetParent<Object> ()
- ;
- return tid;
-}
-
-Ndn::~Ndn ()
-{
-}
-
-} // namespace ns3
diff --git a/model/ndn.h b/model/ndn.h
deleted file mode 100644
index 55c5722..0000000
--- a/model/ndn.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _NDN_H_
-#define _NDN_H_
-
-#include "ns3/object.h"
-#include "ns3/callback.h"
-#include "ns3/traced-callback.h"
-
-namespace ns3 {
-
-class Node;
-class NetDevice;
-class Packet;
-class NdnForwardingStrategy;
-class NdnFace;
-class NdnContentObjectHeader;
-class NdnInterestHeader;
-class NdnPit;
-
-/// @cond include_hidden
-/**
- * \internal
- * \brief Private namespace for Ndn content store implementation
- */
-namespace __ndn_private
-{
-class i_face {};
-class i_metric {};
-class i_nth {};
-class i_prefix {};
-class i_ordered {}; ///< tag for Boost.MultiIndex container (ordered by prefix)
-class i_mru {};
-}
-/// @endcond
-
-// default data size
-// #define NDN_DEFAULT_DATA_SIZE 1024
-// #define NDN_INTEREST_RESET_PERIOD (10*MILLI_SECOND)
-
-/**
- * \defgroup ndn NDN abstraction
- *
- * This is an abstract implementation of NDN protocol
- */
-/**
- * \ingroup ndn
- * \brief Interface to manage Ndn stack
- *
- * This class defines the API to manipulate the following aspects of
- * the Ndn stack implementation:
- * -# register a face (NdnFace-derived object) for use by the Ndn
- * layer
- * -# register forwarding strategy (NdnForwardingStrategy-derived
- * object) to use by Ndn stack
- * -# export Ndn configuration attributes
- *
- * Each NdnFace-derived object has conceptually a single Ndn
- * interface associated with it.
- *
- * In addition, this class defines Ndn packet coding constants
- *
- * \see NdnFace, NdnForwardingStrategy
- */
-class Ndn : public Object
-{
-public:
- /**
- * \brief Interface ID
- *
- * \return interface ID
- */
- static TypeId GetTypeId ();
- virtual ~Ndn ();
-
- /**
- * \brief Add face to Ndn stack
- *
- * \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<NdnFace> &face) = 0;
-
- /**
- * \brief Get current number of faces added to Ndn stack
- *
- * \returns the number of faces
- */
- virtual uint32_t
- GetNFaces (void) const = 0;
-
- /**
- * \brief Get face by face index
- * \param face The face number of an Ndn interface.
- * \returns The NdnFace associated with the Ndn face number.
- */
- virtual Ptr<NdnFace>
- GetFace (uint32_t face) const = 0;
-
- /**
- * \brief Remove face from ndn stack (remove callbacks)
- */
- virtual void
- RemoveFace (Ptr<NdnFace> face) = 0;
-
- /**
- * \brief Get face for NetDevice
- */
- virtual Ptr<NdnFace>
- GetFaceByNetDevice (Ptr<NetDevice> netDevice) const = 0;
-
- // /**
- // * \enum DropReason
- // * \brief A reason why the packet has been dropped
- // */
- // enum DropReason
- // {
- // DUPLICATED, // Interests
- // SUPPRESSED, // Interests and Nacks
- // NO_FACES, // Interests
- // NON_DUPLICATED, // Nacks
- // AFTER_SATISFIED, // Nacks
- // UNSOLICITED, // data
- // PIT_LIMIT // PIT limit reached
- // };
- };
-
-} // namespace ns3
-
-#endif /* _NDN_H_ */
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 */