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

Exchange Statistics. More...

#include <stats_mgr.h>

Public Types

typedef boost::multi_index_container< boost::shared_ptr< T >, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::ordered_non_unique< boost::multi_index::global_fun< const boost::shared_ptr< T > &, uint32_t, &ExchangeStats::hashTransid > > > > PktList
 List of packets (sent or received). More...
 
typedef PktList::iterator PktListIterator
 Packet list iterator for sequential access to elements. More...
 
typedef std::queue< PktListTransidHashIteratorPktListRemovalQueue
 Packet list iterator queue for removal. More...
 
typedef PktList::template nth_index< 1 >::type PktListTransidHashIndex
 Packet list index to search packets using transaction id hash. More...
 
typedef PktListTransidHashIndex::const_iterator PktListTransidHashIterator
 Packet list iterator to access packets using transaction id hash. More...
 

Public Member Functions

 ExchangeStats (const ExchangeType xchg_type, const double drop_time, const bool archive_enabled, const boost::posix_time::ptime boot_time)
 Constructor. More...
 
void appendRcvd (const boost::shared_ptr< T > &packet)
 Add new packet to list of received packets. More...
 
void appendSent (const boost::shared_ptr< T > &packet)
 Add new packet to list of sent packets. More...
 
double getAvgDelay () const
 Return average packet delay. More...
 
double getAvgUnorderedLookupSetSize () const
 Return average unordered lookup set size. More...
 
uint64_t getCollectedNum () const
 Return number of garbage collected packets. More...
 
uint64_t getDroppedPacketsNum () const
 Return number of dropped packets. More...
 
double getMaxDelay () const
 Return maximum delay between sent and received packet. More...
 
double getMinDelay () const
 Return minimum delay between sent and received packet. More...
 
uint64_t getOrderedLookups () const
 Return number of ordered sent packets lookups. More...
 
uint64_t getOrphans () const
 Return number of orphan packets. More...
 
uint64_t getRcvdPacketsNum () const
 Return total number of received packets. More...
 
uint64_t getSentPacketsNum () const
 Return total number of sent packets. More...
 
double getStdDevDelay () const
 Return standard deviation of packet delay. More...
 
uint64_t getUnorderedLookups () const
 Return number of unordered sent packets lookups. More...
 
boost::shared_ptr< T > matchPackets (const boost::shared_ptr< T > &rcvd_packet)
 Match received packet with the corresponding sent packet. More...
 
void printMainStats () const
 Print main statistics for packet exchange. More...
 
void printRTTStats () const
 Print round trip time packets statistics. More...
 
void printTimestamps ()
 Print timestamps for sent and received packets. More...
 
void updateDelays (const boost::shared_ptr< T > &sent_packet, const boost::shared_ptr< T > &rcvd_packet)
 Update delay counters. More...
 

Static Public Member Functions

static uint32_t hashTransid (const boost::shared_ptr< T > &packet)
 Hash transaction id of the packet. More...
 

Detailed Description

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

Exchange Statistics.

This class collects statistics for exchanges. Parent class may define number of different packet exchanges like: DHCPv4 DISCOVER-OFFER, DHCPv6 SOLICIT-ADVERTISE etc. Performance statistics will be collected for each of those separately in corresponding instance of ExchangeStats.

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

Member Typedef Documentation

◆ PktList

template<class T = dhcp::Pkt4>
typedef boost::multi_index_container< boost::shared_ptr<T>, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::ordered_non_unique< boost::multi_index::global_fun< const boost::shared_ptr<T>&, uint32_t, &ExchangeStats::hashTransid > > > > isc::perfdhcp::StatsMgr< T >::ExchangeStats::PktList

List of packets (sent or received).

List of packets based on multi index container allows efficient search of packets based on their sequence (order in which they were inserted) as well as based on their hashed transaction id. The first index (sequenced) provides the way to use container as a regular list (including iterators, removal of elements from the middle of the collection etc.). This index is meant to be used more frequently than the latter one and it is based on the assumption that responses from the DHCP server are received in order. In this case, when next packet is received it can be matched with next packet on the list of sent packets. This prevents intensive searches on the list of sent packets every time new packet arrives. In many cases however packets can be dropped by the server or may be sent out of order and we still want to have ability to search packets using transaction id. The second index can be used for this purpose. This index is hashing transaction ids using custom function hashTransid. Note that other possibility would be to simply specify index that uses transaction id directly (instead of hashing with hashTransid). In this case however we have chosen to use hashing function because it shortens the index size to just 1023 values maximum. Search operation on this index generally returns the range of packets that have the same transaction id hash assigned but most often these ranges will be short so further search within a range to find a packet with particular transaction id will not be intensive.

Example 1: Add elements to the list

PktList packets_collection();
boost::shared_ptr<Pkt4> pkt1(new Pkt4(...));
boost::shared_ptr<Pkt4> pkt2(new Pkt4(...));
// Add new packet to the container, it will be available through
// both indexes
packets_collection.push_back(pkt1);
// Here is another way to add packet to the container. The result
// is exactly the same as previously.
packets_collection.template get<0>().push_back(pkt2);

Example 2: Access elements through sequential index

PktList packets_collection();
... # Add elements to the container
for (PktListIterator it = packets_collection.begin();
it != packets_collection.end();
++it) {
boost::shared_ptr<Pkt4> pkt = *it;
# Do something with packet;
}

Example 3: Access elements through ordered index by hash

// Get the instance of the second search index.
PktListTransidHashIndex& idx = sent_packets_.template get<1>();
// Get the range (bucket) of packets sharing the same transaction
// id hash.
std::pair<PktListTransidHashIterator,PktListTransidHashIterator> p =
idx.equal_range(hashTransid(rcvd_packet));
// Iterate through the returned bucket.
for (PktListTransidHashIterator it = p.first; it != p.second;
++it) {
boost::shared_ptr pkt = *it;
... # Do something with the packet (e.g. check transaction id)
}

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

◆ PktListIterator

template<class T = dhcp::Pkt4>
typedef PktList::iterator isc::perfdhcp::StatsMgr< T >::ExchangeStats::PktListIterator

Packet list iterator for sequential access to elements.

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

◆ PktListRemovalQueue

template<class T = dhcp::Pkt4>
typedef std::queue<PktListTransidHashIterator> isc::perfdhcp::StatsMgr< T >::ExchangeStats::PktListRemovalQueue

Packet list iterator queue for removal.

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

◆ PktListTransidHashIndex

template<class T = dhcp::Pkt4>
typedef PktList::template nth_index<1>::type isc::perfdhcp::StatsMgr< T >::ExchangeStats::PktListTransidHashIndex

Packet list index to search packets using transaction id hash.

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

◆ PktListTransidHashIterator

template<class T = dhcp::Pkt4>
typedef PktListTransidHashIndex::const_iterator isc::perfdhcp::StatsMgr< T >::ExchangeStats::PktListTransidHashIterator

Packet list iterator to access packets using transaction id hash.

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

Constructor & Destructor Documentation

◆ ExchangeStats()

template<class T = dhcp::Pkt4>
isc::perfdhcp::StatsMgr< T >::ExchangeStats::ExchangeStats ( const ExchangeType  xchg_type,
const double  drop_time,
const bool  archive_enabled,
const boost::posix_time::ptime  boot_time 
)
inline

Constructor.

Parameters
xchg_typeexchange type
drop_timemaximum time elapsed before packet is assumed dropped. Negative value disables it.
archive_enabledif true packets archive mode is enabled. In this mode all packets are stored throughout the test execution.
boot_timeHolds the timestamp when perfdhcp has been started.

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

Member Function Documentation

◆ appendRcvd()

template<class T = dhcp::Pkt4>
void isc::perfdhcp::StatsMgr< T >::ExchangeStats::appendRcvd ( const boost::shared_ptr< T > &  packet)
inline

Add new packet to list of received packets.

Method adds new packet to list of received packets.

Parameters
packetpacket object to be added.
Exceptions
isc::BadValueif packet is null.

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

References isc_throw.

◆ appendSent()

template<class T = dhcp::Pkt4>
void isc::perfdhcp::StatsMgr< T >::ExchangeStats::appendSent ( const boost::shared_ptr< T > &  packet)
inline

Add new packet to list of sent packets.

Method adds new packet to list of sent packets.

Parameters
packetpacket object to be added.
Exceptions
isc::BadValueif packet is null.

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

References isc_throw.

◆ getAvgDelay()

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

Return average packet delay.

Method returns average packet delay. If no packets have been received for this exchange avg delay can't be calculated and thus method throws exception.

Exceptions
isc::InvalidOperationif no packets for this exchange have been received yet.
Returns
average packet delay.

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

References isc_throw.

Referenced by isc::perfdhcp::StatsMgr< T >::ExchangeStats::getStdDevDelay(), and isc::perfdhcp::StatsMgr< T >::ExchangeStats::printRTTStats().

◆ getAvgUnorderedLookupSetSize()

template<class T = dhcp::Pkt4>
double isc::perfdhcp::StatsMgr< T >::ExchangeStats::getAvgUnorderedLookupSetSize ( ) 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.

Exceptions
isc::InvalidOperationif there have been no unordered lookups yet.
Returns
average unordered lookup set size.

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

References isc_throw.

◆ getCollectedNum()

template<class T = dhcp::Pkt4>
uint64_t isc::perfdhcp::StatsMgr< T >::ExchangeStats::getCollectedNum ( ) 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.

Returns
number of garbage collected packets.

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

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

◆ getDroppedPacketsNum()

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

Return number of dropped packets.

Method returns number of dropped packets.

Returns
number of dropped packets.

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

References isc::perfdhcp::StatsMgr< T >::ExchangeStats::getRcvdPacketsNum(), and isc::perfdhcp::StatsMgr< T >::ExchangeStats::getSentPacketsNum().

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

+ Here is the call graph for this function:

◆ getMaxDelay()

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

Return maximum delay between sent and received packet.

Method returns maximum delay between sent and received packet.

Returns
maximum delay between packets.

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

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

◆ getMinDelay()

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

Return minimum delay between sent and received packet.

Method returns minimum delay between sent and received packet.

Returns
minimum delay between packets.

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

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

◆ getOrderedLookups()

template<class T = dhcp::Pkt4>
uint64_t isc::perfdhcp::StatsMgr< T >::ExchangeStats::getOrderedLookups ( ) 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).

Returns
number of ordered lookups.

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

◆ getOrphans()

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

Return number of orphan packets.

Method returns number of received packets that had no matching sent packet. It is possible that such packet was late or not for us.

Returns
number of orphan received packets.

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

◆ getRcvdPacketsNum()

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

Return total number of received packets.

Method returns total number of received packets.

Returns
number of received packets.

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

Referenced by isc::perfdhcp::StatsMgr< T >::ExchangeStats::getDroppedPacketsNum(), and isc::perfdhcp::StatsMgr< T >::ExchangeStats::printMainStats().

◆ getSentPacketsNum()

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

Return total number of sent packets.

Method returns total number of sent packets.

Returns
number of sent packets.

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

Referenced by isc::perfdhcp::StatsMgr< T >::ExchangeStats::getDroppedPacketsNum(), and isc::perfdhcp::StatsMgr< T >::ExchangeStats::printMainStats().

◆ getStdDevDelay()

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

Return standard deviation of packet delay.

Method returns standard deviation of packet delay. If no packets have been received for this exchange, the standard deviation can't be calculated and thus method throws exception.

Exceptions
isc::InvalidOperationif number of received packets for the exchange is equal to zero.
Returns
standard deviation of packet delay.

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

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

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

+ Here is the call graph for this function:

◆ getUnorderedLookups()

template<class T = dhcp::Pkt4>
uint64_t isc::perfdhcp::StatsMgr< T >::ExchangeStats::getUnorderedLookups ( ) 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.

Returns
number of unordered lookups.

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

◆ hashTransid()

template<class T = dhcp::Pkt4>
static uint32_t isc::perfdhcp::StatsMgr< T >::ExchangeStats::hashTransid ( const boost::shared_ptr< T > &  packet)
inlinestatic

Hash transaction id of the packet.

Function hashes transaction id of the packet. Hashing is non-unique. Many packets may have the same hash value and thus they belong to the same packet buckets. Packet buckets are used for unordered packets search with multi index container.

Parameters
packetpacket which transaction id is to be hashed.
Exceptions
isc::BadValueif packet is null.
Returns
transaction id hash.

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

References isc_throw.

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

◆ matchPackets()

template<class T = dhcp::Pkt4>
boost::shared_ptr<T> isc::perfdhcp::StatsMgr< T >::ExchangeStats::matchPackets ( const boost::shared_ptr< T > &  rcvd_packet)
inline

Match received packet with the corresponding sent packet.

Method finds packet with specified transaction id on the list of sent packets. It is used to match received packet with corresponding sent packet. Since packets from the server most often come in the same order as they were sent by client, this method will first check if next sent packet matches. If it doesn't, function will search the packet using indexing by transaction id. This reduces packet search time significantly.

Parameters
rcvd_packetreceived packet to be matched with sent packet.
Exceptions
isc::BadValueif received packet is null.
Returns
packet having specified transaction or NULL if packet not found

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

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

+ Here is the call graph for this function:

◆ printMainStats()

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

Print main statistics for packet exchange.

Method prints main statistics for particular exchange. Statistics includes: number of sent and received packets, number of dropped packets and number of orphans.

Todo:
Currently the number of orphans is not displayed because Reply messages received for Renew and Releases are counted as orphans for the 4-way exchanges, which is wrong. We will need to move the orphans counting out of the Statistics Manager so as orphans counter is increased only if the particular message is not identified as a response to any of the messages sent by perfdhcp.

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

References isc::perfdhcp::StatsMgr< T >::ExchangeStats::getDroppedPacketsNum(), isc::perfdhcp::StatsMgr< T >::ExchangeStats::getRcvdPacketsNum(), and isc::perfdhcp::StatsMgr< T >::ExchangeStats::getSentPacketsNum().

+ Here is the call graph for this function:

◆ printRTTStats()

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

Print round trip time packets statistics.

Method prints round trip time packets statistics. Statistics includes minimum packet delay, maximum packet delay, average packet delay and standard deviation of delays. Packet delay is a duration between sending a packet to server and receiving response from server.

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

References isc::perfdhcp::StatsMgr< T >::ExchangeStats::getAvgDelay(), isc::perfdhcp::StatsMgr< T >::ExchangeStats::getCollectedNum(), isc::perfdhcp::StatsMgr< T >::ExchangeStats::getMaxDelay(), isc::perfdhcp::StatsMgr< T >::ExchangeStats::getMinDelay(), and isc::perfdhcp::StatsMgr< T >::ExchangeStats::getStdDevDelay().

+ Here is the call graph for this function:

◆ printTimestamps()

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

Print timestamps for sent and received packets.

Method prints timestamps for all sent and received packets for packet exchange. In order to run this method the packets archiving mode has to be enabled during object constructions. Otherwise sent packets are not stored during tests execution and this method has no ability to get and print their timestamps.

Exceptions
isc::InvalidOperationif found packet with no timestamp or if packets archive mode is disabled.

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

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

+ Here is the call graph for this function:

◆ updateDelays()

template<class T = dhcp::Pkt4>
void isc::perfdhcp::StatsMgr< T >::ExchangeStats::updateDelays ( const boost::shared_ptr< T > &  sent_packet,
const boost::shared_ptr< T > &  rcvd_packet 
)
inline

Update delay counters.

Method updates delay counters based on timestamps of sent and received packets.

Parameters
sent_packetsent packet
rcvd_packetreceived packet
Exceptions
isc::BadValueif sent or received packet is null.
isc::Unexpectedif failed to calculate timestamps

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

References isc_throw.


The documentation for this class was generated from the following file:
isc::perfdhcp::StatsMgr::ExchangeStats::PktListTransidHashIterator
PktListTransidHashIndex::const_iterator PktListTransidHashIterator
Packet list iterator to access packets using transaction id hash.
Definition: bin/perfdhcp/stats_mgr.h:256
isc::perfdhcp::StatsMgr::ExchangeStats::PktList
boost::multi_index_container< boost::shared_ptr< T >, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::ordered_non_unique< boost::multi_index::global_fun< const boost::shared_ptr< T > &, uint32_t, &ExchangeStats::hashTransid > > > > PktList
List of packets (sent or received).
Definition: bin/perfdhcp/stats_mgr.h:247
isc::perfdhcp::StatsMgr::ExchangeStats::PktListIterator
PktList::iterator PktListIterator
Packet list iterator for sequential access to elements.
Definition: bin/perfdhcp/stats_mgr.h:250
isc::perfdhcp::StatsMgr::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:253
isc::perfdhcp::StatsMgr::ExchangeStats::hashTransid
static uint32_t hashTransid(const boost::shared_ptr< T > &packet)
Hash transaction id of the packet.
Definition: bin/perfdhcp/stats_mgr.h:145