Kea 2.7.5
bin/perfdhcp/stats_mgr.h
Go to the documentation of this file.
1// Copyright (C) 2012-2024 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
32enum class ExchangeType {
33 DO,
34 RA,
35 RNA,
36 RLA,
37 SA,
38 RR,
39 RN,
40 RL
41};
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 try {
537 cout << fixed << setprecision(3)
538 << "min delay: " << getMinDelay() * 1e3 << " ms" << endl
539 << "avg delay: " << getAvgDelay() * 1e3 << " ms" << endl
540 << "max delay: " << getMaxDelay() * 1e3 << " ms" << endl
541 << "std deviation: " << getStdDevDelay() * 1e3 << " ms"
542 << endl
543 << "collected packets: " << getCollectedNum() << endl;
544 } catch (const Exception&) {
545 // repeated output for easier automated parsing
546 cout << "min delay: n/a" << endl
547 << "avg delay: n/a" << endl
548 << "max delay: n/a" << endl
549 << "std deviation: n/a" << endl
550 << "collected packets: 0" << endl;
551 }
552 }
553
564 void printTimestamps();
565
566 std::tuple<PktListIterator, PktListIterator> getSentPackets() {
567 return(std::make_tuple(sent_packets_.begin(), sent_packets_.end()));
568 }
569
578 std::string receivedLeases() const;
579
581 void printLeases() const;
582
583 static int malformed_pkts_;
584
585// Private stuff of ExchangeStats class
586private:
587
593
601 PktListIterator eraseSent(const PktListIterator it) {
602 if (archive_enabled_) {
603 // We don't want to keep list of all sent packets
604 // because it will affect packet lookup performance.
605 // If packet is matched with received packet we
606 // move it to list of archived packets. List of
607 // archived packets may be used for diagnostics
608 // when test is completed.
609 static_cast<void>(archived_packets_.push_back(*it));
610 }
611 // get<0>() template returns sequential index to
612 // container.
613 return(sent_packets_.template get<0>().erase(it));
614 }
615
616 ExchangeType xchg_type_;
617 PktList sent_packets_;
618
622 PktListIterator next_sent_;
623
624 PktList rcvd_packets_;
625
629 PktList archived_packets_;
630
642 bool archive_enabled_;
643
646 double drop_time_;
647
648 double min_delay_;
650 double max_delay_;
652 double sum_delay_;
654 double sum_delay_squared_;
656
657 uint64_t orphans_;
658
659 uint64_t collected_;
660
666 uint64_t unordered_lookup_size_sum_;
667
668 uint64_t unordered_lookups_;
670 uint64_t ordered_lookups_;
672
673 uint64_t sent_packets_num_;
674 uint64_t rcvd_packets_num_;
675
676 uint64_t non_unique_addr_num_;
678 uint64_t rejected_leases_num_;
680 boost::posix_time::ptime boot_time_;
681};
682
684typedef boost::shared_ptr<ExchangeStats> ExchangeStatsPtr;
685
687typedef typename std::map<ExchangeType, ExchangeStatsPtr> ExchangesMap;
688
690typedef typename ExchangesMap::const_iterator ExchangesMapIterator;
691
692
708class StatsMgr : public boost::noncopyable {
709public:
720 StatsMgr(CommandOptions& options);
721
732 void addExchangeStats(const ExchangeType xchg_type,
733 const double drop_time = -1) {
734 if (exchanges_.find(xchg_type) != exchanges_.end()) {
735 isc_throw(BadValue, "Exchange of specified type already added.");
736 }
737 exchanges_[xchg_type] =
738 ExchangeStatsPtr(new ExchangeStats(xchg_type,
739 drop_time,
740 archive_enabled_,
741 boot_time_));
742 }
743
754 bool hasExchangeStats(const ExchangeType xchg_type) const {
755 return (exchanges_.find(xchg_type) != exchanges_.end());
756 }
757
765 void addCustomCounter(const std::string& short_name,
766 const std::string& long_name) {
767 if (custom_counters_.find(short_name) != custom_counters_.end()) {
769 "Custom counter " << short_name << " already added.");
770 }
771 custom_counters_[short_name] =
772 CustomCounterPtr(new CustomCounter(long_name));
773 }
774
777 // \return true, if packet drops occurred.
778 bool droppedPackets() const {
779 for (auto const& it : exchanges_) {
780 if (it.second->getDroppedPacketsNum() > 0) {
781 return (true);
782 }
783 }
784 return (false);
785 }
786
794 CustomCounterPtr getCounter(const std::string& counter_key) {
795 CustomCountersMapIterator it = custom_counters_.find(counter_key);
796 if (it == custom_counters_.end()) {
798 "Custom counter " << counter_key << "does not exist");
799 }
800 return(it->second);
801 }
802
810 const CustomCounter& incrementCounter(const std::string& counter_key,
811 const uint64_t value = 1) {
812 CustomCounterPtr counter = getCounter(counter_key);
813 *counter += value;
814 return (*counter);
815 }
816
827 void passSentPacket(const ExchangeType xchg_type,
828 const dhcp::PktPtr& packet) {
829 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
830 xchg_stats->appendSent(packet);
831 }
832
848 const dhcp::PktPtr& packet) {
849 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
850 dhcp::PktPtr sent_packet = xchg_stats->matchPackets(packet);
851
852 if (sent_packet) {
853 xchg_stats->updateDelays(sent_packet, packet);
854 if (archive_enabled_) {
855 xchg_stats->appendRcvd(packet);
856 }
857 }
858 return(sent_packet);
859 }
860
869 double getMinDelay(const ExchangeType xchg_type) const {
870 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
871 return(xchg_stats->getMinDelay());
872 }
873
882 double getMaxDelay(const ExchangeType xchg_type) const {
883 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
884 return(xchg_stats->getMaxDelay());
885 }
886
893 double getAvgDelay(const ExchangeType xchg_type) const {
894 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
895 return(xchg_stats->getAvgDelay());
896 }
897
904 double getStdDevDelay(const ExchangeType xchg_type) const {
905 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
906 return(xchg_stats->getStdDevDelay());
907 }
908
917 uint64_t getOrphans(const ExchangeType xchg_type) const {
918 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
919 return(xchg_stats->getOrphans());
920 }
921
931 double getAvgUnorderedLookupSetSize(const ExchangeType xchg_type) const {
932 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
933 return(xchg_stats->getAvgUnorderedLookupSetSize());
934 }
935
946 uint64_t getUnorderedLookups(const ExchangeType xchg_type) const {
947 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
948 return(xchg_stats->getUnorderedLookups());
949 }
950
962 uint64_t getOrderedLookups(const ExchangeType xchg_type) const {
963 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
964 return(xchg_stats->getOrderedLookups());
965 }
966
975 uint64_t getSentPacketsNum(const ExchangeType xchg_type) const {
976 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
977 return(xchg_stats->getSentPacketsNum());
978 }
979
988 uint64_t getRcvdPacketsNum(const ExchangeType xchg_type) const {
989 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
990 return(xchg_stats->getRcvdPacketsNum());
991 }
992
1001 uint64_t getDroppedPacketsNum(const ExchangeType xchg_type) const {
1002 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1003 return(xchg_stats->getDroppedPacketsNum());
1004 }
1005
1016 uint64_t getCollectedNum(const ExchangeType xchg_type) const {
1017 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1018 return(xchg_stats->getCollectedNum());
1019 }
1020
1029 uint64_t getRejLeasesNum(const ExchangeType xchg_type) const {
1030 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1031 return(xchg_stats->getRejLeasesNum());
1032 }
1033
1038 void updateRejLeases(const ExchangeType xchg_type) {
1039 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1040 xchg_stats->updateRejLeases();
1041 }
1042
1047 void updateNonUniqueAddrNum(const ExchangeType xchg_type) {
1048 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1049 xchg_stats->updateNonUniqueAddr();
1050 }
1051
1060 uint64_t getNonUniqueAddrNum(const ExchangeType xchg_type) const {
1061 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1062 return(xchg_stats->getNonUniqueAddrNum());
1063 }
1064
1072 boost::posix_time::time_period getTestPeriod() const {
1073 using namespace boost::posix_time;
1074 time_period test_period(boot_time_,
1075 microsec_clock::universal_time());
1076 return test_period;
1077 }
1078
1092 void printStats() const {
1093 if (exchanges_.empty()) {
1095 "no exchange type added for tracking");
1096 }
1097 for (auto const& it : exchanges_) {
1098 ExchangeStatsPtr xchg_stats = it.second;
1099 std::cout << "***Statistics for: " << it.first
1100 << "***" << std::endl;
1101 xchg_stats->printMainStats();
1102 std::cout << std::endl;
1103 xchg_stats->printRTTStats();
1104 std::cout << std::endl;
1105 }
1106 }
1107
1116 void
1117 printIntermediateStats(bool clean_report, std::string clean_sep) const {
1118 std::ostringstream stream_sent;
1119 std::ostringstream stream_rcvd;
1120 std::ostringstream stream_drops;
1121 std::ostringstream stream_reject;
1122 std::string sep("");
1123 bool first = true;
1124 for (auto const& it : exchanges_) {
1125 if (!first) {
1126 if (clean_report) {
1127 sep = clean_sep;
1128 } else {
1129 sep = "/";
1130 }
1131 } else {
1132 first = false;
1133 }
1134 stream_sent << sep << it.second->getSentPacketsNum();
1135 stream_rcvd << sep << it.second->getRcvdPacketsNum();
1136 stream_drops << sep << it.second->getDroppedPacketsNum();
1137 stream_reject << sep << it.second->getRejLeasesNum();
1138 }
1139
1140 if (clean_report) {
1141 std::cout << stream_sent.str()
1142 << clean_sep << stream_rcvd.str()
1143 << clean_sep << stream_drops.str()
1144 << clean_sep << stream_reject.str()
1145 << std::endl;
1146
1147 } else {
1148 std::cout << "sent: " << stream_sent.str()
1149 << "; received: " << stream_rcvd.str()
1150 << "; drops: " << stream_drops.str()
1151 << "; rejected: " << stream_reject.str()
1152 << std::endl;
1153 }
1154 }
1155
1167 void printTimestamps() const {
1168 if (exchanges_.empty()) {
1170 "no exchange type added for tracking");
1171 }
1172 for (auto const& it : exchanges_) {
1173 ExchangeStatsPtr xchg_stats = it.second;
1174 std::cout << "***Timestamps for packets: "
1175 << it.first
1176 << "***" << std::endl;
1177 xchg_stats->printTimestamps();
1178 std::cout << std::endl;
1179 }
1180 }
1181
1183 void printLeases() const;
1184
1191 void printCustomCounters() const {
1192 if (custom_counters_.empty()) {
1193 isc_throw(isc::InvalidOperation, "no custom counters specified");
1194 }
1195 for (auto const& it : custom_counters_) {
1196 CustomCounterPtr counter = it.second;
1197 std::cout << counter->getName() << ": " << counter->getValue()
1198 << std::endl;
1199 }
1200 }
1201
1202 std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator>
1203 getSentPackets(const ExchangeType xchg_type) const {
1204 ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1205 std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator> sent_packets_its =
1206 xchg_stats->getSentPackets();
1207 return (sent_packets_its);
1208 }
1209
1210private:
1211
1219 ExchangeStatsPtr getExchangeStats(const ExchangeType xchg_type) const {
1220 ExchangesMapIterator it = exchanges_.find(xchg_type);
1221 if (it == exchanges_.end()) {
1222 isc_throw(BadValue, "Packets exchange not specified");
1223 }
1224 ExchangeStatsPtr xchg_stats = it->second;
1225 return(xchg_stats);
1226 }
1227
1228 ExchangesMap exchanges_;
1229 CustomCountersMap custom_counters_;
1230
1239 bool archive_enabled_;
1240
1241 boost::posix_time::ptime boot_time_;
1242};
1243
1245typedef boost::shared_ptr<StatsMgr> StatsMgrPtr;
1246
1247
1248} // namespace perfdhcp
1249} // namespace isc
1250
1251#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.
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.
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
Definition pkt.h:998
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.
@ RA
DHCPv4 REQUEST-ACK.
@ SA
DHCPv6 SOLICIT-ADVERTISE.
@ RNA
DHCPv4 REQUEST-ACK (renewal)
@ RL
DHCPv6 RELEASE-REPLY.
@ RN
DHCPv6 RENEW-REPLY.
@ DO
DHCPv4 DISCOVER-OFFER.
@ RR
DHCPv6 REQUEST-REPLY.
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.