Implementing base support for TCP-style window-based limiting on per-FIB-prefix and per-face granularity

Currently, limits are supported only by ndn::fw::Limits forwarding
strategy and only at the very basic (not fully tested) level.
diff --git a/model/fib/ndn-fib-entry.cc b/model/fib/ndn-fib-entry.cc
index 01e2970..750f9da 100644
--- a/model/fib/ndn-fib-entry.cc
+++ b/model/fib/ndn-fib-entry.cc
@@ -22,6 +22,7 @@
 
 #include "ns3/ndn-name-components.h"
 #include "ns3/log.h"
+#include "ns3/simulator.h"
 
 #define NDN_RTO_ALPHA 0.125
 #define NDN_RTO_BETA 0.25
diff --git a/model/fib/ndn-fib-entry.h b/model/fib/ndn-fib-entry.h
index 532120f..c8072f4 100644
--- a/model/fib/ndn-fib-entry.h
+++ b/model/fib/ndn-fib-entry.h
@@ -25,6 +25,7 @@
 #include "ns3/nstime.h"
 #include "ns3/ndn-face.h"
 #include "ns3/ndn-name-components.h"
+#include "ns3/ndn-limits.h"
 
 #include <boost/multi_index_container.hpp>
 #include <boost/multi_index/tag.hpp>
@@ -176,7 +177,9 @@
   Entry (const Ptr<const NameComponents> &prefix)
   : m_prefix (prefix)
   , m_needsProbing (false)
-  { }
+  {
+    m_limits = CreateObject<Limits> ();
+  }
   
   /**
    * \brief Update status of FIB next hop
@@ -227,7 +230,16 @@
   {
     m_faces.erase (face);
   }
-	
+
+  /**
+   * @brief Get reference to limits object
+   */
+  Limits &
+  GetLimits ()
+  {
+    return *m_limits;
+  }
+    
 private:
   friend std::ostream& operator<< (std::ostream& os, const Entry &entry);
 
@@ -235,7 +247,9 @@
   Ptr<const NameComponents> m_prefix; ///< \brief Prefix of the FIB entry
   FaceMetricContainer::type m_faces; ///< \brief Indexed list of faces
 
-  bool m_needsProbing;      ///< \brief flag indicating that probing should be performed 
+  bool m_needsProbing;      ///< \brief flag indicating that probing should be performed
+
+  Ptr<Limits> m_limits;
 };
 
 std::ostream& operator<< (std::ostream& os, const Entry &entry);
diff --git a/model/fib/ndn-fib-impl.cc b/model/fib/ndn-fib-impl.cc
index b91e94c..fd12c68 100644
--- a/model/fib/ndn-fib-impl.cc
+++ b/model/fib/ndn-fib-impl.cc
@@ -208,7 +208,7 @@
 }
 
 Ptr<const Entry>
-FibImpl::Begin ()
+FibImpl::Begin () const
 {
   super::parent_trie::const_recursive_iterator item (super::getTrie ());
   super::parent_trie::const_recursive_iterator end (0);
@@ -225,13 +225,13 @@
 }
 
 Ptr<const Entry>
-FibImpl::End ()
+FibImpl::End () const
 {
   return 0;
 }
 
 Ptr<const Entry>
-FibImpl::Next (Ptr<const Entry> from)
+FibImpl::Next (Ptr<const Entry> from) const
 {
   if (from == 0) return 0;
   
@@ -249,6 +249,49 @@
     return item->payload ();
 }
 
+Ptr<Entry>
+FibImpl::Begin ()
+{
+  super::parent_trie::recursive_iterator item (super::getTrie ());
+  super::parent_trie::recursive_iterator end (0);
+  for (; item != end; item++)
+    {
+      if (item->payload () == 0) continue;
+      break;
+    }
+
+  if (item == end)
+    return End ();
+  else
+    return item->payload ();
+}
+
+Ptr<Entry>
+FibImpl::End ()
+{
+  return 0;
+}
+
+Ptr<Entry>
+FibImpl::Next (Ptr<Entry> from)
+{
+  if (from == 0) return 0;
+  
+  super::parent_trie::recursive_iterator item (*StaticCast<EntryImpl> (from)->to_iterator ());
+  super::parent_trie::recursive_iterator end (0);
+  for (item++; item != end; item++)
+    {
+      if (item->payload () == 0) continue;
+      break;
+    }
+
+  if (item == end)
+    return End ();
+  else
+    return item->payload ();
+}
+
+
 } // namespace fib
 } // namespace ndn
 } // namespace ns3
diff --git a/model/fib/ndn-fib-impl.h b/model/fib/ndn-fib-impl.h
index 4c78997..1efead9 100644
--- a/model/fib/ndn-fib-impl.h
+++ b/model/fib/ndn-fib-impl.h
@@ -110,13 +110,22 @@
   GetSize () const;
 
   virtual Ptr<const Entry>
+  Begin () const;
+
+  virtual Ptr<Entry>
   Begin ();
 
   virtual Ptr<const Entry>
+  End () const;
+
+  virtual Ptr<Entry>
   End ();
 
   virtual Ptr<const Entry>
-  Next (Ptr<const Entry> item);
+  Next (Ptr<const Entry> item) const;
+  
+  virtual Ptr<Entry>
+  Next (Ptr<Entry> item);
   
 protected:
   // inherited from Object class
diff --git a/model/fib/ndn-fib.h b/model/fib/ndn-fib.h
index b1b4be7..951f2cb 100644
--- a/model/fib/ndn-fib.h
+++ b/model/fib/ndn-fib.h
@@ -142,19 +142,37 @@
    * @brief Return first element of FIB (no order guaranteed)
    */
   virtual Ptr<const fib::Entry>
-  Begin () = 0;
+  Begin () const = 0;
+
+  /**
+   * @brief Return first element of FIB (no order guaranteed)
+   */
+  virtual Ptr<fib::Entry>
+  Begin () = 0;  
 
   /**
    * @brief Return item next after last (no order guaranteed)
    */
   virtual Ptr<const fib::Entry>
+  End () const = 0;
+
+  /**
+   * @brief Return item next after last (no order guaranteed)
+   */
+  virtual Ptr<fib::Entry>
   End () = 0;
 
   /**
    * @brief Advance the iterator
    */
   virtual Ptr<const fib::Entry>
-  Next (Ptr<const fib::Entry>) = 0;
+  Next (Ptr<const fib::Entry>) const = 0;
+
+  /**
+   * @brief Advance the iterator
+   */
+  virtual Ptr<fib::Entry>
+  Next (Ptr<fib::Entry>) = 0;
 
   ////////////////////////////////////////////////////////////////////////////
   ////////////////////////////////////////////////////////////////////////////