Disabling FIB-entry-limit decrease. Implementing probabilistic interest
acceptance based on accumulated statistics.

Statistics generation is changed to real 1-second averaging
diff --git a/model/fw/fw-stats.cc b/model/fw/fw-stats.cc
index 959d25f..46cd775 100644
--- a/model/fw/fw-stats.cc
+++ b/model/fw/fw-stats.cc
@@ -177,6 +177,22 @@
 }
 
 void
+FwStats::DidExhaustForwardingOptions (const Ptr<Face> &incomingFace,
+                                      Ptr<InterestHeader> header,
+                                      const Ptr<const Packet> &packet,
+                                      Ptr<pit::Entry> pitEntry)
+{
+  super::DidExhaustForwardingOptions (incomingFace, header, packet, pitEntry);
+  
+  if (pitEntry->GetOutgoing ().size () == 0)
+    {
+      m_stats.Timeout (pitEntry->GetPrefix ().cut (1));
+  
+      ScheduleRefreshingIfNecessary ();
+    }
+}
+
+void
 FwStats::ScheduleRefreshingIfNecessary ()
 {
   if (m_statsRefreshEvent.IsRunning ()) return;
diff --git a/model/fw/fw-stats.h b/model/fw/fw-stats.h
index 1a516d8..404f487 100644
--- a/model/fw/fw-stats.h
+++ b/model/fw/fw-stats.h
@@ -96,6 +96,12 @@
   virtual void
   WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
 
+  virtual void
+  DidExhaustForwardingOptions (const Ptr<Face> &incomingFace,
+                               Ptr<InterestHeader> header,
+                               const Ptr<const Packet> &packet,
+                               Ptr<pit::Entry> pitEntry);
+  
   // from Object
   void
   DoDispose ();
diff --git a/model/fw/per-fib-limits.cc b/model/fw/per-fib-limits.cc
index ba11f7f..08ef66b 100644
--- a/model/fw/per-fib-limits.cc
+++ b/model/fw/per-fib-limits.cc
@@ -82,6 +82,28 @@
       return false;
     }
 
+  // check stats
+  Ptr<Face> inFace = pitEntry->GetIncoming ().begin ()->m_face;
+  // const ndnSIM::LoadStatsFace &stats = GetStatsTree ()[header->GetName ()].incoming ().find (inFace)->second;
+  const ndnSIM::LoadStatsFace &stats = GetStatsTree ()["/"].incoming ().find (inFace)->second;
+
+  if (stats.count ().GetStats ().get<0> () >= 0.5 * pitEntry->GetFibEntry ()->GetLimits ().GetMaxLimit ())
+  {
+    double ratio = std::min (1.0, stats.GetSatisfiedRatio ().get<0> ());
+    // NS_ASSERT_MSG (ratio > 0, "If count is a reasonable value, ratio cannot be negative");
+    UniformVariable randAccept (0, 1);
+    double dice = randAccept.GetValue ();
+    if (ratio < 0 || dice < ratio + 0.1)
+      {
+        // ok, accepting the interests
+      }
+    else
+      {
+        // boo. bad luck
+        return false;
+      }
+  }
+  
   if (pitEntry->GetFibEntry ()->GetLimits ().IsBelowLimit ())
     {
       if (outgoingFace->GetLimits ().IsBelowLimit ())
@@ -113,7 +135,7 @@
     }
   
   pitEntry->GetFibEntry ()->GetLimits ().RemoveOutstanding ();
-  pitEntry->GetFibEntry ()->GetLimits ().DecreaseLimit (); // multiplicative decrease
+  // pitEntry->GetFibEntry ()->GetLimits ().DecreaseLimit (); // multiplicative decrease
 
   if (!m_decayLimitsEvent.IsRunning ())
     {
@@ -140,7 +162,7 @@
     }
   
   pitEntry->GetFibEntry ()->GetLimits ().RemoveOutstanding ();
-  pitEntry->GetFibEntry ()->GetLimits ().IncreaseLimit (); // additive increase
+  // pitEntry->GetFibEntry ()->GetLimits ().IncreaseLimit (); // additive increase
 }