Kea
1.9.9-git
|
A message sending rate control class for perfdhcp. More...
#include <rate_control.h>
Public Member Functions | |
RateControl () | |
Default constructor. More... | |
RateControl (const unsigned int rate) | |
Constructor which sets desired rate. More... | |
uint64_t | getOutboundMessageCount (bool const waiting_to_exit=false) |
Returns number of messages to be sent "now". More... | |
unsigned int | getRate () const |
Returns the rate. More... | |
void | setRate (const int rate) |
Sets the new rate. More... | |
Protected Member Functions | |
boost::posix_time::ptime | currentTime () |
Convenience function returning current time. More... | |
Protected Attributes | |
unsigned int | rate_ |
Holds a desired rate value. More... | |
boost::posix_time::ptime | start_time_ |
Holds time of start of testing. More... | |
uint64_t | total_pkts_sent_count_ |
Holds number of packets send from the beginning. More... | |
A message sending rate control class for perfdhcp.
This class provides the means to control the rate at which messages of the specific type are sent by perfdhcp. Each message type, for which the desired rate can be specified, has a corresponding RateControl
object. So, the perfdhcp is using up to three objects of this type at the same time, to control the rate of the following messages being sent:
The purpose of the RateControl class is to track the due time for sending next message (or bunch of messages) to keep outbound rate of particular messages at the desired level. The due time is calculated using the desired rate value and the timestamp when the last message of the particular type has been sent. That puts the responsibility on the TestControl
class to invoke the RateControl::updateSendDue
, every time the message is sent.
The RateControl
object returns the number of messages to be sent at the time. The number returned is 0, if perfdhcp shouldn't send any messages yet, or 1 (sometimes more) if the send due time has been reached.
Definition at line 38 of file rate_control.h.
isc::perfdhcp::RateControl::RateControl | ( | ) |
Default constructor.
Definition at line 19 of file rate_control.cc.
isc::perfdhcp::RateControl::RateControl | ( | const unsigned int | rate | ) |
Constructor which sets desired rate.
rate | A desired rate. |
Definition at line 23 of file rate_control.cc.
|
protected |
Convenience function returning current time.
Definition at line 66 of file rate_control.cc.
Referenced by getOutboundMessageCount().
uint64_t isc::perfdhcp::RateControl::getOutboundMessageCount | ( | bool const | waiting_to_exit = false | ) |
Returns number of messages to be sent "now".
This function calculates how many messages of the given type should be sent immediately when the call to the function returns, to catch up with the desired message rate.
The value returned depends on the due time calculated with the RateControl::updateSendDue
function and the current time. If the due time has been hit, the non-zero number of messages is returned. If the due time hasn't been hit, the number returned is 0.
If the rate is non-zero, the number of messages to be sent is calculated as follows:
where duration is a time period between the due time to send next set of messages and current time. The duration is expressed in seconds with the fractional part having 6 or 9 digits (depending on the timer resolution). If the calculated value is equal to 0, it is rounded to 1, so as at least one message is sent.
Definition at line 28 of file rate_control.cc.
References currentTime(), getRate(), start_time_, and total_pkts_sent_count_.
|
inline |
Returns the rate.
Definition at line 75 of file rate_control.h.
References rate_.
Referenced by getOutboundMessageCount().
void isc::perfdhcp::RateControl::setRate | ( | const int | rate | ) |
Sets the new rate.
rate | A new value of rate. This value must not be negative. |
isc::BadValue | if new rate is negative. |
Definition at line 71 of file rate_control.cc.
References isc_throw, and rate_.
Referenced by isc::perfdhcp::BasicScen::BasicScen().
|
protected |
Holds a desired rate value.
Definition at line 93 of file rate_control.h.
|
protected |
Holds time of start of testing.
It is used to calculate current request rate. Then this is used to estimate number of packets to send in current cycle.
Definition at line 105 of file rate_control.h.
Referenced by getOutboundMessageCount().
|
protected |
Holds number of packets send from the beginning.
It is used to calculate current request rate. Then this is used to estimate number of packets to send in current cycle.
Definition at line 99 of file rate_control.h.
Referenced by getOutboundMessageCount().