2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-01 06:25:34 +00:00

[github55] Merge branch 'perfdhcp-late-exit-delay' of https://github.com/andreipavelQ/kea into github55

# Conflicts:
#	src/bin/perfdhcp/perfdhcp.xml
This commit is contained in:
Tomek Mrugalski
2018-02-14 12:36:07 +00:00
5 changed files with 133 additions and 30 deletions

View File

@@ -124,6 +124,7 @@ CommandOptions::reset() {
mac_list_file_.clear(); mac_list_file_.clear();
mac_list_.clear(); mac_list_.clear();
num_request_.clear(); num_request_.clear();
late_exit_delay_ = 0;
period_ = 0; period_ = 0;
drop_time_set_ = 0; drop_time_set_ = 0;
drop_time_.assign(dt, dt + 2); drop_time_.assign(dt, dt + 2);
@@ -216,7 +217,7 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) {
// In this section we collect argument values from command line // In this section we collect argument values from command line
// they will be tuned and validated elsewhere // they will be tuned and validated elsewhere
while((opt = getopt(argc, argv, "hv46A:r:t:R:b:n:p:d:D:l:P:a:L:M:" while((opt = getopt(argc, argv, "hv46A:r:t:R:b:n:p:d:D:l:P:a:L:M:m:"
"s:iBc1T:X:O:E:S:I:x:w:e:f:F:")) != -1) { "s:iBc1T:X:O:E:S:I:x:w:e:f:F:")) != -1) {
stream << " -" << static_cast<char>(opt); stream << " -" << static_cast<char>(opt);
if (optarg) { if (optarg) {
@@ -307,7 +308,7 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) {
max_pdrop_.push_back(drop_percent); max_pdrop_.push_back(drop_percent);
} else { } else {
num_drops = positiveInteger("value of max drops number:" num_drops = positiveInteger("value of max drops number:"
" -d<value> must be a positive integer"); " -D<value> must be a positive integer");
max_drop_.push_back(num_drops); max_drop_.push_back(num_drops);
} }
break; break;
@@ -368,6 +369,13 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) {
loadMacs(); loadMacs();
break; break;
case 'm':
// 'm' for moratorium
late_exit_delay_ = nonNegativeInteger("value of late exit delay: "
"-m<value> must not be a "
"negative integer");
break;
case 'n': case 'n':
num_req = positiveInteger("value of num-request:" num_req = positiveInteger("value of num-request:"
" -n<value> must be a positive integer"); " -n<value> must be a positive integer");
@@ -981,6 +989,7 @@ CommandOptions::usage() const {
" [-n<num-request>] [-p<test-period>] [-d<drop-time>]\n" " [-n<num-request>] [-p<test-period>] [-d<drop-time>]\n"
" [-D<max-drop>] [-l<local-addr|interface>] [-P<preload>]\n" " [-D<max-drop>] [-l<local-addr|interface>] [-P<preload>]\n"
" [-a<aggressivity>] [-L<local-port>] [-s<seed>] [-i] [-B]\n" " [-a<aggressivity>] [-L<local-port>] [-s<seed>] [-i] [-B]\n"
" [-m<late-exit-delay>]\n"
" [-c] [-1] [-M<mac-list-file>] [-T<template-file>]\n" " [-c] [-1] [-M<mac-list-file>] [-T<template-file>]\n"
" [-X<xid-offset>] [-O<random-offset] [-E<time-offset>]\n" " [-X<xid-offset>] [-O<random-offset] [-E<time-offset>]\n"
" [-S<srvid-offset>] [-I<ip-offset>] [-x<diagnostic-selector>]\n" " [-S<srvid-offset>] [-I<ip-offset>] [-x<diagnostic-selector>]\n"
@@ -1098,12 +1107,12 @@ CommandOptions::usage() const {
"\n" "\n"
"The remaining options are used only in conjunction with -r:\n" "The remaining options are used only in conjunction with -r:\n"
"\n" "\n"
"-D<max-drop>: Abort the test if more than <max-drop> requests have\n" "-D<max-drop>: Abort the test immediately if max-drop requests have\n"
" been dropped. Use -D0 to abort if even a single request has been\n" " been dropped. max-drop must be a positive integer. If max-drop\n"
" dropped. If <max-drop> includes the suffix '%', it specifies a\n" " includes the suffix '%', it specifies a maximum percentage of\n"
" maximum percentage of requests that may be dropped before abort.\n" " requests that may be dropped before abort. In this case, testing\n"
" In this case, testing of the threshold begins after 10 requests\n" " of the threshold begins after 10 requests have been expected to\n"
" have been expected to be received.\n" " be received.\n"
"-n<num-request>: Initiate <num-request> transactions. No report is\n" "-n<num-request>: Initiate <num-request> transactions. No report is\n"
" generated until all transactions have been initiated/waited-for,\n" " generated until all transactions have been initiated/waited-for,\n"
" after which a report is generated and the program terminates.\n" " after which a report is generated and the program terminates.\n"
@@ -1133,6 +1142,5 @@ CommandOptions::version() const {
std::cout << "VERSION: " << VERSION << std::endl; std::cout << "VERSION: " << VERSION << std::endl;
} }
} // namespace perfdhcp
} // namespace perfdhcp } // namespace isc
} // namespace isc

View File

@@ -247,6 +247,11 @@ public:
/// \return local port number. /// \return local port number.
int getLocalPort() const { return local_port_; } int getLocalPort() const { return local_port_; }
/// @brief Returns the time in microseconds to delay the program by.
///
/// @return the time in microseconds to delay the program by.
int getLateExitDelay() const { return late_exit_delay_; }
/// \brief Checks if seed provided. /// \brief Checks if seed provided.
/// ///
/// \return true if seed was provided. /// \return true if seed was provided.
@@ -512,6 +517,8 @@ private:
/// Collection of base values specified with -b<value> /// Collection of base values specified with -b<value>
/// options. Supported "bases" are mac=<mac> and duid=<duid> /// options. Supported "bases" are mac=<mac> and duid=<duid>
std::vector<std::string> base_; std::vector<std::string> base_;
/// Number of microseconds by which you should delay the exit
int late_exit_delay_;
/// Number of 2 or 4-way exchanges to perform. /// Number of 2 or 4-way exchanges to perform.
std::vector<int> num_request_; std::vector<int> num_request_;
/// Test period in seconds /// Test period in seconds
@@ -594,7 +601,7 @@ private:
uint8_t v6_relay_encapsulation_level_; uint8_t v6_relay_encapsulation_level_;
}; };
} // namespace perfdhcp } // namespace perfdhcp
} // namespace isc } // namespace isc
#endif // COMMAND_OPTIONS_H #endif // COMMAND_OPTIONS_H

View File

@@ -711,14 +711,18 @@
<term><option>-D <replaceable class="parameter">max-drop</replaceable></option></term> <term><option>-D <replaceable class="parameter">max-drop</replaceable></option></term>
<listitem> <listitem>
<para> <para>
Abort the test if more than <replaceable class="parameter">max-drop</replaceable> Abort the test immediately if <replaceable
requests have been dropped. Use <option>-D class="parameter">max-drop</replaceable> requests
have been dropped. Use <option>-D
0</option> to abort if even a single 0</option> to abort if even a single
request has been dropped. If <replaceable class="parameter">max-drop</replaceable> includes request has been dropped. <replaceable
the suffix '%', it specifies a maximum percentage class="parameter">max-drop</replaceable> must be a
of requests that may be dropped before abort. positive integer. If <replaceable
In this case, testing of the threshold begins after class="parameter">max-drop</replaceable> includes
10 requests have been expected to be received. the suffix '%', it specifies a maximum percentage of
requests that may be dropped before abort. In this
case, testing of the threshold begins after 10
requests have been expected to be received.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@@ -42,6 +42,68 @@ namespace perfdhcp {
bool TestControl::interrupted_ = false; bool TestControl::interrupted_ = false;
ptime late_exit_target_time_ = ptime(not_a_date_time);
bool
TestControl::hasLateExitCommenced() const {
return !late_exit_target_time_.is_not_a_date_time();
}
bool
TestControl::lateExit() const {
if (haveAllPacketsBeenReceived()) {
return true;
}
const ptime now = microsec_clock::universal_time();
if (late_exit_target_time_.is_not_a_date_time()) {
CommandOptions& options = CommandOptions::instance();
late_exit_target_time_ =
now + time_duration(microseconds(options.getLateExitDelay()));
}
if (late_exit_target_time_ <= now) {
return true;
}
return false;
}
bool
TestControl::haveAllPacketsBeenReceived() const {
const CommandOptions& options = CommandOptions::instance();
const uint8_t& ipversion = options.getIpVersion();
const std::vector<int>& num_request = options.getNumRequests();
const size_t& num_request_size = num_request.size();
if (num_request_size == 0) {
return false;
}
const uint32_t& request_count_DO_SA = num_request[0];
uint32_t request_count_RA_RR;
if (num_request_size >= 2) {
request_count_RA_RR = num_request[1];
} else {
request_count_RA_RR = num_request[0];
}
if (ipversion == 4) {
if (stats_mgr4_->getRcvdPacketsNum(StatsMgr4::XCHG_DO) !=
request_count_DO_SA ||
stats_mgr4_->getRcvdPacketsNum(StatsMgr4::XCHG_RA) !=
request_count_RA_RR) {
return false;
}
} else if (ipversion == 6) {
if (stats_mgr6_->getRcvdPacketsNum(StatsMgr6::XCHG_SA) !=
request_count_DO_SA ||
stats_mgr6_->getRcvdPacketsNum(StatsMgr6::XCHG_RR) !=
request_count_RA_RR) {
return false;
}
}
return true;
}
TestControl::TestControlSocket::TestControlSocket(const int socket) : TestControl::TestControlSocket::TestControlSocket(const int socket) :
SocketInfo(asiolink::IOAddress("127.0.0.1"), 0, socket), SocketInfo(asiolink::IOAddress("127.0.0.1"), 0, socket),
ifindex_(0), valid_(true) { ifindex_(0), valid_(true) {
@@ -196,7 +258,9 @@ TestControl::checkExitConditions() const {
if (testDiags('e')) { if (testDiags('e')) {
std::cout << "reached test-period." << std::endl; std::cout << "reached test-period." << std::endl;
} }
return (true); if (lateExit()) {
return true;
}
} }
bool max_requests = false; bool max_requests = false;
@@ -232,7 +296,9 @@ TestControl::checkExitConditions() const {
if (testDiags('e')) { if (testDiags('e')) {
std::cout << "Reached max requests limit." << std::endl; std::cout << "Reached max requests limit." << std::endl;
} }
return (true); if (lateExit()) {
return true;
}
} }
// Check if we reached maximum number of drops of OFFER/ADVERTISE packets. // Check if we reached maximum number of drops of OFFER/ADVERTISE packets.
@@ -268,7 +334,9 @@ TestControl::checkExitConditions() const {
if (testDiags('e')) { if (testDiags('e')) {
std::cout << "Reached maximum drops number." << std::endl; std::cout << "Reached maximum drops number." << std::endl;
} }
return (true); if (lateExit()) {
return true;
}
} }
// Check if we reached maximum drops percentage of OFFER/ADVERTISE packets. // Check if we reached maximum drops percentage of OFFER/ADVERTISE packets.
@@ -313,7 +381,9 @@ TestControl::checkExitConditions() const {
if (testDiags('e')) { if (testDiags('e')) {
std::cout << "Reached maximum percentage of drops." << std::endl; std::cout << "Reached maximum percentage of drops." << std::endl;
} }
return (true); if (lateExit()) {
return true;
}
} }
return (false); return (false);
} }
@@ -1485,8 +1555,10 @@ TestControl::run() {
break; break;
} }
// Initiate new DHCP packet exchanges. if (!hasLateExitCommenced()) {
sendPackets(socket, packets_due); // Initiate new DHCP packet exchanges.
sendPackets(socket, packets_due);
}
// If -f<renew-rate> option was specified we have to check how many // If -f<renew-rate> option was specified we have to check how many
// Renew packets should be sent to catch up with a desired rate. // Renew packets should be sent to catch up with a desired rate.
@@ -2265,5 +2337,5 @@ TestControl::testDiags(const char diag) const {
return (false); return (false);
} }
} // namespace perfdhcp } // namespace perfdhcp
} // namespace isc } // namespace isc

View File

@@ -136,6 +136,18 @@ public:
/// Packet template buffers list. /// Packet template buffers list.
typedef std::vector<TemplateBuffer> TemplateBufferCollection; typedef std::vector<TemplateBuffer> TemplateBufferCollection;
/// @brief Delay the exit by a fixed given time to catch up to all exchanges
/// that were already started.
bool lateExit() const;
/// @brief Check if the program is in that period where the program was
/// bound to exit, but was delayed by lateExit().
bool hasLateExitCommenced() const;
/// @brief Delay the exit by a fixed given time to catch up to all exchanges
/// that were already started.
bool haveAllPacketsBeenReceived() const;
/// \brief Socket wrapper structure. /// \brief Socket wrapper structure.
/// ///
/// This is the wrapper that holds descriptor of the socket /// This is the wrapper that holds descriptor of the socket
@@ -1136,7 +1148,7 @@ protected:
static bool interrupted_; ///< Is program interrupted. static bool interrupted_; ///< Is program interrupted.
}; };
} // namespace perfdhcp } // namespace perfdhcp
} // namespace isc } // namespace isc
#endif // TEST_CONTROL_H #endif // TEST_CONTROL_H