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.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_H_
22 #define _NDN_LIMITS_H_
23 
24 #include "ns3/ptr.h"
25 #include "ns3/object.h"
26 #include "ns3/traced-value.h"
27 
28 namespace ns3 {
29 namespace ndn {
30 
35 class Limits :
36  public Object
37 {
38 public:
39  typedef Callback<void> CallbackHandler;
40 
41  static TypeId
42  GetTypeId ();
43 
47  Limits ();
48 
52  virtual
53  ~Limits () {}
54 
60  virtual void
61  SetLimits (double rate, double delay)
62  {
63  m_maxRate = rate;
64  m_maxDelay = delay;
65  }
66 
70  virtual double
71  GetMaxRate () const
72  {
73  return m_maxRate;
74  }
75 
79  virtual double
80  GetMaxDelay () const
81  {
82  return m_maxDelay;
83  }
84 
88  virtual
89  double
90  GetMaxLimit () const = 0;
91 
95  virtual inline bool
96  IsEnabled () const
97  {
98  return m_maxRate > 0.0;
99  }
100 
110  virtual void
111  UpdateCurrentLimit (double limit) = 0;
112 
118  virtual double
119  GetCurrentLimit () const = 0;
120 
127  virtual double
128  GetCurrentLimitRate () const = 0;
129 
133 
137  virtual bool
138  IsBelowLimit () = 0;
139 
145  virtual void
146  BorrowLimit () = 0;
147 
151  virtual void
152  ReturnLimit () = 0;
153 
159  virtual void
160  SetLinkDelay (double delay)
161  {
162  m_linkDelay = delay;
163  }
164 
168  virtual double
169  GetLinkDelay () const
170  {
171  return m_linkDelay;
172  }
173 
177 
181  void
182  RegisterAvailableSlotCallback (CallbackHandler handler);
183 
184 protected:
185  void
186  FireAvailableSlotCallback ();
187 
188 private:
189  double m_maxRate;
190  double m_maxDelay;
191 
192  CallbackHandler m_handler;
193 
194  double m_linkDelay;
195 };
196 
197 
198 } // namespace ndn
199 } // namespace ns3
200 
201 #endif // _NDN_LIMITS_H_
Abstract class to manage Interest limits.
Definition: ndn-limits.h:35
virtual double GetLinkDelay() const
Get link delay (in seconds)
Definition: ndn-limits.h:169
virtual void SetLinkDelay(double delay)
Set link delay (in seconds)
Definition: ndn-limits.h:160
virtual bool IsEnabled() const
Check whether limits are enabled or not.
Definition: ndn-limits.h:96
virtual double GetCurrentLimit() const =0
Get value of the current limit.
virtual double GetMaxLimit() const =0
Get maximum limit (interpretation of the limit depends on realization)
virtual bool IsBelowLimit()=0
Realization-specific method called to check availability of the limit.
virtual void UpdateCurrentLimit(double limit)=0
Update a current value of the limit.
Limits()
Default constructor.
Definition: ndn-limits.cc:43
virtual double GetMaxDelay() const
Get maximum delay for BDP product for window-based limits.
Definition: ndn-limits.h:80
virtual void ReturnLimit()=0
"Return" limit
virtual void SetLimits(double rate, double delay)
Set limit for the number of outstanding interests.
Definition: ndn-limits.h:61
virtual void BorrowLimit()=0
"Borrow" limit
virtual double GetMaxRate() const
Get maximum rate that needs to be enforced.
Definition: ndn-limits.h:71
virtual double GetCurrentLimitRate() const =0
Get value of the current limit in terms of maximum rate that needs to be enforced.
void RegisterAvailableSlotCallback(CallbackHandler handler)
Set callback which will be called when exhausted limit gets a new slot.
Definition: ndn-limits.cc:53
virtual ~Limits()
Virtual destructor.
Definition: ndn-limits.h:53