Kea 3.1.1
bin/perfdhcp/stats_mgr.h
Go to the documentation of this file.
1// Copyright (C) 2012-2025 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 STATS_MGR_H
8#define STATS_MGR_H
9
10#include <dhcp/pkt.h>
13
14#include <boost/noncopyable.hpp>
15#include <boost/shared_ptr.hpp>
16#include <boost/multi_index_container.hpp>
17#include <boost/multi_index/ordered_index.hpp>
18#include <boost/multi_index/sequenced_index.hpp>
19#include <boost/multi_index/global_fun.hpp>
20#include <boost/multi_index/mem_fun.hpp>
21#include <boost/date_time/posix_time/posix_time.hpp>
22
23#include <iostream>
24#include <map>
25#include <queue>
26
27
28namespace isc {
29namespace perfdhcp {
30
42
48int dhcpVersion(ExchangeType const exchange_type);
49
58std::ostream& operator<<(std::ostream& os, ExchangeType xchg_type);
59
67public:
74 CustomCounter(const std::string& name) :
75 counter_(0),
76 name_(name) {
77 }
78
81 ++counter_;
82 return (*this);
83 }
84
87 CustomCounter& this_counter(*this);
88 operator++();
89 return (this_counter);
90 }
91
92 const CustomCounter& operator+=(int val) {
93 counter_ += val;
94 return (*this);
95 }
96
102 uint64_t getValue() const {
103 return (counter_);
104 }
105
111 const std::string& getName() const {
112 return (name_);
113 }
114
115private:
121 CustomCounter() : counter_(0) {
122 }
123
124 uint64_t counter_;
125 std::string name_;
126};
127
128typedef typename boost::shared_ptr<CustomCounter> CustomCounterPtr;
129
131typedef typename std::map<std::string, CustomCounterPtr> CustomCountersMap;
132
134typedef typename CustomCountersMap::const_iterator CustomCountersMapIterator;
135
136
145public:
146
157 static uint32_t hashTransid(const dhcp::PktPtr& packet) {
158 if (!packet) {
159 isc_throw(BadValue, "Packet is null");
160 }
161 return(packet->getTransid() & 1023);
162 }
163
233 typedef boost::multi_index_container<
234 // Container holds PktPtr objects.
236 // List container indexes.
237 boost::multi_index::indexed_by<
238 // Sequenced index provides the way to use this container
239 // in the same way as std::list.
240 boost::multi_index::sequenced<>,
241 // The other index keeps products of transaction id.
242 // Elements with the same hash value are grouped together
243 // into buckets and transactions are ordered from the
244 // oldest to latest within a bucket.
245 boost::multi_index::ordered_non_unique<
246 // Specify hash function to get the product of
247 // transaction id. This product is obtained by calling
248 // hashTransid() function.
249 boost::multi_index::global_fun<
250 // Hashing function takes PktPtr as argument.
251 const dhcp::PktPtr&,
252 // ... and returns uint32 value.
253 uint32_t,
254 // ... and here is a reference to it.
256 >
257 >
258 >
260
262 typedef typename PktList::iterator PktListIterator;
264 typedef typename PktList::template nth_index<1>::type
267 typedef typename PktListTransidHashIndex::const_iterator
270 typedef typename std::queue<PktListTransidHashIterator>
272
281 ExchangeStats(const ExchangeType xchg_type,
282 const double drop_time,
283 const bool archive_enabled,
284 const boost::posix_time::ptime boot_time);
285
292 void appendSent(const dhcp::PktPtr& packet) {
293 if (!packet) {
294 isc_throw(BadValue, "Packet is null");
295 }
296 static_cast<void>(sent_packets_.template get<0>().push_back(packet));
297 ++sent_packets_num_;
298 }
299
306 void appendRcvd(const dhcp::PktPtr& packet) {
307 if (!packet) {
308 isc_throw(BadValue, "Packet is null");
309 }
310 static_cast<void>(rcvd_packets_.push_back(packet));
311 }
312
322 void updateDelays(const dhcp::PktPtr& sent_packet,
323 const dhcp::PktPtr& rcvd_packet);
324
340 dhcp::PktPtr matchPackets(const dhcp::PktPtr& rcvd_packet);
341
347 double getMinDelay() const { return(min_delay_); }
348
354 double getMaxDelay() const { return(max_delay_); }
355
365 double getAvgDelay() const {
366 if (rcvd_packets_num_ == 0) {
367 isc_throw(InvalidOperation, "no packets received");
368 }
369 return(sum_delay_ / rcvd_packets_num_);
370 }
371
382 double getStdDevDelay() const {
383 if (rcvd_packets_num_ == 0) {
384 isc_throw(InvalidOperation, "no packets received");
385 }
386 return(sqrt(sum_delay_squared_ / rcvd_packets_num_ -
387 getAvgDelay() * getAvgDelay()));
388 }
389
397 uint64_t getOrphans() const { return(orphans_); }
398
408 uint64_t getCollectedNum() const { return(collected_); }
409
420 if (unordered_lookups_ == 0) {
421 isc_throw(InvalidOperation, "no unordered lookups");
422 }
423 return(static_cast<double>(unordered_lookup_size_sum_) /
424 static_cast<double>(unordered_lookups_));
425 }
426
435 uint64_t getUnorderedLookups() const { return(unordered_lookups_); }
436
446 uint64_t getOrderedLookups() const { return(ordered_lookups_); }
447
453 uint64_t getSentPacketsNum() const { return(sent_packets_num_); }
454
460 uint64_t getRcvdPacketsNum() const { return(rcvd_packets_num_); }
461
467 uint64_t getDroppedPacketsNum() const {
468 uint64_t drops = 0;
471 }
472 return(drops);
473 }
474
480 uint64_t getRejLeasesNum() const { return(rejected_leases_num_); }
481
487 uint64_t getNonUniqueAddrNum() const { return(non_unique_addr_num_); }
488
492 void updateRejLeases() { ++rejected_leases_num_; }
493
497 void updateNonUniqueAddr() { ++non_unique_addr_num_; }
498
512 void printMainStats() const {
513 using namespace std;
514 auto sent = getSentPacketsNum();
515 auto drops = getDroppedPacketsNum();
516 double drops_ratio = 100.0 * static_cast<double>(drops) / static_cast<double>(sent);
517
518 cout << "sent packets: " << sent << endl
519 << "received packets: " << getRcvdPacketsNum() << endl
520 << "drops: " << drops << endl
521 << "drops ratio: " << drops_ratio << " %" << endl
522 << "orphans: " << getOrphans() << endl
523 << "rejected leases: " << getRejLeasesNum() << endl
524 << "non unique addresses: " << getNonUniqueAddrNum() << endl;
525 }
526
534 void printRTTStats() const {
535 using namespace std;
536 // Save cout fmtflags.
537 auto flags(cout.flags());
538 try {
539 cout << fixed << setprecision(3)
540 << "min delay: " << getMinDelay() * 1e3 << " ms" << endl
541 << "avg delay: " << getAvgDelay() * 1e3 << " ms" << endl
542 << "max delay: " << getMaxDelay() * 1e3 << " ms" << endl
543 << "std deviation: " << getStdDevDelay() * 1e3 << " ms"
544 << endl
545 << "collected packets: " << getCollectedNum() << endl;
546 } catch (const Exception&) {
547 // repeated output for easier automated parsing
548 cout << "min delay: n/a" << endl
549 << "avg delay: n/a" << endl
550 << "max delay: n/a" << endl
551 << "std deviation: n/a" << endl
552 << "collected packets: 0" << endl;
553 }
554 // Restore cout fmtflags.
555 cout.flags(flags);
556 }
557
568 void printTimestamps();
569
570 std::tuple<PktListIterator, PktListIterator> getSentPackets() {
571 return(std::make_tuple(sent_packets_.begin(), sent_packets_.end()));
572 }
573
582 std::string receivedLeases() const;
583
585 void printLeases() const;
586
587 static int malformed_pkts_;
588
589// Private stuff of ExchangeStats class
590private:
591
597
605 PktListIterator eraseSent(const PktListIterator it) {
606 if (archive_enabled_) {
607 // We don't want to keep list of all sent packets
608 // because it will affect packet lookup performance.
609 // If packet is matched with received packet we
610 // move it to list of archived packets. List of
611 // archived packets may be used for diagnostics
612 // when test is completed.
613 static_cast<void>(archived_packets_.push_back(*it));
614 }
615 // get<0>() template returns sequential index to
616 // container.
617 return(sent_packets_.template get<0>().erase(it));
618 }
619
620 ExchangeType xchg_type_;
621 PktList sent_packets_;
622
626 PktListIterator next_sent_;
627
628 PktList rcvd_packets_;
629
633 PktList archived_packets_;
634
646 bool archive_enabled_;
647
650 double drop_time_;
651
652 double min_delay_;
654 double max_delay_;
656 double sum_delay_;
658 double sum_delay_squared_;
660
661 uint64_t orphans_;
662
663 uint64_t collected_;
664
670 uint64_t unordered_lookup_size_sum_;
671
672 uint64_t unordered_lookups_;
674 uint64_t ordered_lookups_;
676
677 uint64_t sent_packets_num_;
678 uint64_t rcvd_packets_num_;
679
680 uint64_t non_unique_addr_num_;
682 uint64_t rejected_leases_num_;
684 boost::posix_time::ptime boot_time_;
685};
686
688typedef boost::shared_ptr<ExchangeStats> ExchangeStatsPtr;
689
691typedef typename std::map<ExchangeType, ExchangeStatsPtr> ExchangesMap;
692
694typedef typename ExchangesMap::const_iterator ExchangesMapIterator;
695
696
712class StatsMgr : public boost::noncopyable {
713public:
724 StatsMgr(CommandOptions& options);
725
736 void addExchangeStats(const ExchangeType xchg_type,
737 const double drop_time = -1) {
738 if (exchanges_.find(xchg_type) != exchanges_.end()) {
739 isc_throw(BadValue, "Exchange of specified type already added.");
740 }
741 exchanges_[xchg_type] =
742 ExchangeStatsPtr(new ExchangeStats(xchg_type,
743 drop_time,
744 archive_enabled_,
745 boot_time_));
746 }
747
758 bool hasExchangeStats(const ExchangeType xchg_type) const {
759 return (exchanges_.find(xchg_type) != exchanges_.end());
760 }
761
769 void addCustomCounter(const std::string& short_name,
770 const std::string& long_name) {
771 if (custom_counters_.find(short_name) != custom_counters_.end()) {
773 "Custom counter " << short_name << " already added.");
774 }
775 custom_counters_[short_name] =
776 CustomCounterPtr(new CustomCounter(long_name));
777 }
778
781 // \return true, if packet drops occurred.
782 bool droppedPackets() const {
783 for (auto const& it : exchanges_) {
784 if (it.second->getDroppedPacketsNum() > 0) {
785 return (true);
786 }
787 }
788 return (false);
789 }
790
798 CustomCounterPtr getCounter(const std::string& counter_key) {
799 CustomCountersMapIterator it = custom_counters_.find(counter_key);
800 if (it == custom_counters_.end()) {
802 "Custom counter " << counter_key << "does not exist");
803 }
804 return(it->second);
805 }
806
814 const CustomCounter& incrementCounter(const std::string& counter_key,
815 const uint64_t value = 1) {
816 CustomCounterPtr counter = getCounter(counter_key);
817 *counter += value;
818 return (*counter);
819 }
820
831 void passSentPacket(const ExchangeType xchg_type,
832 const dhcp::PktPtr& packet) {
833 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
834 xchg_stats->appendSent(packet);
835 }
836
852 const dhcp::PktPtr& packet) {
853 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
854 dhcp::PktPtr sent_packet = xchg_stats->matchPackets(packet);
855
856 if (sent_packet) {
857 xchg_stats->updateDelays(sent_packet, packet);
858 if (archive_enabled_) {
859 xchg_stats->appendRcvd(packet);
860 }
861 }
862 return(sent_packet);
863 }
864
873 double getMinDelay(const ExchangeType xchg_type) const {
874 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
875 return(xchg_stats->getMinDelay());
876 }
877
886 double getMaxDelay(const ExchangeType xchg_type) const {
887 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
888 return(xchg_stats->getMaxDelay());
889 }
890
897 double getAvgDelay(const ExchangeType xchg_type) const {
898 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
899 return(xchg_stats->getAvgDelay());
900 }
901
908 double getStdDevDelay(const ExchangeType xchg_type) const {
909 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
910 return(xchg_stats->getStdDevDelay());
911 }
912
921 uint64_t getOrphans(const ExchangeType xchg_type) const {
922 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
923 return(xchg_stats->getOrphans());
924 }
925
935 double getAvgUnorderedLookupSetSize(const ExchangeType xchg_type) const {
936 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
937 return(xchg_stats->getAvgUnorderedLookupSetSize());
938 }
939
950 uint64_t getUnorderedLookups(const ExchangeType xchg_type) const {
951 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
952 return(xchg_stats->getUnorderedLookups());
953 }
954
966 uint64_t getOrderedLookups(const ExchangeType xchg_type) const {
967 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
968 return(xchg_stats->getOrderedLookups());
969 }
970
979 uint64_t getSentPacketsNum(const ExchangeType xchg_type) const {
980 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
981 return(xchg_stats->getSentPacketsNum());
982 }
983
992 uint64_t getRcvdPacketsNum(const ExchangeType xchg_type) const {
993 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
994 return(xchg_stats->getRcvdPacketsNum());
995 }
996
1005 uint64_t getDroppedPacketsNum(const ExchangeType xchg_type) const {
1006 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1007 return(xchg_stats->getDroppedPacketsNum());
1008 }
1009
1020 uint64_t getCollectedNum(const ExchangeType xchg_type) const {
1021 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1022 return(xchg_stats->getCollectedNum());
1023 }
1024
1033 uint64_t getRejLeasesNum(const ExchangeType xchg_type) const {
1034 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1035 return(xchg_stats->getRejLeasesNum());
1036 }
1037
1042 void updateRejLeases(const ExchangeType xchg_type) {
1043 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1044 xchg_stats->updateRejLeases();
1045 }
1046
1051 void updateNonUniqueAddrNum(const ExchangeType xchg_type) {
1052 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1053 xchg_stats->updateNonUniqueAddr();
1054 }
1055
1064 uint64_t getNonUniqueAddrNum(const ExchangeType xchg_type) const {
1065 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1066 return(xchg_stats->getNonUniqueAddrNum());
1067 }
1068
1076 boost::posix_time::time_period getTestPeriod() const {
1077 using namespace boost::posix_time;
1078 time_period test_period(boot_time_,
1079 microsec_clock::universal_time());
1080 return test_period;
1081 }
1082
1096 void printStats() const {
1097 if (exchanges_.empty()) {
1099 "no exchange type added for tracking");
1100 }
1101 for (auto const& it : exchanges_) {
1102 ExchangeStatsPtr xchg_stats = it.second;
1103 std::cout << "***Statistics for: " << it.first
1104 << "***" << std::endl;
1105 xchg_stats->printMainStats();
1106 std::cout << std::endl;
1107 xchg_stats->printRTTStats();
1108 std::cout << std::endl;
1109 }
1110 }
1111
1120 void
1121 printIntermediateStats(bool clean_report, std::string clean_sep) const {
1122 std::ostringstream stream_sent;
1123 std::ostringstream stream_rcvd;
1124 std::ostringstream stream_drops;
1125 std::ostringstream stream_reject;
1126 std::string sep("");
1127 bool first = true;
1128 for (auto const& it : exchanges_) {
1129 if (!first) {
1130 if (clean_report) {
1131 sep = clean_sep;
1132 } else {
1133 sep = "/";
1134 }
1135 } else {
1136 first = false;
1137 }
1138 stream_sent << sep << it.second->getSentPacketsNum();
1139 stream_rcvd << sep << it.second->getRcvdPacketsNum();
1140 stream_drops << sep << it.second->getDroppedPacketsNum();
1141 stream_reject << sep << it.second->getRejLeasesNum();
1142 }
1143
1144 if (clean_report) {
1145 std::cout << stream_sent.str()
1146 << clean_sep << stream_rcvd.str()
1147 << clean_sep << stream_drops.str()
1148 << clean_sep << stream_reject.str()
1149 << std::endl;
1150
1151 } else {
1152 std::cout << "sent: " << stream_sent.str()
1153 << "; received: " << stream_rcvd.str()
1154 << "; drops: " << stream_drops.str()
1155 << "; rejected: " << stream_reject.str()
1156 << std::endl;
1157 }
1158 }
1159
1171 void printTimestamps() const {
1172 if (exchanges_.empty()) {
1174 "no exchange type added for tracking");
1175 }
1176 for (auto const& it : exchanges_) {
1177 ExchangeStatsPtr xchg_stats = it.second;
1178 std::cout << "***Timestamps for packets: "
1179 << it.first
1180 << "***" << std::endl;
1181 xchg_stats->printTimestamps();
1182 std::cout << std::endl;
1183 }
1184 }
1185
1187 void printLeases() const;
1188
1195 void printCustomCounters() const {
1196 if (custom_counters_.empty()) {
1197 isc_throw(isc::InvalidOperation, "no custom counters specified");
1198 }
1199 for (auto const& it : custom_counters_) {
1200 CustomCounterPtr counter = it.second;
1201 std::cout << counter->getName() << ": " << counter->getValue()
1202 << std::endl;
1203 }
1204 }
1205
1206 std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator>
1207 getSentPackets(const ExchangeType xchg_type) const {
1208 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1209 std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator> sent_packets_its =
1210 xchg_stats->getSentPackets();
1211 return (sent_packets_its);
1212 }
1213
1214private:
1215
1223 ExchangeStatsPtr getExchangeStats(const ExchangeType xchg_type) const {
1224 ExchangesMapIterator it = exchanges_.find(xchg_type);
1225 if (it == exchanges_.end()) {
1226 isc_throw(BadValue, "Packets exchange not specified");
1227 }
1228 ExchangeStatsPtr xchg_stats = it->second;
1229 return(xchg_stats);
1230 }
1231
1232 ExchangesMap exchanges_;
1233 CustomCountersMap custom_counters_;
1234
1243 bool archive_enabled_;
1244
1245 boost::posix_time::ptime boot_time_;
1246};
1247
1249typedef boost::shared_ptr<StatsMgr> StatsMgrPtr;
1250
1251
1252} // namespace perfdhcp
1253} // namespace isc
1254
1255#endif // STATS_MGR_H
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
This is a base class for exceptions thrown from the DNS library module.
A generic exception that is thrown if a function is called in a prohibited way.
const CustomCounter & operator+=(int val)
const CustomCounter & operator++(int)
Increment operator.
const CustomCounter & operator++()
Increment operator.
const std::string & getName() const
Return counter name.
CustomCounter(const std::string &name)
Constructor.
uint64_t getValue() const
Return counter value.
std::tuple< PktListIterator, PktListIterator > getSentPackets()
PktList::iterator PktListIterator
Packet list iterator for sequential access to elements.
double getAvgUnorderedLookupSetSize() const
Return average unordered lookup set size.
void updateRejLeases()
Increase number of rejected leases.
void printMainStats() const
Print main statistics for packet exchange.
static uint32_t hashTransid(const dhcp::PktPtr &packet)
Hash transaction id of the packet.
PktListTransidHashIndex::const_iterator PktListTransidHashIterator
Packet list iterator to access packets using transaction id hash.
std::queue< PktListTransidHashIterator > PktListRemovalQueue
Packet list iterator queue for removal.
uint64_t getDroppedPacketsNum() const
Return number of dropped packets.
double getAvgDelay() const
Return average packet delay.
uint64_t getUnorderedLookups() const
Return number of unordered sent packets lookups.
uint64_t getOrphans() const
Return number of orphan packets.
std::string receivedLeases() const
Return the list of received leases in CSV format as string.
uint64_t getRcvdPacketsNum() const
Return total number of received packets.
void appendSent(const dhcp::PktPtr &packet)
Add new packet to list of sent packets.
uint64_t getCollectedNum() const
Return number of garbage collected packets.
uint64_t getSentPacketsNum() const
Return total number of sent packets.
ExchangeStats(const ExchangeType xchg_type, const double drop_time, const bool archive_enabled, const boost::posix_time::ptime boot_time)
Constructor.
double getStdDevDelay() const
Return standard deviation of packet delay.
void updateNonUniqueAddr()
Increase number of non unique addresses.
void appendRcvd(const dhcp::PktPtr &packet)
Add new packet to list of received packets.
uint64_t getOrderedLookups() const
Return number of ordered sent packets lookups.
double getMinDelay() const
Return minimum delay between sent and received packet.
PktList::template nth_index< 1 >::type PktListTransidHashIndex
Packet list index to search packets using transaction id hash.
void printLeases() const
Print the list of received leases.
boost::multi_index_container< dhcp::PktPtr, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::ordered_non_unique< boost::multi_index::global_fun< const dhcp::PktPtr &, uint32_t, &ExchangeStats::hashTransid > > > > PktList
List of packets (sent or received).
void printTimestamps()
Print timestamps for sent and received packets.
void printRTTStats() const
Print round trip time packets statistics.
dhcp::PktPtr matchPackets(const dhcp::PktPtr &rcvd_packet)
Match received packet with the corresponding sent packet.
uint64_t getRejLeasesNum() const
Return total number of rejected leases.
uint64_t getNonUniqueAddrNum() const
Return total number of non unique addresses.
double getMaxDelay() const
Return maximum delay between sent and received packet.
void updateDelays(const dhcp::PktPtr &sent_packet, const dhcp::PktPtr &rcvd_packet)
Update delay counters.
void addCustomCounter(const std::string &short_name, const std::string &long_name)
Add named custom uint64 counter.
std::tuple< typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator > getSentPackets(const ExchangeType xchg_type) const
void updateRejLeases(const ExchangeType xchg_type)
Increase total number of rejected leases.
void printStats() const
Print statistics counters for all exchange types.
void printLeases() const
Delegate to all exchanges to print their leases.
double getAvgDelay(const ExchangeType xchg_type) const
Return average packet delay.
void printCustomCounters() const
Print names and values of custom counters.
uint64_t getDroppedPacketsNum(const ExchangeType xchg_type) const
Return total number of dropped packets.
const CustomCounter & incrementCounter(const std::string &counter_key, const uint64_t value=1)
Increment specified counter.
void printTimestamps() const
Print timestamps of all packets.
double getAvgUnorderedLookupSetSize(const ExchangeType xchg_type) const
Return average unordered lookup set size.
void updateNonUniqueAddrNum(const ExchangeType xchg_type)
Increase total number of non unique addresses.
CustomCounterPtr getCounter(const std::string &counter_key)
Return specified counter.
uint64_t getRcvdPacketsNum(const ExchangeType xchg_type) const
Return total number of received packets.
uint64_t getSentPacketsNum(const ExchangeType xchg_type) const
Return total number of sent packets.
uint64_t getCollectedNum(const ExchangeType xchg_type) const
Return number of garbage collected packets.
bool hasExchangeStats(const ExchangeType xchg_type) const
Check if the exchange type has been specified.
StatsMgr(CommandOptions &options)
Constructor.
void printIntermediateStats(bool clean_report, std::string clean_sep) const
Print intermediate statistics.
boost::posix_time::time_period getTestPeriod() const
Get time period since the start of test.
uint64_t getOrphans(const ExchangeType xchg_type) const
Return number of orphan packets.
bool droppedPackets() const
Check if any packet drops occurred.
void passSentPacket(const ExchangeType xchg_type, const dhcp::PktPtr &packet)
Adds new packet to the sent packets list.
dhcp::PktPtr passRcvdPacket(const ExchangeType xchg_type, const dhcp::PktPtr &packet)
Add new received packet and match with sent packet.
double getMinDelay(const ExchangeType xchg_type) const
Return minimum delay between sent and received packet.
double getMaxDelay(const ExchangeType xchg_type) const
Return maximum delay between sent and received packet.
uint64_t getOrderedLookups(const ExchangeType xchg_type) const
Return number of ordered sent packets lookups.
uint64_t getRejLeasesNum(const ExchangeType xchg_type) const
Return total number of rejected leases.
void addExchangeStats(const ExchangeType xchg_type, const double drop_time=-1)
Specify new exchange type.
uint64_t getNonUniqueAddrNum(const ExchangeType xchg_type) const
Return total number of non unique addresses.
uint64_t getUnorderedLookups(const ExchangeType xchg_type) const
Return number of unordered sent packets lookups.
double getStdDevDelay(const ExchangeType xchg_type) const
Return standard deviation of packet delay.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
int get(CalloutHandle &handle)
The gss-tsig-get command.
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
Definition pkt.h:999
ExchangesMap::const_iterator ExchangesMapIterator
Iterator pointing to ExchangesMap.
boost::shared_ptr< StatsMgr > StatsMgrPtr
Pointer to Statistics Manager;.
CustomCountersMap::const_iterator CustomCountersMapIterator
Iterator for CustomCountersMap.
std::map< ExchangeType, ExchangeStatsPtr > ExchangesMap
Map containing all specified exchange types.
boost::shared_ptr< ExchangeStats > ExchangeStatsPtr
Pointer to ExchangeStats.
int dhcpVersion(ExchangeType const exchange_type)
Get the DHCP version that fits the exchange type.
ExchangeType
DHCP packet exchange types.
@ SA
DHCPv6 SOLICIT-ADVERTISE.
@ RNA
DHCPv4 REQUEST-ACK (renewal)
std::map< std::string, CustomCounterPtr > CustomCountersMap
Map containing custom counters.
boost::shared_ptr< CustomCounter > CustomCounterPtr
std::ostream & operator<<(std::ostream &os, ExchangeType xchg_type)
Return name of the exchange.
Defines the logger used by the top-level component of kea-lfc.