Kea: stats_mgr.h Source File

| Kea 3.2.0-git

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>
11#include <exceptions/exceptions.h>
12#include <perfdhcp/command_options.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
32 enum 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
66 class CustomCounter {
67public:
74 CustomCounter(const std::string& name) :
75 counter_(0),
76 name_(name) {
77 }
78
80 const CustomCounter& operator++() {
81 ++counter_;
82 return (*this);
83 }
84
86 const CustomCounter& operator++(int) {
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
128 typedef typename boost::shared_ptr<CustomCounter> CustomCounterPtr;
129
131 typedef typename std::map<std::string, CustomCounterPtr> CustomCountersMap;
132
134 typedef typename CustomCountersMap::const_iterator CustomCountersMapIterator;
135
136
144 class ExchangeStats {
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.
235 dhcp::PktPtr,
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.
255 &ExchangeStats::hashTransid
256 >
257 >
258 >
259 > PktList;
260
262 typedef typename PktList::iterator PktListIterator;
264 typedef typename PktList::template nth_index<1>::type
265 PktListTransidHashIndex;
267 typedef typename PktListTransidHashIndex::const_iterator
268 PktListTransidHashIterator;
270 typedef typename std::queue<PktListTransidHashIterator>
271 PktListRemovalQueue;
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
419 double getAvgUnorderedLookupSetSize() const {
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;
469 if (getSentPacketsNum() > getRcvdPacketsNum()) {
470 drops = getSentPacketsNum() - getRcvdPacketsNum();
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
596 ExchangeStats();
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
688 typedef boost::shared_ptr<ExchangeStats> ExchangeStatsPtr;
689
691 typedef typename std::map<ExchangeType, ExchangeStatsPtr> ExchangesMap;
692
694 typedef typename ExchangesMap::const_iterator ExchangesMapIterator;
695
696
712 class 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()) {
772 isc_throw(BadValue,
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()) {
801 isc_throw(BadValue,
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
850 dhcp::PktPtr
851 passRcvdPacket(const ExchangeType xchg_type,
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()) {
1098 isc_throw(isc::InvalidOperation,
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()) {
1173 isc_throw(isc::InvalidOperation,
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
1249 typedef boost::shared_ptr<StatsMgr> StatsMgrPtr;
1250
1251
1252} // namespace perfdhcp
1253} // namespace isc
1254
1255#endif // STATS_MGR_H
isc::BadValue
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Definition exceptions/exceptions.h:132
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition exceptions/exceptions.h:23
isc::InvalidOperation
A generic exception that is thrown if a function is called in a prohibited way.
Definition exceptions/exceptions.h:143
isc::perfdhcp::CommandOptions
Command Options.
Definition command_options.h:30
isc::perfdhcp::CustomCounter
Custom Counter.
Definition bin/perfdhcp/stats_mgr.h:66
isc::perfdhcp::CustomCounter::operator+=
const CustomCounter & operator+=(int val)
Definition bin/perfdhcp/stats_mgr.h:92
isc::perfdhcp::CustomCounter::operator++
const CustomCounter & operator++(int)
Increment operator.
Definition bin/perfdhcp/stats_mgr.h:86
isc::perfdhcp::CustomCounter::operator++
const CustomCounter & operator++()
Increment operator.
Definition bin/perfdhcp/stats_mgr.h:80
isc::perfdhcp::CustomCounter::getName
const std::string & getName() const
Return counter name.
Definition bin/perfdhcp/stats_mgr.h:111
isc::perfdhcp::CustomCounter::CustomCounter
CustomCounter(const std::string &name)
Constructor.
Definition bin/perfdhcp/stats_mgr.h:74
isc::perfdhcp::CustomCounter::getValue
uint64_t getValue() const
Return counter value.
Definition bin/perfdhcp/stats_mgr.h:102
isc::perfdhcp::ExchangeStats
Exchange Statistics.
Definition bin/perfdhcp/stats_mgr.h:144
isc::perfdhcp::ExchangeStats::getSentPackets
std::tuple< PktListIterator, PktListIterator > getSentPackets()
Definition bin/perfdhcp/stats_mgr.h:570
isc::perfdhcp::ExchangeStats::PktListIterator
PktList::iterator PktListIterator
Packet list iterator for sequential access to elements.
Definition bin/perfdhcp/stats_mgr.h:262
isc::perfdhcp::ExchangeStats::getAvgUnorderedLookupSetSize
double getAvgUnorderedLookupSetSize() const
Return average unordered lookup set size.
Definition bin/perfdhcp/stats_mgr.h:419
isc::perfdhcp::ExchangeStats::malformed_pkts_
static int malformed_pkts_
Definition bin/perfdhcp/stats_mgr.h:587
isc::perfdhcp::ExchangeStats::updateRejLeases
void updateRejLeases()
Increase number of rejected leases.
Definition bin/perfdhcp/stats_mgr.h:492
isc::perfdhcp::ExchangeStats::printMainStats
void printMainStats() const
Print main statistics for packet exchange.
Definition bin/perfdhcp/stats_mgr.h:512
isc::perfdhcp::ExchangeStats::hashTransid
static uint32_t hashTransid(const dhcp::PktPtr &packet)
Hash transaction id of the packet.
Definition bin/perfdhcp/stats_mgr.h:157
isc::perfdhcp::ExchangeStats::PktListTransidHashIterator
PktListTransidHashIndex::const_iterator PktListTransidHashIterator
Packet list iterator to access packets using transaction id hash.
Definition bin/perfdhcp/stats_mgr.h:268
isc::perfdhcp::ExchangeStats::PktListRemovalQueue
std::queue< PktListTransidHashIterator > PktListRemovalQueue
Packet list iterator queue for removal.
Definition bin/perfdhcp/stats_mgr.h:271
isc::perfdhcp::ExchangeStats::getDroppedPacketsNum
uint64_t getDroppedPacketsNum() const
Return number of dropped packets.
Definition bin/perfdhcp/stats_mgr.h:467
isc::perfdhcp::ExchangeStats::getAvgDelay
double getAvgDelay() const
Return average packet delay.
Definition bin/perfdhcp/stats_mgr.h:365
isc::perfdhcp::ExchangeStats::getUnorderedLookups
uint64_t getUnorderedLookups() const
Return number of unordered sent packets lookups.
Definition bin/perfdhcp/stats_mgr.h:435
isc::perfdhcp::ExchangeStats::getOrphans
uint64_t getOrphans() const
Return number of orphan packets.
Definition bin/perfdhcp/stats_mgr.h:397
isc::perfdhcp::ExchangeStats::receivedLeases
std::string receivedLeases() const
Return the list of received leases in CSV format as string.
Definition bin/perfdhcp/stats_mgr.cc:391
isc::perfdhcp::ExchangeStats::getRcvdPacketsNum
uint64_t getRcvdPacketsNum() const
Return total number of received packets.
Definition bin/perfdhcp/stats_mgr.h:460
isc::perfdhcp::ExchangeStats::appendSent
void appendSent(const dhcp::PktPtr &packet)
Add new packet to list of sent packets.
Definition bin/perfdhcp/stats_mgr.h:292
isc::perfdhcp::ExchangeStats::getCollectedNum
uint64_t getCollectedNum() const
Return number of garbage collected packets.
Definition bin/perfdhcp/stats_mgr.h:408
isc::perfdhcp::ExchangeStats::getSentPacketsNum
uint64_t getSentPacketsNum() const
Return total number of sent packets.
Definition bin/perfdhcp/stats_mgr.h:453
isc::perfdhcp::ExchangeStats::ExchangeStats
ExchangeStats(const ExchangeType xchg_type, const double drop_time, const bool archive_enabled, const boost::posix_time::ptime boot_time)
Constructor.
Definition bin/perfdhcp/stats_mgr.cc:76
isc::perfdhcp::ExchangeStats::getStdDevDelay
double getStdDevDelay() const
Return standard deviation of packet delay.
Definition bin/perfdhcp/stats_mgr.h:382
isc::perfdhcp::ExchangeStats::updateNonUniqueAddr
void updateNonUniqueAddr()
Increase number of non unique addresses.
Definition bin/perfdhcp/stats_mgr.h:497
isc::perfdhcp::ExchangeStats::appendRcvd
void appendRcvd(const dhcp::PktPtr &packet)
Add new packet to list of received packets.
Definition bin/perfdhcp/stats_mgr.h:306
isc::perfdhcp::ExchangeStats::getOrderedLookups
uint64_t getOrderedLookups() const
Return number of ordered sent packets lookups.
Definition bin/perfdhcp/stats_mgr.h:446
isc::perfdhcp::ExchangeStats::getMinDelay
double getMinDelay() const
Return minimum delay between sent and received packet.
Definition bin/perfdhcp/stats_mgr.h:347
isc::perfdhcp::ExchangeStats::PktListTransidHashIndex
PktList::template nth_index< 1 >::type PktListTransidHashIndex
Packet list index to search packets using transaction id hash.
Definition bin/perfdhcp/stats_mgr.h:265
isc::perfdhcp::ExchangeStats::printLeases
void printLeases() const
Print the list of received leases.
Definition bin/perfdhcp/stats_mgr.cc:453
isc::perfdhcp::ExchangeStats::PktList
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).
Definition bin/perfdhcp/stats_mgr.h:259
isc::perfdhcp::ExchangeStats::printTimestamps
void printTimestamps()
Print timestamps for sent and received packets.
Definition bin/perfdhcp/stats_mgr.cc:303
isc::perfdhcp::ExchangeStats::printRTTStats
void printRTTStats() const
Print round trip time packets statistics.
Definition bin/perfdhcp/stats_mgr.h:534
isc::perfdhcp::ExchangeStats::matchPackets
dhcp::PktPtr matchPackets(const dhcp::PktPtr &rcvd_packet)
Match received packet with the corresponding sent packet.
Definition bin/perfdhcp/stats_mgr.cc:156
isc::perfdhcp::ExchangeStats::getRejLeasesNum
uint64_t getRejLeasesNum() const
Return total number of rejected leases.
Definition bin/perfdhcp/stats_mgr.h:480
isc::perfdhcp::ExchangeStats::getNonUniqueAddrNum
uint64_t getNonUniqueAddrNum() const
Return total number of non unique addresses.
Definition bin/perfdhcp/stats_mgr.h:487
isc::perfdhcp::ExchangeStats::getMaxDelay
double getMaxDelay() const
Return maximum delay between sent and received packet.
Definition bin/perfdhcp/stats_mgr.h:354
isc::perfdhcp::ExchangeStats::updateDelays
void updateDelays(const dhcp::PktPtr &sent_packet, const dhcp::PktPtr &rcvd_packet)
Update delay counters.
Definition bin/perfdhcp/stats_mgr.cc:105
isc::perfdhcp::StatsMgr::addCustomCounter
void addCustomCounter(const std::string &short_name, const std::string &long_name)
Add named custom uint64 counter.
Definition bin/perfdhcp/stats_mgr.h:769
isc::perfdhcp::StatsMgr::getSentPackets
std::tuple< typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator > getSentPackets(const ExchangeType xchg_type) const
Definition bin/perfdhcp/stats_mgr.h:1207
isc::perfdhcp::StatsMgr::updateRejLeases
void updateRejLeases(const ExchangeType xchg_type)
Increase total number of rejected leases.
Definition bin/perfdhcp/stats_mgr.h:1042
isc::perfdhcp::StatsMgr::printStats
void printStats() const
Print statistics counters for all exchange types.
Definition bin/perfdhcp/stats_mgr.h:1096
isc::perfdhcp::StatsMgr::printLeases
void printLeases() const
Delegate to all exchanges to print their leases.
Definition bin/perfdhcp/stats_mgr.cc:457
isc::perfdhcp::StatsMgr::getAvgDelay
double getAvgDelay(const ExchangeType xchg_type) const
Return average packet delay.
Definition bin/perfdhcp/stats_mgr.h:897
isc::perfdhcp::StatsMgr::printCustomCounters
void printCustomCounters() const
Print names and values of custom counters.
Definition bin/perfdhcp/stats_mgr.h:1195
isc::perfdhcp::StatsMgr::getDroppedPacketsNum
uint64_t getDroppedPacketsNum(const ExchangeType xchg_type) const
Return total number of dropped packets.
Definition bin/perfdhcp/stats_mgr.h:1005
isc::perfdhcp::StatsMgr::incrementCounter
const CustomCounter & incrementCounter(const std::string &counter_key, const uint64_t value=1)
Increment specified counter.
Definition bin/perfdhcp/stats_mgr.h:814
isc::perfdhcp::StatsMgr::printTimestamps
void printTimestamps() const
Print timestamps of all packets.
Definition bin/perfdhcp/stats_mgr.h:1171
isc::perfdhcp::StatsMgr::getAvgUnorderedLookupSetSize
double getAvgUnorderedLookupSetSize(const ExchangeType xchg_type) const
Return average unordered lookup set size.
Definition bin/perfdhcp/stats_mgr.h:935
isc::perfdhcp::StatsMgr::updateNonUniqueAddrNum
void updateNonUniqueAddrNum(const ExchangeType xchg_type)
Increase total number of non unique addresses.
Definition bin/perfdhcp/stats_mgr.h:1051
isc::perfdhcp::StatsMgr::getCounter
CustomCounterPtr getCounter(const std::string &counter_key)
Return specified counter.
Definition bin/perfdhcp/stats_mgr.h:798
isc::perfdhcp::StatsMgr::getRcvdPacketsNum
uint64_t getRcvdPacketsNum(const ExchangeType xchg_type) const
Return total number of received packets.
Definition bin/perfdhcp/stats_mgr.h:992
isc::perfdhcp::StatsMgr::getSentPacketsNum
uint64_t getSentPacketsNum(const ExchangeType xchg_type) const
Return total number of sent packets.
Definition bin/perfdhcp/stats_mgr.h:979
isc::perfdhcp::StatsMgr::getCollectedNum
uint64_t getCollectedNum(const ExchangeType xchg_type) const
Return number of garbage collected packets.
Definition bin/perfdhcp/stats_mgr.h:1020
isc::perfdhcp::StatsMgr::hasExchangeStats
bool hasExchangeStats(const ExchangeType xchg_type) const
Check if the exchange type has been specified.
Definition bin/perfdhcp/stats_mgr.h:758
isc::perfdhcp::StatsMgr::StatsMgr
StatsMgr(CommandOptions &options)
Constructor.
Definition bin/perfdhcp/stats_mgr.cc:353
isc::perfdhcp::StatsMgr::printIntermediateStats
void printIntermediateStats(bool clean_report, std::string clean_sep) const
Print intermediate statistics.
Definition bin/perfdhcp/stats_mgr.h:1121
isc::perfdhcp::StatsMgr::getTestPeriod
boost::posix_time::time_period getTestPeriod() const
Get time period since the start of test.
Definition bin/perfdhcp/stats_mgr.h:1076
isc::perfdhcp::StatsMgr::getOrphans
uint64_t getOrphans(const ExchangeType xchg_type) const
Return number of orphan packets.
Definition bin/perfdhcp/stats_mgr.h:921
isc::perfdhcp::StatsMgr::droppedPackets
bool droppedPackets() const
Check if any packet drops occurred.
Definition bin/perfdhcp/stats_mgr.h:782
isc::perfdhcp::StatsMgr::passSentPacket
void passSentPacket(const ExchangeType xchg_type, const dhcp::PktPtr &packet)
Adds new packet to the sent packets list.
Definition bin/perfdhcp/stats_mgr.h:831
isc::perfdhcp::StatsMgr::passRcvdPacket
dhcp::PktPtr passRcvdPacket(const ExchangeType xchg_type, const dhcp::PktPtr &packet)
Add new received packet and match with sent packet.
Definition bin/perfdhcp/stats_mgr.h:851
isc::perfdhcp::StatsMgr::getMinDelay
double getMinDelay(const ExchangeType xchg_type) const
Return minimum delay between sent and received packet.
Definition bin/perfdhcp/stats_mgr.h:873
isc::perfdhcp::StatsMgr::getMaxDelay
double getMaxDelay(const ExchangeType xchg_type) const
Return maximum delay between sent and received packet.
Definition bin/perfdhcp/stats_mgr.h:886
isc::perfdhcp::StatsMgr::getOrderedLookups
uint64_t getOrderedLookups(const ExchangeType xchg_type) const
Return number of ordered sent packets lookups.
Definition bin/perfdhcp/stats_mgr.h:966
isc::perfdhcp::StatsMgr::getRejLeasesNum
uint64_t getRejLeasesNum(const ExchangeType xchg_type) const
Return total number of rejected leases.
Definition bin/perfdhcp/stats_mgr.h:1033
isc::perfdhcp::StatsMgr::addExchangeStats
void addExchangeStats(const ExchangeType xchg_type, const double drop_time=-1)
Specify new exchange type.
Definition bin/perfdhcp/stats_mgr.h:736
isc::perfdhcp::StatsMgr::getNonUniqueAddrNum
uint64_t getNonUniqueAddrNum(const ExchangeType xchg_type) const
Return total number of non unique addresses.
Definition bin/perfdhcp/stats_mgr.h:1064
isc::perfdhcp::StatsMgr::getUnorderedLookups
uint64_t getUnorderedLookups(const ExchangeType xchg_type) const
Return number of unordered sent packets lookups.
Definition bin/perfdhcp/stats_mgr.h:950
isc::perfdhcp::StatsMgr::getStdDevDelay
double getStdDevDelay(const ExchangeType xchg_type) const
Return standard deviation of packet delay.
Definition bin/perfdhcp/stats_mgr.h:908
command_options.h
exceptions.h
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition exceptions/exceptions.h:210
get
int get(CalloutHandle &handle)
The gss-tsig-get command.
Definition gss_tsig_callouts.cc:47
isc::dhcp::PktPtr
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
Definition pkt.h:999
isc::perfdhcp
Definition abstract_scen.h:15
isc::perfdhcp::ExchangesMapIterator
ExchangesMap::const_iterator ExchangesMapIterator
Iterator pointing to ExchangesMap.
Definition bin/perfdhcp/stats_mgr.h:694
isc::perfdhcp::StatsMgrPtr
boost::shared_ptr< StatsMgr > StatsMgrPtr
Pointer to Statistics Manager;.
Definition bin/perfdhcp/stats_mgr.h:1249
isc::perfdhcp::CustomCountersMapIterator
CustomCountersMap::const_iterator CustomCountersMapIterator
Iterator for CustomCountersMap.
Definition bin/perfdhcp/stats_mgr.h:134
isc::perfdhcp::ExchangesMap
std::map< ExchangeType, ExchangeStatsPtr > ExchangesMap
Map containing all specified exchange types.
Definition bin/perfdhcp/stats_mgr.h:691
isc::perfdhcp::ExchangeStatsPtr
boost::shared_ptr< ExchangeStats > ExchangeStatsPtr
Pointer to ExchangeStats.
Definition bin/perfdhcp/stats_mgr.h:688
isc::perfdhcp::dhcpVersion
int dhcpVersion(ExchangeType const exchange_type)
Get the DHCP version that fits the exchange type.
Definition bin/perfdhcp/stats_mgr.cc:33
isc::perfdhcp::ExchangeType
ExchangeType
DHCP packet exchange types.
Definition bin/perfdhcp/stats_mgr.h:32
isc::perfdhcp::ExchangeType::RA
@ RA
DHCPv4 REQUEST-ACK.
Definition bin/perfdhcp/stats_mgr.h:34
isc::perfdhcp::ExchangeType::SA
@ SA
DHCPv6 SOLICIT-ADVERTISE.
Definition bin/perfdhcp/stats_mgr.h:37
isc::perfdhcp::ExchangeType::RNA
@ RNA
DHCPv4 REQUEST-ACK (renewal).
Definition bin/perfdhcp/stats_mgr.h:35
isc::perfdhcp::ExchangeType::RL
@ RL
DHCPv6 RELEASE-REPLY.
Definition bin/perfdhcp/stats_mgr.h:40
isc::perfdhcp::ExchangeType::RLA
@ RLA
DHCPv4 RELEASE.
Definition bin/perfdhcp/stats_mgr.h:36
isc::perfdhcp::ExchangeType::RN
@ RN
DHCPv6 RENEW-REPLY.
Definition bin/perfdhcp/stats_mgr.h:39
isc::perfdhcp::ExchangeType::DO
@ DO
DHCPv4 DISCOVER-OFFER.
Definition bin/perfdhcp/stats_mgr.h:33
isc::perfdhcp::ExchangeType::RR
@ RR
DHCPv6 REQUEST-REPLY.
Definition bin/perfdhcp/stats_mgr.h:38
isc::perfdhcp::CustomCountersMap
std::map< std::string, CustomCounterPtr > CustomCountersMap
Map containing custom counters.
Definition bin/perfdhcp/stats_mgr.h:131
isc::perfdhcp::CustomCounterPtr
boost::shared_ptr< CustomCounter > CustomCounterPtr
Definition bin/perfdhcp/stats_mgr.h:128
isc::perfdhcp::operator<<
std::ostream & operator<<(std::ostream &os, ExchangeType xchg_type)
Return name of the exchange.
Definition bin/perfdhcp/stats_mgr.cc:51
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
pkt.h