model: Refactoring PIT and adding experimental support for a new policy to count container operations
diff --git a/model/pit/ndn-pit-impl.cc b/model/pit/ndn-pit-impl.cc
index 777ab39..a0d0c3e 100644
--- a/model/pit/ndn-pit-impl.cc
+++ b/model/pit/ndn-pit-impl.cc
@@ -20,14 +20,12 @@
 
 #include "ndn-pit-impl.h"
 
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-content-object.h"
-#include "ns3/ndn-forwarding-strategy.h"
-
 #include "../../utils/trie/empty-policy.h"
 #include "../../utils/trie/persistent-policy.h"
 #include "../../utils/trie/random-policy.h"
 #include "../../utils/trie/lru-policy.h"
+#include "../../utils/trie/multi-policy.h"
+#include "../../utils/trie/aggregate-stats-policy.h"
 
 #include "ns3/log.h"
 
@@ -62,13 +60,6 @@
 
 using namespace ndnSIM;
 
-template<class Policy>
-uint32_t
-PitImpl<Policy>::GetCurrentSize () const
-{
-  return super::getPolicy ().size ();
-}
-
 template<>
 uint32_t
 PitImpl<serialized_size_policy_traits>::GetCurrentSize () const
@@ -76,358 +67,10 @@
   return super::getPolicy ().get_current_space_used ();
 }
 
-template<class Policy>
-PitImpl<Policy>::PitImpl ()
-{
-}
-
-template<class Policy>
-PitImpl<Policy>::~PitImpl ()
-{
-}
-
-template<class Policy>
-uint32_t
-PitImpl<Policy>::GetMaxSize () const
-{
-  return super::getPolicy ().get_max_size ();
-}
-
-template<class Policy>
-void
-PitImpl<Policy>::SetMaxSize (uint32_t maxSize)
-{
-  super::getPolicy ().set_max_size (maxSize);
-}
-
-template<class Policy>
-void
-PitImpl<Policy>::NotifyNewAggregate ()
-{
-  if (m_fib == 0)
-    {
-      m_fib = GetObject<Fib> ();
-    }
-  if (m_forwardingStrategy == 0)
-    {
-      m_forwardingStrategy = GetObject<ForwardingStrategy> ();
-    }
-
-  Pit::NotifyNewAggregate ();
-}
-
-template<class Policy>
-void
-PitImpl<Policy>::DoDispose ()
-{
-  super::clear ();
-
-  m_forwardingStrategy = 0;
-  m_fib = 0;
-
-  Pit::DoDispose ();
-}
-
-template<class Policy>
-void
-PitImpl<Policy>::RescheduleCleaning ()
-{
-  // m_cleanEvent.Cancel ();
-  Simulator::Remove (m_cleanEvent); // slower, but better for memory
-  if (i_time.empty ())
-    {
-      // NS_LOG_DEBUG ("No items in PIT");
-      return;
-    }
-
-  Time nextEvent = i_time.begin ()->GetExpireTime () - Simulator::Now ();
-  if (nextEvent <= 0) nextEvent = Seconds (0);
-
-  NS_LOG_DEBUG ("Schedule next cleaning in " <<
-                nextEvent.ToDouble (Time::S) << "s (at " <<
-                i_time.begin ()->GetExpireTime () << "s abs time");
-
-  m_cleanEvent = Simulator::Schedule (nextEvent,
-                                      &PitImpl<Policy>::CleanExpired, this);
-}
-
-template<class Policy>
-void
-PitImpl<Policy>::CleanExpired ()
-{
-  NS_LOG_LOGIC ("Cleaning PIT. Total: " << i_time.size ());
-  Time now = Simulator::Now ();
-
-  // uint32_t count = 0;
-  while (!i_time.empty ())
-    {
-      typename time_index::iterator entry = i_time.begin ();
-      if (entry->GetExpireTime () <= now) // is the record stale?
-        {
-          m_forwardingStrategy->WillEraseTimedOutPendingInterest (entry->to_iterator ()->payload ());
-          super::erase (entry->to_iterator ());
-          // count ++;
-        }
-      else
-        break; // nothing else to do. All later records will not be stale
-    }
-
-  if (super::getPolicy ().size ())
-    {
-      NS_LOG_DEBUG ("Size: " << super::getPolicy ().size ());
-      NS_LOG_DEBUG ("i_time size: " << i_time.size ());
-    }
-  RescheduleCleaning ();
-}
-
-template<class Policy>
-Ptr<Entry>
-PitImpl<Policy>::Lookup (const ContentObject &header)
-{
-  /// @todo use predicate to search with exclude filters
-  typename super::iterator item = super::longest_prefix_match_if (header.GetName (), EntryIsNotEmpty ());
-
-  if (item == super::end ())
-    return 0;
-  else
-    return item->payload (); // which could also be 0
-}
-
-template<class Policy>
-Ptr<Entry>
-PitImpl<Policy>::Lookup (const Interest &header)
-{
-  // NS_LOG_FUNCTION (header.GetName ());
-  NS_ASSERT_MSG (m_fib != 0, "FIB should be set");
-  NS_ASSERT_MSG (m_forwardingStrategy != 0, "Forwarding strategy  should be set");
-
-  typename super::iterator foundItem, lastItem;
-  bool reachLast;
-  boost::tie (foundItem, reachLast, lastItem) = super::getTrie ().find (header.GetName ());
-
-  if (!reachLast || lastItem == super::end ())
-    return 0;
-  else
-    return lastItem->payload (); // which could also be 0
-}
-
-template<class Policy>
-Ptr<Entry>
-PitImpl<Policy>::Find (const Name &prefix)
-{
-  typename super::iterator item = super::find_exact (prefix);
-
-  if (item == super::end ())
-    return 0;
-  else
-    return item->payload ();
-}
-
-
-template<class Policy>
-Ptr<Entry>
-PitImpl<Policy>::Create (Ptr<const Interest> header)
-{
-  NS_LOG_DEBUG (header->GetName ());
-  Ptr<fib::Entry> fibEntry = m_fib->LongestPrefixMatch (*header);
-  if (fibEntry == 0)
-    return 0;
-
-  // NS_ASSERT_MSG (fibEntry != 0,
-  //                "There should be at least default route set" <<
-  //                " Prefix = "<< header->GetName() << ", NodeID == " << m_fib->GetObject<Node>()->GetId() << "\n" << *m_fib);
-
-  Ptr< entry > newEntry = ns3::Create< entry > (boost::ref (*this), header, fibEntry);
-  std::pair< typename super::iterator, bool > result = super::insert (header->GetName (), newEntry);
-  if (result.first != super::end ())
-    {
-      if (result.second)
-        {
-          newEntry->SetTrie (result.first);
-          return newEntry;
-        }
-      else
-        {
-          // should we do anything?
-          // update payload? add new payload?
-          return result.first->payload ();
-        }
-    }
-  else
-    return 0;
-}
-
-
-template<class Policy>
-void
-PitImpl<Policy>::MarkErased (Ptr<Entry> item)
-{
-  if (this->m_PitEntryPruningTimout.IsZero ())
-    {
-      super::erase (StaticCast< entry > (item)->to_iterator ());
-    }
-  else
-    {
-      item->OffsetLifetime (this->m_PitEntryPruningTimout - item->GetExpireTime () + Simulator::Now ());
-    }
-}
-
-
-template<class Policy>
-void
-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);
-  for (; item != end; item++)
-    {
-      if (item->payload () == 0) continue;
-
-      os << item->payload ()->GetPrefix () << "\t" << *item->payload () << "\n";
-    }
-}
-
-template<class Policy>
-uint32_t
-PitImpl<Policy>::GetSize () const
-{
-  return super::getPolicy ().size ();
-}
-
-template<class Policy>
-Ptr<Entry>
-PitImpl<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>
-PitImpl<Policy>::End ()
-{
-  return 0;
-}
-
-template<class Policy>
-Ptr<Entry>
-PitImpl<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 ();
-}
-
 //////////////////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////////////////
 
-template<>
-TypeId
-PitImpl<persistent_policy_traits>::GetTypeId ()
-{
-  static TypeId tid = TypeId ("ns3::ndn::pit::Persistent")
-    .SetGroupName ("Ndn")
-    .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 (&PitImpl< persistent_policy_traits >::GetMaxSize,
-                                         &PitImpl< persistent_policy_traits >::SetMaxSize),
-                   MakeUintegerChecker<uint32_t> ())
-    ;
-
-  return tid;
-}
-
-template<>
-TypeId
-PitImpl<random_policy_traits>::GetTypeId ()
-{
-  static TypeId tid = TypeId ("ns3::ndn::pit::Random")
-    .SetGroupName ("Ndn")
-    .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 (&PitImpl< random_policy_traits >::GetMaxSize,
-                                         &PitImpl< random_policy_traits >::SetMaxSize),
-                   MakeUintegerChecker<uint32_t> ())
-    ;
-
-  return tid;
-}
-
-template<>
-TypeId
-PitImpl<lru_policy_traits>::GetTypeId ()
-{
-  static TypeId tid = TypeId ("ns3::ndn::pit::Lru")
-    .SetGroupName ("Ndn")
-    .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 (&PitImpl< lru_policy_traits >::GetMaxSize,
-                                         &PitImpl< lru_policy_traits >::SetMaxSize),
-                   MakeUintegerChecker<uint32_t> ())
-    ;
-
-  return tid;
-}
-
-template<>
-TypeId
-PitImpl<serialized_size_policy_traits>::GetTypeId ()
-{
-  static TypeId tid = TypeId ("ns3::ndn::pit::SerializedSize")
-    .SetGroupName ("Ndn")
-    .SetParent<Pit> ()
-    .AddConstructor< PitImpl< serialized_size_policy_traits > > ()
-    .AddAttribute ("MaxSize",
-                   "Set maximum size of PIT in bytes. If 0, limit is not enforced",
-                   UintegerValue (0),
-                   MakeUintegerAccessor (&PitImpl< serialized_size_policy_traits >::GetMaxSize,
-                                         &PitImpl< serialized_size_policy_traits >::SetMaxSize),
-                   MakeUintegerChecker<uint32_t> ())
-
-    .AddAttribute ("CurrentSize", "Get current size of PIT in bytes",
-                   TypeId::ATTR_GET,
-                   UintegerValue (0),
-                   MakeUintegerAccessor (&PitImpl< serialized_size_policy_traits >::GetCurrentSize),
-                   MakeUintegerChecker<uint32_t> ())
-
-    ;
-
-  return tid;
-}
-
-
 // explicit instantiation and registering
 template class PitImpl<persistent_policy_traits>;
 template class PitImpl<random_policy_traits>;
@@ -439,6 +82,28 @@
 NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, lru_policy_traits);
 NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, serialized_size_policy_traits);
 
+
+typedef multi_policy_traits< boost::mpl::vector2< persistent_policy_traits,
+                                                  aggregate_stats_policy_traits > > PersistentWithCountsTraits;
+typedef multi_policy_traits< boost::mpl::vector2< random_policy_traits,
+                                                  aggregate_stats_policy_traits > > RandomWithCountsTraits;
+typedef multi_policy_traits< boost::mpl::vector2< lru_policy_traits,
+                                                  aggregate_stats_policy_traits > > LruWithCountsTraits;
+typedef multi_policy_traits< boost::mpl::vector2< serialized_size_policy_traits,
+                                                  aggregate_stats_policy_traits > > SerializedSizeWithCountsTraits;
+
+template class PitImpl<PersistentWithCountsTraits>;
+NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, PersistentWithCountsTraits);
+
+template class PitImpl<RandomWithCountsTraits>;
+NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, RandomWithCountsTraits);
+
+template class PitImpl<LruWithCountsTraits>;
+NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, LruWithCountsTraits);
+
+template class PitImpl<SerializedSizeWithCountsTraits>;
+NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, SerializedSizeWithCountsTraits);
+
 #ifdef DOXYGEN
 // /**
 //  * \brief PIT in which new entries will be rejected if PIT size reached its limit
diff --git a/model/pit/ndn-pit-impl.h b/model/pit/ndn-pit-impl.h
index 66ff69b..024054a 100644
--- a/model/pit/ndn-pit-impl.h
+++ b/model/pit/ndn-pit-impl.h
@@ -23,12 +23,18 @@
 
 #include "ndn-pit.h"
 
-#include "../../utils/trie/trie-with-policy.h"
+#include "ns3/log.h"
+#include "ns3/simulator.h"
 
+#include "../../utils/trie/trie-with-policy.h"
 #include "ndn-pit-entry-impl.h"
 
+#include "ns3/ndn-interest.h"
+#include "ns3/ndn-content-object.h"
+#include "ns3/ndn-forwarding-strategy.h"
 #include "ns3/ndn-name.h"
 
+
 namespace ns3 {
 namespace ndn {
 
@@ -104,6 +110,9 @@
   virtual Ptr<Entry>
   Next (Ptr<Entry>);
 
+  const typename super::policy_container &
+  GetPolicy () const { return super::getPolicy (); }
+
 protected:
   void RescheduleCleaning ();
   void CleanExpired ();
@@ -127,6 +136,8 @@
   Ptr<Fib> m_fib; ///< \brief Link to FIB table
   Ptr<ForwardingStrategy> m_forwardingStrategy;
 
+  static LogComponent g_log; ///< @brief Logging variable
+  
   // indexes
   typedef
   boost::intrusive::multiset<entry,
@@ -140,6 +151,311 @@
   friend class EntryImpl< PitImpl >;
 };
 
+//////////////////////////////////////////
+////////// Implementation ////////////////
+//////////////////////////////////////////
+
+template<class Policy>
+LogComponent PitImpl< Policy >::g_log = LogComponent (("ndn.pit." + Policy::GetName ()).c_str ());
+
+
+template<class Policy>
+TypeId
+PitImpl< Policy >::GetTypeId ()
+{
+  static TypeId tid = TypeId (("ns3::ndn::pit::"+Policy::GetName ()).c_str ())
+    .SetGroupName ("Ndn")
+    .SetParent<Pit> ()
+    .AddConstructor< PitImpl< Policy > > ()
+    .AddAttribute ("MaxSize",
+                   "Set maximum size of PIT in bytes. If 0, limit is not enforced",
+                   UintegerValue (0),
+                   MakeUintegerAccessor (&PitImpl< Policy >::GetMaxSize,
+                                         &PitImpl< Policy >::SetMaxSize),
+                   MakeUintegerChecker<uint32_t> ())
+
+    .AddAttribute ("CurrentSize", "Get current size of PIT in bytes",
+                   TypeId::ATTR_GET,
+                   UintegerValue (0),
+                   MakeUintegerAccessor (&PitImpl< Policy >::GetCurrentSize),
+                   MakeUintegerChecker<uint32_t> ())
+    ;
+
+  return tid;
+}
+
+template<class Policy>
+uint32_t
+PitImpl<Policy>::GetCurrentSize () const
+{
+  return super::getPolicy ().size ();
+}
+
+template<class Policy>
+PitImpl<Policy>::PitImpl ()
+{
+}
+
+template<class Policy>
+PitImpl<Policy>::~PitImpl ()
+{
+}
+
+template<class Policy>
+uint32_t
+PitImpl<Policy>::GetMaxSize () const
+{
+  return super::getPolicy ().get_max_size ();
+}
+
+template<class Policy>
+void
+PitImpl<Policy>::SetMaxSize (uint32_t maxSize)
+{
+  super::getPolicy ().set_max_size (maxSize);
+}
+
+template<class Policy>
+void
+PitImpl<Policy>::NotifyNewAggregate ()
+{
+  if (m_fib == 0)
+    {
+      m_fib = GetObject<Fib> ();
+    }
+  if (m_forwardingStrategy == 0)
+    {
+      m_forwardingStrategy = GetObject<ForwardingStrategy> ();
+    }
+
+  Pit::NotifyNewAggregate ();
+}
+
+template<class Policy>
+void
+PitImpl<Policy>::DoDispose ()
+{
+  super::clear ();
+
+  m_forwardingStrategy = 0;
+  m_fib = 0;
+
+  Pit::DoDispose ();
+}
+
+template<class Policy>
+void
+PitImpl<Policy>::RescheduleCleaning ()
+{
+  // m_cleanEvent.Cancel ();
+  Simulator::Remove (m_cleanEvent); // slower, but better for memory
+  if (i_time.empty ())
+    {
+      // NS_LOG_DEBUG ("No items in PIT");
+      return;
+    }
+
+  Time nextEvent = i_time.begin ()->GetExpireTime () - Simulator::Now ();
+  if (nextEvent <= 0) nextEvent = Seconds (0);
+
+  NS_LOG_DEBUG ("Schedule next cleaning in " <<
+                nextEvent.ToDouble (Time::S) << "s (at " <<
+                i_time.begin ()->GetExpireTime () << "s abs time");
+
+  m_cleanEvent = Simulator::Schedule (nextEvent,
+                                      &PitImpl<Policy>::CleanExpired, this);
+}
+
+template<class Policy>
+void
+PitImpl<Policy>::CleanExpired ()
+{
+  NS_LOG_LOGIC ("Cleaning PIT. Total: " << i_time.size ());
+  Time now = Simulator::Now ();
+
+  // uint32_t count = 0;
+  while (!i_time.empty ())
+    {
+      typename time_index::iterator entry = i_time.begin ();
+      if (entry->GetExpireTime () <= now) // is the record stale?
+        {
+          m_forwardingStrategy->WillEraseTimedOutPendingInterest (entry->to_iterator ()->payload ());
+          super::erase (entry->to_iterator ());
+          // count ++;
+        }
+      else
+        break; // nothing else to do. All later records will not be stale
+    }
+
+  if (super::getPolicy ().size ())
+    {
+      NS_LOG_DEBUG ("Size: " << super::getPolicy ().size ());
+      NS_LOG_DEBUG ("i_time size: " << i_time.size ());
+    }
+  RescheduleCleaning ();
+}
+
+template<class Policy>
+Ptr<Entry>
+PitImpl<Policy>::Lookup (const ContentObject &header)
+{
+  /// @todo use predicate to search with exclude filters
+  typename super::iterator item = super::longest_prefix_match_if (header.GetName (), EntryIsNotEmpty ());
+
+  if (item == super::end ())
+    return 0;
+  else
+    return item->payload (); // which could also be 0
+}
+
+template<class Policy>
+Ptr<Entry>
+PitImpl<Policy>::Lookup (const Interest &header)
+{
+  // NS_LOG_FUNCTION (header.GetName ());
+  NS_ASSERT_MSG (m_fib != 0, "FIB should be set");
+  NS_ASSERT_MSG (m_forwardingStrategy != 0, "Forwarding strategy  should be set");
+
+  typename super::iterator foundItem, lastItem;
+  bool reachLast;
+  boost::tie (foundItem, reachLast, lastItem) = super::getTrie ().find (header.GetName ());
+
+  if (!reachLast || lastItem == super::end ())
+    return 0;
+  else
+    return lastItem->payload (); // which could also be 0
+}
+
+template<class Policy>
+Ptr<Entry>
+PitImpl<Policy>::Find (const Name &prefix)
+{
+  typename super::iterator item = super::find_exact (prefix);
+
+  if (item == super::end ())
+    return 0;
+  else
+    return item->payload ();
+}
+
+
+template<class Policy>
+Ptr<Entry>
+PitImpl<Policy>::Create (Ptr<const Interest> header)
+{
+  NS_LOG_DEBUG (header->GetName ());
+  Ptr<fib::Entry> fibEntry = m_fib->LongestPrefixMatch (*header);
+  if (fibEntry == 0)
+    return 0;
+
+  // NS_ASSERT_MSG (fibEntry != 0,
+  //                "There should be at least default route set" <<
+  //                " Prefix = "<< header->GetName() << ", NodeID == " << m_fib->GetObject<Node>()->GetId() << "\n" << *m_fib);
+
+  Ptr< entry > newEntry = ns3::Create< entry > (boost::ref (*this), header, fibEntry);
+  std::pair< typename super::iterator, bool > result = super::insert (header->GetName (), newEntry);
+  if (result.first != super::end ())
+    {
+      if (result.second)
+        {
+          newEntry->SetTrie (result.first);
+          return newEntry;
+        }
+      else
+        {
+          // should we do anything?
+          // update payload? add new payload?
+          return result.first->payload ();
+        }
+    }
+  else
+    return 0;
+}
+
+
+template<class Policy>
+void
+PitImpl<Policy>::MarkErased (Ptr<Entry> item)
+{
+  if (this->m_PitEntryPruningTimout.IsZero ())
+    {
+      super::erase (StaticCast< entry > (item)->to_iterator ());
+    }
+  else
+    {
+      item->OffsetLifetime (this->m_PitEntryPruningTimout - item->GetExpireTime () + Simulator::Now ());
+    }
+}
+
+
+template<class Policy>
+void
+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);
+  for (; item != end; item++)
+    {
+      if (item->payload () == 0) continue;
+
+      os << item->payload ()->GetPrefix () << "\t" << *item->payload () << "\n";
+    }
+}
+
+template<class Policy>
+uint32_t
+PitImpl<Policy>::GetSize () const
+{
+  return super::getPolicy ().size ();
+}
+
+template<class Policy>
+Ptr<Entry>
+PitImpl<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>
+PitImpl<Policy>::End ()
+{
+  return 0;
+}
+
+template<class Policy>
+Ptr<Entry>
+PitImpl<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 pit
 } // namespace ndn
 } // namespace ns3
diff --git a/utils/trie/aggregate-stats-policy.h b/utils/trie/aggregate-stats-policy.h
new file mode 100644
index 0000000..c8d9dea
--- /dev/null
+++ b/utils/trie/aggregate-stats-policy.h
@@ -0,0 +1,146 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011-2013 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 AGGREGATE_STATS_POLICY_H_
+#define AGGREGATE_STATS_POLICY_H_
+
+#include <boost/intrusive/options.hpp>
+#include <boost/intrusive/list.hpp>
+
+namespace ns3 {
+namespace ndn {
+namespace ndnSIM {
+
+/**
+ * @brief Traits for policy that just keeps track of number of elements
+ * It's doing a rather expensive job, but just in case it needs to be extended later
+ */
+struct aggregate_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 "AggregateStats"; }
+  struct policy_hook_type { };
+
+  template<class Container>
+  struct container_hook
+  {
+    struct type { };
+  };
+
+  template<class Base,
+           class Container,
+           class Hook>
+  struct policy
+  {
+    // typedef typename boost::intrusive::list< Container, Hook > policy_container;
+
+    // could be just typedef
+    class type
+    {
+    public:
+      typedef Container parent_trie;
+
+      type (Base &base)
+        : base_ (base)
+        , m_updates (0)
+        , m_inserts (0)
+        , m_lookups (0)
+        , m_erases (0)
+      {
+      }
+
+      inline void
+      update (typename parent_trie::iterator item)
+      {
+        m_updates ++;
+        // do nothing
+      }
+
+      inline bool
+      insert (typename parent_trie::iterator item)
+      {
+        m_inserts ++;
+        return true;
+      }
+
+      inline void
+      lookup (typename parent_trie::iterator item)
+      {
+        m_lookups ++;
+      }
+
+      inline void
+      erase (typename parent_trie::iterator item)
+      {
+        m_erases ++;
+      }
+
+      inline void
+      set_max_size (uint32_t) {}
+
+      inline uint32_t
+      get_max_size () const { return 0; }
+
+      inline void
+      clear ()
+      {
+        // is called only at the end of simulation
+      }
+
+      inline void
+      resetStats ()
+      {
+        m_updates = 0;
+        m_inserts = 0;
+        m_lookups = 0;
+        m_erases = 0;
+      }
+
+      inline uint64_t
+      GetUpdates () const { return m_updates; }
+
+      inline uint64_t
+      GetInserts () const { return m_inserts; }
+
+      inline uint64_t
+      GetLookups () const { return m_lookups; }
+
+      inline uint64_t
+      GetErases () const { return m_erases; }
+
+    private:
+      type () : base_(*((Base*)0)) { };
+
+    private:
+      Base &base_;
+      
+      uint64_t m_updates;
+      uint64_t m_inserts;
+      uint64_t m_lookups;
+      uint64_t m_erases;
+    };
+  };
+};
+
+} // ndnSIM
+} // ndn
+} // ns3
+
+#endif // AGGREGATE_STATS_POLICY_H_
diff --git a/utils/trie/multi-policy.h b/utils/trie/multi-policy.h
index e662aff..314a2a0 100644
--- a/utils/trie/multi-policy.h
+++ b/utils/trie/multi-policy.h
@@ -163,6 +163,8 @@
     
     template< typename U > void operator() (U index)
     {
+      if (!m_name.empty ())
+        m_name += "::";
       m_name += boost::mpl::at_c< policy_traits, U::value >::type::GetName ();
     }