Adding Hit/Miss trace source
Also, correcting a bug with modular ContentStore and small update of
docs
diff --git a/docs/source/intro.rst b/docs/source/intro.rst
index bcc3e3f..3453d47 100644
--- a/docs/source/intro.rst
+++ b/docs/source/intro.rst
@@ -116,7 +116,9 @@
ndnSIM source code should be placed in ``src/ndnSIM`` folder under NS-3 simulator source tree. For example::
cd ns-3-dev
- git clone git://github.com/NDN-Routing/ndnSIM.git ns-3/src/ndnSIM
+ git clone gitolite@git.irl.cs.ucla.edu:ndn/ndnSIM.git ns-3/src/ndnSIM
+
+.. git clone git://github.com/NDN-Routing/ndnSIM.git ns-3/src/ndnSIM
After cloning, a number of patches need to be applied to the base NS-3 to make sure ndnSIM compiles and works::
@@ -130,7 +132,7 @@
mkdir ndnSIM
cd ndnSIM
- git clone git://github.com/cawka/ns-3-dev-ndnSIM.git ns-3
+ git clone gitolite@git.irl.cs.ucla.edu:ndn/ndnSIM.git ns-3/src/ndnSIM
git clone git://github.com/cawka/pybindgen.git pybindgen
git clone git://github.com/NDN-Routing/ndnSIM.git ns-3/src/ndnSIM
diff --git a/helper/ccnx-stack-helper.cc b/helper/ccnx-stack-helper.cc
index 34010e4..85cef6c 100644
--- a/helper/ccnx-stack-helper.cc
+++ b/helper/ccnx-stack-helper.cc
@@ -136,7 +136,11 @@
Ptr<CcnxL3Protocol> ccnx = CreateObject<CcnxL3Protocol> ();
node->AggregateObject (ccnx);
+ // Create and set forwarding strategy
ccnx->SetForwardingStrategy (m_strategyFactory.Create<CcnxForwardingStrategy> ());
+
+ // Create and set content store
+ node->AggregateObject (m_contentStoreFactory.Create ());
for (uint32_t index=0; index < node->GetNDevices (); index++)
{
diff --git a/model/ccnx-content-store-lru.cc b/model/ccnx-content-store-lru.cc
index bb35c1b..8c0d777 100644
--- a/model/ccnx-content-store-lru.cc
+++ b/model/ccnx-content-store-lru.cc
@@ -80,37 +80,6 @@
type;
};
-/**
- * \ingroup ccnx
- * \brief Typedef for MRU index of content store container
- */
-struct CcnxContentStoreByMru
-{
- typedef
- CcnxContentStoreLruContainer::type::index<i_mru>::type
- type;
-};
-
-#ifdef _DEBUG
-#define DUMP_INDEX_TAG i_ordered
-#define DUMP_INDEX CcnxContentStoreOrderedPrefix
-/**
- * \ingroup ccnx
- * \brief Typedef for ordered index of content store container
- */
-struct CcnxContentStoreOrderedPrefix
-{
- typedef
- CcnxContentStoreLruContainer::type::index<i_ordered>::type
- type;
-};
-#else
-#define DUMP_INDEX_TAG i_mru
-#define DUMP_INDEX CcnxContentStoreByMru
-#endif
-
-
-
CcnxContentStoreLru::CcnxContentStoreLru ()
: m_maxSize (100)
{ } // this value shouldn't matter, NS-3 should call SetSize with default value specified in AddAttribute earlier
@@ -130,9 +99,12 @@
m_contentStore.get<i_mru> ().relocate (m_contentStore.get<i_mru> ().begin (),
m_contentStore.project<i_mru> (it));
+ m_cacheHitsTrace (interest, it->GetHeader ());
+
// return fully formed CCNx packet
return boost::make_tuple (it->GetFullyFormedCcnxPacket (), it->GetHeader (), it->GetPacket ());
}
+ m_cacheMissesTrace (interest);
return boost::tuple<Ptr<Packet>, Ptr<CcnxContentObjectHeader>, Ptr<Packet> > (0, 0, 0);
}
@@ -161,12 +133,9 @@
void
CcnxContentStoreLru::Print() const
{
- for( DUMP_INDEX::type::iterator it=m_contentStore.get<DUMP_INDEX_TAG> ().begin ();
- it != m_contentStore.get<DUMP_INDEX_TAG> ().end ();
- it++
- )
+ BOOST_FOREACH (const CcnxContentStoreEntry &entry, m_contentStore.get<i_mru> ())
{
- NS_LOG_INFO (it->GetName ());
+ NS_LOG_INFO (entry.GetName ());
}
}
diff --git a/model/ccnx-content-store-lru.h b/model/ccnx-content-store-lru.h
index 66a81a2..b510646 100644
--- a/model/ccnx-content-store-lru.h
+++ b/model/ccnx-content-store-lru.h
@@ -29,13 +29,9 @@
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/mem_fun.hpp>
-#include <boost/tuple/tuple.hpp>
#include "ccnx.h"
#include "ccnx-name-components-hash-helper.h"
-// #include "ccnx-content-object-header.h"
-// #include "ccnx-interest-header.h"
-// #include "ccnx-name-components.h"
namespace ns3
{
@@ -45,7 +41,6 @@
*
* - First index (tag<prefix>) is a unique hash index based on NDN prefix of the stored content.
* - Second index (tag<mru>) is a sequential index used to maintain up to m_maxSize most recent used (MRU) entries in the content store
- * - Third index (tag<ordered>) is just a helper to provide stored prefixes in ordered way. Should be disabled in production build
*
* \see http://www.boost.org/doc/libs/1_46_1/libs/multi_index/doc/ for more information on Boost.MultiIndex library
*/
@@ -63,15 +58,6 @@
&CcnxContentStoreEntry::GetName>,
CcnxPrefixHash>,
boost::multi_index::sequenced<boost::multi_index::tag<__ccnx_private::i_mru> >
-#ifdef _DEBUG
- ,
- boost::multi_index::ordered_unique<
- boost::multi_index::tag<__ccnx_private::i_ordered>,
- boost::multi_index::const_mem_fun<CcnxContentStoreEntry,
- const CcnxNameComponents&,
- &CcnxContentStoreEntry::GetName>
- >
-#endif
>
> type;
/// @endcond
diff --git a/model/ccnx-content-store.cc b/model/ccnx-content-store.cc
index 986405f..c5a66c9 100644
--- a/model/ccnx-content-store.cc
+++ b/model/ccnx-content-store.cc
@@ -40,6 +40,11 @@
static TypeId tid = TypeId ("ns3::CcnxContentStore")
.SetGroupName ("Ccnx")
.SetParent<Object> ()
+
+ .AddTraceSource ("CacheHits", "Trace called every time there is a cache hit",
+ MakeTraceSourceAccessor (&CcnxContentStore::m_cacheHitsTrace))
+ .AddTraceSource ("CacheMisses", "Trace called every time there is a cache miss",
+ MakeTraceSourceAccessor (&CcnxContentStore::m_cacheMissesTrace))
;
return tid;
diff --git a/model/ccnx-content-store.h b/model/ccnx-content-store.h
index dd56867..97615db 100644
--- a/model/ccnx-content-store.h
+++ b/model/ccnx-content-store.h
@@ -24,6 +24,8 @@
#include "ns3/object.h"
#include "ns3/ptr.h"
+#include "ns3/traced-callback.h"
+
#include <boost/tuple/tuple.hpp>
namespace ns3
@@ -157,6 +159,12 @@
*/
virtual void
Print () const = 0;
+
+protected:
+ TracedCallback<Ptr<const CcnxInterestHeader>,
+ Ptr<const CcnxContentObjectHeader> > m_cacheHitsTrace; ///< @brief trace of cache hits
+
+ TracedCallback<Ptr<const CcnxInterestHeader> > m_cacheMissesTrace; ///< @brief trace of cache misses
};
inline std::ostream&