12 #include <boost/date_time/posix_time/posix_time.hpp>
25 BasicScen::checkExitConditions() {
26 if (tc_.interrupted()) {
30 const StatsMgr& stats_mgr(tc_.getStatsMgr());
33 if (options_.getPeriod() != 0) {
34 time_period period(stats_mgr.getTestPeriod());
35 if (period.length().total_seconds() >= options_.getPeriod()) {
36 if (options_.testDiags(
'e')) {
37 std::cout <<
"reached test-period." << std::endl;
39 if (!tc_.waitToExit()) {
45 bool max_requests =
false;
47 if (options_.getNumRequests().size() > 0) {
48 if (stats_mgr.getSentPacketsNum(stage1_xchg_) >=
49 options_.getNumRequests()[0]) {
54 if (options_.getNumRequests().size() > 1) {
55 if (stats_mgr.getSentPacketsNum(stage2_xchg_) >=
56 options_.getNumRequests()[1]) {
61 if (options_.testDiags(
'e')) {
62 std::cout <<
"Reached max requests limit." << std::endl;
64 if (!tc_.waitToExit()) {
70 bool max_drops =
false;
71 if (options_.getMaxDrop().size() > 0) {
72 if (stats_mgr.getDroppedPacketsNum(stage1_xchg_) >=
73 options_.getMaxDrop()[0]) {
78 if (options_.getMaxDrop().size() > 1) {
79 if (stats_mgr.getDroppedPacketsNum(stage2_xchg_) >=
80 options_.getMaxDrop()[1]) {
85 if (options_.testDiags(
'e')) {
86 std::cout <<
"Reached maximum drops number." << std::endl;
88 if (!tc_.waitToExit()) {
94 bool max_pdrops =
false;
95 if (options_.getMaxDropPercentage().size() > 0) {
96 if ((stats_mgr.getSentPacketsNum(stage1_xchg_) > 10) &&
97 ((100. * stats_mgr.getDroppedPacketsNum(stage1_xchg_) /
98 stats_mgr.getSentPacketsNum(stage1_xchg_)) >=
99 options_.getMaxDropPercentage()[0]))
105 if (options_.getMaxDropPercentage().size() > 1) {
106 if ((stats_mgr.getSentPacketsNum(stage2_xchg_) > 10) &&
107 ((100. * stats_mgr.getDroppedPacketsNum(stage2_xchg_) /
108 stats_mgr.getSentPacketsNum(stage2_xchg_)) >=
109 options_.getMaxDropPercentage()[1]))
115 if (options_.testDiags(
'e')) {
116 std::cout <<
"Reached maximum percentage of drops." << std::endl;
118 if (!tc_.waitToExit()) {
127 StatsMgr& stats_mgr(tc_.getStatsMgr());
130 if (options_.getPreload() > 0) {
131 tc_.sendPackets(options_.getPreload(),
true);
135 if (!options_.getWrapped().empty()) {
144 uint64_t packets_due =
145 basic_rate_control_.getOutboundMessageCount(!tc_.exit_time_.is_not_a_date_time());
146 if ((packets_due == 0) && options_.testDiags(
'i')) {
152 auto pkt_count = tc_.consumeReceivedPackets();
157 if (options_.getRate() < 10000 && packets_due == 0 && pkt_count == 0) {
166 if (checkExitConditions()) {
171 tc_.sendPackets(packets_due);
175 if (options_.getRenewRate() != 0) {
176 uint64_t renew_packets_due =
177 renew_rate_control_.getOutboundMessageCount(!tc_.exit_time_.is_not_a_date_time());
180 if (options_.getIpVersion() == 4) {
181 tc_.sendMultipleRequests(renew_packets_due);
183 tc_.sendMultipleMessages6(
DHCPV6_RENEW, renew_packets_due);
189 if ((options_.getIpVersion() == 6) && (options_.getReleaseRate() != 0)) {
190 uint64_t release_packets_due =
191 release_rate_control_.getOutboundMessageCount(!tc_.exit_time_.is_not_a_date_time());
198 if (options_.getReportDelay() > 0) {
199 tc_.printIntermediateStats();
208 tc_.cleanCachedPackets();
215 if (!options_.getWrapped().empty()) {
217 tc_.runWrapped(
true);
221 if (options_.testDiags(
't')) {
222 stats_mgr.printTimestamps();
226 if (options_.testDiags(
's') && tc_.serverIdReceived()) {
227 std::cout <<
"Server id: " << tc_.getServerId() << std::endl;
231 if (options_.testDiags(
'e')) {
232 std::cout <<
"Interrupted" << std::endl;
236 if (options_.testDiags(
'T')) {
237 tc_.printTemplates();
241 if (options_.testDiags(
'l')) {
242 stats_mgr.printLeases();
247 ret_code = stats_mgr.droppedPackets() ? 3 : 0;
const CustomCounter & incrementCounter(const std::string &counter_key, const uint64_t value=1)
Increment specified counter.
Defines the logger used by the top-level component of kea-dhcp-ddns.