limits: one more update and small interface changes
diff --git a/utils/ndn-limits-rate.h b/utils/ndn-limits-rate.h
new file mode 100644
index 0000000..4050bb2
--- /dev/null
+++ b/utils/ndn-limits-rate.h
@@ -0,0 +1,118 @@
+/* -*- 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 _NDN_LIMITS_RATE_H_
+#define	_NDN_LIMITS_RATE_H_
+
+#include "ndn-limits.h"
+
+namespace ns3 {
+namespace ndn {
+
+/**
+ * \ingroup ndn
+ * \brief Structure to manage limits for outstanding interests
+ */
+class LimitsRate :
+    public Limits
+{
+public:
+  typedef Limits super;
+  
+  static TypeId
+  GetTypeId ();
+  
+  /**
+   * \brief Constructor
+   * \param prefix smart pointer to the prefix for the FIB entry
+   */
+  LimitsRate ()
+    : m_bucketMax (0)
+    , m_bucketLeak (0)
+    , m_bucket (0)
+  { }
+
+  virtual
+  ~LimitsRate () { }
+
+  virtual void
+  SetLimits (double rate, double delay)
+  {
+    super::SetLimits (rate, delay);
+
+    // maximum allowed burst
+    m_bucketMax = GetMaxRate () * GetMaxDelay ();
+
+    // amount of packets allowed every second (leak rate)
+    m_bucketLeak = GetMaxRate ();
+  }
+
+  /**
+   * @brief Check if Interest limit is reached (token bucket is not empty)
+   */
+  virtual bool
+  IsBelowLimit ();
+
+  /**
+   * @brief Get token from the bucket
+   */
+  virtual void
+  BorrowLimit ();
+
+  /**
+   * @brief Does nothing (token bucket leakage is time-dependent only)
+   */
+  virtual void
+  ReturnLimit ();
+
+  /**
+   * @brief Update current leak ratio and maximum burst
+   */
+  virtual void
+  UpdateCurrentLimit (double limit);
+
+  /**
+   */
+  virtual double
+  GetCurrentLimit () const
+  {
+    return m_bucketLeak;
+  }
+
+private:
+  /**
+   * @brief Leak bucket, assuming `interval' seconds between leakages
+   *
+   * @param interval Time interval for leakage. Used to calculate size of the leak
+   */
+  void
+  LeakBucket (double interval);
+
+private:
+  double m_bucketMax;   ///< \brief Maximum Interest allowance for this face (maximum tokens that can be issued at the same time)
+  double m_bucketLeak;  ///< \brief Normalized amount that should be leaked every second (token bucket leak rate)
+  double m_bucket;      ///< \brief Value representing current size of the Interest allowance for this face (current size of token bucket)
+};
+  
+
+} // namespace ndn
+} // namespace ns3
+
+#endif // _NDN_LIMITS_RATE_H_