Introducing a couple of real test cases.

Also, basic PIT test shows that everything works as expected...

There was one big change in PIT. Previously, when PIT entry was
satisfied, it was immediately removed. As of recently, PIT entry is
immediately removed.
diff --git a/model/ccnx-fib-impl.cc b/model/ccnx-fib-impl.cc
index e298875..10217e3 100644
--- a/model/ccnx-fib-impl.cc
+++ b/model/ccnx-fib-impl.cc
@@ -200,6 +200,12 @@
     }
 }
 
+uint32_t
+CcnxFibImpl::GetSize () const
+{
+  return super::getPolicy ().size ();
+}
+
 Ptr<const CcnxFibEntry>
 CcnxFibImpl::Begin ()
 {
diff --git a/model/ccnx-fib-impl.h b/model/ccnx-fib-impl.h
index 2768a7d..eaedeee 100644
--- a/model/ccnx-fib-impl.h
+++ b/model/ccnx-fib-impl.h
@@ -25,7 +25,7 @@
 #include "ns3/ccnx-name-components.h"
 
 #include "../utils/trie-with-policy.h"
-#include "../utils/empty-policy.h"
+#include "../utils/counting-policy.h"
 
 namespace ns3 {
 
@@ -35,7 +35,7 @@
   typedef ndnSIM::trie_with_policy<
     CcnxNameComponents,
     ndnSIM::smart_pointer_payload_traits<CcnxFibEntryImpl>,
-    ndnSIM::empty_policy_traits
+    ndnSIM::counting_policy_traits
     > trie;
 
   CcnxFibEntryImpl (const Ptr<const CcnxNameComponents> &prefix)
@@ -62,7 +62,7 @@
   typedef ndnSIM::trie_with_policy<
     CcnxNameComponents,
     ndnSIM::smart_pointer_payload_traits<CcnxFibEntryImpl>,
-    ndnSIM::empty_policy_traits
+    ndnSIM::counting_policy_traits
     > type;
 };
 
@@ -109,6 +109,9 @@
   virtual void
   Print (std::ostream &os) const;
 
+  virtual uint32_t
+  GetSize () const;
+
   virtual Ptr<const CcnxFibEntry>
   Begin ();
 
diff --git a/model/ccnx-fib.h b/model/ccnx-fib.h
index e5bda1e..eae0c65 100644
--- a/model/ccnx-fib.h
+++ b/model/ccnx-fib.h
@@ -132,6 +132,12 @@
   Print (std::ostream &os) const = 0;
 
   /**
+   * @brief Get number of entries in FIB
+   */
+  virtual uint32_t
+  GetSize () const = 0;
+
+  /**
    * @brief Return first element of FIB (no order guaranteed)
    */
   virtual Ptr<const CcnxFibEntry>
diff --git a/model/ccnx-name-components.cc b/model/ccnx-name-components.cc
index 893f7bb..a79b6bb 100644
--- a/model/ccnx-name-components.cc
+++ b/model/ccnx-name-components.cc
@@ -43,7 +43,14 @@
       Add (component.get ());
     }
 }
-  
+
+CcnxNameComponents::CcnxNameComponents (const std::string &prefix)
+{
+  istringstream is (prefix);
+  is >> *this;
+}
+
+
 const std::list<std::string> &
 CcnxNameComponents::GetComponents () const
 {
diff --git a/model/ccnx-name-components.h b/model/ccnx-name-components.h
index 1d8ef2a..eb4f8c1 100644
--- a/model/ccnx-name-components.h
+++ b/model/ccnx-name-components.h
@@ -63,6 +63,13 @@
   CcnxNameComponents (const std::list<boost::reference_wrapper<const std::string> > &components);
 
   /**
+   * @brief Constructor
+   * Creates a prefix from the string (string is parsed using operator>>)
+   * @param[in] prefix A string representation of a prefix
+   */
+  CcnxNameComponents (const std::string &prefix);
+  
+  /**
    * \brief Generic Add method
    * Appends object of type T to the list of components 
    * @param[in] value The object to be appended
diff --git a/model/ccnx-pit-entry.cc b/model/ccnx-pit-entry.cc
index dde19e7..4b075ab 100644
--- a/model/ccnx-pit-entry.cc
+++ b/model/ccnx-pit-entry.cc
@@ -41,7 +41,9 @@
                             Ptr<CcnxFibEntry> fibEntry)
   : m_container (container)
   , m_prefix (header->GetNamePtr ())
-  , m_expireTime (Simulator::Now () + header->GetInterestLifetime ())
+  , m_expireTime (Simulator::Now () + (!header->GetInterestLifetime ().IsZero ()?
+                                       header->GetInterestLifetime ():
+                                       Seconds (1.0)))
   , m_fibEntry (fibEntry)
   , m_maxRetxCount (0)
 {
diff --git a/model/ccnx-pit-impl.cc b/model/ccnx-pit-impl.cc
index 0dcfef2..f68f9dd 100644
--- a/model/ccnx-pit-impl.cc
+++ b/model/ccnx-pit-impl.cc
@@ -110,9 +110,18 @@
 {
   m_cleanEvent.Cancel ();
   if (i_time.empty ())
-    return;
+    {
+      NS_LOG_DEBUG ("No items in PIT");
+      return;
+    }
 
-  m_cleanEvent = Simulator::Schedule (i_time.begin ()->GetExpireTime (),
+  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,
                                       &CcnxPitImpl::CleanExpired, this);
 }
 
@@ -217,6 +226,12 @@
     }
 }
 
+uint32_t
+CcnxPitImpl::GetSize () const
+{
+  return super::getPolicy ().size ();
+}
+
 Ptr<CcnxPitEntry>
 CcnxPitImpl::Begin ()
 {
diff --git a/model/ccnx-pit-impl.h b/model/ccnx-pit-impl.h
index d03134c..123ed85 100644
--- a/model/ccnx-pit-impl.h
+++ b/model/ccnx-pit-impl.h
@@ -82,6 +82,9 @@
   virtual void
   Print (std::ostream &os) const;
 
+  virtual uint32_t
+  GetSize () const;
+
   virtual Ptr<CcnxPitEntry>
   Begin ();
 
diff --git a/model/ccnx-pit.h b/model/ccnx-pit.h
index 0ae3968..941b079 100644
--- a/model/ccnx-pit.h
+++ b/model/ccnx-pit.h
@@ -113,19 +113,11 @@
   virtual void
   Print (std::ostream &os) const = 0;
 
-  // template<class A,class M>
-  // void
-  // modify (A, M)
-  // {
-  //   ;
-  // }
-
-  // template<class A>
-  // void
-  // erase (A)
-  // {
-  //   ;
-  // }
+  /**
+   * @brief Get number of entries in PIT
+   */
+  virtual uint32_t
+  GetSize () const = 0;
 
   /**
    * @brief Return first element of FIB (no order guaranteed)
diff --git a/test/basic-regression-test.cc b/test/basic-regression-test.cc
deleted file mode 100644
index 8d3c661..0000000
--- a/test/basic-regression-test.cc
+++ /dev/null
@@ -1,184 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#include "ns3/test.h"
-#include "ns3/ccnx-interest-header.h"
-#include "ns3/uinteger.h"
-#include "ns3/random-variable.h"
-#include <limits> 
-#include "ns3/ccnx-header-helper.h"
-#include "ns3/header.h"
-#include "ns3/ccnx-name-components.h"
-#include "ns3/nstime.h"
-#include "ns3/buffer.h"
-#include "ns3/log.h"
-
-#include <ctime>
-#include <sstream>
-
-#include "ns3/internet-stack-helper.h"
-#include "ns3/ipv4-list-routing-helper.h"
-#include "ns3/ipv4-static-routing-helper.h"
-#include "ns3/point-to-point-helper.h"
-#include "ns3/application.h"
-#include "ns3/ipv4-static-routing-helper.h"
-#include "ns3/ipv4-list-routing-helper.h"
-
-#include <list>
-
-
-using namespace ns3;
-using namespace std;
-
-NS_LOG_COMPONENT_DEFINE ("CcnxBasicRegressionTest");
-
-class BasicRegressionTest : public TestCase
-{
-public:
-    
-  BasicRegressionTest ();
-  virtual ~BasicRegressionTest ();
-    
-private:
-  virtual void DoRun (void);
-};
-
-BasicRegressionTest::BasicRegressionTest ()
-  : TestCase ("Basic regression test")
-{
-}
-
-BasicRegressionTest::~BasicRegressionTest ()
-{
-}
-
-void
-BasicRegressionTest::DoRun(void)
-{
-  //string input ("/Users/iliamo/ns3-abstract-ndn/ns-3.11/src/NDNabstraction/examples/simpletopology.txt");
-    
-  // Set up command line parameters used to control the experiment.
-  //CommandLine cmd;
-  //cmd.AddValue ("input", "Name of the input file.",
-  //              input);
-  //cmd.Parse (argc, argv);
-    
-    
-  // ------------------------------------------------------------
-  // -- Read topology data.
-  // --------------------------------------------
-    
-  // string input = NS_TEST_SOURCEDIR;
-  // input += "/testtopology.txt";
-    
-  // Ptr<AnnotatedTopologyReader> reader = CreateObject<AnnotatedTopologyReader> ();
-  // reader->SetFileName (input);
-    
-  // NodeContainer nodes;
-  // if (reader != 0)
-  // {
-  //     nodes = reader->Read ();
-  // }
-  // else
-  // {
-  //     NS_TEST_ASSERT_MSG_EQ (true, false, "file not found");
-  // }
-    
-  // NS_TEST_ASSERT_MSG_EQ (7, reader->LinksSize (), "link count is wrong");
-    
-    
-  // // ------------------------------------------------------------
-  // // -- Create nodes and network stacks
-  // // --------------------------------------------
-  // NS_LOG_INFO ("creating internet stack");
-  // InternetStackHelper stack;
-    
-    
-  // //routing
-  // /*Ipv4StaticRoutingHelper staticRouting;
-  // Ipv4ListRoutingHelper listRH;
-  // listRH.Add (staticRouting, 0);
-  // stack.SetRoutingHelper (listRH);  // has effect on the next Install ()
-  // stack.Install (nodes);
-    
-  // NS_LOG_INFO ("creating ip4 addresses");
-  // Ipv4AddressHelper address;
-  // address.SetBase ("10.0.0.0", "255.255.255.252");*/
-    
-  // int totlinks = reader->LinksSize ();
-    
-    
-  // /// applying settings
-  // NS_LOG_INFO ("creating node containers");
-  // NodeContainer* nc = new NodeContainer[totlinks];
-  // TopologyReader::ConstLinksIterator iter;
-  // int i = 0;
-  // for ( iter = reader->LinksBegin (); iter != reader->LinksEnd (); iter++, i++ )
-  // {
-  //     nc[i] = NodeContainer (iter->GetFromNode (), iter->GetToNode ());
-  // }
-    
-  // NetDeviceContainer* ndc = new NetDeviceContainer[totlinks];
-  // reader->ApplySettings(ndc,nc);
-  // /// settings applied
-    
-    
-    
-    
-  // it creates little subnets, one for each couple of nodes.
-  /*NS_LOG_INFO ("creating ipv4 interfaces");
-    Ipv4InterfaceContainer* ipic = new Ipv4InterfaceContainer[totlinks];
-    for (int i = 0; i < totlinks; i++)
-    {
-    ipic[i] = address.Assign (ndc[i]);
-    address.NewNetwork ();
-    }
-    
-    // ------------------------------------------------------------
-    // -- Run the simulation
-    // --------------------------------------------
-    NS_LOG_INFO ("Run Simulation.");
-    Simulator::Stop (Seconds (20));
-    Simulator::Run ();
-    Simulator::Destroy ();
-    
-    delete[] ipic;
-    delete[] ndc;
-    delete[] nc;
-    
-    NS_LOG_INFO ("Done.");
-    
-  */
-}
-
-class BasicRegressionTestSuite : public TestSuite
-{
-public:
-  BasicRegressionTestSuite ();
-};
-
-BasicRegressionTestSuite::BasicRegressionTestSuite ()
-  : TestSuite ("ccnx-basic-regression-test-suite", UNIT)
-{
-  SetDataDir (NS_TEST_SOURCEDIR);
-  AddTestCase (new BasicRegressionTest);
-}
-
-static BasicRegressionTestSuite suite;
diff --git a/test/content-object-test.cc b/test/content-object-test.cc
deleted file mode 100644
index 44f881c..0000000
--- a/test/content-object-test.cc
+++ /dev/null
@@ -1,110 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#include "ns3/test.h"
-#include "ns3/ccnx-interest-header.h"
-#include "ns3/uinteger.h"
-#include "ns3/random-variable.h"
-#include "ns3/packet.h"
-#include <limits> 
-#include "ns3/ccnx-header-helper.h"
-#include "ns3/header.h"
-#include "ns3/ccnx-name-components.h"
-#include "ns3/nstime.h"
-#include "ns3/buffer.h"
-#include "ns3/log.h"
-#include "ns3/ccnx-content-object-header.h"
-#include <iostream>
-#include <fstream>
-#include <sstream>
-
-using namespace ns3;
-using namespace std;
-
-NS_LOG_COMPONENT_DEFINE ("ContentObjectTest");
-
-class ContentObjectTest : public TestCase
-{
-public:
-  ContentObjectTest ();
-  virtual ~ContentObjectTest ();
-    
-private:
-  virtual void DoRun (void);
-};
-
-ContentObjectTest::ContentObjectTest ()
-  : TestCase ("Content Obejct Serialization Test")
-{
-}
-
-ContentObjectTest::~ContentObjectTest ()
-{
-}
-
-void
-ContentObjectTest::DoRun(void)
-{
-  Packet::EnablePrinting ();
-  Packet::EnableChecking (); 
-  Packet packet (10);
-	
-  CcnxContentObjectHeader header;
-  CcnxContentObjectTail   trailer;
-	
-  Ptr<CcnxNameComponents> testname = Create<CcnxNameComponents> ();
-  (*testname) ("iwant")("icecream");
-  header.SetName(testname);
-    
-  NS_LOG_INFO ("Source: \n" << header << trailer);
-    
-  packet.AddHeader (header);
-  packet.AddTrailer (trailer);
-    
-  // NS_LOG_INFO ("Deserialized packet: \n" << packet);
-    
-  NS_LOG_INFO ("Removing and deserializing individual headers");
-	
-  CcnxContentObjectHeader targetHeader;
-  CcnxContentObjectTail   targetTrailer;
-    
-  packet.RemoveHeader (targetHeader);
-  packet.RemoveTrailer (targetTrailer);
-    
-    
-  NS_TEST_ASSERT_MSG_EQ (targetHeader.GetName(), *testname, "Content Object name deserialization failed");
-    
-  NS_TEST_ASSERT_MSG_EQ (packet.GetSize(), 10, "Content Object size inequality");
-}
-
-class ContentObjectTestSuite : public TestSuite
-{
-public:
-  ContentObjectTestSuite ();
-};
-
-ContentObjectTestSuite::ContentObjectTestSuite ()
-  : TestSuite ("content-object-test-suite", UNIT)
-{
-  SetDataDir (NS_TEST_SOURCEDIR);
-  AddTestCase (new ContentObjectTest);
-}
-
-static ContentObjectTestSuite suite;
diff --git a/test/interest-header-serialization-test.cc b/test/interest-header-serialization-test.cc
deleted file mode 100644
index 81b7972..0000000
--- a/test/interest-header-serialization-test.cc
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#include "ns3/test.h"
-#include "ns3/ccnx-interest-header.h"
-#include "ns3/uinteger.h"
-#include "ns3/random-variable.h"
-#include <limits> 
-#include "ns3/ccnx-header-helper.h"
-#include "ns3/header.h"
-#include "ns3/ccnx-name-components.h"
-#include "ns3/nstime.h"
-#include "ns3/buffer.h"
-#include "ns3/log.h"
-#include "ns3/packet.h"
-
-#include <iostream>
-#include <fstream>
-#include <sstream>
-
-using namespace ns3;
-using namespace std;
-
-NS_LOG_COMPONENT_DEFINE ("InterestHeaderSerializationTest");
-
-class InterestHeaderSerializationTest : public TestCase
-{
-public:
-  InterestHeaderSerializationTest ();
-  virtual ~InterestHeaderSerializationTest ();
-    
-private:
-  virtual void DoRun (void);
-};
-
-InterestHeaderSerializationTest::InterestHeaderSerializationTest ()
-  : TestCase ("Interest Header Serialization Test")
-{
-}
-
-InterestHeaderSerializationTest::~InterestHeaderSerializationTest ()
-{
-}
-
-void
-InterestHeaderSerializationTest::DoRun(void)
-{
-  Packet packet (0);
-    
-  uint32_t randomNonce = UniformVariable().GetInteger(1, std::numeric_limits<uint32_t>::max ());
-  Ptr<CcnxNameComponents> testname = Create<CcnxNameComponents> ();
-  (*testname) ("test") ("test2");
-    
-  Ptr<CcnxNameComponents> exclude = Create<CcnxNameComponents> ();
-  (*exclude) ("exclude") ("exclude2");
-    
-  Time lifetime = Seconds(4.0);
-  bool child = true;
-    
-  uint32_t maxSuffixComponents = 40;
-  uint32_t minSuffixComponents = 20;
-    
-  CcnxInterestHeader interestHeader;
-  interestHeader.SetNonce(randomNonce);
-  interestHeader.SetName(testname);
-  interestHeader.SetInterestLifetime(lifetime);
-  interestHeader.SetChildSelector(child);
-  interestHeader.SetExclude(exclude);
-  interestHeader.SetMaxSuffixComponents(maxSuffixComponents);
-  interestHeader.SetMinSuffixComponents(minSuffixComponents);
-
-  //serialization
-  packet.AddHeader (interestHeader);
-	
-  //deserialization
-  CcnxInterestHeader target;
-  packet.RemoveHeader (target);
-
-    
-  NS_TEST_ASSERT_MSG_EQ (target.GetNonce(), randomNonce, "Interest Header nonce deserialization failed");
-    
-  NS_TEST_ASSERT_MSG_EQ (target.GetName(), *testname, "Interest Header name deserialization failed");
-    
-  NS_TEST_ASSERT_MSG_EQ (target.GetInterestLifetime(), lifetime, "Interest Header lifetime deserialization failed");
-    
-  NS_TEST_ASSERT_MSG_EQ (target.IsEnabledChildSelector(), child, "Interest Header childselector deserialization failed");
-    
-  NS_TEST_ASSERT_MSG_EQ (target.GetExclude(), *exclude, "Interest Header exclude deserialization failed");
-    
-  NS_TEST_ASSERT_MSG_EQ (target.GetMaxSuffixComponents(), (int)maxSuffixComponents, "Interest Header maxSuffixComponents deserialization failed");
-    
-  NS_TEST_ASSERT_MSG_EQ (target.GetMinSuffixComponents(), (int)minSuffixComponents, "Interest Header minSuffixComponents deserialization failed");
-}
-
-class InterestHeaderSerializationTestSuite : public TestSuite
-{
-public:
-  InterestHeaderSerializationTestSuite ();
-};
-
-InterestHeaderSerializationTestSuite::InterestHeaderSerializationTestSuite ()
-  : TestSuite ("interest-header-serialization-test-suite", UNIT)
-{
-  SetDataDir (NS_TEST_SOURCEDIR);
-  AddTestCase (new InterestHeaderSerializationTest);
-}
-
-static InterestHeaderSerializationTestSuite suite;
diff --git a/test/ndnSIM-pit.cc b/test/ndnSIM-pit.cc
new file mode 100644
index 0000000..f039c79
--- /dev/null
+++ b/test/ndnSIM-pit.cc
@@ -0,0 +1,137 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011,2012 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ndnSIM-pit.h"
+#include "ns3/core-module.h"
+#include "ns3/ndnSIM-module.h"
+
+#include <boost/lexical_cast.hpp>
+
+NS_LOG_COMPONENT_DEFINE ("CcnxPitTest");
+
+namespace ns3
+{
+
+class Client : public CcnxApp
+{
+protected:
+  void
+  StartApplication ()
+  {
+    CcnxApp::StartApplication ();
+
+    // add default route
+    Ptr<CcnxFibEntry> fibEntry = GetNode ()->GetObject<CcnxFib> ()->Add (CcnxNameComponents ("/"), m_face, 0);
+    fibEntry->UpdateStatus (m_face, CcnxFibFaceMetric::NDN_FIB_GREEN);
+    
+    Simulator::Schedule (Seconds (0.1), &Client::SendPacket, this, std::string("/1"), 1);
+    Simulator::Schedule (Seconds (0.2), &Client::SendPacket, this, std::string("/2"), 1);
+    Simulator::Schedule (Seconds (0.3), &Client::SendPacket, this, std::string("/3"), 1);
+    Simulator::Schedule (Seconds (0.4), &Client::SendPacket, this, std::string("/1"), 2);
+  }
+
+  void
+  StopApplication ()
+  {
+    CcnxApp::StopApplication ();
+  }
+
+private:
+  void
+  SendPacket (const std::string &prefix, uint32_t nonce)
+  {
+    Ptr<Packet> pkt = Create<Packet> (0);
+    CcnxInterestHeader i;
+    i.SetName (Create<CcnxNameComponents> (prefix));
+    i.SetNonce (nonce);
+    i.SetInterestLifetime (Seconds (0.5));
+
+    pkt->AddHeader (i);
+    m_protocolHandler (pkt);
+  }
+};
+
+void
+PitTest::Test (Ptr<CcnxFib> fib)
+{
+  NS_TEST_ASSERT_MSG_EQ (fib->GetSize (), 1, "There should be only one entry");
+
+  Ptr<const CcnxFibEntry> fibEntry = fib->Begin ();
+  NS_TEST_ASSERT_MSG_EQ (fibEntry->GetPrefix (), CcnxNameComponents ("/"), "prefix should be /");
+}
+
+void
+PitTest::Check0 (Ptr<CcnxPit> pit)
+{
+  // NS_LOG_DEBUG (*GetNode ()->GetObject<CcnxPit> ());
+  NS_TEST_ASSERT_MSG_EQ (pit->GetSize (), 0, "There should 0 entries in PIT");
+}
+
+void
+PitTest::Check1 (Ptr<CcnxPit> pit)
+{
+  NS_TEST_ASSERT_MSG_EQ (pit->GetSize (), 1, "There should 1 entry in PIT");
+}
+
+void
+PitTest::Check2 (Ptr<CcnxPit> pit)
+{
+  // NS_LOG_DEBUG (*GetNode ()->GetObject<CcnxPit> ());
+  NS_TEST_ASSERT_MSG_EQ (pit->GetSize (), 2, "There should 2 entries in PIT");
+}
+
+void
+PitTest::Check3 (Ptr<CcnxPit> pit)
+{
+  // NS_LOG_DEBUG (*GetNode ()->GetObject<CcnxPit> ());
+  NS_TEST_ASSERT_MSG_EQ (pit->GetSize (), 3, "There should 3 entries in PIT");
+}
+
+
+void
+PitTest::DoRun ()
+{
+  Ptr<Node> node = CreateObject<Node> ();
+  CcnxStackHelper ccnx;
+  ccnx.Install (node);
+
+  Ptr<Client> app1 = CreateObject<Client> ();
+  node->AddApplication (app1);
+
+  Simulator::Schedule (Seconds (0.0001), &PitTest::Test, this, node->GetObject<CcnxFib> ());
+    
+  Simulator::Schedule (Seconds (0.01), &PitTest::Check0, this, node->GetObject<CcnxPit> ());
+
+  Simulator::Schedule (Seconds (0.11), &PitTest::Check1, this, node->GetObject<CcnxPit> ());
+  Simulator::Schedule (Seconds (0.21), &PitTest::Check2, this, node->GetObject<CcnxPit> ());
+  Simulator::Schedule (Seconds (0.31), &PitTest::Check3, this, node->GetObject<CcnxPit> ());
+  
+  Simulator::Schedule (Seconds (0.61), &PitTest::Check3, this, node->GetObject<CcnxPit> ());
+  Simulator::Schedule (Seconds (0.71), &PitTest::Check2, this, node->GetObject<CcnxPit> ());
+  Simulator::Schedule (Seconds (0.81), &PitTest::Check1, this, node->GetObject<CcnxPit> ());
+
+  Simulator::Schedule (Seconds (0.91), &PitTest::Check0, this, node->GetObject<CcnxPit> ());
+
+  Simulator::Stop (Seconds (1.0));
+  Simulator::Run ();
+  Simulator::Destroy ();
+}
+
+}
diff --git a/test/ndnSIM-pit.h b/test/ndnSIM-pit.h
new file mode 100644
index 0000000..3bc1705
--- /dev/null
+++ b/test/ndnSIM-pit.h
@@ -0,0 +1,53 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef NDNSIM_TEST_PIT_H
+#define NDNSIM_TEST_PIT_H
+
+#include "ns3/test.h"
+#include "ns3/ptr.h"
+
+namespace ns3
+{
+
+class CcnxFib;
+class CcnxPit;
+  
+class PitTest : public TestCase
+{
+public:
+  PitTest ()
+    : TestCase ("PIT test")
+  {
+  }
+    
+private:
+  virtual void DoRun ();
+
+  void Test (Ptr<CcnxFib> fib);
+  void Check0 (Ptr<CcnxPit> pit);
+  void Check1 (Ptr<CcnxPit> pit);
+  void Check2 (Ptr<CcnxPit> pit);
+  void Check3 (Ptr<CcnxPit> pit);
+};
+  
+}
+
+#endif // NDNSIM_TEST_PIT_H
diff --git a/test/ndnSIM-serialization.cc b/test/ndnSIM-serialization.cc
new file mode 100644
index 0000000..6c3d722
--- /dev/null
+++ b/test/ndnSIM-serialization.cc
@@ -0,0 +1,99 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
+ */
+
+#include "ns3/core-module.h"
+#include "ns3/ndnSIM-module.h"
+#include "ndnSIM-serialization.h"
+
+#include <boost/lexical_cast.hpp>
+
+using namespace std;
+
+namespace ns3
+{
+
+NS_LOG_COMPONENT_DEFINE ("NdnSimSerialization");
+
+void
+InterestSerializationTest::DoRun ()
+{
+  CcnxInterestHeader source;
+  source.SetName                (Create<CcnxNameComponents> (boost::lexical_cast<CcnxNameComponents> ("/test/test2")));
+  NS_TEST_ASSERT_MSG_EQ (source.GetName (), boost::lexical_cast<CcnxNameComponents> ("/test/test2"), "set/get name failed");
+  
+  source.SetMinSuffixComponents (20);
+  NS_TEST_ASSERT_MSG_EQ (source.GetMinSuffixComponents (), 20, "set/get minSuffixComponents failed");
+  
+  source.SetMaxSuffixComponents (40);
+  NS_TEST_ASSERT_MSG_EQ (source.GetMaxSuffixComponents (), 40, "set/get maxSuffixComponents failed");
+
+  source.SetExclude (Create<CcnxNameComponents> (boost::lexical_cast<CcnxNameComponents> ("/exclude/exclude2")));
+  NS_TEST_ASSERT_MSG_EQ (source.GetExclude (), boost::lexical_cast<CcnxNameComponents> ("/exclude/exclude2"), "set/get exclude failed");
+
+  source.SetChildSelector       (false);
+  NS_TEST_ASSERT_MSG_EQ (source.IsEnabledChildSelector (), false, "set/get child selector failed");
+  source.SetChildSelector       (true);
+  NS_TEST_ASSERT_MSG_EQ (source.IsEnabledChildSelector (), true, "set/get child selector failed");
+
+  source.SetAnswerOriginKind    (false);
+  NS_TEST_ASSERT_MSG_EQ (source.IsEnabledAnswerOriginKind (), false, "set/get answer origin kind failed");
+  source.SetAnswerOriginKind    (true);
+  NS_TEST_ASSERT_MSG_EQ (source.IsEnabledAnswerOriginKind (), true, "set/get answer origin kind failed");
+
+  source.SetScope (2);
+  NS_TEST_ASSERT_MSG_EQ (source.GetScope (), 2, "set/get scope failed");
+
+  source.SetInterestLifetime (Seconds (100));
+  NS_TEST_ASSERT_MSG_EQ (source.GetInterestLifetime (), Seconds (100), "set/get interest lifetime failed");
+
+  source.SetNonce (200);
+  NS_TEST_ASSERT_MSG_EQ (source.GetNonce (), 200, "set/get nonce failed");
+
+  source.SetNack (10);
+  NS_TEST_ASSERT_MSG_EQ (source.GetNack (), 10, "set/get NACK failed");
+
+  Packet packet (0);
+  //serialization
+  packet.AddHeader (source);
+	
+  //deserialization
+  CcnxInterestHeader target;
+  packet.RemoveHeader (target);
+  
+  NS_TEST_ASSERT_MSG_EQ (source.GetName ()                  , target.GetName ()                 , "source/target name failed");
+  NS_TEST_ASSERT_MSG_EQ (source.GetMinSuffixComponents ()   , target.GetMinSuffixComponents ()   , "source/target minSuffixComponents failed");
+  NS_TEST_ASSERT_MSG_EQ (source.GetMaxSuffixComponents ()   , target.GetMaxSuffixComponents ()   , "source/target maxSuffixComponents failed");
+  NS_TEST_ASSERT_MSG_EQ (source.GetExclude ()               , target.GetExclude ()               , "source/target exclude failed");
+  NS_TEST_ASSERT_MSG_EQ (source.IsEnabledChildSelector ()   , target.IsEnabledChildSelector ()   , "source/target child selector failed");
+  NS_TEST_ASSERT_MSG_EQ (source.IsEnabledAnswerOriginKind (), target.IsEnabledAnswerOriginKind (), "source/target answer origin kind failed");
+  NS_TEST_ASSERT_MSG_EQ (source.GetScope ()                 , target.GetScope ()                 , "source/target scope failed");
+  NS_TEST_ASSERT_MSG_EQ (source.GetInterestLifetime ()      , target.GetInterestLifetime ()      , "source/target interest lifetime failed");
+  NS_TEST_ASSERT_MSG_EQ (source.GetNonce ()                 , target.GetNonce ()                 , "source/target nonce failed");
+  NS_TEST_ASSERT_MSG_EQ (source.GetNack ()                  , target.GetNack ()                  , "source/target NACK failed");
+}
+
+void
+ContentObjectSerializationTest::DoRun ()
+{
+  // NS_TEST_ASSERT_MSG_EQ (true, false, "test not implemented yet");
+}
+
+}
+
diff --git a/test/ndnSIM-serialization.h b/test/ndnSIM-serialization.h
new file mode 100644
index 0000000..ff52fd2
--- /dev/null
+++ b/test/ndnSIM-serialization.h
@@ -0,0 +1,56 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011,2012 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
+ *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef NDNSIM_SERIALIZATION_H
+#define NDNSIM_SERIALIZATION_H
+
+#include "ns3/test.h"
+
+namespace ns3
+{
+
+class InterestSerializationTest : public TestCase
+{
+public:
+  InterestSerializationTest ()
+    : TestCase ("Interest Serialization Test")
+  {
+  }
+    
+private:
+  virtual void DoRun ();
+};
+
+class ContentObjectSerializationTest : public TestCase
+{
+public:
+  ContentObjectSerializationTest ()
+    : TestCase ("ContentObject Serialization Test")
+  {
+  }
+    
+private:
+  virtual void DoRun ();
+};
+
+}
+
+#endif // NDNSIM_SERIALIZATION_H
diff --git a/test/ndnSIM-tests.cc b/test/ndnSIM-tests.cc
new file mode 100644
index 0000000..004f761
--- /dev/null
+++ b/test/ndnSIM-tests.cc
@@ -0,0 +1,46 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011,2012 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
+ *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ns3/test.h"
+
+#include "ndnSIM-serialization.h"
+#include "ndnSIM-pit.h"
+
+namespace ns3
+{
+
+class NdnSimTestSuite : public TestSuite
+{
+public:
+  NdnSimTestSuite ()
+    : TestSuite ("ndnSIM-suite", UNIT)
+  {
+    SetDataDir (NS_TEST_SOURCEDIR);
+    
+    AddTestCase (new InterestSerializationTest ());
+    AddTestCase (new ContentObjectSerializationTest ());
+    AddTestCase (new PitTest ());
+  }
+};
+
+static NdnSimTestSuite suite;
+
+}
diff --git a/test/ndnabstraction-basictest.cc b/test/ndnabstraction-basictest.cc
deleted file mode 100644
index 66f4fcc..0000000
--- a/test/ndnabstraction-basictest.cc
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- *  ndnabstraction-basictest.c
- *  XcodeProject
- *
- *  Created by Ilya Moiseenko on 7/18/11.
- *  Copyright 2011 University of California, Los Angeles. All rights reserved.
- *
- */
-
-#include "ndnabstraction-basictest.h"
-
diff --git a/test/ndnabstraction-basictest.h b/test/ndnabstraction-basictest.h
deleted file mode 100644
index 22aa6b8..0000000
--- a/test/ndnabstraction-basictest.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- *  ndnabstraction-basictest.h
- *  XcodeProject
- *
- *  Created by Ilya Moiseenko on 7/18/11.
- *  Copyright 2011 University of California, Los Angeles. All rights reserved.
- *
- */
-
diff --git a/test/packet-sizes.cc b/test/packet-sizes.cc
deleted file mode 100644
index 041cac6..0000000
--- a/test/packet-sizes.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ns3/core-module.h"
-#include "ns3/ccnx-content-object-header.h"
-#include "ns3/ccnx-interest-header.h"
-#include "ns3/ccnx-header-helper.h"
-#include "ns3/header.h"
-#include "ns3/ccnx-name-components.h"
-#include "ns3/nstime.h"
-#include "ns3/string.h"
-#include "ns3/buffer.h"
-#include "ns3/packet.h"
-#include "ns3/log.h"
-
-using namespace ns3;
-#include <fstream>
-
-NS_LOG_COMPONENT_DEFINE ("PacketSizes");
-
-int
-main (int argc, char *argv[])
-{
-  NS_LOG_INFO ("Test started");
-
-  uint32_t size = 1024;
-  std::string namePrefixStr = "/1";
-  uint32_t start=0, end=100;
-
-  CommandLine	cmd;
-  cmd.AddValue ("size",  "ContentObject payload size", size);
-  cmd.AddValue ("name",  "Prefix",                     namePrefixStr);
-  cmd.AddValue ("start", "Range start", start);
-  cmd.AddValue ("end",   "Range end",   end);
-  cmd.Parse (argc, argv);
- 
-  CcnxNameComponents namePrefixValue;
-  std::istringstream is (namePrefixStr);
-  is >> namePrefixValue;
-
-  Packet::EnablePrinting ();
-  Packet::EnableChecking ();
-
-  double interestSize = 0.0;
-  double nackSize = 0.0;
-  double contentObjectSize = 0.0;
-
-  double progress = start;
-  double step = (end-start)/100.0;
-
-  progress += step;
-
-  NS_LOG_INFO (progress << ", " << step);
-
-  for (uint32_t currentSize = start; currentSize < end; currentSize++)
-    {
-      Ptr<CcnxNameComponents> namePrefix = Create<CcnxNameComponents> (namePrefixValue);
-      namePrefix->Add (currentSize);
-
-      NS_LOG_LOGIC (boost::cref (*namePrefix));
-
-      // Interest Packet (doesn't have a payload)
-      CcnxInterestHeader interestHeader;
-
-      interestHeader.SetName (namePrefix);
-      interestHeader.SetInterestLifetime (Seconds (4.0));
-      interestHeader.SetNonce (10101010);
-      
-      Ptr<Packet> interestPacket =  Create<Packet> (0);
-      interestPacket->AddHeader (interestHeader);
-
-      interestSize = interestSize + (1.0*interestPacket->GetSize () - interestSize) / (currentSize - start + 1);
-
-      
-
-      // NACK
-      interestHeader.SetNack (CcnxInterestHeader::NACK_GIVEUP_PIT);
-
-      Ptr<Packet> nackPacket = Create<Packet> (0);
-      nackPacket->AddHeader (interestHeader);
-      
-      nackSize = nackSize + (1.0*nackPacket->GetSize () - nackSize) / (currentSize - start + 1);
-
-      // ContentObject
-      CcnxContentObjectHeader coHeader;
-      CcnxContentObjectTail   coTrailer;
-      
-      coHeader.SetName (namePrefix);
-      
-      Ptr<Packet> contentObject = Create<Packet> (size);
-
-      contentObject->AddHeader (coHeader);
-      contentObject->AddTrailer (coTrailer);
-
-      contentObjectSize = contentObjectSize + (1.0*contentObject->GetSize () - contentObjectSize ) / (currentSize - start + 1);
-
-      NS_LOG_DEBUG (interestSize << ", " << nackSize << ", " << contentObjectSize);
-
-      if (currentSize >= progress) 
-	{
-	  NS_LOG_INFO ("Current: " << currentSize << "/" << end);
-	  progress += step;
-	}
-    }
-
-  NS_LOG_INFO ("Avg interest: " << interestSize << ", avg nack: " << nackSize << ", avg contentObject: " << contentObjectSize);
-
-  return 0;
-}
diff --git a/test/testtopology.txt b/test/testtopology.txt
deleted file mode 100644
index 8e39d06..0000000
--- a/test/testtopology.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-7   7
-1   3   10000   1   80  120
-2   3   10000   1   110 150
-3   4   1000    1   40  30
-3   5   1000    50  55  50
-4   5   1000    1   10  20
-5   6   10000   1   15  35
-5   7   10000   50  25  45
diff --git a/utils/counting-policy.h b/utils/counting-policy.h
new file mode 100644
index 0000000..b7d992e
--- /dev/null
+++ b/utils/counting-policy.h
@@ -0,0 +1,107 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef COUNTING_POLICY_H_
+#define COUNTING_POLICY_H_
+
+#include <boost/intrusive/options.hpp>
+#include <boost/intrusive/list.hpp>
+
+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 counting_policy_traits
+{
+  struct policy_hook_type : public boost::intrusive::list_member_hook<> {};
+
+  template<class Container>
+  struct container_hook
+  {
+    // could be class/struct implementation
+    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;
+    
+    // could be just typedef
+    class type : public policy_container
+    {
+    public:
+      typedef Container parent_trie;
+
+      type (Base &base)
+        : base_ (base)
+      {
+      }
+
+      inline void
+      update (typename parent_trie::iterator item)
+      {
+        // do nothing
+      }
+  
+      inline bool
+      insert (typename parent_trie::iterator item)
+      {
+        policy_container::push_back (*item);
+        return true;
+      }
+  
+      inline void
+      lookup (typename parent_trie::iterator item)
+      {
+        // do nothing
+      }
+  
+      inline void
+      erase (typename parent_trie::iterator item)
+      {
+        policy_container::erase (policy_container::s_iterator_to (*item));
+      }
+
+      inline void
+      clear ()
+      {
+        policy_container::clear ();
+      }
+
+    private:
+      type () : base_(*((Base*)0)) { };
+
+    private:
+      Base &base_;
+    };
+  };
+};
+
+} // ndnSIM
+
+#endif // COUNTING_POLICY_H_