Kea  2.1.7-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  RLA,
37  SA,
38  RR,
39  RN,
40  RL
41 };
42 
48 int dhcpVersion(ExchangeType const exchange_type);
49 
58 std::ostream& operator<<(std::ostream& os, ExchangeType xchg_type);
59 
67 public:
74  CustomCounter(const std::string& name) :
75  counter_(0),
76  name_(name) {
77  }
78 
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 
115 private:
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 
145 public:
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 
235  typedef boost::multi_index_container<
236  // Container holds PktPtr objects.
237  dhcp::PktPtr,
238  // List container indexes.
239  boost::multi_index::indexed_by<
240  // Sequenced index provides the way to use this container
241  // in the same way as std::list.
242  boost::multi_index::sequenced<>,
243  // The other index keeps products of transaction id.
244  // Elements with the same hash value are grouped together
245  // into buckets and transactions are ordered from the
246  // oldest to latest within a bucket.
247  boost::multi_index::ordered_non_unique<
248  // Specify hash function to get the product of
249  // transaction id. This product is obtained by calling
250  // hashTransid() function.
251  boost::multi_index::global_fun<
252  // Hashing function takes PktPtr as argument.
253  const dhcp::PktPtr&,
254  // ... and returns uint32 value.
255  uint32_t,
256  // ... and here is a reference to it.
258  >
259  >
260  >
262 
264  typedef typename PktList::iterator PktListIterator;
266  typedef typename PktList::template nth_index<1>::type
269  typedef typename PktListTransidHashIndex::const_iterator
272  typedef typename std::queue<PktListTransidHashIterator>
274 
283  ExchangeStats(const ExchangeType xchg_type,
284  const double drop_time,
285  const bool archive_enabled,
286  const boost::posix_time::ptime boot_time);
287 
294  void appendSent(const dhcp::PktPtr& packet) {
295  if (!packet) {
296  isc_throw(BadValue, "Packet is null");
297  }
298  static_cast<void>(sent_packets_.template get<0>().push_back(packet));
299  ++sent_packets_num_;
300  }
301 
308  void appendRcvd(const dhcp::PktPtr& packet) {
309  if (!packet) {
310  isc_throw(BadValue, "Packet is null");
311  }
312  static_cast<void>(rcvd_packets_.push_back(packet));
313  }
314 
324  void updateDelays(const dhcp::PktPtr& sent_packet,
325  const dhcp::PktPtr& rcvd_packet);
326 
342  dhcp::PktPtr matchPackets(const dhcp::PktPtr& rcvd_packet);
343 
349  double getMinDelay() const { return(min_delay_); }
350 
356  double getMaxDelay() const { return(max_delay_); }
357 
367  double getAvgDelay() const {
368  if (rcvd_packets_num_ == 0) {
369  isc_throw(InvalidOperation, "no packets received");
370  }
371  return(sum_delay_ / rcvd_packets_num_);
372  }
373 
384  double getStdDevDelay() const {
385  if (rcvd_packets_num_ == 0) {
386  isc_throw(InvalidOperation, "no packets received");
387  }
388  return(sqrt(sum_delay_squared_ / rcvd_packets_num_ -
389  getAvgDelay() * getAvgDelay()));
390  }
391 
399  uint64_t getOrphans() const { return(orphans_); }
400 
410  uint64_t getCollectedNum() const { return(collected_); }
411 
422  if (unordered_lookups_ == 0) {
423  isc_throw(InvalidOperation, "no unordered lookups");
424  }
425  return(static_cast<double>(unordered_lookup_size_sum_) /
426  static_cast<double>(unordered_lookups_));
427  }
428 
437  uint64_t getUnorderedLookups() const { return(unordered_lookups_); }
438 
448  uint64_t getOrderedLookups() const { return(ordered_lookups_); }
449 
455  uint64_t getSentPacketsNum() const { return(sent_packets_num_); }
456 
462  uint64_t getRcvdPacketsNum() const { return(rcvd_packets_num_); }
463 
469  uint64_t getDroppedPacketsNum() const {
470  uint64_t drops = 0;
471  if (getSentPacketsNum() > getRcvdPacketsNum()) {
472  drops = getSentPacketsNum() - getRcvdPacketsNum();
473  }
474  return(drops);
475  }
476 
482  uint64_t getRejLeasesNum() const { return(rejected_leases_num_); }
483 
489  uint64_t getNonUniqueAddrNum() const { return(non_unique_addr_num_); }
490 
494  void updateRejLeases() { ++rejected_leases_num_; }
495 
499  void updateNonUniqueAddr() { ++non_unique_addr_num_; }
500 
514  void printMainStats() const {
515  using namespace std;
516  auto sent = getSentPacketsNum();
517  auto drops = getDroppedPacketsNum();
518  double drops_ratio = 100.0 * static_cast<double>(drops) / static_cast<double>(sent);
519 
520  cout << "sent packets: " << sent << endl
521  << "received packets: " << getRcvdPacketsNum() << endl
522  << "drops: " << drops << endl
523  << "drops ratio: " << drops_ratio << " %" << endl
524  << "orphans: " << getOrphans() << endl
525  << "rejected leases: " << getRejLeasesNum() << endl
526  << "non unique addresses: " << getNonUniqueAddrNum() << endl;
527  }
528 
536  void printRTTStats() const {
537  using namespace std;
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  }
555 
566  void printTimestamps();
567 
568  std::tuple<PktListIterator, PktListIterator> getSentPackets() {
569  return(std::make_tuple(sent_packets_.begin(), sent_packets_.end()));
570  }
571 
580  std::string receivedLeases() const;
581 
583  void printLeases() const;
584 
585  static int malformed_pkts_;
586 
587 // Private stuff of ExchangeStats class
588 private:
589 
594  ExchangeStats();
595 
603  PktListIterator eraseSent(const PktListIterator it) {
604  if (archive_enabled_) {
605  // We don't want to keep list of all sent packets
606  // because it will affect packet lookup performance.
607  // If packet is matched with received packet we
608  // move it to list of archived packets. List of
609  // archived packets may be used for diagnostics
610  // when test is completed.
611  static_cast<void>(archived_packets_.push_back(*it));
612  }
613  // get<0>() template returns sequential index to
614  // container.
615  return(sent_packets_.template get<0>().erase(it));
616  }
617 
618  ExchangeType xchg_type_;
619  PktList sent_packets_;
620 
624  PktListIterator next_sent_;
625 
626  PktList rcvd_packets_;
627 
631  PktList archived_packets_;
632 
644  bool archive_enabled_;
645 
648  double drop_time_;
649 
650  double min_delay_;
651  double max_delay_;
653  double sum_delay_;
655  double sum_delay_squared_;
657 
659  uint64_t orphans_;
660 
661  uint64_t collected_;
662 
668  uint64_t unordered_lookup_size_sum_;
669 
670  uint64_t unordered_lookups_;
671  uint64_t ordered_lookups_;
673 
675  uint64_t sent_packets_num_;
676  uint64_t rcvd_packets_num_;
677 
678  uint64_t non_unique_addr_num_;
679  uint64_t rejected_leases_num_;
681  boost::posix_time::ptime boot_time_;
683 };
684 
686 typedef boost::shared_ptr<ExchangeStats> ExchangeStatsPtr;
687 
689 typedef typename std::map<ExchangeType, ExchangeStatsPtr> ExchangesMap;
690 
692 typedef typename ExchangesMap::const_iterator ExchangesMapIterator;
693 
694 
710 class StatsMgr : public boost::noncopyable {
711 public:
722  StatsMgr(CommandOptions& options);
723 
734  void addExchangeStats(const ExchangeType xchg_type,
735  const double drop_time = -1) {
736  if (exchanges_.find(xchg_type) != exchanges_.end()) {
737  isc_throw(BadValue, "Exchange of specified type already added.");
738  }
739  exchanges_[xchg_type] =
740  ExchangeStatsPtr(new ExchangeStats(xchg_type,
741  drop_time,
742  archive_enabled_,
743  boot_time_));
744  }
745 
756  bool hasExchangeStats(const ExchangeType xchg_type) const {
757  return (exchanges_.find(xchg_type) != exchanges_.end());
758  }
759 
767  void addCustomCounter(const std::string& short_name,
768  const std::string& long_name) {
769  if (custom_counters_.find(short_name) != custom_counters_.end()) {
771  "Custom counter " << short_name << " already added.");
772  }
773  custom_counters_[short_name] =
774  CustomCounterPtr(new CustomCounter(long_name));
775  }
776 
779  // \return true, if packet drops occurred.
780  bool droppedPackets() const {
781  for (ExchangesMapIterator it = exchanges_.begin();
782  it != exchanges_.end();
783  ++it) {
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 
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()) {
1099  "no exchange type added for tracking");
1100  }
1101  for (ExchangesMapIterator it = exchanges_.begin();
1102  it != exchanges_.end();
1103  ++it) {
1104  ExchangeStatsPtr xchg_stats = it->second;
1105  std::cout << "***Statistics for: " << it->first
1106  << "***" << std::endl;
1107  xchg_stats->printMainStats();
1108  std::cout << std::endl;
1109  xchg_stats->printRTTStats();
1110  std::cout << std::endl;
1111  }
1112  }
1113 
1122  void
1123  printIntermediateStats(bool clean_report, std::string clean_sep) const {
1124  std::ostringstream stream_sent;
1125  std::ostringstream stream_rcvd;
1126  std::ostringstream stream_drops;
1127  std::ostringstream stream_reject;
1128  std::string sep("");
1129  for (ExchangesMapIterator it = exchanges_.begin();
1130  it != exchanges_.end(); ++it) {
1131 
1132  if (it != exchanges_.begin()) {
1133  if (clean_report) {
1134  sep = clean_sep;
1135  } else {
1136  sep = "/";
1137  }
1138  }
1139  stream_sent << sep << it->second->getSentPacketsNum();
1140  stream_rcvd << sep << it->second->getRcvdPacketsNum();
1141  stream_drops << sep << it->second->getDroppedPacketsNum();
1142  stream_reject << sep << it->second->getRejLeasesNum();
1143  }
1144 
1145  if (clean_report) {
1146  std::cout << stream_sent.str()
1147  << clean_sep << stream_rcvd.str()
1148  << clean_sep << stream_drops.str()
1149  << clean_sep << stream_reject.str()
1150  << std::endl;
1151 
1152  } else {
1153  std::cout << "sent: " << stream_sent.str()
1154  << "; received: " << stream_rcvd.str()
1155  << "; drops: " << stream_drops.str()
1156  << "; rejected: " << stream_reject.str()
1157  << std::endl;
1158  }
1159  }
1160 
1172  void printTimestamps() const {
1173  if (exchanges_.empty()) {
1175  "no exchange type added for tracking");
1176  }
1177  for (ExchangesMapIterator it = exchanges_.begin();
1178  it != exchanges_.end();
1179  ++it) {
1180  ExchangeStatsPtr xchg_stats = it->second;
1181  std::cout << "***Timestamps for packets: "
1182  << it->first
1183  << "***" << std::endl;
1184  xchg_stats->printTimestamps();
1185  std::cout << std::endl;
1186  }
1187  }
1188 
1190  void printLeases() const;
1191 
1198  void printCustomCounters() const {
1199  if (custom_counters_.empty()) {
1200  isc_throw(isc::InvalidOperation, "no custom counters specified");
1201  }
1202  for (CustomCountersMapIterator it = custom_counters_.begin();
1203  it != custom_counters_.end();
1204  ++it) {
1205  CustomCounterPtr counter = it->second;
1206  std::cout << counter->getName() << ": " << counter->getValue()
1207  << std::endl;
1208  }
1209  }
1210 
1211  std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator> getSentPackets(const ExchangeType xchg_type) const {
1212  ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
1213  std::tuple<typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator> sent_packets_its = xchg_stats->getSentPackets();
1214  return(sent_packets_its);
1215  }
1216 
1217 private:
1218 
1226  ExchangeStatsPtr getExchangeStats(const ExchangeType xchg_type) const {
1227  ExchangesMapIterator it = exchanges_.find(xchg_type);
1228  if (it == exchanges_.end()) {
1229  isc_throw(BadValue, "Packets exchange not specified");
1230  }
1231  ExchangeStatsPtr xchg_stats = it->second;
1232  return(xchg_stats);
1233  }
1234 
1235  ExchangesMap exchanges_;
1236  CustomCountersMap custom_counters_;
1237 
1246  bool archive_enabled_;
1247 
1248  boost::posix_time::ptime boot_time_;
1249 };
1250 
1252 typedef boost::shared_ptr<StatsMgr> StatsMgrPtr;
1253 
1254 
1255 } // namespace perfdhcp
1256 } // namespace isc
1257 
1258 #endif // STATS_MGR_H
const CustomCounter & incrementCounter(const std::string &counter_key, const uint64_t value=1)
Increment specified counter.
uint64_t getRcvdPacketsNum() const
Return total number of received packets.
void printRTTStats() const
Print round trip time packets statistics.
void printStats() const
Print statistics counters for all exchange types.
double getStdDevDelay() const
Return standard deviation of packet delay.
uint64_t getRejLeasesNum(const ExchangeType xchg_type) const
Return total number of rejected leases.
double getStdDevDelay(const ExchangeType xchg_type) const
Return standard deviation of packet delay.
DHCPv6 SOLICIT-ADVERTISE.
ExchangeType
DHCP packet exchange types.
ExchangesMap::const_iterator ExchangesMapIterator
Iterator pointing to ExchangesMap.
CustomCounter(const std::string &name)
Constructor.
uint64_t getRcvdPacketsNum(const ExchangeType xchg_type) const
Return total number of received packets.
static uint32_t hashTransid(const dhcp::PktPtr &packet)
Hash transaction id of the packet.
CustomCountersMap::const_iterator CustomCountersMapIterator
Iterator for CustomCountersMap.
std::queue< PktListTransidHashIterator > PktListRemovalQueue
Packet list iterator queue for removal.
uint64_t getNonUniqueAddrNum() const
Return total number of non unique addresses.
double getMaxDelay(const ExchangeType xchg_type) const
Return maximum delay between sent and received packet.
double getAvgUnorderedLookupSetSize() const
Return average unordered lookup set size.
double getAvgUnorderedLookupSetSize(const ExchangeType xchg_type) const
Return average unordered lookup set size.
STL namespace.
void updateRejLeases()
Increase number of rejected leases.
uint64_t getDroppedPacketsNum() const
Return number of dropped packets.
void appendSent(const dhcp::PktPtr &packet)
Add new packet to list of sent packets.
void printCustomCounters() const
Print names and values of custom counters.
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).
#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...
uint64_t getUnorderedLookups() const
Return number of unordered sent packets lookups.
double getMinDelay(const ExchangeType xchg_type) const
Return minimum delay between sent and received packet.
uint64_t getNonUniqueAddrNum(const ExchangeType xchg_type) const
Return total number of non unique addresses.
uint64_t getOrderedLookups() const
Return number of ordered sent packets lookups.
DHCPv4 REQUEST-ACK (renewal)
std::map< std::string, CustomCounterPtr > CustomCountersMap
Map containing custom counters.
uint64_t getOrphans() const
Return number of orphan packets.
boost::shared_ptr< StatsMgr > StatsMgrPtr
Pointer to Statistics Manager;.
DHCPv6 RELEASE-REPLY.
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.
uint64_t getCollectedNum() const
Return number of garbage collected packets.
CustomCounterPtr getCounter(const std::string &counter_key)
Return specified counter.
const std::string & getName() const
Return counter name.
void printIntermediateStats(bool clean_report, std::string clean_sep) const
Print intermediate statistics.
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.
boost::posix_time::time_period getTestPeriod() const
Get time period since the start of test.
bool hasExchangeStats(const ExchangeType xchg_type) const
Check if the exchange type has been specified.
const CustomCounter & operator++()
Increment operator.
This is a base class for exceptions thrown from the DNS library module.
void printMainStats() const
Print main statistics for packet exchange.
Defines the logger used by the top-level component of kea-lfc.
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.
uint64_t getDroppedPacketsNum(const ExchangeType xchg_type) const
Return total number of dropped packets.
uint64_t getOrphans(const ExchangeType xchg_type) const
Return number of orphan packets.
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.
const Name & name_
Definition: dns/message.cc:693
DHCPv6 REQUEST-REPLY.
A generic exception that is thrown if a function is called in a prohibited way.
double getMaxDelay() const
Return maximum delay between sent and received packet.
double getAvgDelay(const ExchangeType xchg_type) const
Return average packet delay.
uint64_t getUnorderedLookups(const ExchangeType xchg_type) const
Return number of unordered sent packets lookups.
uint64_t getRejLeasesNum() const
Return total number of rejected leases.
uint64_t getOrderedLookups(const ExchangeType xchg_type) const
Return number of ordered sent packets lookups.
uint64_t getValue() const
Return counter value.
void addCustomCounter(const std::string &short_name, const std::string &long_name)
Add named custom uint64 counter.
bool droppedPackets() const
Check if any packet drops occurred.
double getMinDelay() const
Return minimum delay between sent and received packet.
uint64_t getSentPacketsNum() const
Return total number of sent packets.
uint64_t getCollectedNum(const ExchangeType xchg_type) const
Return number of garbage collected packets.
double getAvgDelay() const
Return average packet delay.
std::tuple< PktListIterator, PktListIterator > getSentPackets()
boost::shared_ptr< ExchangeStats > ExchangeStatsPtr
Pointer to ExchangeStats.
boost::shared_ptr< CustomCounter > CustomCounterPtr
unsigned int counter_
Definition: dns/message.cc:221
std::map< ExchangeType, ExchangeStatsPtr > ExchangesMap
Map containing all specified exchange types.
void printTimestamps() const
Print timestamps of all packets.
void updateNonUniqueAddrNum(const ExchangeType xchg_type)
Increase total number of non unique addresses.
uint64_t getSentPacketsNum(const ExchangeType xchg_type) const
Return total number of sent packets.
std::tuple< typename ExchangeStats::PktListIterator, typename ExchangeStats::PktListIterator > getSentPackets(const ExchangeType xchg_type) const
void passSentPacket(const ExchangeType xchg_type, const dhcp::PktPtr &packet)
Adds new packet to the sent packets list.
const CustomCounter & operator++(int)
Increment operator.