Kea  1.9.9-git
bin/perfdhcp/stats_mgr.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2021 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>
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 
28 namespace isc {
29 namespace perfdhcp {
30 
32 enum class ExchangeType {
33  DO,
34  RA,
35  RNA,
36  SA,
37  RR,
38  RN,
39  RL
40 };
41 
47 int dhcpVersion(ExchangeType const exchange_type);
48 
57 std::ostream& operator<<(std::ostream& os, ExchangeType xchg_type);
58 
66 public:
73  CustomCounter(const std::string& name) :
74  counter_(0),
75  name_(name) { };
76 
79  ++counter_;
80  return (*this);
81  }
82 
84  const CustomCounter& operator++(int) {
85  CustomCounter& this_counter(*this);
86  operator++();
87  return (this_counter);
88  }
89 
90  const CustomCounter& operator+=(int val) {
91  counter_ += val;
92  return (*this);
93  }
94 
100  uint64_t getValue() const { return(counter_); }
101 
107  const std::string& getName() const { return(name_); }
108 
109 private:
115  CustomCounter() { };
116 
117  uint64_t counter_;
118  std::string name_;
119 };
120 
121 typedef typename boost::shared_ptr<CustomCounter> CustomCounterPtr;
122 
124 typedef typename std::map<std::string, CustomCounterPtr> CustomCountersMap;
125 
127 typedef typename CustomCountersMap::const_iterator CustomCountersMapIterator;
128 
129 
138 public:
139 
150  static uint32_t hashTransid(const dhcp::PktPtr& packet) {
151  if (!packet) {
152  isc_throw(BadValue, "Packet is null");
153  }
154  return(packet->getTransid() & 1023);
155  }
156 
228  typedef boost::multi_index_container<
229  // Container holds PktPtr objects.
230  dhcp::PktPtr,
231  // List container indexes.
232  boost::multi_index::indexed_by<
233  // Sequenced index provides the way to use this container
234  // in the same way as std::list.
235  boost::multi_index::sequenced<>,
236  // The other index keeps products of transaction id.
237  // Elements with the same hash value are grouped together
238  // into buckets and transactions are ordered from the
239  // oldest to latest within a bucket.
240  boost::multi_index::ordered_non_unique<
241  // Specify hash function to get the product of
242  // transaction id. This product is obtained by calling
243  // hashTransid() function.
244  boost::multi_index::global_fun<
245  // Hashing function takes PktPtr as argument.
246  const dhcp::PktPtr&,
247  // ... and returns uint32 value.
248  uint32_t,
249  // ... and here is a reference to it.
251  >
252  >
253  >
255 
257  typedef typename PktList::iterator PktListIterator;
259  typedef typename PktList::template nth_index<1>::type
262  typedef typename PktListTransidHashIndex::const_iterator
265  typedef typename std::queue<PktListTransidHashIterator>
267 
276  ExchangeStats(const ExchangeType xchg_type,
277  const double drop_time,
278  const bool archive_enabled,
279  const boost::posix_time::ptime boot_time);
280 
287  void appendSent(const dhcp::PktPtr& packet) {
288  if (!packet) {
289  isc_throw(BadValue, "Packet is null");
290  }
291  static_cast<void>(sent_packets_.template get<0>().push_back(packet));
292  ++sent_packets_num_;
293  }
294 
301  void appendRcvd(const dhcp::PktPtr& packet) {
302  if (!packet) {
303  isc_throw(BadValue, "Packet is null");
304  }
305  static_cast<void>(rcvd_packets_.push_back(packet));
306  }
307 
317  void updateDelays(const dhcp::PktPtr& sent_packet,
318  const dhcp::PktPtr& rcvd_packet);
319 
335  dhcp::PktPtr matchPackets(const dhcp::PktPtr& rcvd_packet);
336 
342  double getMinDelay() const { return(min_delay_); }
343 
349  double getMaxDelay() const { return(max_delay_); }
350 
360  double getAvgDelay() const {
361  if (rcvd_packets_num_ == 0) {
362  isc_throw(InvalidOperation, "no packets received");
363  }
364  return(sum_delay_ / rcvd_packets_num_);
365  }
366 
377  double getStdDevDelay() const {
378  if (rcvd_packets_num_ == 0) {
379  isc_throw(InvalidOperation, "no packets received");
380  }
381  return(sqrt(sum_delay_squared_ / rcvd_packets_num_ -
382  getAvgDelay() * getAvgDelay()));
383  }
384 
392  uint64_t getOrphans() const { return(orphans_); }
393 
403  uint64_t getCollectedNum() const { return(collected_); }
404 
415  if (unordered_lookups_ == 0) {
416  isc_throw(InvalidOperation, "no unordered lookups");
417  }
418  return(static_cast<double>(unordered_lookup_size_sum_) /
419  static_cast<double>(unordered_lookups_));
420  }
421 
430  uint64_t getUnorderedLookups() const { return(unordered_lookups_); }
431 
441  uint64_t getOrderedLookups() const { return(ordered_lookups_); }
442 
448  uint64_t getSentPacketsNum() const { return(sent_packets_num_); }
449 
455  uint64_t getRcvdPacketsNum() const { return(rcvd_packets_num_); }
456 
462  uint64_t getDroppedPacketsNum() const {
463  uint64_t drops = 0;
465  drops = getSentPacketsNum() - getRcvdPacketsNum();
466  }
467  return(drops);
468  }
469 
475  uint64_t getRejLeasesNum() const { return(rejected_leases_num_); }
476 
482  uint64_t getNonUniqueAddrNum() const { return(non_unique_addr_num_); }
483 
487  void updateRejLeases() { ++rejected_leases_num_; }
488 
492  void updateNonUniqueAddr() { ++non_unique_addr_num_; }
493 
507  void printMainStats() const {
508  using namespace std;
509  auto sent = getSentPacketsNum();
510  auto drops = getDroppedPacketsNum();
511  double drops_ratio = 100.0 * static_cast<double>(drops) / static_cast<double>(sent);
512 
513  cout << "sent packets: " << sent << endl
514  << "received packets: " << getRcvdPacketsNum() << endl
515  << "drops: " << drops << endl
516  << "drops ratio: " << drops_ratio << " %" << endl
517  << "orphans: " << getOrphans() << endl
518  << "rejected leases: " << getRejLeasesNum() << endl
519  << "non unique addresses: " << getNonUniqueAddrNum() << endl;
520  }
521 
529  void printRTTStats() const {
530  using namespace std;
531  try {
532  cout << fixed << setprecision(3)
533  << "min delay: " << getMinDelay() * 1e3 << " ms" << endl
534  << "avg delay: " << getAvgDelay() * 1e3 << " ms" << endl
535  << "max delay: " << getMaxDelay() * 1e3 << " ms" << endl
536  << "std deviation: " << getStdDevDelay() * 1e3 << " ms"
537  << endl
538  << "collected packets: " << getCollectedNum() << endl;
539  } catch (const Exception&) {
540  // repeated output for easier automated parsing
541  cout << "min delay: n/a" << endl
542  << "avg delay: n/a" << endl
543  << "max delay: n/a" << endl
544  << "std deviation: n/a" << endl
545  << "collected packets: 0" << endl;
546  }
547  }
548 
559  void printTimestamps();
560 
561  std::tuple<PktListIterator, PktListIterator> getSentPackets() {
562  return(std::make_tuple(sent_packets_.begin(), sent_packets_.end()));
563  }
564 
573  std::string receivedLeases() const;
574 
576  void printLeases() const;
577 
578  static int malformed_pkts_;
579 
580 // Private stuff of ExchangeStats class
581 private:
582 
587  ExchangeStats();
588 
596  PktListIterator eraseSent(const PktListIterator it) {
597  if (archive_enabled_) {
598  // We don't want to keep list of all sent packets
599  // because it will affect packet lookup performance.
600  // If packet is matched with received packet we
601  // move it to list of archived packets. List of
602  // archived packets may be used for diagnostics
603  // when test is completed.
604  static_cast<void>(archived_packets_.push_back(*it));
605  }
606  // get<0>() template returns sequential index to
607  // container.
608  return(sent_packets_.template get<0>().erase(it));
609  }
610 
611  ExchangeType xchg_type_;
612  PktList sent_packets_;
613 
617  PktListIterator next_sent_;
618 
619  PktList rcvd_packets_;
620 
624  PktList archived_packets_;
625 
637  bool archive_enabled_;
638 
641  double drop_time_;
642 
643  double min_delay_;
644  double max_delay_;
646  double sum_delay_;
648  double sum_delay_squared_;
650 
652  uint64_t orphans_;
653 
654  uint64_t collected_;
655 
661  uint64_t unordered_lookup_size_sum_;
662 
663  uint64_t unordered_lookups_;
664  uint64_t ordered_lookups_;
666 
668  uint64_t sent_packets_num_;
669  uint64_t rcvd_packets_num_;
670 
671  uint64_t non_unique_addr_num_;
672  uint64_t rejected_leases_num_;
674  boost::posix_time::ptime boot_time_;
676 };
677 
679 typedef boost::shared_ptr<ExchangeStats> ExchangeStatsPtr;
680 
682 typedef typename std::map<ExchangeType, ExchangeStatsPtr> ExchangesMap;
683 
685 typedef typename ExchangesMap::const_iterator ExchangesMapIterator;
686 
687 
703 class StatsMgr : public boost::noncopyable {
704 public:
715  StatsMgr(CommandOptions& options);
716 
727  void addExchangeStats(const ExchangeType xchg_type,
728  const double drop_time = -1) {
729  if (exchanges_.find(xchg_type) != exchanges_.end()) {
730  isc_throw(BadValue, "Exchange of specified type already added.");
731  }
732  exchanges_[xchg_type] =
733  ExchangeStatsPtr(new ExchangeStats(xchg_type,
734  drop_time,
735  archive_enabled_,
736  boot_time_));
737  }
738 
749  bool hasExchangeStats(const ExchangeType xchg_type) const {
750  return (exchanges_.find(xchg_type) != exchanges_.end());
751  }
752 
760  void addCustomCounter(const std::string& short_name,
761  const std::string& long_name) {
762  if (custom_counters_.find(short_name) != custom_counters_.end()) {
764  "Custom counter " << short_name << " already added.");
765  }
766  custom_counters_[short_name] =
767  CustomCounterPtr(new CustomCounter(long_name));
768  }
769 
772  // \return true, if packet drops occurred.
773  bool droppedPackets() const {
774  for (ExchangesMapIterator it = exchanges_.begin();
775  it != exchanges_.end();
776  ++it) {
777  if (it->second->getDroppedPacketsNum() > 0) {
778  return (true);
779  }
780  }
781  return (false);
782  }
783 
791  CustomCounterPtr getCounter(const std::string& counter_key) {
792  CustomCountersMapIterator it = custom_counters_.find(counter_key);
793  if (it == custom_counters_.end()) {
795  "Custom counter " << counter_key << "does not exist");
796  }
797  return(it->second);
798  }
799 
807  const CustomCounter& incrementCounter(const std::string& counter_key,
808  const uint64_t value = 1) {
809  CustomCounterPtr counter = getCounter(counter_key);
810  *counter += value;
811  return (*counter);
812  }
813 
824  void passSentPacket(const ExchangeType xchg_type,
825  const dhcp::PktPtr& packet) {
826  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
827  xchg_stats->appendSent(packet);
828  }
829 
843  dhcp::PktPtr
844  passRcvdPacket(const ExchangeType xchg_type,
845  const dhcp::PktPtr& packet) {
846  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
847  dhcp::PktPtr sent_packet = xchg_stats->matchPackets(packet);
848 
849  if (sent_packet) {
850  xchg_stats->updateDelays(sent_packet, packet);
851  if (archive_enabled_) {
852  xchg_stats->appendRcvd(packet);
853  }
854  }
855  return(sent_packet);
856  }
857 
866  double getMinDelay(const ExchangeType xchg_type) const {
867  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
868  return(xchg_stats->getMinDelay());
869  }
870 
879  double getMaxDelay(const ExchangeType xchg_type) const {
880  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
881  return(xchg_stats->getMaxDelay());
882  }
883 
890  double getAvgDelay(const ExchangeType xchg_type) const {
891  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
892  return(xchg_stats->getAvgDelay());
893  }
894 
901  double getStdDevDelay(const ExchangeType xchg_type) const {
902  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
903  return(xchg_stats->getStdDevDelay());
904  }
905 
914  uint64_t getOrphans(const ExchangeType xchg_type) const {
915  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
916  return(xchg_stats->getOrphans());
917  }
918 
928  double getAvgUnorderedLookupSetSize(const ExchangeType xchg_type) const {
929  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
930  return(xchg_stats->getAvgUnorderedLookupSetSize());
931  }
932 
943  uint64_t getUnorderedLookups(const ExchangeType xchg_type) const {
944  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
945  return(xchg_stats->getUnorderedLookups());
946  }
947 
959  uint64_t getOrderedLookups(const ExchangeType xchg_type) const {
960  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
961  return(xchg_stats->getOrderedLookups());
962  }
963 
972  uint64_t getSentPacketsNum(const ExchangeType xchg_type) const {
973  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
974  return(xchg_stats->getSentPacketsNum());
975  }
976 
985  uint64_t getRcvdPacketsNum(const ExchangeType xchg_type) const {
986  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
987  return(xchg_stats->getRcvdPacketsNum());
988  }
989 
998  uint64_t getDroppedPacketsNum(const ExchangeType xchg_type) const {
999  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1000  return(xchg_stats->getDroppedPacketsNum());
1001  }
1002 
1013  uint64_t getCollectedNum(const ExchangeType xchg_type) const {
1014  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1015  return(xchg_stats->getCollectedNum());
1016  }
1017 
1026  uint64_t getRejLeasesNum(const ExchangeType xchg_type) const {
1027  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1028  return(xchg_stats->getRejLeasesNum());
1029  }
1030 
1035  void updateRejLeases(const ExchangeType xchg_type) {
1036  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1037  xchg_stats->updateRejLeases();
1038  }
1039 
1044  void updateNonUniqueAddrNum(const ExchangeType xchg_type) {
1045  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1046  xchg_stats->updateNonUniqueAddr();
1047  }
1048 
1057  uint64_t getNonUniqueAddrNum(const ExchangeType xchg_type) const {
1058  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1059  return(xchg_stats->getNonUniqueAddrNum());
1060  }
1061 
1069  boost::posix_time::time_period getTestPeriod() const {
1070  using namespace boost::posix_time;
1071  time_period test_period(boot_time_,
1072  microsec_clock::universal_time());
1073  return test_period;
1074  }
1075 
1089  void printStats() const {
1090  if (exchanges_.empty()) {
1092  "no exchange type added for tracking");
1093  }
1094  for (ExchangesMapIterator it = exchanges_.begin();
1095  it != exchanges_.end();
1096  ++it) {
1097  ExchangeStatsPtr xchg_stats = it->second;
1098  std::cout << "***Statistics for: " << it->first
1099  << "***" << std::endl;
1100  xchg_stats->printMainStats();
1101  std::cout << std::endl;
1102  xchg_stats->printRTTStats();
1103  std::cout << std::endl;
1104  }
1105  }
1106 
1115  void
1116  printIntermediateStats(bool clean_report, std::string clean_sep) const {
1117  std::ostringstream stream_sent;
1118  std::ostringstream stream_rcvd;
1119  std::ostringstream stream_drops;
1120  std::ostringstream stream_reject;
1121  std::string sep("");
1122  for (ExchangesMapIterator it = exchanges_.begin();
1123  it != exchanges_.end(); ++it) {
1124 
1125  if (it != exchanges_.begin()) {
1126  if (clean_report) {
1127  sep = clean_sep;
1128  } else {
1129  sep = "/";
1130  }
1131  }
1132  stream_sent << sep << it->second->getSentPacketsNum();
1133  stream_rcvd << sep << it->second->getRcvdPacketsNum();
1134  stream_drops << sep << it->second->getDroppedPacketsNum();
1135  stream_reject << sep << it->second->getRejLeasesNum();
1136  }
1137 
1138  if (clean_report) {
1139  std::cout << stream_sent.str()
1140  << clean_sep << stream_rcvd.str()
1141  << clean_sep << stream_drops.str()
1142  << clean_sep << stream_reject.str()
1143  << std::endl;
1144 
1145  } else {
1146  std::cout << "sent: " << stream_sent.str()
1147  << "; received: " << stream_rcvd.str()
1148  << "; drops: " << stream_drops.str()
1149  << "; rejected: " << stream_reject.str()
1150  << std::endl;
1151  }
1152  }
1153 
1165  void printTimestamps() const {
1166  if (exchanges_.empty()) {
1168  "no exchange type added for tracking");
1169  }
1170  for (ExchangesMapIterator it = exchanges_.begin();
1171  it != exchanges_.end();
1172  ++it) {
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 (CustomCountersMapIterator it = custom_counters_.begin();
1196  it != custom_counters_.end();
1197  ++it) {
1198  CustomCounterPtr counter = it->second;
1199  std::cout << counter->getName() << ": " << counter->getValue()
1200  << std::endl;
1201  }
1202  }
1203 
1204  std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator> getSentPackets(const ExchangeType xchg_type) const {
1205  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1206  std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator> sent_packets_its = xchg_stats->getSentPackets();
1207  return(sent_packets_its);
1208  }
1209 
1210 private:
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 
1245 typedef boost::shared_ptr<StatsMgr> StatsMgrPtr;
1246 
1247 
1248 } // namespace perfdhcp
1249 } // namespace isc
1250 
1251 #endif // STATS_MGR_H
uint64_t getRcvdPacketsNum(const ExchangeType xchg_type) const
Return total number of received packets.
const CustomCounter & incrementCounter(const std::string &counter_key, const uint64_t value=1)
Increment specified counter.
uint64_t getOrphans() const
Return number of orphan packets.
bool droppedPackets() const
Check if any packet drops occurred.
uint64_t getSentPacketsNum(const ExchangeType xchg_type) const
Return total number of sent packets.
double getAvgUnorderedLookupSetSize(const ExchangeType xchg_type) const
Return average unordered lookup set size.
DHCPv6 SOLICIT-ADVERTISE.
ExchangeType
DHCP packet exchange types.
bool hasExchangeStats(const ExchangeType xchg_type) const
Check if the exchange type has been specified.
uint64_t getRejLeasesNum(const ExchangeType xchg_type) const
Return total number of rejected leases.
ExchangesMap::const_iterator ExchangesMapIterator
Iterator pointing to ExchangesMap.
CustomCounter(const std::string &name)
Constructor.
uint64_t getCollectedNum(const ExchangeType xchg_type) const
Return number of garbage collected packets.
double getMaxDelay() const
Return maximum delay between sent and received packet.
static uint32_t hashTransid(const dhcp::PktPtr &packet)
Hash transaction id of the packet.
uint64_t getValue() const
Return counter value.
std::tuple< typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator > getSentPackets(const ExchangeType xchg_type) const
uint64_t getOrderedLookups(const ExchangeType xchg_type) const
Return number of ordered sent packets lookups.
CustomCountersMap::const_iterator CustomCountersMapIterator
Iterator for CustomCountersMap.
std::queue< PktListTransidHashIterator > PktListRemovalQueue
Packet list iterator queue for removal.
double getAvgUnorderedLookupSetSize() const
Return average unordered lookup set size.
uint64_t getRcvdPacketsNum() const
Return total number of received packets.
STL namespace.
void updateRejLeases()
Increase number of rejected leases.
uint64_t getNonUniqueAddrNum(const ExchangeType xchg_type) const
Return total number of non unique addresses.
void appendSent(const dhcp::PktPtr &packet)
Add new packet to list of sent packets.
void updateDelays(const dhcp::PktPtr &sent_packet, const dhcp::PktPtr &rcvd_packet)
Update delay counters.
void printMainStats() const
Print main statistics for packet exchange.
void printCustomCounters() const
Print names and values of custom counters.
double getMinDelay() const
Return minimum delay between sent and received packet.
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 printRTTStats() const
Print round trip time packets statistics.
double getAvgDelay() const
Return average packet delay.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
double getMaxDelay(const ExchangeType xchg_type) const
Return maximum delay between sent and received packet.
uint64_t getUnorderedLookups() const
Return number of unordered sent packets lookups.
uint64_t getCollectedNum() const
Return number of garbage collected packets.
DHCPv4 REQUEST-ACK (renewal)
std::map< std::string, CustomCounterPtr > CustomCountersMap
Map containing custom counters.
boost::shared_ptr< StatsMgr > StatsMgrPtr
Pointer to Statistics Manager;.
DHCPv6 RELEASE-REPLY.
void printLeases() const
Print the list of received leases.
int dhcpVersion(ExchangeType const exchange_type)
Get the DHCP version that fits the exchange type.
void updateRejLeases(const ExchangeType xchg_type)
Increase total number of rejected leases.
std::ostream & operator<<(std::ostream &os, ExchangeType xchg_type)
Return name of the exchange.
CustomCounterPtr getCounter(const std::string &counter_key)
Return specified counter.
const std::string & getName() const
Return counter name.
uint64_t getOrderedLookups() const
Return number of ordered sent packets lookups.
uint64_t getNonUniqueAddrNum() const
Return total number of non unique addresses.
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
Definition: pkt.h:797
dhcp::PktPtr passRcvdPacket(const ExchangeType xchg_type, const dhcp::PktPtr &packet)
Add new received packet and match with sent packet.
const CustomCounter & operator+=(int val)
void updateNonUniqueAddr()
Increase number of non unique addresses.
void printStats() const
Print statistics counters for all exchange types.
double getAvgDelay(const ExchangeType xchg_type) const
Return average packet delay.
dhcp::PktPtr matchPackets(const dhcp::PktPtr &rcvd_packet)
Match received packet with the corresponding sent packet.
const CustomCounter & operator++()
Increment operator.
This is a base class for exceptions thrown from the DNS library module.
uint64_t getDroppedPacketsNum(const ExchangeType xchg_type) const
Return total number of dropped packets.
Defines the logger used by the top-level component of kea-dhcp-ddns.
PktList::iterator PktListIterator
Packet list iterator for sequential access to elements.
PktList::template nth_index< 1 >::type PktListTransidHashIndex
Packet list index to search packets using transaction id hash.
void appendRcvd(const dhcp::PktPtr &packet)
Add new packet to list of received packets.
void printIntermediateStats(bool clean_report, std::string clean_sep) const
Print intermediate statistics.
void addExchangeStats(const ExchangeType xchg_type, const double drop_time=-1)
Specify new exchange type.
DHCPv4 DISCOVER-OFFER.
PktListTransidHashIndex::const_iterator PktListTransidHashIterator
Packet list iterator to access packets using transaction id hash.
uint64_t getUnorderedLookups(const ExchangeType xchg_type) const
Return number of unordered sent packets lookups.
uint64_t getOrphans(const ExchangeType xchg_type) const
Return number of orphan packets.
DHCPv6 REQUEST-REPLY.
uint64_t getSentPacketsNum() const
Return total number of sent packets.
A generic exception that is thrown if a function is called in a prohibited way.
double getStdDevDelay() const
Return standard deviation of packet delay.
double getMinDelay(const ExchangeType xchg_type) const
Return minimum delay between sent and received packet.
double getStdDevDelay(const ExchangeType xchg_type) const
Return standard deviation of packet delay.
void addCustomCounter(const std::string &short_name, const std::string &long_name)
Add named custom uint64 counter.
std::tuple< PktListIterator, PktListIterator > getSentPackets()
boost::shared_ptr< ExchangeStats > ExchangeStatsPtr
Pointer to ExchangeStats.
boost::shared_ptr< CustomCounter > CustomCounterPtr
uint64_t getDroppedPacketsNum() const
Return number of dropped packets.
boost::posix_time::time_period getTestPeriod() const
Get time period since the start of test.
std::map< ExchangeType, ExchangeStatsPtr > ExchangesMap
Map containing all specified exchange types.
void updateNonUniqueAddrNum(const ExchangeType xchg_type)
Increase total number of non unique addresses.
uint64_t getRejLeasesNum() const
Return total number of rejected leases.
void printTimestamps()
Print timestamps for sent and received packets.
void printTimestamps() const
Print timestamps of all packets.
void passSentPacket(const ExchangeType xchg_type, const dhcp::PktPtr &packet)
Adds new packet to the sent packets list.
std::string receivedLeases() const
Return the list of received leases in CSV format as string.
const CustomCounter & operator++(int)
Increment operator.