NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ndn-limits-rate.h
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2011 University of California, Los Angeles
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19  */
20 
21 #ifndef _NDN_LIMITS_RATE_H_
22 #define _NDN_LIMITS_RATE_H_
23 
24 #include "ndn-limits.h"
25 #include <ns3/nstime.h>
26 
27 namespace ns3 {
28 namespace ndn {
29 
34 class LimitsRate :
35  public Limits
36 {
37 public:
38  typedef Limits super;
39 
40  static TypeId
41  GetTypeId ();
42 
48  : m_isLeakScheduled (false)
49  , m_bucketMax (0)
50  , m_bucketLeak (1)
51  , m_bucket (0)
52  { }
53 
54  virtual
55  ~LimitsRate () { }
56 
57  virtual void
58  SetLimits (double rate, double delay);
59 
60  virtual
61  double
62  GetMaxLimit () const
63  {
64  return GetMaxRate ();
65  }
66 
70  virtual bool
71  IsBelowLimit ();
72 
76  virtual void
77  BorrowLimit ();
78 
82  virtual void
83  ReturnLimit ();
84 
88  virtual void
89  UpdateCurrentLimit (double limit);
90 
94  virtual double
95  GetCurrentLimit () const
96  {
97  return m_bucketLeak;
98  }
99 
100  virtual double
102  {
103  return m_bucketLeak;
104  }
105 
106 protected:
107  // from Node
108  void
109  NotifyNewAggregate ();
110 
111 private:
117  void
118  LeakBucket (double interval);
119 
120 private:
121  bool m_isLeakScheduled;
122 
123  double m_bucketMax;
124  double m_bucketLeak;
125  double m_bucket;
126 
127  Time m_leakRandomizationInteral;
128 };
129 
130 
131 } // namespace ndn
132 } // namespace ns3
133 
134 #endif // _NDN_LIMITS_RATE_H_
Abstract class to manage Interest limits.
Definition: ndn-limits.h:35
virtual bool IsBelowLimit()
Check if Interest limit is reached (token bucket is not empty)
virtual double GetCurrentLimitRate() const
Get value of the current limit in terms of maximum rate that needs to be enforced.
virtual void BorrowLimit()
Get token from the bucket.
virtual void SetLimits(double rate, double delay)
Set limit for the number of outstanding interests.
virtual double GetMaxLimit() const
Get maximum limit (interpretation of the limit depends on realization)
LimitsRate()
Constructor.
Structure to manage limits for outstanding interests.
virtual double GetMaxRate() const
Get maximum rate that needs to be enforced.
Definition: ndn-limits.h:71
virtual void ReturnLimit()
Does nothing (token bucket leakage is time-dependent only)
virtual double GetCurrentLimit() const
Get normalized amount that should be leaked every second (token bucket leak rate) ...
virtual void UpdateCurrentLimit(double limit)
Update normalized amount that should be leaked every second (token bucket leak rate) and leak rate...