ndnSIM-v2: Initial implementation
- Name, name::Components, Interest, Data now use ndn-cxx
- Ptr is replaced with shared_ptr for ndn-cxx structures
Credits for the change also to Mickey Sweat, Wentao Shang, and Alex Afanasyev
diff --git a/model/cs/content-store-impl.hpp b/model/cs/content-store-impl.hpp
index b35fdb4..4692486 100644
--- a/model/cs/content-store-impl.hpp
+++ b/model/cs/content-store-impl.hpp
@@ -21,11 +21,11 @@
#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 "ns3/ndn-interest.h"
-#include "ns3/ndn-data.h"
#include <boost/foreach.hpp>
#include "ns3/log.h"
@@ -48,7 +48,7 @@
typedef Entry base_type;
public:
- EntryImpl(Ptr<ContentStore> cs, Ptr<const Data> data)
+ EntryImpl(Ptr<ContentStore> cs, shared_ptr<const Data> data)
: Entry(cs, data)
, item_(0)
{
@@ -103,14 +103,14 @@
// from ContentStore
- virtual inline Ptr<Data>
- Lookup(Ptr<const Interest> interest);
+ virtual inline shared_ptr<Data>
+ Lookup(shared_ptr<const Interest> interest);
virtual inline bool
- Add(Ptr<const Data> data);
+ Add(shared_ptr<const Data> data);
// virtual bool
- // Remove (Ptr<Interest> header);
+ // Remove (shared_ptr<Interest> header);
virtual inline void
Print(std::ostream& os) const;
@@ -200,8 +200,8 @@
};
template<class Policy>
-Ptr<Data>
-ContentStoreImpl<Policy>::Lookup(Ptr<const Interest> interest)
+shared_ptr<Data>
+ContentStoreImpl<Policy>::Lookup(shared_ptr<const Interest> interest)
{
NS_LOG_FUNCTION(this << interest->GetName());
@@ -217,7 +217,7 @@
if (node != this->end()) {
this->m_cacheHitsTrace(interest, node->payload()->GetData());
- Ptr<Data> copy = Create<Data>(*node->payload()->GetData());
+ shared_ptr<Data> copy = make_shared<Data>(*node->payload()->GetData());
ConstCast<Packet>(copy->GetPayload())->RemoveAllPacketTags();
return copy;
}
@@ -229,7 +229,7 @@
template<class Policy>
bool
-ContentStoreImpl<Policy>::Add(Ptr<const Data> data)
+ContentStoreImpl<Policy>::Add(shared_ptr<const Data> data)
{
NS_LOG_FUNCTION(this << data->GetName());
diff --git a/model/cs/content-store-nocache.cpp b/model/cs/content-store-nocache.cpp
index 85505d1..9aef87b 100644
--- a/model/cs/content-store-nocache.cpp
+++ b/model/cs/content-store-nocache.cpp
@@ -52,15 +52,15 @@
{
}
-Ptr<Data>
-Nocache::Lookup(Ptr<const Interest> interest)
+shared_ptr<Data>
+Nocache::Lookup(shared_ptr<const Interest> interest)
{
this->m_cacheMissesTrace(interest);
return 0;
}
bool
-Nocache::Add(Ptr<const Data> data)
+Nocache::Add(shared_ptr<const Data> data)
{
return false;
}
diff --git a/model/cs/content-store-nocache.hpp b/model/cs/content-store-nocache.hpp
index 5745821..bf271cb 100644
--- a/model/cs/content-store-nocache.hpp
+++ b/model/cs/content-store-nocache.hpp
@@ -22,6 +22,8 @@
#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 {
@@ -52,11 +54,11 @@
*/
virtual ~Nocache();
- virtual Ptr<Data>
- Lookup(Ptr<const Interest> interest);
+ virtual shared_ptr<Data>
+ Lookup(shared_ptr<const Interest> interest);
virtual bool
- Add(Ptr<const Data> data);
+ Add(shared_ptr<const Data> data);
virtual void
Print(std::ostream& os) const;
diff --git a/model/cs/content-store-with-freshness.hpp b/model/cs/content-store-with-freshness.hpp
index 07aa56f..836a94f 100644
--- a/model/cs/content-store-with-freshness.hpp
+++ b/model/cs/content-store-with-freshness.hpp
@@ -21,7 +21,7 @@
#ifndef NDN_CONTENT_STORE_WITH_FRESHNESS_H_
#define NDN_CONTENT_STORE_WITH_FRESHNESS_H_
-#include "content-store-impl.h"
+#include "ns3/ndnSIM/model/ndn-common.hpp"
#include "content-store-impl.hpp"
@@ -57,7 +57,7 @@
Print(std::ostream& os) const;
virtual inline bool
- Add(Ptr<const Data> data);
+ Add(shared_ptr<const Data> data);
private:
inline void
@@ -98,7 +98,7 @@
template<class Policy>
inline bool
-ContentStoreWithFreshness<Policy>::Add(Ptr<const Data> data)
+ContentStoreWithFreshness<Policy>::Add(shared_ptr<const Data> data)
{
bool ok = super::Add(data);
if (!ok)
diff --git a/model/cs/content-store-with-probability.hpp b/model/cs/content-store-with-probability.hpp
index cca50c1..b442e4a 100644
--- a/model/cs/content-store-with-probability.hpp
+++ b/model/cs/content-store-with-probability.hpp
@@ -21,7 +21,7 @@
#ifndef NDN_CONTENT_STORE_WITH_PROBABILITY_H_
#define NDN_CONTENT_STORE_WITH_PROBABILITY_H_
-#include "content-store-impl.h"
+#include "ns3/ndnSIM/model/ndn-common.hpp"
#include "content-store-impl.hpp"
diff --git a/model/cs/content-store-with-stats.hpp b/model/cs/content-store-with-stats.hpp
index b5f7540..f1ba5b2 100644
--- a/model/cs/content-store-with-stats.hpp
+++ b/model/cs/content-store-with-stats.hpp
@@ -21,7 +21,7 @@
#ifndef NDN_CONTENT_STORE_WITH_STATS_H_
#define NDN_CONTENT_STORE_WITH_STATS_H_
-#include "content-store-impl.h"
+#include "ns3/ndnSIM/model/ndn-common.hpp"
#include "content-store-impl.hpp"
diff --git a/model/cs/custom-policies/freshness-policy.hpp b/model/cs/custom-policies/freshness-policy.hpp
index 999c61d..9d66c66 100644
--- a/model/cs/custom-policies/freshness-policy.hpp
+++ b/model/cs/custom-policies/freshness-policy.hpp
@@ -21,6 +21,8 @@
#ifndef FRESHNESS_POLICY_H_
#define FRESHNESS_POLICY_H_
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
#include <boost/intrusive/options.hpp>
#include <boost/intrusive/list.hpp>
diff --git a/model/cs/custom-policies/lifetime-stats-policy.hpp b/model/cs/custom-policies/lifetime-stats-policy.hpp
index 1102ef1..1abf39d 100644
--- a/model/cs/custom-policies/lifetime-stats-policy.hpp
+++ b/model/cs/custom-policies/lifetime-stats-policy.hpp
@@ -21,6 +21,8 @@
#ifndef LIFETIME_STATS_POLICY_H_
#define LIFETIME_STATS_POLICY_H_
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
#include <boost/intrusive/options.hpp>
#include <boost/intrusive/list.hpp>
diff --git a/model/cs/custom-policies/probability-policy.hpp b/model/cs/custom-policies/probability-policy.hpp
index 57d6835..8638c0a 100644
--- a/model/cs/custom-policies/probability-policy.hpp
+++ b/model/cs/custom-policies/probability-policy.hpp
@@ -21,6 +21,8 @@
#ifndef PROBABILITY_POLICY_H_
#define PROBABILITY_POLICY_H_
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
#include <boost/intrusive/options.hpp>
#include <boost/intrusive/list.hpp>
diff --git a/model/cs/ndn-content-store.cpp b/model/cs/ndn-content-store.cpp
index 3588eb9..8df04c6 100644
--- a/model/cs/ndn-content-store.cpp
+++ b/model/cs/ndn-content-store.cpp
@@ -57,7 +57,7 @@
//////////////////////////////////////////////////////////////////////
-Entry::Entry(Ptr<ContentStore> cs, Ptr<const Data> data)
+Entry::Entry(Ptr<ContentStore> cs, shared_ptr<const Data> data)
: m_cs(cs)
, m_data(data)
{
@@ -69,7 +69,7 @@
return m_data->GetName();
}
-Ptr<const Data>
+shared_ptr<const Data>
Entry::GetData() const
{
return m_data;
diff --git a/model/cs/ndn-content-store.hpp b/model/cs/ndn-content-store.hpp
index 23266c4..e28eea0 100644
--- a/model/cs/ndn-content-store.hpp
+++ b/model/cs/ndn-content-store.hpp
@@ -22,6 +22,8 @@
#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"
@@ -65,7 +67,7 @@
* The constructor will make a copy of the supplied packet and calls
* RemoveHeader and RemoveTail on the copy.
*/
- Entry(Ptr<ContentStore> cs, Ptr<const Data> data);
+ Entry(Ptr<ContentStore> cs, shared_ptr<const Data> data);
/**
* \brief Get prefix of the stored entry
@@ -78,7 +80,7 @@
* \brief Get Data of the stored entry
* \returns Data of the stored entry
*/
- Ptr<const Data>
+ shared_ptr<const Data>
GetData() const;
/**
@@ -89,7 +91,7 @@
private:
Ptr<ContentStore> m_cs; ///< \brief content store to which entry is added
- Ptr<const Data> m_data; ///< \brief non-modifiable Data
+ shared_ptr<const Data> m_data; ///< \brief non-modifiable Data
};
} // namespace cs
@@ -124,8 +126,8 @@
* If an entry is found, it is promoted to the top of most recent
* used entries index, \see m_contentStore
*/
- virtual Ptr<Data>
- Lookup(Ptr<const Interest> interest) = 0;
+ virtual shared_ptr<Data>
+ Lookup(shared_ptr<const Interest> interest) = 0;
/**
* \brief Add a new content to the content store.
@@ -136,7 +138,7 @@
* @returns true if an existing entry was updated, false otherwise
*/
virtual bool
- Add(Ptr<const Data> data) = 0;
+ Add(shared_ptr<const Data> data) = 0;
// /*
// * \brief Add a new content to the content store.
@@ -145,7 +147,7 @@
// * @returns true if an existing entry was removed, false otherwise
// */
// virtual bool
- // Remove (Ptr<Interest> header) = 0;
+ // Remove (shared_ptr<Interest> header) = 0;
/**
* \brief Print out content store entries
@@ -187,10 +189,10 @@
GetContentStore(Ptr<Object> node);
protected:
- TracedCallback<Ptr<const Interest>,
- Ptr<const Data>> m_cacheHitsTrace; ///< @brief trace of cache hits
+ TracedCallback<shared_ptr<const Interest>,
+ shared_ptr<const Data>> m_cacheHitsTrace; ///< @brief trace of cache hits
- TracedCallback<Ptr<const Interest>> m_cacheMissesTrace; ///< @brief trace of cache misses
+ TracedCallback<shared_ptr<const Interest>> m_cacheMissesTrace; ///< @brief trace of cache misses
};
inline std::ostream&