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