model: Remove deprecated "old" content store policies
Use policies and policy interface provided by NFD
Change-Id: I6d4b06225114d1680c9ff3c17b2616298959b0dc
diff --git a/model/cs/content-store-impl.cpp b/model/cs/content-store-impl.cpp
deleted file mode 100644
index b5b00f2..0000000
--- a/model/cs/content-store-impl.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "content-store-impl.hpp"
-
-#include "../../utils/trie/random-policy.hpp"
-#include "../../utils/trie/lru-policy.hpp"
-#include "../../utils/trie/fifo-policy.hpp"
-#include "../../utils/trie/lfu-policy.hpp"
-#include "../../utils/trie/multi-policy.hpp"
-#include "../../utils/trie/aggregate-stats-policy.hpp"
-
-#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
- static struct X##type##templ##RegistrationClass { \
- X##type##templ##RegistrationClass() \
- { \
- ns3::TypeId tid = type<templ>::GetTypeId(); \
- tid.GetParent(); \
- } \
- } x_##type##templ##RegistrationVariable
-
-namespace ns3 {
-namespace ndn {
-
-using namespace ndnSIM;
-
-namespace cs {
-
-// explicit instantiation and registering
-/**
- * @brief ContentStore with LRU cache replacement policy
- **/
-template class ContentStoreImpl<lru_policy_traits>;
-
-/**
- * @brief ContentStore with random cache replacement policy
- **/
-template class ContentStoreImpl<random_policy_traits>;
-
-/**
- * @brief ContentStore with FIFO cache replacement policy
- **/
-template class ContentStoreImpl<fifo_policy_traits>;
-
-/**
- * @brief ContentStore with Least Frequently Used (LFU) cache replacement policy
- **/
-template class ContentStoreImpl<lfu_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);
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, lfu_policy_traits);
-
-typedef multi_policy_traits<boost::mpl::vector2<lru_policy_traits, aggregate_stats_policy_traits>>
- LruWithCountsTraits;
-typedef multi_policy_traits<boost::mpl::vector2<random_policy_traits,
- aggregate_stats_policy_traits>>
- RandomWithCountsTraits;
-typedef multi_policy_traits<boost::mpl::vector2<fifo_policy_traits, aggregate_stats_policy_traits>>
- FifoWithCountsTraits;
-typedef multi_policy_traits<boost::mpl::vector2<lfu_policy_traits, aggregate_stats_policy_traits>>
- LfuWithCountsTraits;
-
-template class ContentStoreImpl<LruWithCountsTraits>;
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, LruWithCountsTraits);
-
-template class ContentStoreImpl<RandomWithCountsTraits>;
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, RandomWithCountsTraits);
-
-template class ContentStoreImpl<FifoWithCountsTraits>;
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, FifoWithCountsTraits);
-
-template class ContentStoreImpl<LfuWithCountsTraits>;
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, LfuWithCountsTraits);
-
-#ifdef DOXYGEN
-// /**
-// * \brief Content Store implementing LRU cache replacement policy
-// */
-class Lru : public ContentStoreImpl<lru_policy_traits> {
-};
-
-/**
- * \brief Content Store implementing FIFO cache replacement policy
- */
-class Fifo : public ContentStoreImpl<fifo_policy_traits> {
-};
-
-/**
- * \brief Content Store implementing Random cache replacement policy
- */
-class Random : public ContentStoreImpl<random_policy_traits> {
-};
-
-/**
- * \brief Content Store implementing Least Frequently Used cache replacement policy
- */
-class Lfu : public ContentStoreImpl<lfu_policy_traits> {
-};
-#endif
-
-} // namespace cs
-} // namespace ndn
-} // namespace ns3
diff --git a/model/cs/content-store-impl.hpp b/model/cs/content-store-impl.hpp
deleted file mode 100644
index 5765120..0000000
--- a/model/cs/content-store-impl.hpp
+++ /dev/null
@@ -1,338 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#ifndef NDN_CONTENT_STORE_IMPL_H_
-#define NDN_CONTENT_STORE_IMPL_H_
-
-#include "ns3/ndnSIM/model/ndn-common.hpp"
-
-#include "ndn-content-store.hpp"
-
-#include "ns3/packet.h"
-#include <boost/foreach.hpp>
-
-#include "ns3/log.h"
-#include "ns3/uinteger.h"
-#include "ns3/string.h"
-
-#include "../../utils/trie/trie-with-policy.hpp"
-
-namespace ns3 {
-namespace ndn {
-namespace cs {
-
-/**
- * @ingroup ndn-cs
- * @brief Cache entry implementation with additional references to the base container
- */
-template<class CS>
-class EntryImpl : public Entry {
-public:
- typedef Entry base_type;
-
-public:
- EntryImpl(Ptr<ContentStore> cs, shared_ptr<const Data> data)
- : Entry(cs, data)
- , item_(0)
- {
- }
-
- void
- SetTrie(typename CS::super::iterator item)
- {
- item_ = item;
- }
-
- typename CS::super::iterator
- to_iterator()
- {
- return item_;
- }
- typename CS::super::const_iterator
- to_iterator() const
- {
- return item_;
- }
-
-private:
- typename CS::super::iterator item_;
-};
-
-/**
- * @ingroup ndn-cs
- * @brief Base implementation of NDN content store
- */
-template<class Policy>
-class ContentStoreImpl
- : public ContentStore,
- protected ndnSIM::
- trie_with_policy<Name,
- ndnSIM::smart_pointer_payload_traits<EntryImpl<ContentStoreImpl<Policy>>,
- Entry>,
- Policy> {
-public:
- typedef ndnSIM::
- trie_with_policy<Name, ndnSIM::smart_pointer_payload_traits<EntryImpl<ContentStoreImpl<Policy>>,
- Entry>,
- Policy> super;
-
- typedef EntryImpl<ContentStoreImpl<Policy>> entry;
-
- static TypeId
- GetTypeId();
-
- ContentStoreImpl(){};
- virtual ~ContentStoreImpl(){};
-
- // from ContentStore
-
- virtual inline shared_ptr<Data>
- Lookup(shared_ptr<const Interest> interest);
-
- virtual inline bool
- Add(shared_ptr<const Data> data);
-
- // virtual bool
- // Remove (shared_ptr<Interest> header);
-
- virtual inline void
- Print(std::ostream& os) const;
-
- virtual uint32_t
- GetSize() const;
-
- virtual Ptr<Entry>
- Begin();
-
- virtual Ptr<Entry>
- End();
-
- virtual Ptr<Entry> Next(Ptr<Entry>);
-
- const typename super::policy_container&
- GetPolicy() const
- {
- return super::getPolicy();
- }
-
- typename super::policy_container&
- GetPolicy()
- {
- return super::getPolicy();
- }
-
-public:
- typedef void (*CsEntryCallback)(Ptr<const Entry>);
-
-private:
- void
- SetMaxSize(uint32_t maxSize);
-
- uint32_t
- GetMaxSize() const;
-
-private:
- static LogComponent g_log; ///< @brief Logging variable
-
- /// @brief trace of for entry additions (fired every time entry is successfully added to the
- /// cache): first parameter is pointer to the CS entry
- TracedCallback<Ptr<const Entry>> m_didAddEntry;
-};
-
-//////////////////////////////////////////
-////////// Implementation ////////////////
-//////////////////////////////////////////
-
-template<class Policy>
-LogComponent ContentStoreImpl<Policy>::g_log = LogComponent(("ndn.cs." + Policy::GetName()).c_str(), __FILE__);
-
-template<class Policy>
-TypeId
-ContentStoreImpl<Policy>::GetTypeId()
-{
- static TypeId tid =
- TypeId(("ns3::ndn::cs::" + Policy::GetName()).c_str())
- .SetGroupName("Ndn")
- .SetParent<ContentStore>()
- .AddConstructor<ContentStoreImpl<Policy>>()
- .AddAttribute("MaxSize",
- "Set maximum number of entries in ContentStore. If 0, limit is not enforced",
- StringValue("100"), MakeUintegerAccessor(&ContentStoreImpl<Policy>::GetMaxSize,
- &ContentStoreImpl<Policy>::SetMaxSize),
- MakeUintegerChecker<uint32_t>())
-
- .AddTraceSource("DidAddEntry",
- "Trace fired every time entry is successfully added to the cache",
- MakeTraceSourceAccessor(&ContentStoreImpl<Policy>::m_didAddEntry),
- "ns3::ndn::cs::ContentStoreImpl::CsEntryCallback");
-
- return tid;
-}
-
-struct isNotExcluded {
- inline isNotExcluded(const Exclude& exclude)
- : m_exclude(exclude)
- {
- }
-
- bool
- operator()(const name::Component& comp) const
- {
- return !m_exclude.isExcluded(comp);
- }
-
-private:
- const Exclude& m_exclude;
-};
-
-template<class Policy>
-shared_ptr<Data>
-ContentStoreImpl<Policy>::Lookup(shared_ptr<const Interest> interest)
-{
- NS_LOG_FUNCTION(this << interest->getName());
-
- typename super::const_iterator node;
- if (interest->getExclude().empty()) {
- node = this->deepest_prefix_match(interest->getName());
- }
- else {
- node = this->deepest_prefix_match_if_next_level(interest->getName(),
- isNotExcluded(interest->getExclude()));
- }
-
- if (node != this->end()) {
- this->m_cacheHitsTrace(interest, node->payload()->GetData());
-
- shared_ptr<Data> copy = make_shared<Data>(*node->payload()->GetData());
- return copy;
- }
- else {
- this->m_cacheMissesTrace(interest);
- return 0;
- }
-}
-
-template<class Policy>
-bool
-ContentStoreImpl<Policy>::Add(shared_ptr<const Data> data)
-{
- NS_LOG_FUNCTION(this << data->getName());
-
- Ptr<entry> newEntry = Create<entry>(this, data);
- std::pair<typename super::iterator, bool> result = super::insert(data->getName(), newEntry);
-
- if (result.first != super::end()) {
- if (result.second) {
- newEntry->SetTrie(result.first);
-
- m_didAddEntry(newEntry);
- return true;
- }
- else {
- // should we do anything?
- // update payload? add new payload?
- return false;
- }
- }
- else
- return false; // cannot insert entry
-}
-
-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++) {
- 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();
-}
-
-template<class Policy>
-uint32_t
-ContentStoreImpl<Policy>::GetSize() const
-{
- return this->getPolicy().size();
-}
-
-template<class Policy>
-Ptr<Entry>
-ContentStoreImpl<Policy>::Begin()
-{
- typename super::parent_trie::recursive_iterator item(super::getTrie()), end(0);
- for (; item != end; item++) {
- if (item->payload() == 0)
- continue;
- break;
- }
-
- if (item == end)
- return End();
- else
- return item->payload();
-}
-
-template<class Policy>
-Ptr<Entry>
-ContentStoreImpl<Policy>::End()
-{
- return 0;
-}
-
-template<class Policy>
-Ptr<Entry>
-ContentStoreImpl<Policy>::Next(Ptr<Entry> from)
-{
- if (from == 0)
- return 0;
-
- typename super::parent_trie::recursive_iterator item(*StaticCast<entry>(from)->to_iterator()),
- end(0);
-
- for (item++; item != end; item++) {
- if (item->payload() == 0)
- continue;
- break;
- }
-
- if (item == end)
- return End();
- else
- return item->payload();
-}
-
-} // namespace cs
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDN_CONTENT_STORE_IMPL_H_
diff --git a/model/cs/content-store-nocache.cpp b/model/cs/content-store-nocache.cpp
deleted file mode 100644
index 6b10df1..0000000
--- a/model/cs/content-store-nocache.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "content-store-nocache.hpp"
-
-#include "ns3/log.h"
-#include "ns3/packet.h"
-
-NS_LOG_COMPONENT_DEFINE("ndn.cs.Nocache");
-
-namespace ns3 {
-namespace ndn {
-namespace cs {
-
-NS_OBJECT_ENSURE_REGISTERED(Nocache);
-
-TypeId
-Nocache::GetTypeId(void)
-{
- static TypeId tid = TypeId("ns3::ndn::cs::Nocache")
- .SetGroupName("Ndn")
- .SetParent<ContentStore>()
- .AddConstructor<Nocache>();
-
- return tid;
-}
-
-Nocache::Nocache()
-{
-}
-
-Nocache::~Nocache()
-{
-}
-
-shared_ptr<Data>
-Nocache::Lookup(shared_ptr<const Interest> interest)
-{
- this->m_cacheMissesTrace(interest);
- return 0;
-}
-
-bool
-Nocache::Add(shared_ptr<const Data> data)
-{
- return false;
-}
-
-void
-Nocache::Print(std::ostream& os) const
-{
-}
-
-uint32_t
-Nocache::GetSize() const
-{
- return 0;
-}
-
-Ptr<cs::Entry>
-Nocache::Begin()
-{
- return 0;
-}
-
-Ptr<cs::Entry>
-Nocache::End()
-{
- return 0;
-}
-
-Ptr<cs::Entry> Nocache::Next(Ptr<cs::Entry>)
-{
- return 0;
-}
-
-} // namespace cs
-} // namespace ndn
-} // namespace ns3
diff --git a/model/cs/content-store-nocache.hpp b/model/cs/content-store-nocache.hpp
deleted file mode 100644
index 019926b..0000000
--- a/model/cs/content-store-nocache.hpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#ifndef NDN_CONTENT_STORE_NOCACHE_H
-#define NDN_CONTENT_STORE_NOCACHE_H
-
-#include "ns3/ndnSIM/model/ndn-common.hpp"
-
-#include "ns3/ndnSIM/model/cs/ndn-content-store.hpp"
-
-namespace ns3 {
-namespace ndn {
-namespace cs {
-
-/**
- * @ingroup ndn-cs
- * @brief Implementation of ContentStore that completely disables caching
- */
-class Nocache : public ContentStore {
-public:
- /**
- * \brief Interface ID
- *
- * \return interface ID
- */
- static TypeId
- GetTypeId();
-
- /**
- * @brief Default constructor
- */
- Nocache();
-
- /**
- * @brief Virtual destructor
- */
- virtual ~Nocache();
-
- virtual shared_ptr<Data>
- Lookup(shared_ptr<const Interest> interest);
-
- virtual bool
- Add(shared_ptr<const Data> data);
-
- virtual void
- Print(std::ostream& os) const;
-
- virtual uint32_t
- GetSize() const;
-
- virtual Ptr<cs::Entry>
- Begin();
-
- virtual Ptr<cs::Entry>
- End();
-
- virtual Ptr<cs::Entry> Next(Ptr<cs::Entry>);
-};
-
-} // namespace cs
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDN_CONTENT_STORE_NOCACHE_H
diff --git a/model/cs/content-store-with-freshness.cpp b/model/cs/content-store-with-freshness.cpp
deleted file mode 100644
index c60236b..0000000
--- a/model/cs/content-store-with-freshness.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "content-store-with-freshness.hpp"
-
-#include "../../utils/trie/random-policy.hpp"
-#include "../../utils/trie/lru-policy.hpp"
-#include "../../utils/trie/fifo-policy.hpp"
-#include "../../utils/trie/lfu-policy.hpp"
-
-#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
- static struct X##type##templ##RegistrationClass { \
- X##type##templ##RegistrationClass() \
- { \
- ns3::TypeId tid = type<templ>::GetTypeId(); \
- tid.GetParent(); \
- } \
- } x_##type##templ##RegistrationVariable
-
-namespace ns3 {
-namespace ndn {
-
-using namespace ndnSIM;
-
-namespace cs {
-
-// explicit instantiation and registering
-/**
- * @brief ContentStore with freshness and LRU cache replacement policy
- **/
-template class ContentStoreWithFreshness<lru_policy_traits>;
-
-/**
- * @brief ContentStore with freshness and random cache replacement policy
- **/
-template class ContentStoreWithFreshness<random_policy_traits>;
-
-/**
- * @brief ContentStore with freshness and FIFO cache replacement policy
- **/
-template class ContentStoreWithFreshness<fifo_policy_traits>;
-
-/**
- * @brief ContentStore with freshness and Least Frequently Used (LFU) cache replacement policy
- **/
-template class ContentStoreWithFreshness<lfu_policy_traits>;
-
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithFreshness, lru_policy_traits);
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithFreshness, random_policy_traits);
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithFreshness, fifo_policy_traits);
-
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithFreshness, lfu_policy_traits);
-
-#ifdef DOXYGEN
-// /**
-// * \brief Content Store with freshness implementing LRU cache replacement policy
-// */
-class Freshness::Lru : public ContentStoreWithFreshness<lru_policy_traits> {
-};
-
-/**
- * \brief Content Store with freshness implementing FIFO cache replacement policy
- */
-class Freshness::Fifo : public ContentStoreWithFreshness<fifo_policy_traits> {
-};
-
-/**
- * \brief Content Store with freshness implementing Random cache replacement policy
- */
-class Freshness::Random : public ContentStoreWithFreshness<random_policy_traits> {
-};
-
-/**
- * \brief Content Store with freshness implementing Least Frequently Used cache replacement policy
- */
-class Freshness::Lfu : public ContentStoreWithFreshness<lfu_policy_traits> {
-};
-
-#endif
-
-} // namespace cs
-} // namespace ndn
-} // namespace ns3
diff --git a/model/cs/content-store-with-freshness.hpp b/model/cs/content-store-with-freshness.hpp
deleted file mode 100644
index 4cfa700..0000000
--- a/model/cs/content-store-with-freshness.hpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#ifndef NDN_CONTENT_STORE_WITH_FRESHNESS_H_
-#define NDN_CONTENT_STORE_WITH_FRESHNESS_H_
-
-#include "ns3/ndnSIM/model/ndn-common.hpp"
-
-#include "content-store-impl.hpp"
-
-#include "../../utils/trie/multi-policy.hpp"
-#include "custom-policies/freshness-policy.hpp"
-
-namespace ns3 {
-namespace ndn {
-namespace cs {
-
-/**
- * @ingroup ndn-cs
- * @brief Special content store realization that honors Freshness parameter in Data packets
- */
-template<class Policy>
-class ContentStoreWithFreshness
- : public ContentStoreImpl<ndnSIM::
- multi_policy_traits<boost::mpl::
- vector2<Policy,
- ndnSIM::freshness_policy_traits>>> {
-public:
- typedef ContentStoreImpl<ndnSIM::multi_policy_traits<boost::mpl::
- vector2<Policy,
- ndnSIM::freshness_policy_traits>>>
- super;
-
- typedef typename super::policy_container::template index<1>::type freshness_policy_container;
-
- static TypeId
- GetTypeId();
-
- virtual inline void
- Print(std::ostream& os) const;
-
- virtual inline bool
- Add(shared_ptr<const Data> data);
-
-private:
- inline void
- CleanExpired();
-
- inline void
- RescheduleCleaning();
-
-private:
- static LogComponent g_log; ///< @brief Logging variable
-
- EventId m_cleanEvent;
- Time m_scheduledCleaningTime;
-};
-
-//////////////////////////////////////////
-////////// Implementation ////////////////
-//////////////////////////////////////////
-
-template<class Policy>
-LogComponent ContentStoreWithFreshness<Policy>::g_log = LogComponent(("ndn.cs.Freshness."
- + Policy::GetName()).c_str(), __FILE__);
-
-template<class Policy>
-TypeId
-ContentStoreWithFreshness<Policy>::GetTypeId()
-{
- static TypeId tid = TypeId(("ns3::ndn::cs::Freshness::" + Policy::GetName()).c_str())
- .SetGroupName("Ndn")
- .SetParent<super>()
- .template AddConstructor<ContentStoreWithFreshness<Policy>>()
-
- // trace stuff here
- ;
-
- return tid;
-}
-
-template<class Policy>
-inline bool
-ContentStoreWithFreshness<Policy>::Add(shared_ptr<const Data> data)
-{
- bool ok = super::Add(data);
- if (!ok)
- return false;
-
- NS_LOG_DEBUG(data->getName() << " added to cache");
- RescheduleCleaning();
- return true;
-}
-
-template<class Policy>
-inline void
-ContentStoreWithFreshness<Policy>::RescheduleCleaning()
-{
- const freshness_policy_container& freshness =
- this->getPolicy().template get<freshness_policy_container>();
-
- if (freshness.size() > 0) {
- Time nextStateTime =
- freshness_policy_container::policy_base::get_freshness(&(*freshness.begin()));
-
- if (m_scheduledCleaningTime.IsZero() || // if not yet scheduled
- m_scheduledCleaningTime > nextStateTime) // if new item expire sooner than already scheduled
- {
- if (m_cleanEvent.IsRunning()) {
- Simulator::Remove(m_cleanEvent); // just canceling would not clean up list of events
- }
-
- // NS_LOG_DEBUG ("Next event in: " << (nextStateTime - Now ()).ToDouble (Time::S) << "s");
- m_cleanEvent = Simulator::Schedule(nextStateTime - Now(),
- &ContentStoreWithFreshness<Policy>::CleanExpired, this);
- m_scheduledCleaningTime = nextStateTime;
- }
- }
- else {
- if (m_cleanEvent.IsRunning()) {
- Simulator::Remove(m_cleanEvent); // just canceling would not clean up list of events
- }
- }
-}
-
-template<class Policy>
-inline void
-ContentStoreWithFreshness<Policy>::CleanExpired()
-{
- freshness_policy_container& freshness =
- this->getPolicy().template get<freshness_policy_container>();
-
- // NS_LOG_LOGIC (">> Cleaning: Total number of items:" << this->getPolicy ().size () << ", items
- // with freshness: " << freshness.size ());
- Time now = Simulator::Now();
-
- while (!freshness.empty()) {
- typename freshness_policy_container::iterator entry = freshness.begin();
-
- if (freshness_policy_container::policy_base::get_freshness(&(*entry))
- <= now) // is the record stale?
- {
- super::erase(&(*entry));
- }
- else
- break; // nothing else to do. All later records will not be stale
- }
- // NS_LOG_LOGIC ("<< Cleaning: Total number of items:" << this->getPolicy ().size () << ", items
- // with freshness: " << freshness.size ());
-
- m_scheduledCleaningTime = Time();
- RescheduleCleaning();
-}
-
-template<class Policy>
-void
-ContentStoreWithFreshness<Policy>::Print(std::ostream& os) const
-{
- // const freshness_policy_container &freshness = this->getPolicy ().template
- // get<freshness_policy_container> ();
-
- for (typename super::policy_container::const_iterator item = this->getPolicy().begin();
- item != this->getPolicy().end(); item++) {
- Time ttl = freshness_policy_container::policy_base::get_freshness(&(*item)) - Simulator::Now();
- os << item->payload()->GetName() << "(left: " << ttl.ToDouble(Time::S) << "s)" << std::endl;
- }
-}
-
-} // namespace cs
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDN_CONTENT_STORE_WITH_FRESHNESS_H_
diff --git a/model/cs/content-store-with-probability.cpp b/model/cs/content-store-with-probability.cpp
deleted file mode 100644
index 5f28c0a..0000000
--- a/model/cs/content-store-with-probability.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "content-store-with-probability.hpp"
-
-#include "../../utils/trie/random-policy.hpp"
-#include "../../utils/trie/lru-policy.hpp"
-#include "../../utils/trie/fifo-policy.hpp"
-#include "../../utils/trie/lfu-policy.hpp"
-
-#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
- static struct X##type##templ##RegistrationClass { \
- X##type##templ##RegistrationClass() \
- { \
- ns3::TypeId tid = type<templ>::GetTypeId(); \
- tid.GetParent(); \
- } \
- } x_##type##templ##RegistrationVariable
-
-namespace ns3 {
-namespace ndn {
-
-using namespace ndnSIM;
-
-namespace cs {
-
-// explicit instantiation and registering
-/**
- * @brief ContentStore with freshness and LRU cache replacement policy
- **/
-template class ContentStoreWithProbability<lru_policy_traits>;
-
-/**
- * @brief ContentStore with freshness and random cache replacement policy
- **/
-template class ContentStoreWithProbability<random_policy_traits>;
-
-/**
- * @brief ContentStore with freshness and FIFO cache replacement policy
- **/
-template class ContentStoreWithProbability<fifo_policy_traits>;
-
-/**
- * @brief ContentStore with freshness and Least Frequently Used (LFU) cache replacement policy
- **/
-template class ContentStoreWithProbability<lfu_policy_traits>;
-
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithProbability, lru_policy_traits);
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithProbability, random_policy_traits);
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithProbability, fifo_policy_traits);
-
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithProbability, lfu_policy_traits);
-
-#ifdef DOXYGEN
-// /**
-// * \brief Content Store with freshness implementing LRU cache replacement policy
-// */
-class Probability::Lru : public ContentStoreWithProbability<lru_policy_traits> {
-};
-
-/**
- * \brief Content Store with freshness implementing FIFO cache replacement policy
- */
-class Probability::Fifo : public ContentStoreWithProbability<fifo_policy_traits> {
-};
-
-/**
- * \brief Content Store with freshness implementing Random cache replacement policy
- */
-class Probability::Random : public ContentStoreWithProbability<random_policy_traits> {
-};
-
-/**
- * \brief Content Store with freshness implementing Least Frequently Used cache replacement policy
- */
-class Probability::Lfu : public ContentStoreWithProbability<lfu_policy_traits> {
-};
-
-#endif
-
-} // namespace cs
-} // namespace ndn
-} // namespace ns3
diff --git a/model/cs/content-store-with-probability.hpp b/model/cs/content-store-with-probability.hpp
deleted file mode 100644
index 5ba9b58..0000000
--- a/model/cs/content-store-with-probability.hpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#ifndef NDN_CONTENT_STORE_WITH_PROBABILITY_H_
-#define NDN_CONTENT_STORE_WITH_PROBABILITY_H_
-
-#include "ns3/ndnSIM/model/ndn-common.hpp"
-
-#include "content-store-impl.hpp"
-
-#include "../../utils/trie/multi-policy.hpp"
-#include "custom-policies/probability-policy.hpp"
-#include "ns3/double.h"
-#include "ns3/type-id.h"
-
-namespace ns3 {
-namespace ndn {
-namespace cs {
-
-/**
- * @ingroup ndn-cs
- * @brief Special content store realization that probabilistically accepts data packet
- * into CS (placement policy)
- */
-template<class Policy>
-class ContentStoreWithProbability
- : public ContentStoreImpl<ndnSIM::multi_policy_traits<boost::mpl::
- vector2<ndnSIM::probability_policy_traits,
- Policy>>> {
-public:
- typedef ContentStoreImpl<ndnSIM::multi_policy_traits<boost::mpl::
- vector2<ndnSIM::probability_policy_traits,
- Policy>>> super;
-
- typedef typename super::policy_container::template index<0>::type probability_policy_container;
-
- ContentStoreWithProbability(){};
-
- static TypeId
- GetTypeId();
-
-private:
- void
- SetCacheProbability(double probability)
- {
- this->getPolicy().template get<probability_policy_container>().set_probability(probability);
- }
-
- double
- GetCacheProbability() const
- {
- return this->getPolicy().template get<probability_policy_container>().get_probability();
- }
-};
-
-//////////////////////////////////////////
-////////// Implementation ////////////////
-//////////////////////////////////////////
-
-template<class Policy>
-TypeId
-ContentStoreWithProbability<Policy>::GetTypeId()
-{
- static TypeId tid =
- TypeId(("ns3::ndn::cs::Probability::" + Policy::GetName()).c_str())
- .SetGroupName("Ndn")
- .SetParent<super>()
- .template AddConstructor<ContentStoreWithProbability<Policy>>()
-
- .AddAttribute("CacheProbability",
- "Set probability of caching in ContentStore. "
- "If 1, every content is cached. If 0, no content is cached.",
- DoubleValue(1.0), //(+)
- MakeDoubleAccessor(&ContentStoreWithProbability<Policy>::GetCacheProbability,
- &ContentStoreWithProbability<Policy>::SetCacheProbability),
- MakeDoubleChecker<double>());
-
- return tid;
-}
-
-} // namespace cs
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDN_CONTENT_STORE_WITH_PROBABILITY_H_
diff --git a/model/cs/content-store-with-stats.cpp b/model/cs/content-store-with-stats.cpp
deleted file mode 100644
index bcdf098..0000000
--- a/model/cs/content-store-with-stats.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "content-store-with-stats.hpp"
-
-#include "../../utils/trie/random-policy.hpp"
-#include "../../utils/trie/lru-policy.hpp"
-#include "../../utils/trie/fifo-policy.hpp"
-#include "../../utils/trie/lfu-policy.hpp"
-
-#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
- static struct X##type##templ##RegistrationClass { \
- X##type##templ##RegistrationClass() \
- { \
- ns3::TypeId tid = type<templ>::GetTypeId(); \
- tid.GetParent(); \
- } \
- } x_##type##templ##RegistrationVariable
-
-namespace ns3 {
-namespace ndn {
-
-using namespace ndnSIM;
-
-namespace cs {
-
-// explicit instantiation and registering
-/**
- * @brief ContentStore with stats and LRU cache replacement policy
- **/
-template class ContentStoreWithStats<lru_policy_traits>;
-
-/**
- * @brief ContentStore with stats and random cache replacement policy
- **/
-template class ContentStoreWithStats<random_policy_traits>;
-
-/**
- * @brief ContentStore with stats and FIFO cache replacement policy
- **/
-template class ContentStoreWithStats<fifo_policy_traits>;
-
-/**
- * @brief ContentStore with stats and Least Frequently Used (LFU) cache replacement policy
- **/
-template class ContentStoreWithStats<lfu_policy_traits>;
-
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithStats, lru_policy_traits);
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithStats, random_policy_traits);
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithStats, fifo_policy_traits);
-
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreWithStats, lfu_policy_traits);
-
-#ifdef DOXYGEN
-// /**
-// * \brief Content Store with stats implementing LRU cache replacement policy
-// */
-class Stats::Lru : public ContentStoreWithStats<lru_policy_traits> {
-};
-
-/**
- * \brief Content Store with stats implementing FIFO cache replacement policy
- */
-class Stats::Fifo : public ContentStoreWithStats<fifo_policy_traits> {
-};
-
-/**
- * \brief Content Store with stats implementing Random cache replacement policy
- */
-class Stats::Random : public ContentStoreWithStats<random_policy_traits> {
-};
-
-/**
- * \brief Content Store with stats implementing Least Frequently Used cache replacement policy
- */
-class Stats::Lfu : public ContentStoreWithStats<lfu_policy_traits> {
-};
-
-#endif
-
-} // namespace cs
-} // namespace ndn
-} // namespace ns3
diff --git a/model/cs/content-store-with-stats.hpp b/model/cs/content-store-with-stats.hpp
deleted file mode 100644
index 3b84ac2..0000000
--- a/model/cs/content-store-with-stats.hpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#ifndef NDN_CONTENT_STORE_WITH_STATS_H_
-#define NDN_CONTENT_STORE_WITH_STATS_H_
-
-#include "ns3/ndnSIM/model/ndn-common.hpp"
-
-#include "content-store-impl.hpp"
-
-#include "../../utils/trie/multi-policy.hpp"
-#include "custom-policies/lifetime-stats-policy.hpp"
-
-namespace ns3 {
-namespace ndn {
-namespace cs {
-
-/**
- * @ingroup ndn-cs
- * @brief Special content store realization that provides ability to track stats of CS operations
- */
-template<class Policy>
-class ContentStoreWithStats
- : public ContentStoreImpl<ndnSIM::
- multi_policy_traits<boost::mpl::
- vector2<Policy,
- ndnSIM::
- lifetime_stats_policy_traits>>> {
-public:
- typedef ContentStoreImpl<ndnSIM::
- multi_policy_traits<boost::mpl::
- vector2<Policy,
- ndnSIM::lifetime_stats_policy_traits>>>
- super;
-
- typedef typename super::policy_container::template index<1>::type lifetime_stats_container;
-
- ContentStoreWithStats()
- {
- // connect traceback to the policy
- super::getPolicy().template get<1>().set_traced_callback(&m_willRemoveEntry);
- }
-
- static TypeId
- GetTypeId();
-
- virtual inline void
- Print(std::ostream& os) const;
-
-public:
- typedef void (*RemoveCsEntryCallback)(Ptr<const Entry>, Time);
-
-private:
- static LogComponent g_log; ///< @brief Logging variable
-
- /// @brief trace of for entry removal: first parameter is pointer to the CS entry, second is how
- /// long entry was in the cache
- TracedCallback<Ptr<const Entry>, Time> m_willRemoveEntry;
-};
-
-//////////////////////////////////////////
-////////// Implementation ////////////////
-//////////////////////////////////////////
-
-template<class Policy>
-LogComponent ContentStoreWithStats<Policy>::g_log = LogComponent(("ndn.cs.Stats."
- + Policy::GetName()).c_str(), __FILE__);
-
-template<class Policy>
-TypeId
-ContentStoreWithStats<Policy>::GetTypeId()
-{
- static TypeId tid =
- TypeId(("ns3::ndn::cs::Stats::" + Policy::GetName()).c_str())
- .SetGroupName("Ndn")
- .SetParent<super>()
- .template AddConstructor<ContentStoreWithStats<Policy>>()
-
- .AddTraceSource("WillRemoveEntry",
- "Trace called just before content store entry will be removed",
- MakeTraceSourceAccessor(&ContentStoreWithStats<Policy>::m_willRemoveEntry),
- "ns3::ndn::cs::ContentStoreWithStats::RemoveCsEntryCallback")
-
- // trace stuff here
- ;
-
- return tid;
-}
-
-template<class Policy>
-void
-ContentStoreWithStats<Policy>::Print(std::ostream& os) const
-{
- // const freshness_policy_container &freshness = this->getPolicy ().template
- // get<freshness_policy_container> ();
-
- for (typename super::policy_container::const_iterator item = this->getPolicy().begin();
- item != this->getPolicy().end(); item++) {
- Time alive = lifetime_stats_container::policy_base::get_time(&(*item)) - Simulator::Now();
- os << item->payload()->GetName() << "(alive: " << alive.ToDouble(Time::S) << "s)" << std::endl;
- }
-}
-
-} // namespace cs
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDN_CONTENT_STORE_IMPL_H_
diff --git a/model/cs/custom-policies/freshness-policy.hpp b/model/cs/custom-policies/freshness-policy.hpp
deleted file mode 100644
index 415ab0b..0000000
--- a/model/cs/custom-policies/freshness-policy.hpp
+++ /dev/null
@@ -1,173 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#ifndef FRESHNESS_POLICY_H_
-#define FRESHNESS_POLICY_H_
-
-/// @cond include_hidden
-
-#include "ns3/ndnSIM/model/ndn-common.hpp"
-
-#include <boost/intrusive/options.hpp>
-#include <boost/intrusive/list.hpp>
-
-#include <ns3/nstime.h>
-#include <ns3/simulator.h>
-#include <ns3/traced-callback.h>
-
-namespace ns3 {
-namespace ndn {
-namespace ndnSIM {
-
-/**
- * @brief Traits for freshness policy
- */
-struct freshness_policy_traits {
- /// @brief Name that can be used to identify the policy (for NS-3 object model and logging)
- static std::string
- GetName()
- {
- return "Freshness";
- }
-
- struct policy_hook_type : public boost::intrusive::set_member_hook<> {
- Time timeWhenShouldExpire;
- };
-
- template<class Container>
- struct container_hook {
- typedef boost::intrusive::member_hook<Container, policy_hook_type, &Container::policy_hook_>
- type;
- };
-
- template<class Base, class Container, class Hook>
- struct policy {
- static Time&
- get_freshness(typename Container::iterator item)
- {
- return static_cast<typename policy_container::value_traits::hook_type*>(
- policy_container::value_traits::to_node_ptr(*item))->timeWhenShouldExpire;
- }
-
- static const Time&
- get_freshness(typename Container::const_iterator item)
- {
- return static_cast<const typename policy_container::value_traits::hook_type*>(
- policy_container::value_traits::to_node_ptr(*item))->timeWhenShouldExpire;
- }
-
- template<class Key>
- struct MemberHookLess {
- bool
- operator()(const Key& a, const Key& b) const
- {
- return get_freshness(&a) < get_freshness(&b);
- }
- };
-
- typedef boost::intrusive::multiset<Container,
- boost::intrusive::compare<MemberHookLess<Container>>,
- Hook> policy_container;
-
- class type : public policy_container {
- public:
- typedef policy policy_base; // to get access to get_freshness methods from outside
- typedef Container parent_trie;
-
- type(Base& base)
- : base_(base)
- , max_size_(100)
- {
- }
-
- inline void
- update(typename parent_trie::iterator item)
- {
- // do nothing
- }
-
- inline bool
- insert(typename parent_trie::iterator item)
- {
- time::milliseconds freshness = item->payload()->GetData()->getFreshnessPeriod();
- if (freshness > time::milliseconds::zero()) {
- get_freshness(item) = Simulator::Now() + MilliSeconds(freshness.count());
-
- // push item only if freshness is non zero. otherwise, this payload is not
- // controlled by the policy.
- // Note that .size() on this policy would return only the number of items with
- // non-infinite freshness policy
- policy_container::insert(*item);
- }
-
- return true;
- }
-
- inline void
- lookup(typename parent_trie::iterator item)
- {
- // do nothing. it's random policy
- }
-
- inline void
- erase(typename parent_trie::iterator item)
- {
- time::milliseconds freshness = item->payload()->GetData()->getFreshnessPeriod();
- if (freshness > time::milliseconds::zero()) {
- // erase only if freshness is positive (otherwise an item is not in the policy)
- policy_container::erase(policy_container::s_iterator_to(*item));
- }
- }
-
- inline void
- clear()
- {
- policy_container::clear();
- }
-
- inline void
- set_max_size(size_t max_size)
- {
- max_size_ = max_size;
- }
-
- inline size_t
- get_max_size() const
- {
- return max_size_;
- }
-
- private:
- type()
- : base_(*((Base*)0)){};
-
- private:
- Base& base_;
- size_t max_size_;
- };
- };
-};
-
-} // ndnSIM
-} // ndn
-} // ns3
-
-/// @endcond
-
-#endif // LIFETIME_STATS_POLICY_H
diff --git a/model/cs/custom-policies/lifetime-stats-policy.hpp b/model/cs/custom-policies/lifetime-stats-policy.hpp
deleted file mode 100644
index 6e81618..0000000
--- a/model/cs/custom-policies/lifetime-stats-policy.hpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#ifndef LIFETIME_STATS_POLICY_H_
-#define LIFETIME_STATS_POLICY_H_
-
-/// @cond include_hidden
-
-#include "ns3/ndnSIM/model/ndn-common.hpp"
-
-#include <boost/intrusive/options.hpp>
-#include <boost/intrusive/list.hpp>
-
-#include <ns3/nstime.h>
-#include <ns3/simulator.h>
-#include <ns3/traced-callback.h>
-
-namespace ns3 {
-namespace ndn {
-namespace ndnSIM {
-
-/**
- * @brief Traits for lifetime stats policy
- */
-struct lifetime_stats_policy_traits {
- /// @brief Name that can be used to identify the policy (for NS-3 object model and logging)
- static std::string
- GetName()
- {
- return "LifetimeStats";
- }
-
- struct policy_hook_type : public boost::intrusive::list_member_hook<> {
- Time timeWhenAdded;
- };
-
- template<class Container>
- struct container_hook {
- typedef boost::intrusive::member_hook<Container, policy_hook_type, &Container::policy_hook_>
- type;
- };
-
- template<class Base, class Container, class Hook>
- struct policy {
- typedef typename boost::intrusive::list<Container, Hook> policy_container;
-
- static Time&
- get_time(typename Container::iterator item)
- {
- return static_cast<typename policy_container::value_traits::hook_type*>(
- policy_container::value_traits::to_node_ptr(*item))->timeWhenAdded;
- }
-
- static const Time&
- get_time(typename Container::const_iterator item)
- {
- return static_cast<const typename policy_container::value_traits::hook_type*>(
- policy_container::value_traits::to_node_ptr(*item))->timeWhenAdded;
- }
-
- class type : public policy_container {
- public:
- typedef policy policy_base; // to get access to get_time methods from outside
- typedef Container parent_trie;
-
- type(Base& base)
- : base_(base)
- , max_size_(100)
- , m_willRemoveEntry(0)
- {
- }
-
- inline void
- update(typename parent_trie::iterator item)
- {
- // do nothing. it's random policy
- }
-
- inline bool
- insert(typename parent_trie::iterator item)
- {
- get_time(item) = Simulator::Now();
-
- policy_container::push_back(*item);
- return true;
- }
-
- inline void
- lookup(typename parent_trie::iterator item)
- {
- // do nothing. it's random policy
- }
-
- inline void
- erase(typename parent_trie::iterator item)
- {
- Time lifetime = Simulator::Now() - get_time(item);
-
- if (m_willRemoveEntry != 0) {
- (*m_willRemoveEntry)(item->payload(), lifetime);
- }
-
- policy_container::erase(policy_container::s_iterator_to(*item));
- }
-
- inline void
- clear()
- {
- policy_container::clear();
- }
-
- inline void
- set_max_size(size_t max_size)
- {
- max_size_ = max_size;
- }
-
- inline size_t
- get_max_size() const
- {
- return max_size_;
- }
-
- void
- set_traced_callback(
- TracedCallback<typename parent_trie::payload_traits::const_base_type, Time>* callback)
- {
- m_willRemoveEntry = callback;
- }
-
- private:
- type()
- : base_(*((Base*)0)){};
-
- private:
- Base& base_;
- size_t max_size_;
-
- TracedCallback<typename parent_trie::payload_traits::const_base_type, Time>*
- m_willRemoveEntry;
- };
- };
-};
-
-} // ndnSIM
-} // ndn
-} // ns3
-
-/// @endcond
-
-#endif // LIFETIME_STATS_POLICY_H
diff --git a/model/cs/custom-policies/probability-policy.hpp b/model/cs/custom-policies/probability-policy.hpp
deleted file mode 100644
index 8bfb1c6..0000000
--- a/model/cs/custom-policies/probability-policy.hpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#ifndef PROBABILITY_POLICY_H_
-#define PROBABILITY_POLICY_H_
-
-/// @cond include_hidden
-
-#include "ns3/ndnSIM/model/ndn-common.hpp"
-
-#include <boost/intrusive/options.hpp>
-#include <boost/intrusive/list.hpp>
-
-#include <ns3/random-variable-stream.h>
-
-namespace ns3 {
-namespace ndn {
-namespace ndnSIM {
-
-/**
- * @brief Traits for freshness policy
- */
-struct probability_policy_traits {
- static std::string
- GetName()
- {
- return "ProbabilityImpl";
- }
-
- struct policy_hook_type : public boost::intrusive::list_member_hook<> {
- };
-
- template<class Container>
- struct container_hook {
- typedef boost::intrusive::member_hook<Container, policy_hook_type, &Container::policy_hook_>
- type;
- };
-
- template<class Base, class Container, class Hook>
- struct policy {
- typedef typename boost::intrusive::list<Container, Hook> policy_container;
-
- class type : public policy_container {
- public:
- typedef policy policy_base; // to get access to get_freshness methods from outside
- typedef Container parent_trie;
-
- type(Base& base)
- : base_(base)
- , max_size_(100)
- , probability_(1.0)
- , ns3_rand_(CreateObject<UniformRandomVariable>())
- {
- }
-
- inline void
- update(typename parent_trie::iterator item)
- {
- }
-
- inline bool
- insert(typename parent_trie::iterator item)
- {
- if (ns3_rand_->GetValue() < probability_) {
- policy_container::push_back(*item);
-
- // allow caching
- return true;
- }
- else {
- // don't allow caching
- return false;
- }
- }
-
- inline void
- lookup(typename parent_trie::iterator item)
- {
- // do nothing. it's random policy
- }
-
- inline void
- erase(typename parent_trie::iterator item)
- {
- policy_container::erase(policy_container::s_iterator_to(*item));
- }
-
- inline void
- clear()
- {
- policy_container::clear();
- }
-
- inline void
- set_max_size(size_t max_size)
- {
- max_size_ = max_size;
- }
-
- inline size_t
- get_max_size() const
- {
- return max_size_;
- }
-
- inline void
- set_probability(double probability)
- {
- probability_ = probability;
- }
-
- inline double
- get_probability() const
- {
- return probability_;
- }
-
- private:
- type()
- : base_(*((Base*)0)){};
-
- private:
- Base& base_;
- size_t max_size_;
- double probability_;
- Ptr<UniformRandomVariable> ns3_rand_;
- };
- };
-};
-
-} // ndnSIM
-} // ndn
-} // ns3
-
-/// @endcond
-
-#endif // PROBABILITY_POLICY_H
diff --git a/model/cs/ndn-content-store.cpp b/model/cs/ndn-content-store.cpp
deleted file mode 100644
index 416bde3..0000000
--- a/model/cs/ndn-content-store.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "ndn-content-store.hpp"
-
-#include "ns3/log.h"
-#include "ns3/packet.h"
-
-NS_LOG_COMPONENT_DEFINE("ndn.cs.ContentStore");
-
-namespace ns3 {
-namespace ndn {
-
-NS_OBJECT_ENSURE_REGISTERED(ContentStore);
-
-TypeId
-ContentStore::GetTypeId(void)
-{
- static TypeId tid =
- TypeId("ns3::ndn::ContentStore")
- .SetGroupName("Ndn")
- .SetParent<Object>()
-
- .AddTraceSource("CacheHits", "Trace called every time there is a cache hit",
- MakeTraceSourceAccessor(&ContentStore::m_cacheHitsTrace),
- "ns3::ndn::ContentStore::CacheHitsCallback")
-
- .AddTraceSource("CacheMisses", "Trace called every time there is a cache miss",
- MakeTraceSourceAccessor(&ContentStore::m_cacheMissesTrace),
- "ns3::ndn::ContentStrore::CacheMissesCallback");
-
- return tid;
-}
-
-ContentStore::~ContentStore()
-{
-}
-
-namespace cs {
-
-//////////////////////////////////////////////////////////////////////
-
-Entry::Entry(Ptr<ContentStore> cs, shared_ptr<const Data> data)
- : m_cs(cs)
- , m_data(data)
-{
-}
-
-const Name&
-Entry::GetName() const
-{
- return m_data->getName();
-}
-
-shared_ptr<const Data>
-Entry::GetData() const
-{
- return m_data;
-}
-
-Ptr<ContentStore>
-Entry::GetContentStore()
-{
- return m_cs;
-}
-
-} // namespace cs
-} // namespace ndn
-} // namespace ns3
diff --git a/model/cs/ndn-content-store.hpp b/model/cs/ndn-content-store.hpp
deleted file mode 100644
index 54c177b..0000000
--- a/model/cs/ndn-content-store.hpp
+++ /dev/null
@@ -1,218 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2011-2015 Regents of the University of California.
- *
- * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
- * contributors.
- *
- * ndnSIM is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndnSIM 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
- * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#ifndef NDN_CONTENT_STORE_H
-#define NDN_CONTENT_STORE_H
-
-#include "ns3/ndnSIM/model/ndn-common.hpp"
-
-#include "ns3/object.h"
-#include "ns3/ptr.h"
-#include "ns3/traced-callback.h"
-
-#include <tuple>
-
-namespace ns3 {
-
-class Packet;
-
-namespace ndn {
-
-class ContentStore;
-
-/**
- * @ingroup ndn
- * @defgroup ndn-cs Content Store
- */
-
-/**
- * @ingroup ndn-cs
- * @brief Namespace for ContentStore operations
- */
-namespace cs {
-
-/**
- * @ingroup ndn-cs
- * @brief NDN content store entry
- */
-class Entry : public SimpleRefCount<Entry> {
-public:
- /**
- * \brief Construct content store entry
- *
- * \param header Parsed Data header
- * \param packet Original Ndn packet
- *
- * The constructor will make a copy of the supplied packet and calls
- * RemoveHeader and RemoveTail on the copy.
- */
- Entry(Ptr<ContentStore> cs, shared_ptr<const Data> data);
-
- /**
- * \brief Get prefix of the stored entry
- * \returns prefix of the stored entry
- */
- const Name&
- GetName() const;
-
- /**
- * \brief Get Data of the stored entry
- * \returns Data of the stored entry
- */
- shared_ptr<const Data>
- GetData() const;
-
- /**
- * @brief Get pointer to access store, to which this entry is added
- */
- Ptr<ContentStore>
- GetContentStore();
-
-private:
- Ptr<ContentStore> m_cs; ///< \brief content store to which entry is added
- shared_ptr<const Data> m_data; ///< \brief non-modifiable Data
-};
-
-} // namespace cs
-
-/**
- * @ingroup ndn-cs
- * \brief Base class for NDN content store
- *
- * Particular implementations should implement Lookup, Add, and Print methods
- */
-class ContentStore : public Object {
-public:
- /**
- * \brief Interface ID
- *
- * \return interface ID
- */
- static TypeId
- GetTypeId();
-
- /**
- * @brief Virtual destructor
- */
- virtual ~ContentStore();
-
- /**
- * \brief Find corresponding CS entry for the given interest
- *
- * \param interest Interest for which matching content store entry will be searched
- *
- * If an entry is found, it is promoted to the top of most recent
- * used entries index, \see m_contentStore
- */
- virtual shared_ptr<Data>
- Lookup(shared_ptr<const Interest> interest) = 0;
-
- /**
- * \brief Add a new content to the content store.
- * \returns true if an existing entry was updated, false otherwise
- */
- virtual bool
- Add(shared_ptr<const Data> data) = 0;
-
- // /*
- // * \brief Add a new content to the content store.
- // *
- // * \param header Interest header for which an entry should be removed
- // * @returns true if an existing entry was removed, false otherwise
- // */
- // virtual bool
- // Remove (shared_ptr<Interest> header) = 0;
-
- /**
- * \brief Print out content store entries
- */
- virtual void
- Print(std::ostream& os) const = 0;
-
- /**
- * @brief Get number of entries in content store
- */
- virtual uint32_t
- GetSize() const = 0;
-
- /**
- * @brief Return first element of content store (no order guaranteed)
- */
- virtual Ptr<cs::Entry>
- Begin() = 0;
-
- /**
- * @brief Return item next after last (no order guaranteed)
- */
- virtual Ptr<cs::Entry>
- End() = 0;
-
- /**
- * @brief Advance the iterator
- */
- virtual Ptr<cs::Entry> Next(Ptr<cs::Entry>) = 0;
-
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
-
- /**
- * @brief Static call to cheat python bindings
- */
- static inline Ptr<ContentStore>
- GetContentStore(Ptr<Object> node);
-
-public:
- typedef void (*CacheHitsCallback)(shared_ptr<const Interest>, shared_ptr<const Data>);
- typedef void (*CacheMissesCallback)(shared_ptr<const Interest>);
-
-protected:
- TracedCallback<shared_ptr<const Interest>,
- shared_ptr<const Data>> m_cacheHitsTrace; ///< @brief trace of cache hits
-
- TracedCallback<shared_ptr<const Interest>> m_cacheMissesTrace; ///< @brief trace of cache misses
-};
-
-inline std::ostream&
-operator<<(std::ostream& os, const ContentStore& cs)
-{
- cs.Print(os);
- return os;
-}
-
-inline Ptr<ContentStore>
-ContentStore::GetContentStore(Ptr<Object> node)
-{
- return node->GetObject<ContentStore>();
-}
-
-} // namespace ndn
-} // namespace ns3
-
-#include <boost/functional/hash.hpp>
-namespace boost {
-inline std::size_t
-hash_value(const ::ndn::name::Component component)
-{
- return boost::hash_range(component.wireEncode().wire(),
- component.wireEncode().wire() + component.wireEncode().size());
-}
-}
-
-#endif // NDN_CONTENT_STORE_H
diff --git a/model/ndn-l3-protocol.cpp b/model/ndn-l3-protocol.cpp
index c5db46c..47ce00c 100644
--- a/model/ndn-l3-protocol.cpp
+++ b/model/ndn-l3-protocol.cpp
@@ -32,7 +32,6 @@
#include "ndn-net-device-transport.hpp"
#include "../helper/ndn-stack-helper.hpp"
-#include "cs/ndn-content-store.hpp"
#include <boost/property_tree/info_parser.hpp>
@@ -192,7 +191,6 @@
nfd::ConfigSection m_config;
- Ptr<ContentStore> m_csFromNdnSim;
PolicyCreationCallback m_policy;
};
@@ -291,11 +289,7 @@
ConfigFile config(&ConfigFile::ignoreUnknownSection);
- // if we use NFD's CS, we have to specify a replacement policy
- m_impl->m_csFromNdnSim = GetObject<ContentStore>();
- if (m_impl->m_csFromNdnSim == nullptr) {
- forwarder->getCs().setPolicy(m_impl->m_policy());
- }
+ forwarder->getCs().setPolicy(m_impl->m_policy());
TablesConfigSection tablesConfig(*forwarder);
tablesConfig.setConfigFile(config);
@@ -371,12 +365,6 @@
m_node = GetObject<Node>();
if (m_node != nullptr) {
initialize();
-
- NS_ASSERT(m_impl->m_forwarder != nullptr);
- m_impl->m_csFromNdnSim = GetObject<ContentStore>();
- if (m_impl->m_csFromNdnSim != nullptr) {
- m_impl->m_forwarder->setCsFromNdnSim(m_impl->m_csFromNdnSim);
- }
}
}