 |
Kea
1.5.0
|
Go to the documentation of this file.
15 using namespace boost::posix_time;
19 aggressivity_(1), rate_(0), late_sent_(false) {
24 aggressivity_(aggressivity), rate_(rate), late_sent_(false) {
27 << aggressivity <<
", expected value is greater than 0");
31 <<
", expected non-negative value");
46 uint64_t due_exchanges = 0;
51 time_duration duration = period.length();
55 static_cast<double>(duration.fractional_seconds()) /
56 static_cast<double>(time_duration::ticks_per_second());
57 due_factor +=
static_cast<double>(duration.total_seconds());
60 due_exchanges =
static_cast<uint64_t
>(due_factor *
getRate());
62 if (due_exchanges == 0) {
76 return (due_exchanges);
81 boost::posix_time::ptime
83 return (microsec_clock::universal_time());
111 duration = time_duration::ticks_per_second() /
getRate();
124 if (aggressivity < 1) {
126 << aggressivity <<
", expected value is greater than 0");
135 <<
", expected non-negative value");
int getAggressivity() const
Returns the value of aggressivity.
A generic exception that is thrown when an unexpected error condition occurs.
int rate_
Holds a desired rate value.
void setAggressivity(const int aggressivity)
Sets the value of aggressivity.
bool late_sent_
A flag which indicates that the calculated due time is in the past.
static boost::posix_time::ptime currentTime()
Convenience function returning current time.
Defines the logger used by the top-level component of kea-dhcp-ddns.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
int aggressivity_
Holds an aggressivity value.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
void setRelativeDue(const int offset)
Sets the value of the due time.
boost::posix_time::ptime send_due_
Holds a timestamp when the next message should be sent.
int getRate() const
Returns the rate.
void setRate(const int rate)
Sets the new rate.
void updateSendTime()
Sets the timestamp of the last sent message to current time.
RateControl()
Default constructor.
string currentTime()
Create Time.
uint64_t getOutboundMessageCount()
Returns number of messages to be sent "now".
boost::posix_time::ptime last_sent_
Holds a timestamp when the last message was sent.
void updateSendDue()
Calculates the send due.