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
isc::perfdhcp::RateControl::getAggressivity
int getAggressivity() const
Returns the value of aggressivity.
Definition: rate_control.h:51
isc::perfdhcp::RateControl
A message sending rate control class for perfdhcp.
Definition: rate_control.h:38
isc::perfdhcp::RateControl::rate_
int rate_
Holds a desired rate value.
Definition: rate_control.h:161
isc::perfdhcp::RateControl::setAggressivity
void setAggressivity(const int aggressivity)
Sets the value of aggressivity.
Definition: rate_control.cc:123
isc::perfdhcp::RateControl::late_sent_
bool late_sent_
A flag which indicates that the calculated due time is in the past.
Definition: rate_control.h:165
isc::perfdhcp::RateControl::currentTime
static boost::posix_time::ptime currentTime()
Convenience function returning current time.
Definition: rate_control.cc:82
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
perfdhcp
isc::perfdhcp::RateControl::aggressivity_
int aggressivity_
Holds an aggressivity value.
Definition: rate_control.h:158
isc::perfdhcp::RateControl::isLateSent
bool isLateSent() const
Returns the value of the late send flag.
Definition: rate_control.h:104
isc::perfdhcp::RateControl::setRelativeDue
void setRelativeDue(const int offset)
Sets the value of the due time.
Definition: rate_control.cc:141
isc::perfdhcp::RateControl::send_due_
boost::posix_time::ptime send_due_
Holds a timestamp when the next message should be sent.
Definition: rate_control.h:152
isc::perfdhcp::RateControl::getRate
int getRate() const
Returns the rate.
Definition: rate_control.h:94
isc::perfdhcp::RateControl::setRate
void setRate(const int rate)
Sets the new rate.
Definition: rate_control.cc:132
isc::perfdhcp::RateControl::getDue
boost::posix_time::ptime getDue() const
Returns current due time to send next message.
Definition: rate_control.h:56
isc::perfdhcp::RateControl::updateSendTime
void updateSendTime()
Sets the timestamp of the last sent message to current time.
Definition: rate_control.cc:148
isc::perfdhcp::RateControl::RateControl
RateControl()
Default constructor.
Definition: rate_control.cc:17
isc::perfdhcp::RateControl::getOutboundMessageCount
uint64_t getOutboundMessageCount()
Returns number of messages to be sent "now".
Definition: rate_control.cc:36
isc::perfdhcp::RateControl::last_sent_
boost::posix_time::ptime last_sent_
Holds a timestamp when the last message was sent.
Definition: rate_control.h:155
isc::perfdhcp::RateControl::updateSendDue
void updateSendDue()
Calculates the send due.
Definition: rate_control.cc:87