Separating interface and implementation of FIB. Right now everything is
kind of broken.
diff --git a/model/ccnx-fib-entry.cc b/model/ccnx-fib-entry.cc
new file mode 100644
index 0000000..c0c575a
--- /dev/null
+++ b/model/ccnx-fib-entry.cc
@@ -0,0 +1,185 @@
+/* -*- 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 "ccnx-fib-entry.h"
+
+#include "ns3/ccnx-name-components.h"
+#include "ns3/log.h"
+
+#define NDN_RTO_ALPHA 0.125
+#define NDN_RTO_BETA 0.25
+#define NDN_RTO_K 4
+
+#include <boost/ref.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <boost/lambda/bind.hpp>
+namespace ll = boost::lambda;
+
+NS_LOG_COMPONENT_DEFINE ("CcnxFibEntry");
+
+namespace ns3
+{
+
+//////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////
+namespace __ccnx_private {
+
+struct CcnxFibFaceMetricByFace
+{
+  typedef CcnxFibFaceMetricContainer::type::index<i_face>::type
+  type;
+};
+
+}
+//////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////
+
+using namespace __ccnx_private;
+
+void
+CcnxFibFaceMetric::UpdateRtt (const Time &rttSample)
+{
+  // const Time & this->m_rttSample
+  
+  //update srtt and rttvar (RFC 2988)
+  if (m_sRtt.IsZero ())
+    {
+      //first RTT measurement
+      NS_ASSERT_MSG (m_rttVar.IsZero (), "SRTT is zero, but variation is not");
+      
+      m_sRtt = rttSample;
+      m_rttVar = Time (m_sRtt / 2.0);
+    }
+  else
+    {
+      m_rttVar = Time ((1 - NDN_RTO_BETA) * m_rttVar + NDN_RTO_BETA * Abs(m_sRtt - rttSample));
+      m_sRtt = Time ((1 - NDN_RTO_ALPHA) * m_sRtt + NDN_RTO_ALPHA * rttSample);
+    }
+}
+
+/////////////////////////////////////////////////////////////////////
+
+void
+CcnxFibEntry::UpdateFaceRtt (Ptr<CcnxFace> face, const Time &sample)
+{
+  CcnxFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
+  NS_ASSERT_MSG (record != m_faces.get<i_face> ().end (),
+                 "Update status can be performed only on existing faces of CcxnFibEntry");
+
+  m_faces.modify (record,
+                  ll::bind (&CcnxFibFaceMetric::UpdateRtt, ll::_1, sample));
+
+  // reordering random access index same way as by metric index
+  m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
+}
+
+void
+CcnxFibEntry::UpdateStatus (Ptr<CcnxFace> face, CcnxFibFaceMetric::Status status)
+{
+  NS_LOG_FUNCTION (this << boost::cref(*face) << status);
+
+  CcnxFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
+  NS_ASSERT_MSG (record != m_faces.get<i_face> ().end (),
+                 "Update status can be performed only on existing faces of CcxnFibEntry");
+
+  m_faces.modify (record,
+                  (&ll::_1)->*&CcnxFibFaceMetric::m_status = status);
+
+  // reordering random access index same way as by metric index
+  m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
+}
+
+void
+CcnxFibEntry::AddOrUpdateRoutingMetric (Ptr<CcnxFace> face, int32_t metric)
+{
+  NS_LOG_FUNCTION (this);
+  NS_ASSERT_MSG (face != NULL, "Trying to Add or Update NULL face");
+
+  CcnxFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
+  if (record == m_faces.get<i_face> ().end ())
+    {
+      m_faces.insert (CcnxFibFaceMetric (face, metric));
+    }
+  else
+  {
+    // don't update metric to higher value
+    if (record->m_routingCost > metric || record->m_status == CcnxFibFaceMetric::NDN_FIB_RED)
+      {
+        m_faces.modify (record,
+                        (&ll::_1)->*&CcnxFibFaceMetric::m_routingCost = metric);
+
+        m_faces.modify (record,
+                        (&ll::_1)->*&CcnxFibFaceMetric::m_status = CcnxFibFaceMetric::NDN_FIB_YELLOW);
+      }
+  }
+  
+  // reordering random access index same way as by metric index
+  m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
+}
+
+void
+CcnxFibEntry::Invalidate ()
+{
+  for (CcnxFibFaceMetricByFace::type::iterator face = m_faces.begin ();
+       face != m_faces.end ();
+       face++)
+    {
+      m_faces.modify (face,
+                      (&ll::_1)->*&CcnxFibFaceMetric::m_routingCost = std::numeric_limits<uint16_t>::max ());
+
+      m_faces.modify (face,
+                      (&ll::_1)->*&CcnxFibFaceMetric::m_status = CcnxFibFaceMetric::NDN_FIB_RED);
+    }
+}
+
+const CcnxFibFaceMetric &
+CcnxFibEntry::FindBestCandidate (uint32_t skip/* = 0*/) const
+{
+  if (m_faces.size () == 0) throw CcnxFibEntry::NoFaces ();
+  skip = skip % m_faces.size();
+  return m_faces.get<i_nth> () [skip];
+}
+
+std::ostream& operator<< (std::ostream& os, const CcnxFibEntry &entry)
+{
+  for (CcnxFibFaceMetricContainer::type::index<i_nth>::type::iterator metric =
+         entry.m_faces.get<i_nth> ().begin ();
+       metric != entry.m_faces.get<i_nth> ().end ();
+       metric++)
+    {
+      if (metric != entry.m_faces.get<i_nth> ().begin ())
+        os << ", ";
+
+      os << *metric;
+    }
+  return os;
+}
+
+std::ostream& operator<< (std::ostream& os, const CcnxFibFaceMetric &metric)
+{
+  static const std::string statusString[] = {"","g","y","r"};
+
+  os << *metric.m_face << "(" << metric.m_routingCost << ","<< statusString [metric.m_status] << "," << metric.m_face->GetMetric () << ")";
+  return os;
+}
+
+
+} // ns3
diff --git a/model/ccnx-fib-entry.h b/model/ccnx-fib-entry.h
new file mode 100644
index 0000000..9aa75cb
--- /dev/null
+++ b/model/ccnx-fib-entry.h
@@ -0,0 +1,237 @@
+/* -*- 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 _CCNX_FIB_ENTRY_H_
+#define	_CCNX_FIB_ENTRY_H_
+
+#include "ns3/ptr.h"
+#include "ns3/nstime.h"
+#include "ns3/ccnx.h"
+#include "ns3/ccnx-face.h"
+
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/tag.hpp>
+#include <boost/multi_index/ordered_index.hpp>
+#include <boost/multi_index/composite_key.hpp>
+#include <boost/multi_index/hashed_index.hpp>
+#include <boost/multi_index/random_access_index.hpp>
+#include <boost/multi_index/member.hpp>
+#include <boost/multi_index/mem_fun.hpp>
+
+namespace ns3
+{
+
+class CcnxNameComponents;
+
+/**
+ * \ingroup ccnx
+ * \brief Structure holding various parameters associated with a (FibEntry, Face) tuple
+ */
+class CcnxFibFaceMetric
+{
+public:
+  /**
+   * @brief Color codes for FIB face status
+   */
+  enum Status { NDN_FIB_GREEN = 1,
+                NDN_FIB_YELLOW = 2,
+                NDN_FIB_RED = 3 };
+public:
+  /**
+   * \brief Metric constructor
+   *
+   * \param face Face for which metric
+   * \param cost Initial value for routing cost
+   */
+  CcnxFibFaceMetric (Ptr<CcnxFace> face, int32_t cost)
+    : m_face (face)
+    , m_status (NDN_FIB_YELLOW)
+    , m_routingCost (cost)
+    , m_sRtt   (Seconds (0))
+    , m_rttVar (Seconds (0))
+  { }
+
+  /**
+   * \brief Comparison operator used by boost::multi_index::identity<>
+   */
+  bool
+  operator< (const CcnxFibFaceMetric &fm) const { return *m_face < *fm.m_face; } // return identity of the face
+
+  /**
+   * @brief Comparison between CcnxFibFaceMetric and CcnxFace
+   */
+  bool
+  operator< (const Ptr<CcnxFace> &face) const { return *m_face < *face; } 
+
+  /**
+   * @brief Return CcnxFace associated with CcnxFibFaceMetric
+   */
+  Ptr<CcnxFace>
+  GetFace () const { return m_face; }
+
+  /**
+   * \brief Recalculate smoothed RTT and RTT variation
+   * \param rttSample RTT sample
+   */
+  void
+  UpdateRtt (const Time &rttSample);
+  
+private:
+  friend std::ostream& operator<< (std::ostream& os, const CcnxFibFaceMetric &metric);
+public:
+  Ptr<CcnxFace> m_face; ///< Face
+  
+  Status m_status;		///< \brief Status of the next hop: 
+				///<		- NDN_FIB_GREEN
+				///<		- NDN_FIB_YELLOW
+				///<		- NDN_FIB_RED
+  
+  int32_t m_routingCost; ///< \brief routing protocol cost (interpretation of the value depends on the underlying routing protocol)
+
+  Time m_sRtt;         ///< \brief smoothed round-trip time
+  Time m_rttVar;       ///< \brief round-trip time variation
+};
+
+/**
+ * \ingroup ccnx
+ * \brief Typedef for indexed face container of CcnxFibEntry
+ *
+ * Currently, there are 2 indexes:
+ * - by face (used to find record and update metric)
+ * - by metric (face ranking)
+ * - random access index (for fast lookup on nth face). Order is
+ *   maintained manually to be equal to the 'by metric' order
+ */
+struct CcnxFibFaceMetricContainer
+{
+  /// @cond include_hidden
+  typedef boost::multi_index::multi_index_container<
+    CcnxFibFaceMetric,
+    boost::multi_index::indexed_by<
+      // For fast access to elements using CcnxFace
+      boost::multi_index::ordered_unique<
+        boost::multi_index::tag<__ccnx_private::i_face>,
+        boost::multi_index::member<CcnxFibFaceMetric,Ptr<CcnxFace>,&CcnxFibFaceMetric::m_face>
+      >,
+
+      // List of available faces ordered by (status, m_routingCost)
+      boost::multi_index::ordered_non_unique<
+        boost::multi_index::tag<__ccnx_private::i_metric>,
+        boost::multi_index::composite_key<
+          CcnxFibFaceMetric,
+          boost::multi_index::member<CcnxFibFaceMetric,CcnxFibFaceMetric::Status,&CcnxFibFaceMetric::m_status>,
+          boost::multi_index::member<CcnxFibFaceMetric,int32_t,&CcnxFibFaceMetric::m_routingCost>
+        >
+      >,
+
+      // To optimize nth candidate selection (sacrifice a little bit space to gain speed)
+      boost::multi_index::random_access<
+        boost::multi_index::tag<__ccnx_private::i_nth>
+      >
+    >
+   > type;
+  /// @endcond
+};
+
+/**
+ * \ingroup ccnx
+ * \brief Structure for FIB table entry, holding indexed list of
+ *        available faces and their respective metrics
+ */
+class CcnxFibEntry : public SimpleRefCount<CcnxFibEntry>
+{
+public:
+  class NoFaces {}; ///< @brief Exception class for the case when FIB entry is not found
+  
+  /**
+   * \brief Constructor
+   * \param prefix smart pointer to the prefix for the FIB entry
+   */
+  CcnxFibEntry (const Ptr<const CcnxNameComponents> &prefix)
+  : m_prefix (prefix)
+  , m_needsProbing (false)
+  { }
+  
+  /**
+   * \brief Update status of FIB next hop
+   * \param status Status to set on the FIB entry
+   */
+  void UpdateStatus (Ptr<CcnxFace> face, CcnxFibFaceMetric::Status status);
+
+  /**
+   * \brief Add or update routing metric of FIB next hop
+   *
+   * Initial status of the next hop is set to YELLOW
+   */
+  void AddOrUpdateRoutingMetric (Ptr<CcnxFace> face, int32_t metric);
+
+  /**
+   * @brief Invalidate face
+   *
+   * Set routing metric on all faces to max and status to RED
+   */
+  void
+  Invalidate ();
+
+  /**
+   * @brief Update RTT averages for the face
+   */
+  void
+  UpdateFaceRtt (Ptr<CcnxFace> face, const Time &sample);
+  
+  /**
+   * \brief Get prefix for the FIB entry
+   */
+  const CcnxNameComponents&
+  GetPrefix () const { return *m_prefix; }
+
+  /**
+   * \brief Find "best route" candidate, skipping `skip' first candidates (modulo # of faces)
+   *
+   * throws CcnxFibEntry::NoFaces if m_faces.size()==0
+   */
+  const CcnxFibFaceMetric &
+  FindBestCandidate (uint32_t skip = 0) const;
+
+  /**
+   * @brief Remove record associated with `face`
+   */
+  void
+  RemoveFace (const Ptr<CcnxFace> &face)
+  {
+    m_faces.erase (face);
+  }
+	
+private:
+  friend std::ostream& operator<< (std::ostream& os, const CcnxFibEntry &entry);
+
+public:
+  Ptr<const CcnxNameComponents> m_prefix; ///< \brief Prefix of the FIB entry
+  CcnxFibFaceMetricContainer::type m_faces; ///< \brief Indexed list of faces
+
+  bool m_needsProbing;      ///< \brief flag indicating that probing should be performed 
+};
+
+std::ostream& operator<< (std::ostream& os, const CcnxFibEntry &entry);
+std::ostream& operator<< (std::ostream& os, const CcnxFibFaceMetric &metric);
+
+} // ns3
+
+#endif // _CCNX_FIB_ENTRY_H_
diff --git a/model/ccnx-fib-impl.cc b/model/ccnx-fib-impl.cc
new file mode 100644
index 0000000..18d07ad
--- /dev/null
+++ b/model/ccnx-fib-impl.cc
@@ -0,0 +1,179 @@
+/* -*- 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 "ccnx-fib-impl.h"
+
+#include "ccnx.h"
+#include "ccnx-face.h"
+#include "ccnx-interest-header.h"
+
+#include "ns3/node.h"
+#include "ns3/assert.h"
+#include "ns3/names.h"
+#include "ns3/log.h"
+
+#include <boost/ref.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <boost/lambda/bind.hpp>
+namespace ll = boost::lambda;
+
+NS_LOG_COMPONENT_DEFINE ("CcnxFibImpl");
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (CcnxFibImpl);
+
+TypeId 
+CcnxFibImpl::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::CcnxFib") // cheating ns3 object system
+    .SetParent<Object> ()
+    .SetGroupName ("Ccnx")
+    .AddConstructor<CcnxFibImpl> ()
+  ;
+  return tid;
+}
+
+CcnxFibImpl::CcnxFibImpl ()
+{
+}
+
+void
+CcnxFibImpl::NotifyNewAggregate ()
+{
+  Object::NotifyNewAggregate ();
+}
+
+void 
+CcnxFibImpl::DoDispose (void)
+{
+  clear ();
+  Object::DoDispose ();
+}
+
+
+CcnxFib::iterator
+CcnxFibImpl::LongestPrefixMatch (const CcnxInterestHeader &interest) const
+{
+  super::iterator item = const_cast<CcnxFibImpl*> (this)->super::longest_prefix_match (interest.GetName ());
+  // @todo use predicate to search with exclude filters
+
+  if (item == super::end ())
+    return 0;
+  else
+    return item->payload ();
+}
+
+
+CcnxFib::iterator
+CcnxFibImpl::Add (const CcnxNameComponents &prefix, Ptr<CcnxFace> face, int32_t metric)
+{
+  return Add (Create<CcnxNameComponents> (prefix), face, metric);
+}
+  
+CcnxFib::iterator
+CcnxFibImpl::Add (const Ptr<const CcnxNameComponents> &prefix, Ptr<CcnxFace> face, int32_t metric)
+{
+  NS_LOG_FUNCTION(this->GetObject<Node> ()->GetId () << boost::cref(*prefix) << boost::cref(*face) << metric);
+
+  // will add entry if doesn't exists, or just return an iterator to the existing entry
+  std::pair< super::iterator, bool > result = super::insert (*prefix, Create<CcnxFibEntry> (prefix));
+  
+  NS_ASSERT_MSG (face != NULL, "Trying to modify NULL face");
+  
+  super::modify (result.first,
+                 ll::bind (&CcnxFibEntry::AddOrUpdateRoutingMetric, ll::_1, face, metric));
+    
+  return result.first->payload ();
+}
+
+void
+CcnxFibImpl::Remove (const Ptr<const CcnxNameComponents> &prefix)
+{
+  NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix));
+
+  super::erase (*prefix);
+}
+
+void
+CcnxFibImpl::Invalidate (const Ptr<const CcnxNameComponents> &prefix)
+{
+  NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix));
+
+  super::iterator foundItem, lastItem;
+  bool reachLast;
+  boost::tie (foundItem, reachLast, lastItem) = super::getTrie ().find (*prefix);
+  
+  if (!reachLast || lastItem->payload () == 0)
+    return; // nothing to invalidate
+
+  super::modify (lastItem,
+                 ll::bind (&CcnxFibEntry::Invalidate, ll::_1));
+}
+
+void
+CcnxFibImpl::InvalidateAll ()
+{
+  // NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId ());
+
+  // for (super::iterator entry = m_fib.begin ();
+  //      entry != m_fib.end ();
+  //      entry ++)
+  //   {
+  //     m_fib.modify (entry,
+  //                   ll::bind (&CcnxFibEntry::Invalidate, ll::_1));
+  //   }
+}
+
+void
+CcnxFibImpl::Remove (const CcnxFibEntry &entry, Ptr<CcnxFace> face)
+{
+  // NS_LOG_FUNCTION (this);
+
+  // m_fib.modify (m_fib.iterator_to (entry),
+  //               ll::bind (&CcnxFibEntry::RemoveFace, ll::_1, face));
+  // if (entry.m_faces.size () == 0)
+  //   {
+  //     m_fib.erase (m_fib.iterator_to (entry));
+  //   }
+}
+
+void
+CcnxFibImpl::RemoveFromAll (Ptr<CcnxFace> face)
+{
+  // NS_LOG_FUNCTION (this);
+
+  // for_each (m_fib.begin (), m_fib.end (), 
+  //           ll::bind (static_cast< void (CcnxFib::*) (const CcnxFibEntry &, Ptr<CcnxFace>) > (&CcnxFib::Remove),
+  //                     this, ll::_1, face));
+}
+
+void
+CcnxFibImpl::Print (std::ostream &os) const
+{
+  // for (super::iterator entry = fib.m_fib.begin ();
+  //      entry != fib.m_fib.end ();
+  //      entry++)
+  //   {
+  //     os << entry->GetPrefix () << "\t" << *entry << "\n";
+  //   }
+}
+
+} // namespace ns3
diff --git a/model/ccnx-fib-impl.h b/model/ccnx-fib-impl.h
new file mode 100644
index 0000000..b10d558
--- /dev/null
+++ b/model/ccnx-fib-impl.h
@@ -0,0 +1,166 @@
+/* -*- 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 _CCNX_FIB_IMPL_H_
+#define	_CCNX_FIB_IMPL_H_
+
+#include "ns3/ccnx-fib.h"
+#include "ns3/ccnx-name-components.h"
+
+#include "../utils/trie-with-policy.h"
+#include "../utils/empty-policy.h"
+
+namespace ns3 {
+
+struct CcnxFibEntryContainer
+{
+  typedef ndnSIM::trie_with_policy<
+    CcnxNameComponents,
+    ndnSIM::smart_pointer_payload_traits<CcnxFibEntry>,
+    ndnSIM::empty_policy_traits
+    > type;
+};
+
+/**
+ * \ingroup ccnx
+ * \brief Class implementing FIB functionality
+ */
+class CcnxFibImpl : public CcnxFib,
+                    private CcnxFibEntryContainer::type
+{
+public:
+  typedef CcnxFibEntryContainer::type super;
+  
+  /**
+   * \brief Interface ID
+   *
+   * \return interface ID
+   */
+  static TypeId GetTypeId ();
+
+  /**
+   * \brief Constructor
+   */
+  CcnxFibImpl ();
+
+  /**
+   * \brief Perform longest prefix match
+   *
+   * \todo Implement exclude filters
+   *
+   * \param interest Interest packet header
+   * \returns If entry found a valid iterator will be returned, otherwise end ()
+   */
+  CcnxFib::iterator
+  LongestPrefixMatch (const CcnxInterestHeader &interest) const;
+  
+  /**
+   * \brief Add or update FIB entry
+   *
+   * If the entry exists, metric will be updated. Otherwise, new entry will be created
+   *
+   * Entries in FIB never deleted. They can be invalidated with metric==NETWORK_UNREACHABLE
+   *
+   * @param name	Prefix
+   * @param face	Forwarding face
+   * @param metric	Routing metric
+   */
+  CcnxFib::iterator
+  Add (const CcnxNameComponents &prefix, Ptr<CcnxFace> face, int32_t metric);
+
+  /**
+   * \brief Add or update FIB entry using smart pointer to prefix
+   *
+   * If the entry exists, metric will be updated. Otherwise, new entry will be created
+   *
+   * Entries in FIB never deleted. They can be invalidated with metric==NETWORK_UNREACHABLE
+   *
+   * @param name	Smart pointer to prefix
+   * @param face	Forwarding face
+   * @param metric	Routing metric
+   */
+  CcnxFib::iterator
+  Add (const Ptr<const CcnxNameComponents> &prefix, Ptr<CcnxFace> face, int32_t metric);
+
+  /**
+   * @brief Remove FIB entry
+   *
+   * ! ATTENTION ! Use with caution.  All PIT entries referencing the corresponding FIB entry will become invalid.
+   * So, simulation may crash.
+   *
+   * @param name	Smart pointer to prefix
+   */
+  void
+  Remove (const Ptr<const CcnxNameComponents> &prefix);
+
+  /**
+   * @brief Invalidate FIB entry ("Safe" version of Remove)
+   *
+   * All faces for the entry will be assigned maximum routing metric and NDN_FIB_RED status   
+   * @param name	Smart pointer to prefix
+   */
+  void
+  Invalidate (const Ptr<const CcnxNameComponents> &prefix);
+
+  /**
+   * @brief Invalidate all FIB entries
+   */
+  void
+  InvalidateAll ();
+  
+  /**
+   * @brief Remove reference to a face from the entry. If entry had only this face, the whole
+   * entry will be removed
+   */
+  void
+  Remove (const CcnxFibEntry &entry, Ptr<CcnxFace> face);
+
+  /**
+   * @brief Remove all references to a face from FIB.  If for some enty that face was the only element,
+   * this FIB entry will be removed.
+   */
+  void
+  RemoveFromAll (Ptr<CcnxFace> face);
+
+  void
+  Print (std::ostream &os) const;
+  
+  /**
+   * @brief Modify element in container
+   */
+  template<typename Modifier>
+  bool
+  modify (CcnxFib::iterator position, Modifier mod)
+  {
+    return this->modify (position, mod);
+  }
+  
+protected:
+  // inherited from Object class
+  virtual void NotifyNewAggregate (); ///< @brief Notify when object is aggregated
+  virtual void DoDispose (); ///< @brief Perform cleanup
+  
+private:
+  Ptr<Node> m_node;
+};
+ 
+} // namespace ns3
+
+#endif	/* _CCNX_FIB_IMPL_H_ */
diff --git a/model/ccnx-fib.cc b/model/ccnx-fib.cc
index 4159f73..5bbbc15 100644
--- a/model/ccnx-fib.cc
+++ b/model/ccnx-fib.cc
@@ -24,336 +24,29 @@
 #include "ccnx-face.h"
 #include "ccnx-interest-header.h"
 
-#include "ns3/node.h"
-#include "ns3/assert.h"
-#include "ns3/names.h"
-#include "ns3/log.h"
+#include "ccnx-name-components.h"
+#include "ccnx-fib-impl.h"
 
-#define NDN_RTO_ALPHA 0.125
-#define NDN_RTO_BETA 0.25
-#define NDN_RTO_K 4
+#include "ns3/node.h"
+#include "ns3/names.h"
 
 #include <boost/ref.hpp>
 #include <boost/lambda/lambda.hpp>
 #include <boost/lambda/bind.hpp>
 namespace ll = boost::lambda;
 
-NS_LOG_COMPONENT_DEFINE ("CcnxFib");
-
 namespace ns3 {
 
-NS_OBJECT_ENSURE_REGISTERED (CcnxFib);
-
-//////////////////////////////////////////////////////////////////////
-// Helpers
-//////////////////////////////////////////////////////////////////////
-namespace __ccnx_private {
-
-struct CcnxFibFaceMetricByFace
-{
-  typedef CcnxFibFaceMetricContainer::type::index<i_face>::type
-  type;
-};
-
-}
-//////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////
-    
 using namespace __ccnx_private;
 
-TypeId 
-CcnxFib::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::CcnxFib")
-    .SetParent<Object> ()
-    .SetGroupName ("Ccnx")
-    .AddConstructor<CcnxFib> ()
-
-  ;
-  return tid;
-}
-
-/////////////////////////////////////////////////////////////////////
-
-void
-CcnxFibFaceMetric::UpdateRtt (const Time &rttSample)
-{
-  // const Time & this->m_rttSample
-  
-  //update srtt and rttvar (RFC 2988)
-  if (m_sRtt.IsZero ())
-    {
-      //first RTT measurement
-      NS_ASSERT_MSG (m_rttVar.IsZero (), "SRTT is zero, but variation is not");
-      
-      m_sRtt = rttSample;
-      m_rttVar = Time (m_sRtt / 2.0);
-    }
-  else
-    {
-      m_rttVar = Time ((1 - NDN_RTO_BETA) * m_rttVar + NDN_RTO_BETA * Abs(m_sRtt - rttSample));
-      m_sRtt = Time ((1 - NDN_RTO_ALPHA) * m_sRtt + NDN_RTO_ALPHA * rttSample);
-    }
-}
-
-/////////////////////////////////////////////////////////////////////
-
-void
-CcnxFibEntry::UpdateFaceRtt (Ptr<CcnxFace> face, const Time &sample)
-{
-  CcnxFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
-  NS_ASSERT_MSG (record != m_faces.get<i_face> ().end (),
-                 "Update status can be performed only on existing faces of CcxnFibEntry");
-
-  m_faces.modify (record,
-                  ll::bind (&CcnxFibFaceMetric::UpdateRtt, ll::_1, sample));
-
-  // reordering random access index same way as by metric index
-  m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
-}
-
-void
-CcnxFibEntry::UpdateStatus (Ptr<CcnxFace> face, CcnxFibFaceMetric::Status status)
-{
-  NS_LOG_FUNCTION (this << boost::cref(*face) << status);
-
-  CcnxFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
-  NS_ASSERT_MSG (record != m_faces.get<i_face> ().end (),
-                 "Update status can be performed only on existing faces of CcxnFibEntry");
-
-  m_faces.modify (record,
-                  (&ll::_1)->*&CcnxFibFaceMetric::m_status = status);
-
-  // reordering random access index same way as by metric index
-  m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
-}
-
-void
-CcnxFibEntry::AddOrUpdateRoutingMetric (Ptr<CcnxFace> face, int32_t metric)
-{
-  NS_LOG_FUNCTION (this);
-  NS_ASSERT_MSG (face != NULL, "Trying to Add or Update NULL face");
-
-  CcnxFibFaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
-  if (record == m_faces.get<i_face> ().end ())
-    {
-      m_faces.insert (CcnxFibFaceMetric (face, metric));
-    }
-  else
-  {
-    // don't update metric to higher value
-    if (record->m_routingCost > metric || record->m_status == CcnxFibFaceMetric::NDN_FIB_RED)
-      {
-        m_faces.modify (record,
-                        (&ll::_1)->*&CcnxFibFaceMetric::m_routingCost = metric);
-
-        m_faces.modify (record,
-                        (&ll::_1)->*&CcnxFibFaceMetric::m_status = CcnxFibFaceMetric::NDN_FIB_YELLOW);
-      }
-  }
-  
-  // reordering random access index same way as by metric index
-  m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
-}
-
-void
-CcnxFibEntry::Invalidate ()
-{
-  for (CcnxFibFaceMetricByFace::type::iterator face = m_faces.begin ();
-       face != m_faces.end ();
-       face++)
-    {
-      m_faces.modify (face,
-                      (&ll::_1)->*&CcnxFibFaceMetric::m_routingCost = std::numeric_limits<uint16_t>::max ());
-
-      m_faces.modify (face,
-                      (&ll::_1)->*&CcnxFibFaceMetric::m_status = CcnxFibFaceMetric::NDN_FIB_RED);
-    }
-}
-
-const CcnxFibFaceMetric &
-CcnxFibEntry::FindBestCandidate (uint32_t skip/* = 0*/) const
-{
-  if (m_faces.size () == 0) throw CcnxFibEntry::NoFaces ();
-  skip = skip % m_faces.size();
-  return m_faces.get<i_nth> () [skip];
-}
-
-
-CcnxFib::CcnxFib ()
-{
-}
-
-void
-CcnxFib::NotifyNewAggregate ()
-{
-  if (m_node == 0)
-      m_node = this->GetObject<Node>();
-  Object::NotifyNewAggregate ();
-}
-
-void 
-CcnxFib::DoDispose (void)
-{
-  m_fib.clear ();
-  m_node = 0;
-  Object::DoDispose ();
-}
-
-
-CcnxFibEntryContainer::type::iterator
-CcnxFib::LongestPrefixMatch (const CcnxInterestHeader &interest) const
-{
-  const CcnxNameComponents &name = interest.GetName ();
-  for (size_t componentsCount = name.GetComponents ().size ()+1;
-       componentsCount > 0;
-       componentsCount--)
-    {
-      CcnxNameComponents subPrefix (name.GetSubComponents (componentsCount-1));
-      CcnxFibEntryContainer::type::iterator match = m_fib.find (subPrefix);
-      if (match != m_fib.end())
-        return match;
-    }
-  
-  return m_fib.end ();
-}
-
-
-CcnxFibEntryContainer::type::iterator
-CcnxFib::Add (const CcnxNameComponents &prefix, Ptr<CcnxFace> face, int32_t metric)
-{
-  return Add (Create<CcnxNameComponents> (prefix), face, metric);
-}
-  
-CcnxFibEntryContainer::type::iterator
-CcnxFib::Add (const Ptr<const CcnxNameComponents> &prefix, Ptr<CcnxFace> face, int32_t metric)
-{
-// CcnxFibFaceMetric
-  NS_LOG_FUNCTION(this->GetObject<Node> ()->GetId () << boost::cref(*prefix) << boost::cref(*face) << metric);
-  CcnxFibEntryContainer::type::iterator entry = m_fib.find (*prefix);
-  if (entry == m_fib.end ())
-    {
-      entry = m_fib.insert (m_fib.end (), CcnxFibEntry (prefix));
-      // insert new
-    }
-
-  NS_ASSERT_MSG (face != NULL, "Trying to modify NULL face");
-  m_fib.modify (entry,
-                ll::bind (&CcnxFibEntry::AddOrUpdateRoutingMetric, ll::_1, face, metric));
-    
-  return entry;
-}
-
-void
-CcnxFib::Remove (const Ptr<const CcnxNameComponents> &prefix)
-{
-  NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix));
-  CcnxFibEntryContainer::type::iterator entry = m_fib.find (*prefix);
-  if (entry != m_fib.end ())
-    m_fib.erase (entry);
-}
-
-void
-CcnxFib::Invalidate (const Ptr<const CcnxNameComponents> &prefix)
-{
-  NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix));
-
-  CcnxFibEntryContainer::type::iterator entry = m_fib.find (*prefix);
-  if (entry == m_fib.end ())
-    return; // nothing to invalidate
-
-  m_fib.modify (entry,
-                ll::bind (&CcnxFibEntry::Invalidate, ll::_1));
-}
-
-void
-CcnxFib::InvalidateAll ()
-{
-  NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId ());
-
-  for (CcnxFibEntryContainer::type::iterator entry = m_fib.begin ();
-       entry != m_fib.end ();
-       entry ++)
-    {
-      m_fib.modify (entry,
-                    ll::bind (&CcnxFibEntry::Invalidate, ll::_1));
-    }
-}
-
-void
-CcnxFib::Remove (const CcnxFibEntry &entry, Ptr<CcnxFace> face)
-{
-  NS_LOG_FUNCTION (this);
-
-  m_fib.modify (m_fib.iterator_to (entry),
-                ll::bind (&CcnxFibEntry::RemoveFace, ll::_1, face));
-  if (entry.m_faces.size () == 0)
-    {
-      m_fib.erase (m_fib.iterator_to (entry));
-    }
-}
-
-void
-CcnxFib::RemoveFromAll (Ptr<CcnxFace> face)
-{
-  NS_LOG_FUNCTION (this);
-
-  for_each (m_fib.begin (), m_fib.end (), 
-            ll::bind (static_cast< void (CcnxFib::*) (const CcnxFibEntry &, Ptr<CcnxFace>) > (&CcnxFib::Remove),
-                      this, ll::_1, face));
-}
-
-
 std::ostream& operator<< (std::ostream& os, const CcnxFib &fib)
 {
-  os << "Node " << Names::FindName (fib.m_node) << "\n";
+  os << "Node " << Names::FindName (fib.GetObject<Node>()) << "\n";
   os << "  Dest prefix      Interfaces(Costs)                  \n";
   os << "+-------------+--------------------------------------+\n";
-  
-  for (CcnxFibEntryContainer::type::iterator entry = fib.m_fib.begin ();
-       entry != fib.m_fib.end ();
-       entry++)
-    {
-      os << entry->GetPrefix () << "\t" << *entry << "\n";
-    }
+
+  fib.Print (os);
   return os;
 }
 
-std::ostream& operator<< (std::ostream& os, const CcnxFibEntry &entry)
-{
-  for (CcnxFibFaceMetricContainer::type::index<i_nth>::type::iterator metric =
-         entry.m_faces.get<i_nth> ().begin ();
-       metric != entry.m_faces.get<i_nth> ().end ();
-       metric++)
-    {
-      if (metric != entry.m_faces.get<i_nth> ().begin ())
-        os << ", ";
-
-      os << *metric;
-    }
-  return os;
-}
-
-std::ostream& operator<< (std::ostream& os, const CcnxFibFaceMetric &metric)
-{
-  static const std::string statusString[] = {"","g","y","r"};
-
-  os << *metric.m_face << "(" << metric.m_routingCost << ","<< statusString [metric.m_status] << "," << metric.m_face->GetMetric () << ")";
-  return os;
-}
-
-// void CcnxFib::resetProbing()
-// {
-//     for(FibRangeIterator fib = _fib.begin(); fib != _fib.end(); fib++)
-//         VALUE(fib).needsProbing = true;
-// }
-
-// void CcnxFib::updateInterfaceStatus( int interface, int status )
-// {
-// 	for( FibRangeIterator fib = _fib.begin(); fib!=_fib.end(); fib++ )
-// 	{
-// 		VALUE(fib).updateStatus( interface, status );
-// 	}
-// }
-
 } // namespace ns3
diff --git a/model/ccnx-fib.h b/model/ccnx-fib.h
index 1baaf6f..31fd2d8 100644
--- a/model/ccnx-fib.h
+++ b/model/ccnx-fib.h
@@ -21,23 +21,10 @@
 #ifndef _CCNX_FIB_H_
 #define	_CCNX_FIB_H_
 
-#include "ccnx-name-components-hash-helper.h"
-#include "ccnx-face.h"
-#include "ccnx.h"
-#include "ns3/nstime.h"
 #include "ns3/simple-ref-count.h"
 #include "ns3/node.h"
 
-#include <boost/multi_index_container.hpp>
-#include <boost/multi_index/tag.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-#include <boost/multi_index/composite_key.hpp>
-#include <boost/multi_index/hashed_index.hpp>
-#include <boost/multi_index/random_access_index.hpp>
-#include <boost/multi_index/member.hpp>
-#include <boost/multi_index/mem_fun.hpp>
-
-#include <iostream>
+#include "ns3/ccnx-fib-entry.h"
 
 namespace ns3 {
 
@@ -45,242 +32,24 @@
 
 /**
  * \ingroup ccnx
- * \brief Structure holding various parameters associated with a (FibEntry, Face) tuple
- */
-class CcnxFibFaceMetric
-{
-public:
-  /**
-   * @brief Color codes for FIB face status
-   */
-  enum Status { NDN_FIB_GREEN = 1,
-                NDN_FIB_YELLOW = 2,
-                NDN_FIB_RED = 3 };
-public:
-  /**
-   * \brief Metric constructor
-   *
-   * \param face Face for which metric
-   * \param cost Initial value for routing cost
-   */
-  CcnxFibFaceMetric (Ptr<CcnxFace> face, int32_t cost)
-    : m_face (face)
-    , m_status (NDN_FIB_YELLOW)
-    , m_routingCost (cost)
-    , m_sRtt   (Seconds (0))
-    , m_rttVar (Seconds (0))
-  { }
-
-  /**
-   * \brief Comparison operator used by boost::multi_index::identity<>
-   */
-  bool
-  operator< (const CcnxFibFaceMetric &fm) const { return *m_face < *fm.m_face; } // return identity of the face
-
-  /**
-   * @brief Comparison between CcnxFibFaceMetric and CcnxFace
-   */
-  bool
-  operator< (const Ptr<CcnxFace> &face) const { return *m_face < *face; } 
-
-  /**
-   * @brief Return CcnxFace associated with CcnxFibFaceMetric
-   */
-  Ptr<CcnxFace>
-  GetFace () const { return m_face; }
-
-  /**
-   * \brief Recalculate smoothed RTT and RTT variation
-   * \param rttSample RTT sample
-   */
-  void
-  UpdateRtt (const Time &rttSample);
-  
-private:
-  friend std::ostream& operator<< (std::ostream& os, const CcnxFibFaceMetric &metric);
-public:
-  Ptr<CcnxFace> m_face; ///< Face
-  
-  Status m_status;		///< \brief Status of the next hop: 
-				///<		- NDN_FIB_GREEN
-				///<		- NDN_FIB_YELLOW
-				///<		- NDN_FIB_RED
-  
-  int32_t m_routingCost; ///< \brief routing protocol cost (interpretation of the value depends on the underlying routing protocol)
-
-  Time m_sRtt;         ///< \brief smoothed round-trip time
-  Time m_rttVar;       ///< \brief round-trip time variation
-};
-
-/**
- * \ingroup ccnx
- * \brief Typedef for indexed face container of CcnxFibEntry
- *
- * Currently, there are 2 indexes:
- * - by face (used to find record and update metric)
- * - by metric (face ranking)
- * - random access index (for fast lookup on nth face). Order is
- *   maintained manually to be equal to the 'by metric' order
- */
-struct CcnxFibFaceMetricContainer
-{
-  /// @cond include_hidden
-  typedef boost::multi_index::multi_index_container<
-    CcnxFibFaceMetric,
-    boost::multi_index::indexed_by<
-      // For fast access to elements using CcnxFace
-      boost::multi_index::ordered_unique<
-        boost::multi_index::tag<__ccnx_private::i_face>,
-        boost::multi_index::member<CcnxFibFaceMetric,Ptr<CcnxFace>,&CcnxFibFaceMetric::m_face>
-      >,
-
-      // List of available faces ordered by (status, m_routingCost)
-      boost::multi_index::ordered_non_unique<
-        boost::multi_index::tag<__ccnx_private::i_metric>,
-        boost::multi_index::composite_key<
-          CcnxFibFaceMetric,
-          boost::multi_index::member<CcnxFibFaceMetric,CcnxFibFaceMetric::Status,&CcnxFibFaceMetric::m_status>,
-          boost::multi_index::member<CcnxFibFaceMetric,int32_t,&CcnxFibFaceMetric::m_routingCost>
-        >
-      >,
-
-      // To optimize nth candidate selection (sacrifice a little bit space to gain speed)
-      boost::multi_index::random_access<
-        boost::multi_index::tag<__ccnx_private::i_nth>
-      >
-    >
-   > type;
-  /// @endcond
-};
-
-/**
- * \ingroup ccnx
- * \brief Structure for FIB table entry, holding indexed list of
- *        available faces and their respective metrics
- */
-class CcnxFibEntry // : public SimpleRefCount<CcnxFibEntry>
-{
-public:
-  class NoFaces {}; ///< @brief Exception class for the case when FIB entry is not found
-  
-  /**
-   * \brief Constructor
-   * \param prefix smart pointer to the prefix for the FIB entry
-   */
-  CcnxFibEntry (const Ptr<const CcnxNameComponents> &prefix)
-  : m_prefix (prefix)
-  , m_needsProbing (false)
-  { }
-  
-  /**
-   * \brief Update status of FIB next hop
-   * \param status Status to set on the FIB entry
-   */
-  void UpdateStatus (Ptr<CcnxFace> face, CcnxFibFaceMetric::Status status);
-
-  /**
-   * \brief Add or update routing metric of FIB next hop
-   *
-   * Initial status of the next hop is set to YELLOW
-   */
-  void AddOrUpdateRoutingMetric (Ptr<CcnxFace> face, int32_t metric);
-
-  /**
-   * @brief Invalidate face
-   *
-   * Set routing metric on all faces to max and status to RED
-   */
-  void
-  Invalidate ();
-
-  /**
-   * @brief Update RTT averages for the face
-   */
-  void
-  UpdateFaceRtt (Ptr<CcnxFace> face, const Time &sample);
-  
-  /**
-   * \brief Get prefix for the FIB entry
-   */
-  const CcnxNameComponents&
-  GetPrefix () const { return *m_prefix; }
-
-  /**
-   * \brief Find "best route" candidate, skipping `skip' first candidates (modulo # of faces)
-   *
-   * throws CcnxFibEntry::NoFaces if m_faces.size()==0
-   */
-  const CcnxFibFaceMetric &
-  FindBestCandidate (uint32_t skip = 0) const;
-
-  /**
-   * @brief Remove record associated with `face`
-   */
-  void
-  RemoveFace (const Ptr<CcnxFace> &face)
-  {
-    m_faces.erase (face);
-  }
-	
-private:
-  friend std::ostream& operator<< (std::ostream& os, const CcnxFibEntry &entry);
-
-public:
-  Ptr<const CcnxNameComponents> m_prefix; ///< \brief Prefix of the FIB entry
-  CcnxFibFaceMetricContainer::type m_faces; ///< \brief Indexed list of faces
-
-  bool m_needsProbing;      ///< \brief flag indicating that probing should be performed 
-};
-
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-
-/**
- * \ingroup ccnx
- * \brief Typedef for indexed container for FIB entries
- *
- * Currently, there is only one index
- * - by prefix hash, which is used to perform prefix match
- */
-struct CcnxFibEntryContainer 
-{
-  /// @cond include_hidden
-  typedef boost::multi_index::multi_index_container<
-    CcnxFibEntry,
-    boost::multi_index::indexed_by<
-      // For fast access to elements using CcnxFace
-      boost::multi_index::hashed_unique<
-        boost::multi_index::tag<__ccnx_private::i_prefix>,
-        boost::multi_index::const_mem_fun<CcnxFibEntry,
-                                          const CcnxNameComponents&,
-                                          &CcnxFibEntry::GetPrefix>,
-        CcnxPrefixHash>
-      >
-    > type;
-  /// @endcond
-};
-
-/**
- * \ingroup ccnx
  * \brief Class implementing FIB functionality
  */
 class CcnxFib : public Object
 {
 public:
-  typedef CcnxFibEntryContainer::type::iterator iterator;
+  typedef ns3::Ptr<CcnxFibEntry> iterator; // not sure, but let's see what will happen
+  typedef ns3::Ptr<CcnxFibEntry> const_iterator;
+
+  /**
+   * @brief Default constructor
+   */
+  CcnxFib () {}
   
   /**
-   * \brief Interface ID
-   *
-   * \return interface ID
+   * @brief Virtual destructor
    */
-  static TypeId GetTypeId ();
-
-  /**
-   * \brief Constructor
-   */
-  CcnxFib ();
-
+  virtual ~CcnxFib () { };
+  
   /**
    * \brief Perform longest prefix match
    *
@@ -289,8 +58,8 @@
    * \param interest Interest packet header
    * \returns If entry found a valid iterator will be returned, otherwise end ()
    */
-  CcnxFibEntryContainer::type::iterator
-  LongestPrefixMatch (const CcnxInterestHeader &interest) const;
+  virtual iterator
+  LongestPrefixMatch (const CcnxInterestHeader &interest) const = 0;
   
   /**
    * \brief Add or update FIB entry
@@ -303,8 +72,8 @@
    * @param face	Forwarding face
    * @param metric	Routing metric
    */
-  CcnxFibEntryContainer::type::iterator
-  Add (const CcnxNameComponents &prefix, Ptr<CcnxFace> face, int32_t metric);
+  virtual iterator
+  Add (const CcnxNameComponents &prefix, Ptr<CcnxFace> face, int32_t metric) = 0;
 
   /**
    * \brief Add or update FIB entry using smart pointer to prefix
@@ -317,8 +86,8 @@
    * @param face	Forwarding face
    * @param metric	Routing metric
    */
-  CcnxFibEntryContainer::type::iterator
-  Add (const Ptr<const CcnxNameComponents> &prefix, Ptr<CcnxFace> face, int32_t metric);
+  virtual iterator
+  Add (const Ptr<const CcnxNameComponents> &prefix, Ptr<CcnxFace> face, int32_t metric) = 0;
 
   /**
    * @brief Remove FIB entry
@@ -328,8 +97,8 @@
    *
    * @param name	Smart pointer to prefix
    */
-  void
-  Remove (const Ptr<const CcnxNameComponents> &prefix);
+  virtual void
+  Remove (const Ptr<const CcnxNameComponents> &prefix) = 0;
 
   /**
    * @brief Invalidate FIB entry ("Safe" version of Remove)
@@ -337,51 +106,54 @@
    * All faces for the entry will be assigned maximum routing metric and NDN_FIB_RED status   
    * @param name	Smart pointer to prefix
    */
-  void
-  Invalidate (const Ptr<const CcnxNameComponents> &prefix);
+  virtual void
+  Invalidate (const Ptr<const CcnxNameComponents> &prefix) = 0;
 
   /**
    * @brief Invalidate all FIB entries
    */
-  void
-  InvalidateAll ();
+  virtual void
+  InvalidateAll () = 0;
   
   /**
    * @brief Remove reference to a face from the entry. If entry had only this face, the whole
    * entry will be removed
    */
-  void
-  Remove (const CcnxFibEntry &entry, Ptr<CcnxFace> face);
+  virtual void
+  Remove (const CcnxFibEntry &entry, Ptr<CcnxFace> face) = 0;
 
   /**
    * @brief Remove all references to a face from FIB.  If for some enty that face was the only element,
    * this FIB entry will be removed.
    */
-  void
-  RemoveFromAll (Ptr<CcnxFace> face);
+  virtual void
+  RemoveFromAll (Ptr<CcnxFace> face) = 0;
 
-public:
-  CcnxFibEntryContainer::type m_fib; ///< @brief Internal container
-
-protected:
-  // inherited from Object class
-  virtual void NotifyNewAggregate (); ///< @brief Notify when object is aggregated
-  virtual void DoDispose (); ///< @brief Perform cleanup
+  /**
+   * @brief Print out entries in FIB
+   */
+  virtual void
+  Print (std::ostream &os) const = 0;
+  
+  // /**
+  //  * @brief Modify element in container
+  //  */
+  // template<typename Modifier>
+  // virtual bool
+  // modify (iterator position, Modifier mod) = 0;
+  // // {
+  // //   return this->m_fib.modify (position, mod);
+  // // }
   
 private:
   friend std::ostream& operator<< (std::ostream& os, const CcnxFib &fib);
   CcnxFib(const CcnxFib&) {} ; ///< \brief copy constructor is disabled
-  
-private:
-  Ptr<Node> m_node;
 };
 
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
 
 std::ostream& operator<< (std::ostream& os, const CcnxFib &fib);
-std::ostream& operator<< (std::ostream& os, const CcnxFibEntry &entry);
-std::ostream& operator<< (std::ostream& os, const CcnxFibFaceMetric &metric);
  
 } // namespace ns3
 
diff --git a/model/ccnx-l3-protocol.cc b/model/ccnx-l3-protocol.cc
index 9abe297..72273d5 100644
--- a/model/ccnx-l3-protocol.cc
+++ b/model/ccnx-l3-protocol.cc
@@ -40,6 +40,7 @@
 #include "ccnx-forwarding-strategy.h"
 #include "ccnx-interest-header.h"
 #include "ccnx-content-object-header.h"
+#include "ccnx-fib-impl.h"
 
 #include "ccnx-net-device-face.h"
 
@@ -333,9 +334,9 @@
                      ll::bind (&CcnxPitEntry::RemoveIncoming, ll::_1, incomingFace));
     }
 
-  m_fib->m_fib.modify (pitEntry->m_fibEntry,
-                       ll::bind (&CcnxFibEntry::UpdateStatus,
-                                 ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
+  StaticCast<CcnxFibImpl> (m_fib)->modify (pitEntry->m_fibEntry,
+                                            ll::bind (&CcnxFibEntry::UpdateStatus,
+                                                      ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
 
   if (pitEntry->m_incoming.size () == 0) // interest was actually satisfied
     {
@@ -484,9 +485,9 @@
 
       // ?? not sure if we need to do that ?? ...
       
-      m_fib->m_fib.modify(pitEntry->m_fibEntry,
-                          ll::bind (&CcnxFibEntry::UpdateStatus,
-                                    ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
+      StaticCast<CcnxFibImpl> (m_fib)->modify(pitEntry->m_fibEntry,
+                                               ll::bind (&CcnxFibEntry::UpdateStatus,
+                                                         ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
     }
   else
     if (!isNew && !isRetransmitted)
@@ -588,11 +589,11 @@
       // If we have sent interest for this data via this face, then update stats.
       if (out != pitEntry->m_outgoing.end ())
         {
-          m_fib->m_fib.modify (pitEntry->m_fibEntry,
-                               ll::bind (&CcnxFibEntry::UpdateFaceRtt,
-                                         ll::_1,
-                                         incomingFace,
-                                         Simulator::Now () - out->m_sendTime));
+          StaticCast<CcnxFibImpl> (m_fib)->modify (pitEntry->m_fibEntry,
+                                                   ll::bind (&CcnxFibEntry::UpdateFaceRtt,
+                                                             ll::_1,
+                                                             incomingFace,
+                                                             Simulator::Now () - out->m_sendTime));
         }
       else
         {
@@ -615,9 +616,9 @@
         }
 
       // Update metric status for the incoming interface in the corresponding FIB entry
-      m_fib->m_fib.modify (pitEntry->m_fibEntry,
-                           ll::bind (&CcnxFibEntry::UpdateStatus, ll::_1,
-                                     incomingFace, CcnxFibFaceMetric::NDN_FIB_GREEN));
+      StaticCast<CcnxFibImpl>(m_fib)->modify (pitEntry->m_fibEntry,
+                                               ll::bind (&CcnxFibEntry::UpdateStatus, ll::_1,
+                                                         incomingFace, CcnxFibFaceMetric::NDN_FIB_GREEN));
   
       // Add or update entry in the content store
       m_contentStore->Add (header, payload);
diff --git a/model/ccnx-pit-entry.cc b/model/ccnx-pit-entry.cc
index 127b589..8375cf9 100644
--- a/model/ccnx-pit-entry.cc
+++ b/model/ccnx-pit-entry.cc
@@ -27,6 +27,7 @@
 
 #include <boost/lambda/lambda.hpp>
 #include <boost/lambda/bind.hpp>
+#include <boost/foreach.hpp>
 namespace ll = boost::lambda;
 
 NS_LOG_COMPONENT_DEFINE ("CcnxPitEntry");