Kea  1.5.0
isc::perfdhcp::StatsMgr< T > Class Template Reference

Statistics Manager. More...

#include <stats_mgr.h>

+ Inheritance diagram for isc::perfdhcp::StatsMgr< T >:

Classes

class  CustomCounter
 Custom Counter. More...
 
class  ExchangeStats
 Exchange Statistics. More...
 

Public Types

typedef boost::shared_ptr< CustomCounterCustomCounterPtr
 
typedef std::map< std::string, CustomCounterPtrCustomCountersMap
 Map containing custom counters. More...
 
typedef CustomCountersMap::const_iterator CustomCountersMapIterator
 Iterator for CustomCountersMap. More...
 
typedef std::map< ExchangeType, ExchangeStatsPtrExchangesMap
 Map containing all specified exchange types. More...
 
typedef ExchangesMap::const_iterator ExchangesMapIterator
 Iterator pointing to ExchangesMap. More...
 
typedef boost::shared_ptr< ExchangeStatsExchangeStatsPtr
 Pointer to ExchangeStats. More...
 
enum  ExchangeType {
  XCHG_DO, XCHG_RA, XCHG_RNA, XCHG_SA,
  XCHG_RR, XCHG_RN, XCHG_RL
}
 DHCP packet exchange types. More...
 

Public Member Functions

 StatsMgr (const bool archive_enabled=false)
 Constructor. More...
 
void addCustomCounter (const std::string &short_name, const std::string &long_name)
 Add named custom uint64 counter. More...
 
void addExchangeStats (const ExchangeType xchg_type, const double drop_time=-1)
 Specify new exchange type. More...
 
bool droppedPackets () const
 Check if any packet drops occurred. More...
 
double getAvgDelay (const ExchangeType xchg_type) const
 Return average packet delay. More...
 
double getAvgUnorderedLookupSetSize (const ExchangeType xchg_type) const
 Return average unordered lookup set size. More...
 
uint64_t getCollectedNum (const ExchangeType xchg_type) const
 Return number of garbage collected packets. More...
 
CustomCounterPtr getCounter (const std::string &counter_key)
 Return specified counter. More...
 
uint64_t getDroppedPacketsNum (const ExchangeType xchg_type) const
 Return total number of dropped packets. More...
 
double getMaxDelay (const ExchangeType xchg_type) const
 Return maximum delay between sent and received packet. More...
 
double getMinDelay (const ExchangeType xchg_type) const
 Return minimum delay between sent and received packet. More...
 
uint64_t getOrderedLookups (const ExchangeType xchg_type) const
 Return number of ordered sent packets lookups. More...
 
uint64_t getOrphans (const ExchangeType xchg_type) const
 Return number of orphan packets. More...
 
uint64_t getRcvdPacketsNum (const ExchangeType xchg_type) const
 Return total number of received packets. More...
 
uint64_t getSentPacketsNum (const ExchangeType xchg_type) const
 Return total number of sent packets. More...
 
double getStdDevDelay (const ExchangeType xchg_type) const
 Return standard deviation of packet delay. More...
 
boost::posix_time::time_period getTestPeriod () const
 Get time period since the start of test. More...
 
uint64_t getUnorderedLookups (const ExchangeType xchg_type) const
 Return number of unordered sent packets lookups. More...
 
bool hasExchangeStats (const ExchangeType xchg_type) const
 Check if the exchange type has been specified. More...
 
const CustomCounterincrementCounter (const std::string &counter_key, const uint64_t value=1)
 Increment specified counter. More...
 
boost::shared_ptr< T > passRcvdPacket (const ExchangeType xchg_type, const boost::shared_ptr< T > &packet)
 Add new received packet and match with sent packet. More...
 
void passSentPacket (const ExchangeType xchg_type, const boost::shared_ptr< T > &packet)
 Adds new packet to the sent packets list. More...
 
void printCustomCounters () const
 Print names and values of custom counters. More...
 
void printIntermediateStats () const
 Print intermediate statistics. More...
 
void printStats () const
 Print statistics counters for all exchange types. More...
 
void printTimestamps () const
 Print timestamps of all packets. More...
 

Static Public Member Functions

static std::string exchangeToString (ExchangeType xchg_type)
 Return name of the exchange. More...
 

Detailed Description

template<class T = dhcp::Pkt4>
class isc::perfdhcp::StatsMgr< T >

Statistics Manager.

This class template is a storage for various performance statistics collected during performance tests execution with perfdhcp tool.

Statistics Manager holds lists of sent and received packets and groups them into exchanges. For example: DHCPDISCOVER message and corresponding DHCPOFFER messages belong to one exchange, DHCPREQUEST and corresponding DHCPACK message belong to another exchange etc. In order to update statistics for a particular exchange type, client class passes sent and received packets. Internally, Statistics Manager tries to match transaction id of received packet with sent packet stored on the list of sent packets. When packets are matched the round trip time can be calculated.

Parameters
Tclass representing DHCPv4 or DHCPv6 packet.

Definition at line 48 of file bin/perfdhcp/stats_mgr.h.

Member Typedef Documentation

◆ CustomCounterPtr

template<class T = dhcp::Pkt4>
typedef boost::shared_ptr<CustomCounter> isc::perfdhcp::StatsMgr< T >::CustomCounterPtr

Definition at line 112 of file bin/perfdhcp/stats_mgr.h.

◆ CustomCountersMap

template<class T = dhcp::Pkt4>
typedef std::map<std::string, CustomCounterPtr> isc::perfdhcp::StatsMgr< T >::CustomCountersMap

Map containing custom counters.

Definition at line 877 of file bin/perfdhcp/stats_mgr.h.

◆ CustomCountersMapIterator

template<class T = dhcp::Pkt4>
typedef CustomCountersMap::const_iterator isc::perfdhcp::StatsMgr< T >::CustomCountersMapIterator

Iterator for CustomCountersMap.

Definition at line 879 of file bin/perfdhcp/stats_mgr.h.

◆ ExchangesMap

template<class T = dhcp::Pkt4>
typedef std::map<ExchangeType, ExchangeStatsPtr> isc::perfdhcp::StatsMgr< T >::ExchangesMap

Map containing all specified exchange types.

Definition at line 873 of file bin/perfdhcp/stats_mgr.h.

◆ ExchangesMapIterator

template<class T = dhcp::Pkt4>
typedef ExchangesMap::const_iterator isc::perfdhcp::StatsMgr< T >::ExchangesMapIterator

Iterator pointing to ExchangesMap.

Definition at line 875 of file bin/perfdhcp/stats_mgr.h.

◆ ExchangeStatsPtr

template<class T = dhcp::Pkt4>
typedef boost::shared_ptr<ExchangeStats> isc::perfdhcp::StatsMgr< T >::ExchangeStatsPtr

Pointer to ExchangeStats.

Definition at line 871 of file bin/perfdhcp/stats_mgr.h.

Member Enumeration Documentation

◆ ExchangeType

template<class T = dhcp::Pkt4>
enum isc::perfdhcp::StatsMgr::ExchangeType

DHCP packet exchange types.

Enumerator
XCHG_DO 

DHCPv4 DISCOVER-OFFER.

XCHG_RA 

DHCPv4 REQUEST-ACK.

XCHG_RNA 

DHCPv4 REQUEST-ACK (renewal)

XCHG_SA 

DHCPv6 SOLICIT-ADVERTISE.

XCHG_RR 

DHCPv6 REQUEST-REPLY.

XCHG_RN 

DHCPv6 RENEW-REPLY.

XCHG_RL 

DHCPv6 RELEASE-REPLY.

Definition at line 115 of file bin/perfdhcp/stats_mgr.h.

Constructor & Destructor Documentation

◆ StatsMgr()

template<class T = dhcp::Pkt4>
isc::perfdhcp::StatsMgr< T >::StatsMgr ( const bool  archive_enabled = false)
inline

Constructor.

This constructor by default disables packets archiving mode. In this mode all packets from the list of sent packets are moved to list of archived packets once they have been matched with received packets. This is required if it has been selected from the command line to print timestamps for all packets after the test. If this is not selected archiving should be disabled for performance reasons and to avoid waste of memory for storing large list of archived packets.

Parameters
archive_enabledtrue indicates that packets archive mode is enabled.

Definition at line 894 of file bin/perfdhcp/stats_mgr.h.

Member Function Documentation

◆ addCustomCounter()

template<class T = dhcp::Pkt4>
void isc::perfdhcp::StatsMgr< T >::addCustomCounter ( const std::string &  short_name,
const std::string &  long_name 
)
inline

Add named custom uint64 counter.

Method creates new named counter and stores in counter's map under key specified here as short_name.

Parameters
short_namekey to use to access counter in the map.
long_namename of the counter presented in the log file.

Definition at line 943 of file bin/perfdhcp/stats_mgr.h.

References isc_throw.

◆ addExchangeStats()

template<class T = dhcp::Pkt4>
void isc::perfdhcp::StatsMgr< T >::addExchangeStats ( const ExchangeType  xchg_type,
const double  drop_time = -1 
)
inline

Specify new exchange type.

This method creates new ExchangeStats object that will collect statistics data from packets exchange of the specified type.

Parameters
xchg_typeexchange type.
drop_timemaximum time elapsed before packet is assumed dropped. Negative value disables it.
Exceptions
isc::BadValueif exchange of specified type exists.

Definition at line 910 of file bin/perfdhcp/stats_mgr.h.

References isc_throw.

◆ droppedPackets()

template<class T = dhcp::Pkt4>
bool isc::perfdhcp::StatsMgr< T >::droppedPackets ( ) const
inline

Check if any packet drops occurred.

Definition at line 956 of file bin/perfdhcp/stats_mgr.h.

◆ exchangeToString()

template<class T = dhcp::Pkt4>
static std::string isc::perfdhcp::StatsMgr< T >::exchangeToString ( ExchangeType  xchg_type)
inlinestatic

Return name of the exchange.

Method returns name of the specified exchange type. This function is mainly for logging purposes.

Parameters
xchg_typeexchange type.
Returns
string representing name of the exchange.

Definition at line 1224 of file bin/perfdhcp/stats_mgr.h.

References isc::perfdhcp::StatsMgr< T >::XCHG_DO, isc::perfdhcp::StatsMgr< T >::XCHG_RA, isc::perfdhcp::StatsMgr< T >::XCHG_RL, isc::perfdhcp::StatsMgr< T >::XCHG_RN, isc::perfdhcp::StatsMgr< T >::XCHG_RNA, isc::perfdhcp::StatsMgr< T >::XCHG_RR, and isc::perfdhcp::StatsMgr< T >::XCHG_SA.

Referenced by isc::perfdhcp::StatsMgr< T >::printStats(), and isc::perfdhcp::StatsMgr< T >::printTimestamps().

◆ getAvgDelay()

template<class T = dhcp::Pkt4>
double isc::perfdhcp::StatsMgr< T >::getAvgDelay ( const ExchangeType  xchg_type) const
inline

Return average packet delay.

Method returns average packet delay for specified exchange type.

Returns
average packet delay.

Definition at line 1074 of file bin/perfdhcp/stats_mgr.h.

◆ getAvgUnorderedLookupSetSize()

template<class T = dhcp::Pkt4>
double isc::perfdhcp::StatsMgr< T >::getAvgUnorderedLookupSetSize ( const ExchangeType  xchg_type) const
inline

Return average unordered lookup set size.

Method returns average unordered lookup set size. This value changes every time ExchangeStats::matchPackets function performs unordered packet lookup.

Parameters
xchg_typeexchange type.
Exceptions
isc::BadValueif invalid exchange type specified.
Returns
average unordered lookup set size.

Definition at line 1112 of file bin/perfdhcp/stats_mgr.h.

◆ getCollectedNum()

template<class T = dhcp::Pkt4>
uint64_t isc::perfdhcp::StatsMgr< T >::getCollectedNum ( const ExchangeType  xchg_type) const
inline

Return number of garbage collected packets.

Method returns number of garbage collected timed out packets. Packet is assumed timed out when duration between sending it to server and receiving server's response is greater than value specified with -d<value> command line argument.

Exceptions
isc::BadValueif invalid exchange type specified.
Returns
number of garbage collected packets.

Definition at line 1197 of file bin/perfdhcp/stats_mgr.h.

◆ getCounter()

template<class T = dhcp::Pkt4>
CustomCounterPtr isc::perfdhcp::StatsMgr< T >::getCounter ( const std::string &  counter_key)
inline

Return specified counter.

Method returns specified counter.

Parameters
counter_keykey pointing to the counter in the counters map. The short counter name has to be used to access counter.
Returns
pointer to specified counter object.

Definition at line 974 of file bin/perfdhcp/stats_mgr.h.

References isc_throw.

Referenced by isc::perfdhcp::StatsMgr< T >::incrementCounter().

◆ getDroppedPacketsNum()

template<class T = dhcp::Pkt4>
uint64_t isc::perfdhcp::StatsMgr< T >::getDroppedPacketsNum ( const ExchangeType  xchg_type) const
inline

Return total number of dropped packets.

Method returns total number of dropped packets for specified exchange type.

Parameters
xchg_typeexchange type.
Exceptions
isc::BadValueif invalid exchange type specified.
Returns
number of dropped packets.

Definition at line 1182 of file bin/perfdhcp/stats_mgr.h.

◆ getMaxDelay()

template<class T = dhcp::Pkt4>
double isc::perfdhcp::StatsMgr< T >::getMaxDelay ( const ExchangeType  xchg_type) const
inline

Return maximum delay between sent and received packet.

Method returns maximum delay between sent and received packet for specified exchange type.

Parameters
xchg_typeexchange type.
Exceptions
isc::BadValueif invalid exchange type specified.
Returns
maximum delay between packets.

Definition at line 1063 of file bin/perfdhcp/stats_mgr.h.

◆ getMinDelay()

template<class T = dhcp::Pkt4>
double isc::perfdhcp::StatsMgr< T >::getMinDelay ( const ExchangeType  xchg_type) const
inline

Return minimum delay between sent and received packet.

Method returns minimum delay between sent and received packet for specified exchange type.

Parameters
xchg_typeexchange type.
Exceptions
isc::BadValueif invalid exchange type specified.
Returns
minimum delay between packets.

Definition at line 1050 of file bin/perfdhcp/stats_mgr.h.

◆ getOrderedLookups()

template<class T = dhcp::Pkt4>
uint64_t isc::perfdhcp::StatsMgr< T >::getOrderedLookups ( const ExchangeType  xchg_type) const
inline

Return number of ordered sent packets lookups.

Method returns number of ordered sent packet lookups. Ordered lookup is used when packets are received in the same order as they were sent to the server. If packets are skipped or received out of order, lookup function will use unordered lookup (with hash table).

Parameters
xchg_typeexchange type.
Exceptions
isc::BadValueif invalid exchange type specified.
Returns
number of ordered lookups.

Definition at line 1143 of file bin/perfdhcp/stats_mgr.h.

◆ getOrphans()

template<class T = dhcp::Pkt4>
uint64_t isc::perfdhcp::StatsMgr< T >::getOrphans ( const ExchangeType  xchg_type) const
inline

Return number of orphan packets.

Method returns number of orphan packets for specified exchange type.

Parameters
xchg_typeexchange type.
Exceptions
isc::BadValueif invalid exchange type specified.
Returns
number of orphan packets so far.

Definition at line 1098 of file bin/perfdhcp/stats_mgr.h.

◆ getRcvdPacketsNum()

template<class T = dhcp::Pkt4>
uint64_t isc::perfdhcp::StatsMgr< T >::getRcvdPacketsNum ( const ExchangeType  xchg_type) const
inline

Return total number of received packets.

Method returns total number of received packets for specified exchange type.

Parameters
xchg_typeexchange type.
Exceptions
isc::BadValueif invalid exchange type specified.
Returns
number of received packets.

Definition at line 1169 of file bin/perfdhcp/stats_mgr.h.

◆ getSentPacketsNum()

template<class T = dhcp::Pkt4>
uint64_t isc::perfdhcp::StatsMgr< T >::getSentPacketsNum ( const ExchangeType  xchg_type) const
inline

Return total number of sent packets.

Method returns total number of sent packets for specified exchange type.

Parameters
xchg_typeexchange type.
Exceptions
isc::BadValueif invalid exchange type specified.
Returns
number of sent packets.

Definition at line 1156 of file bin/perfdhcp/stats_mgr.h.

◆ getStdDevDelay()

template<class T = dhcp::Pkt4>
double isc::perfdhcp::StatsMgr< T >::getStdDevDelay ( const ExchangeType  xchg_type) const
inline

Return standard deviation of packet delay.

Method returns standard deviation of packet delay for specified exchange type.

Returns
standard deviation of packet delay.

Definition at line 1085 of file bin/perfdhcp/stats_mgr.h.

◆ getTestPeriod()

template<class T = dhcp::Pkt4>
boost::posix_time::time_period isc::perfdhcp::StatsMgr< T >::getTestPeriod ( ) const
inline

Get time period since the start of test.

Calculate dna return period since the test start. This can be specifically helpful when calculating packet exchange rates.

Returns
test period so far.

Definition at line 1210 of file bin/perfdhcp/stats_mgr.h.

◆ getUnorderedLookups()

template<class T = dhcp::Pkt4>
uint64_t isc::perfdhcp::StatsMgr< T >::getUnorderedLookups ( const ExchangeType  xchg_type) const
inline

Return number of unordered sent packets lookups.

Method returns number of unordered sent packet lookups. Unordered lookup is used when received packet was sent out of order by server - transaction id of received packet does not match transaction id of next sent packet.

Parameters
xchg_typeexchange type.
Exceptions
isc::BadValueif invalid exchange type specified.
Returns
number of unordered lookups.

Definition at line 1127 of file bin/perfdhcp/stats_mgr.h.

◆ hasExchangeStats()

template<class T = dhcp::Pkt4>
bool isc::perfdhcp::StatsMgr< T >::hasExchangeStats ( const ExchangeType  xchg_type) const
inline

Check if the exchange type has been specified.

This method checks if the ExchangeStats object of a particular type exists (has been added using addExchangeStats function).

Parameters
xchg_typeA type of the exchange being represented by the ExchangeStats object.
Returns
true if the ExchangeStats object has been added for a specified exchange type.

Definition at line 932 of file bin/perfdhcp/stats_mgr.h.

◆ incrementCounter()

template<class T = dhcp::Pkt4>
const CustomCounter& isc::perfdhcp::StatsMgr< T >::incrementCounter ( const std::string &  counter_key,
const uint64_t  value = 1 
)
inline

Increment specified counter.

Increment counter value by one.

Parameters
counter_keykey pointing to the counter in the counters map.
valuevalue to increment counter by.
Returns
pointer to specified counter after incrementation.

Definition at line 990 of file bin/perfdhcp/stats_mgr.h.

References isc::perfdhcp::StatsMgr< T >::getCounter().

+ Here is the call graph for this function:

◆ passRcvdPacket()

template<class T = dhcp::Pkt4>
boost::shared_ptr<T> isc::perfdhcp::StatsMgr< T >::passRcvdPacket ( const ExchangeType  xchg_type,
const boost::shared_ptr< T > &  packet 
)
inline

Add new received packet and match with sent packet.

Method adds new packet to the list of received packets. It also searches for corresponding packet on the list of sent packets. When packets are matched the statistics counters are updated accordingly for the particular exchange type.

Parameters
xchg_typeexchange type.
packetreceived packet
Exceptions
isc::BadValueif invalid exchange type specified or packet is null.
isc::Unexpectedif corresponding packet was not found on the list of sent packets.

Definition at line 1027 of file bin/perfdhcp/stats_mgr.h.

◆ passSentPacket()

template<class T = dhcp::Pkt4>
void isc::perfdhcp::StatsMgr< T >::passSentPacket ( const ExchangeType  xchg_type,
const boost::shared_ptr< T > &  packet 
)
inline

Adds new packet to the sent packets list.

Method adds new packet to the sent packets list. Packets are added to the list sequentially and most often read sequentially.

Parameters
xchg_typeexchange type.
packetpacket to be added to the list
Exceptions
isc::BadValueif invalid exchange type specified or packet is null.

Definition at line 1007 of file bin/perfdhcp/stats_mgr.h.

◆ printCustomCounters()

template<class T = dhcp::Pkt4>
void isc::perfdhcp::StatsMgr< T >::printCustomCounters ( ) const
inline

Print names and values of custom counters.

Method prints names and values of custom counters. Custom counters are defined by client class for tracking different statistics.

Exceptions
isc::InvalidOperationif no custom counters added for tracking.

Definition at line 1336 of file bin/perfdhcp/stats_mgr.h.

References isc_throw.

◆ printIntermediateStats()

template<class T = dhcp::Pkt4>
void isc::perfdhcp::StatsMgr< T >::printIntermediateStats ( ) const
inline

Print intermediate statistics.

Method prints intermediate statistics for all exchanges. Statistics includes sent, received and dropped packets counters.

Definition at line 1281 of file bin/perfdhcp/stats_mgr.h.

◆ printStats()

template<class T = dhcp::Pkt4>
void isc::perfdhcp::StatsMgr< T >::printStats ( ) const
inline

Print statistics counters for all exchange types.

Method prints statistics for all exchange types. Statistics includes:

  • number of sent and received packets
  • number of dropped packets and number of orphans
  • minimum packets delay,
  • average packets delay,
  • maximum packets delay,
  • standard deviation of packets delay.
Exceptions
isc::InvalidOperationif no exchange type added to track statistics.

Definition at line 1258 of file bin/perfdhcp/stats_mgr.h.

References isc::perfdhcp::StatsMgr< T >::exchangeToString(), and isc_throw.

+ Here is the call graph for this function:

◆ printTimestamps()

template<class T = dhcp::Pkt4>
void isc::perfdhcp::StatsMgr< T >::printTimestamps ( ) const
inline

Print timestamps of all packets.

Method prints timestamps of all sent and received packets for all defined exchange types.

Exceptions
isc::InvalidOperationif one of the packets has no timestamp value set or if packets archive mode is disabled.
isc::InvalidOperationif no exchange type added to track statistics or packets archive mode is disabled.

Definition at line 1313 of file bin/perfdhcp/stats_mgr.h.

References isc::perfdhcp::StatsMgr< T >::exchangeToString(), and isc_throw.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: