Merge feature branch 'feature-trace-value-for-fib-entry'
diff --git a/model/fib/ndn-fib-entry.cc b/model/fib/ndn-fib-entry.cc
index c04e43b..35b3a99 100644
--- a/model/fib/ndn-fib-entry.cc
+++ b/model/fib/ndn-fib-entry.cc
@@ -54,13 +54,13 @@
 FaceMetric::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);
     }
@@ -97,7 +97,7 @@
                  "Update status can be performed only on existing faces of CcxnFibEntry");
 
   m_faces.modify (record,
-                  (&ll::_1)->*&FaceMetric::m_status = status);
+                  ll::bind (&FaceMetric::SetStatus, ll::_1, status));
 
   // reordering random access index same way as by metric index
   m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
@@ -117,16 +117,16 @@
   else
   {
     // don't update metric to higher value
-    if (record->m_routingCost > metric || record->m_status == FaceMetric::NDN_FIB_RED)
+    if (record->GetRoutingCost () > metric || record->GetStatus () == FaceMetric::NDN_FIB_RED)
       {
         m_faces.modify (record,
-                        (&ll::_1)->*&FaceMetric::m_routingCost = metric);
+                        ll::bind (&FaceMetric::SetRoutingCost, ll::_1, metric));
 
         m_faces.modify (record,
-                        (&ll::_1)->*&FaceMetric::m_status = FaceMetric::NDN_FIB_YELLOW);
+                        ll::bind (&FaceMetric::SetStatus, ll::_1, FaceMetric::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 ());
 }
@@ -141,7 +141,7 @@
   if (record != m_faces.get<i_face> ().end ())
     {
       m_faces.modify (record,
-                      (&ll::_1)->*&FaceMetric::m_realDelay = delay);
+                      ll::bind (&FaceMetric::SetRealDelay, ll::_1, delay));
     }
 }
 
@@ -154,10 +154,10 @@
        face++)
     {
       m_faces.modify (face,
-                      (&ll::_1)->*&FaceMetric::m_routingCost = std::numeric_limits<uint16_t>::max ());
+                      ll::bind (&FaceMetric::SetRoutingCost, ll::_1, std::numeric_limits<uint16_t>::max ()));
 
       m_faces.modify (face,
-                      (&ll::_1)->*&FaceMetric::m_status = FaceMetric::NDN_FIB_RED);
+                      ll::bind (&FaceMetric::SetStatus, ll::_1, FaceMetric::NDN_FIB_RED));
     }
 }
 
diff --git a/model/fib/ndn-fib-entry.h b/model/fib/ndn-fib-entry.h
index 214b0eb..93fa2aa 100644
--- a/model/fib/ndn-fib-entry.h
+++ b/model/fib/ndn-fib-entry.h
@@ -26,6 +26,7 @@
 #include "ns3/ndn-face.h"
 #include "ns3/ndn-name-components.h"
 #include "ns3/ndn-limits.h"
+#include "ns3/traced-value.h"
 
 #include <boost/multi_index_container.hpp>
 #include <boost/multi_index/tag.hpp>
@@ -82,7 +83,7 @@
    * @brief Comparison between FaceMetric and Face
    */
   bool
-  operator< (const Ptr<Face> &face) const { return *m_face < *face; } 
+  operator< (const Ptr<Face> &face) const { return *m_face < *face; }
 
   /**
    * @brief Return Face associated with FaceMetric
@@ -96,17 +97,81 @@
    */
   void
   UpdateRtt (const Time &rttSample);
-  
+
+  /**
+   * @brief Get current status of FIB entry
+   */
+  Status
+  GetStatus () const
+  {
+    return m_status;
+  }
+
+  /**
+   * @brief Set current status of FIB entry
+   */
+  void
+  SetStatus (Status status)
+  {
+    m_status.Set (status);
+  }
+
+  /**
+   * @brief Get current routing cost
+   */
+  int32_t
+  GetRoutingCost () const
+  {
+    return m_routingCost;
+  }
+
+  /**
+   * @brief Set routing cost
+   */
+  void
+  SetRoutingCost (int32_t routingCost)
+  {
+    m_routingCost = routingCost;
+  }
+
+  /**
+   * @brief Get real propagation delay to the producer, calculated based on NS-3 p2p link delays
+   */
+  Time
+  GetRealDelay () const
+  {
+    return m_realDelay;
+  }
+
+  /**
+   * @brief Set real propagation delay to the producer, calculated based on NS-3 p2p link delays
+   */
+  void
+  SetRealDelay (Time realDelay)
+  {
+    m_realDelay = realDelay;
+  }
+
+  /**
+   * @brief Get direct access to status trace
+   */
+  TracedValue<Status> &
+  GetStatusTrace ()
+  {
+    return m_status;
+  }
+
 private:
   friend std::ostream& operator<< (std::ostream& os, const FaceMetric &metric);
-public:
+
+private:
   Ptr<Face> m_face; ///< Face
-  
-  Status m_status;		///< \brief Status of the next hop: 
+
+  TracedValue<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
@@ -141,7 +206,7 @@
       // For fast access to elements using Face
       boost::multi_index::ordered_unique<
         boost::multi_index::tag<i_face>,
-        boost::multi_index::member<FaceMetric,Ptr<Face>,&FaceMetric::m_face>
+        boost::multi_index::const_mem_fun<FaceMetric,Ptr<Face>,&FaceMetric::GetFace>
       >,
 
       // List of available faces ordered by (status, m_routingCost)
@@ -149,8 +214,8 @@
         boost::multi_index::tag<i_metric>,
         boost::multi_index::composite_key<
           FaceMetric,
-          boost::multi_index::member<FaceMetric,FaceMetric::Status,&FaceMetric::m_status>,
-          boost::multi_index::member<FaceMetric,int32_t,&FaceMetric::m_routingCost>
+          boost::multi_index::const_mem_fun<FaceMetric,FaceMetric::Status,&FaceMetric::GetStatus>,
+          boost::multi_index::const_mem_fun<FaceMetric,int32_t,&FaceMetric::GetRoutingCost>
         >
       >,
 
@@ -172,10 +237,10 @@
 {
 public:
   typedef Entry base_type;
-  
+
 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
@@ -185,7 +250,7 @@
   , m_needsProbing (false)
   {
   }
-  
+
   /**
    * \brief Update status of FIB next hop
    * \param status Status to set on the FIB entry
@@ -204,7 +269,7 @@
    */
   void
   SetRealDelayToProducer (Ptr<Face> face, Time delay);
-  
+
   /**
    * @brief Invalidate face
    *
@@ -218,7 +283,7 @@
    */
   void
   UpdateFaceRtt (Ptr<Face> face, const Time &sample);
-  
+
   /**
    * \brief Get prefix for the FIB entry
    */
diff --git a/model/fw/best-route.cc b/model/fw/best-route.cc
index 03400b7..08bbd7c 100644
--- a/model/fw/best-route.cc
+++ b/model/fw/best-route.cc
@@ -58,11 +58,11 @@
     ;
   return tid;
 }
-    
+
 BestRoute::BestRoute ()
 {
 }
-    
+
 bool
 BestRoute::DoPropagateInterest (Ptr<Face> inFace,
                                 Ptr<const InterestHeader> header,
@@ -77,14 +77,14 @@
     return true;
 
   int propagatedCount = 0;
-  
+
   BOOST_FOREACH (const fib::FaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<fib::i_metric> ())
     {
       NS_LOG_DEBUG ("Trying " << boost::cref(metricFace));
-      if (metricFace.m_status == fib::FaceMetric::NDN_FIB_RED) // all non-read faces are in front
+      if (metricFace.GetStatus () == fib::FaceMetric::NDN_FIB_RED) // all non-read faces are in front
         break;
 
-      if (!TrySendOutInterest (inFace, metricFace.m_face, header, origPacket, pitEntry))
+      if (!TrySendOutInterest (inFace, metricFace.GetFace (), header, origPacket, pitEntry))
         {
           continue;
         }
diff --git a/model/fw/flooding.cc b/model/fw/flooding.cc
index 80b863a..0c369b7 100644
--- a/model/fw/flooding.cc
+++ b/model/fw/flooding.cc
@@ -59,7 +59,7 @@
     ;
   return tid;
 }
-    
+
 Flooding::Flooding ()
 {
 }
@@ -77,14 +77,14 @@
   BOOST_FOREACH (const fib::FaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<fib::i_metric> ())
     {
       NS_LOG_DEBUG ("Trying " << boost::cref(metricFace));
-      if (metricFace.m_status == fib::FaceMetric::NDN_FIB_RED) // all non-read faces are in the front of the list
+      if (metricFace.GetStatus () == fib::FaceMetric::NDN_FIB_RED) // all non-read faces are in the front of the list
         break;
-      
-      if (!TrySendOutInterest (inFace, metricFace.m_face, header, origPacket, pitEntry))
+
+      if (!TrySendOutInterest (inFace, metricFace.GetFace (), header, origPacket, pitEntry))
         {
           continue;
         }
-      
+
       propagatedCount++;
     }
 
diff --git a/model/fw/green-yellow-red.cc b/model/fw/green-yellow-red.cc
index 2045634..3b5fd13 100644
--- a/model/fw/green-yellow-red.cc
+++ b/model/fw/green-yellow-red.cc
@@ -75,11 +75,11 @@
 
   BOOST_FOREACH (const fib::FaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<fib::i_metric> ())
     {
-      if (metricFace.m_status == fib::FaceMetric::NDN_FIB_RED ||
-          metricFace.m_status == fib::FaceMetric::NDN_FIB_YELLOW)
+      if (metricFace.GetStatus () == fib::FaceMetric::NDN_FIB_RED ||
+          metricFace.GetStatus () == fib::FaceMetric::NDN_FIB_YELLOW)
         break; //propagate only to green faces
 
-      if (!TrySendOutInterest (inFace, metricFace.m_face, header, origPacket, pitEntry))
+      if (!TrySendOutInterest (inFace, metricFace.GetFace (), header, origPacket, pitEntry))
         {
           continue;
         }
@@ -108,11 +108,12 @@
 GreenYellowRed::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry)
 {
   NS_LOG_DEBUG ("WillEraseTimedOutPendingInterest for " << pitEntry->GetPrefix ());
+
   for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
        face != pitEntry->GetOutgoing ().end ();
        face ++)
     {
-      NS_LOG_DEBUG ("Face: " << face->m_face);
+      // NS_LOG_DEBUG ("Face: " << face->m_face);
       pitEntry->GetFibEntry ()->UpdateStatus (face->m_face, fib::FaceMetric::NDN_FIB_YELLOW);
     }
 
diff --git a/model/fw/green-yellow-red.h b/model/fw/green-yellow-red.h
index 93c00ca..e82c93b 100644
--- a/model/fw/green-yellow-red.h
+++ b/model/fw/green-yellow-red.h
@@ -57,7 +57,6 @@
                        Ptr<const InterestHeader> header,
                        Ptr<const Packet> origPacket,
                        Ptr<pit::Entry> pitEntry);
-
 private:
   typedef Nacks super;
 };
diff --git a/model/fw/per-fib-limits.h b/model/fw/per-fib-limits.h
index 47f9ee6..4affec9 100644
--- a/model/fw/per-fib-limits.h
+++ b/model/fw/per-fib-limits.h
@@ -57,13 +57,13 @@
    */
   static std::string
   GetLogName ();
-  
+
   /**
    * @brief Default constructor
    */
   PerFibLimits ()
   { }
-  
+
   /// \copydoc ForwardingStrategy::WillEraseTimedOutPendingInterest
   virtual void
   WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
@@ -86,14 +86,14 @@
   DidAddFibEntry (Ptr<fib::Entry> fibEntry)
   {
     ObjectFactory factory;
-    factory.SetTypeId (fibEntry->m_faces.begin ()->m_face->GetObject<Limits> ()->GetInstanceTypeId ());
-    
+    factory.SetTypeId (fibEntry->m_faces.begin ()->GetFace ()->GetObject<Limits> ()->GetInstanceTypeId ());
+
     Ptr<Limits> limits = factory.template Create<Limits> ();
     fibEntry->AggregateObject (limits);
 
     super::DidAddFibEntry (fibEntry);
   }
-  
+
 protected:
   /// \copydoc ForwardingStrategy::CanSendOutInterest
   virtual bool
@@ -102,7 +102,7 @@
                       Ptr<const InterestHeader> header,
                       Ptr<const Packet> origPacket,
                       Ptr<pit::Entry> pitEntry);
-  
+
   /// \copydoc ForwardingStrategy::WillSatisfyPendingInterest
   virtual void
   WillSatisfyPendingInterest (Ptr<Face> inFace,
@@ -110,7 +110,7 @@
 
 protected:
   static LogComponent g_log; ///< @brief Logging variable
-  
+
 private:
   std::string m_limitType;
 };
@@ -149,7 +149,7 @@
 
   Ptr<Limits> fibLimits = pitEntry->GetFibEntry ()->template GetObject<Limits> ();
   // no checks for the limit here. the check should be somewhere elese
-  
+
   if (fibLimits->IsBelowLimit ())
     {
       if (super::CanSendOutInterest (inFace, outFace, header, origPacket, pitEntry))
@@ -158,7 +158,7 @@
           return true;
         }
     }
-  
+
   return false;
 }
 
@@ -184,7 +184,7 @@
 
   Ptr<Limits> fibLimits = pitEntry->GetFibEntry ()->template GetObject<Limits> ();
   fibLimits->ReturnLimit ();
-  
+
   super::WillSatisfyPendingInterest (inFace, pitEntry);
 }
 
diff --git a/model/fw/smart-flooding.cc b/model/fw/smart-flooding.cc
index 3777739..c8b8406 100644
--- a/model/fw/smart-flooding.cc
+++ b/model/fw/smart-flooding.cc
@@ -59,7 +59,7 @@
     ;
   return tid;
 }
-    
+
 SmartFlooding::SmartFlooding ()
 {
 }
@@ -82,14 +82,14 @@
   BOOST_FOREACH (const fib::FaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<fib::i_metric> ())
     {
       NS_LOG_DEBUG ("Trying " << boost::cref(metricFace));
-      if (metricFace.m_status == fib::FaceMetric::NDN_FIB_RED) // all non-read faces are in the front of the list
+      if (metricFace.GetStatus () == fib::FaceMetric::NDN_FIB_RED) // all non-read faces are in the front of the list
         break;
-      
-      if (!TrySendOutInterest (inFace, metricFace.m_face, header, origPacket, pitEntry))
+
+      if (!TrySendOutInterest (inFace, metricFace.GetFace (), header, origPacket, pitEntry))
         {
           continue;
         }
-      
+
       propagatedCount++;
     }
 
diff --git a/model/ndn-l3-protocol.cc b/model/ndn-l3-protocol.cc
index b0957c5..28d337b 100644
--- a/model/ndn-l3-protocol.cc
+++ b/model/ndn-l3-protocol.cc
@@ -69,7 +69,7 @@
 }
 
 
-TypeId 
+TypeId
 L3Protocol::GetTypeId (void)
 {
   static TypeId tid = TypeId ("ns3::ndn::L3Protocol")
@@ -134,7 +134,7 @@
   Object::NotifyNewAggregate ();
 }
 
-void 
+void
 L3Protocol::DoDispose (void)
 {
   NS_LOG_FUNCTION (this);
@@ -152,7 +152,7 @@
   Object::DoDispose ();
 }
 
-uint32_t 
+uint32_t
 L3Protocol::AddFace (const Ptr<Face> &face)
 {
   NS_LOG_FUNCTION (this << &face);
@@ -165,7 +165,7 @@
   m_faces.push_back (face);
   m_faceCounter++;
 
-  m_forwardingStrategy->AddFace (face); // notify that face is added    
+  m_forwardingStrategy->AddFace (face); // notify that face is added
   return face->GetId ();
 }
 
@@ -181,11 +181,11 @@
   for (Ptr<pit::Entry> pitEntry = pit->Begin (); pitEntry != 0; pitEntry = pit->Next (pitEntry))
     {
       pitEntry->RemoveAllReferencesToFace (face);
-      
+
       // If this face is the only for the associated FIB entry, then FIB entry will be removed soon.
       // Thus, we have to remove the whole PIT entry
       if (pitEntry->GetFibEntry ()->m_faces.size () == 1 &&
-          pitEntry->GetFibEntry ()->m_faces.begin ()->m_face == face)
+          pitEntry->GetFibEntry ()->m_faces.begin ()->GetFace () == face)
         {
           entriesToRemoves.push_back (pitEntry);
         }
@@ -200,7 +200,7 @@
   m_faces.erase (face_it);
 
   GetObject<Fib> ()->RemoveFromAll (face);
-  m_forwardingStrategy->RemoveFace (face); // notify that face is removed  
+  m_forwardingStrategy->RemoveFace (face); // notify that face is removed
 }
 
 Ptr<Face>
@@ -235,21 +235,21 @@
   return 0;
 }
 
-uint32_t 
+uint32_t
 L3Protocol::GetNFaces (void) const
 {
   return m_faces.size ();
 }
 
 // Callback from lower layer
-void 
+void
 L3Protocol::Receive (const Ptr<Face> &face, const Ptr<const Packet> &p)
 {
   if (!face->IsUp ())
     return;
 
   NS_LOG_DEBUG (*p);
-  
+
   NS_LOG_LOGIC ("Packet from face " << *face << " received on node " <<  m_node->GetId ());
 
   Ptr<Packet> packet = p->Copy (); // give upper layers a rw copy of the packet
@@ -271,21 +271,21 @@
             // if (header->GetNack () > 0)
             //   OnNack (face, header, p/*original packet*/);
             // else
-            //   OnInterest (face, header, p/*original packet*/);  
+            //   OnInterest (face, header, p/*original packet*/);
             break;
           }
         case HeaderHelper::CONTENT_OBJECT_NDNSIM:
           {
             s_dataCounter ++;
             Ptr<ContentObjectHeader> header = Create<ContentObjectHeader> ();
-            
+
             static ContentObjectTail contentObjectTrailer; //there is no data in this object
 
             // Deserialization. Exception may be thrown
             packet->RemoveHeader (*header);
             packet->RemoveTrailer (contentObjectTrailer);
 
-            m_forwardingStrategy->OnData (face, header, packet/*payload*/, p/*original packet*/);  
+            m_forwardingStrategy->OnData (face, header, packet/*payload*/, p/*original packet*/);
             break;
           }
         case HeaderHelper::INTEREST_CCNB:
@@ -293,7 +293,7 @@
           NS_FATAL_ERROR ("ccnb support is broken in this implementation");
           break;
         }
-      
+
       // exception will be thrown if packet is not recognized
     }
   catch (UnknownHeaderException)