Kea  1.5.0
rate_control.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef RATE_CONTROL_H
8 #define RATE_CONTROL_H
9 
10 #include <boost/date_time/posix_time/posix_time.hpp>
11 
12 namespace isc {
13 namespace perfdhcp {
14 
38 class RateControl {
39 public:
40 
42  RateControl();
43 
48  RateControl(const int rate, const int aggressivity);
49 
51  int getAggressivity() const {
52  return (aggressivity_);
53  }
54 
56  boost::posix_time::ptime getDue() const {
57  return (send_due_);
58  }
59 
91  uint64_t getOutboundMessageCount();
92 
94  int getRate() const {
95  return (rate_);
96  }
97 
104  bool isLateSent() const {
105  return (late_sent_);
106  }
107 
113  void setAggressivity(const int aggressivity);
114 
119  void setRate(const int rate);
120 
129  void setRelativeDue(const int offset);
130 
132  void updateSendTime();
133 
134 protected:
135 
139  static boost::posix_time::ptime currentTime();
140 
149  void updateSendDue();
150 
152  boost::posix_time::ptime send_due_;
153 
155  boost::posix_time::ptime last_sent_;
156 
159 
161  int rate_;
162 
166 
167 };
168 
169 }
170 }
171 
172 #endif
static boost::posix_time::ptime currentTime()
Convenience function returning current time.
Definition: rate_control.cc:82
RateControl()
Default constructor.
Definition: rate_control.cc:17
int getRate() const
Returns the rate.
Definition: rate_control.h:94
boost::posix_time::ptime last_sent_
Holds a timestamp when the last message was sent.
Definition: rate_control.h:155
boost::posix_time::ptime getDue() const
Returns current due time to send next message.
Definition: rate_control.h:56
void setRelativeDue(const int offset)
Sets the value of the due time.
void updateSendDue()
Calculates the send due.
Definition: rate_control.cc:87
A message sending rate control class for perfdhcp.
Definition: rate_control.h:38
int aggressivity_
Holds an aggressivity value.
Definition: rate_control.h:158
uint64_t getOutboundMessageCount()
Returns number of messages to be sent "now".
Definition: rate_control.cc:36
void updateSendTime()
Sets the timestamp of the last sent message to current time.
void setRate(const int rate)
Sets the new rate.
bool late_sent_
A flag which indicates that the calculated due time is in the past.
Definition: rate_control.h:165
int rate_
Holds a desired rate value.
Definition: rate_control.h:161
int getAggressivity() const
Returns the value of aggressivity.
Definition: rate_control.h:51
void setAggressivity(const int aggressivity)
Sets the value of aggressivity.
Defines the logger used by the top-level component of kea-dhcp-ddns.
boost::posix_time::ptime send_due_
Holds a timestamp when the next message should be sent.
Definition: rate_control.h:152
bool isLateSent() const
Returns the value of the late send flag.
Definition: rate_control.h:104