Kea 2.7.6
|
Exchange Statistics. More...
#include <stats_mgr.h>
Public Types | |
typedef 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). | |
typedef PktList::iterator | PktListIterator |
Packet list iterator for sequential access to elements. | |
typedef std::queue< PktListTransidHashIterator > | PktListRemovalQueue |
Packet list iterator queue for removal. | |
typedef PktList::template nth_index< 1 >::type | PktListTransidHashIndex |
Packet list index to search packets using transaction id hash. | |
typedef PktListTransidHashIndex::const_iterator | PktListTransidHashIterator |
Packet list iterator to access packets using transaction id hash. | |
Public Member Functions | |
ExchangeStats (const ExchangeType xchg_type, const double drop_time, const bool archive_enabled, const boost::posix_time::ptime boot_time) | |
Constructor. | |
void | appendRcvd (const dhcp::PktPtr &packet) |
Add new packet to list of received packets. | |
void | appendSent (const dhcp::PktPtr &packet) |
Add new packet to list of sent packets. | |
double | getAvgDelay () const |
Return average packet delay. | |
double | getAvgUnorderedLookupSetSize () const |
Return average unordered lookup set size. | |
uint64_t | getCollectedNum () const |
Return number of garbage collected packets. | |
uint64_t | getDroppedPacketsNum () const |
Return number of dropped packets. | |
double | getMaxDelay () const |
Return maximum delay between sent and received packet. | |
double | getMinDelay () const |
Return minimum delay between sent and received packet. | |
uint64_t | getNonUniqueAddrNum () const |
Return total number of non unique addresses. | |
uint64_t | getOrderedLookups () const |
Return number of ordered sent packets lookups. | |
uint64_t | getOrphans () const |
Return number of orphan packets. | |
uint64_t | getRcvdPacketsNum () const |
Return total number of received packets. | |
uint64_t | getRejLeasesNum () const |
Return total number of rejected leases. | |
std::tuple< PktListIterator, PktListIterator > | getSentPackets () |
uint64_t | getSentPacketsNum () const |
Return total number of sent packets. | |
double | getStdDevDelay () const |
Return standard deviation of packet delay. | |
uint64_t | getUnorderedLookups () const |
Return number of unordered sent packets lookups. | |
dhcp::PktPtr | matchPackets (const dhcp::PktPtr &rcvd_packet) |
Match received packet with the corresponding sent packet. | |
void | printLeases () const |
Print the list of received leases. | |
void | printMainStats () const |
Print main statistics for packet exchange. | |
void | printRTTStats () const |
Print round trip time packets statistics. | |
void | printTimestamps () |
Print timestamps for sent and received packets. | |
std::string | receivedLeases () const |
Return the list of received leases in CSV format as string. | |
void | updateDelays (const dhcp::PktPtr &sent_packet, const dhcp::PktPtr &rcvd_packet) |
Update delay counters. | |
void | updateNonUniqueAddr () |
Increase number of non unique addresses. | |
void | updateRejLeases () |
Increase number of rejected leases. | |
Static Public Member Functions | |
static uint32_t | hashTransid (const dhcp::PktPtr &packet) |
Hash transaction id of the packet. | |
Static Public Attributes | |
static int | malformed_pkts_ {0} |
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 144 of file bin/perfdhcp/stats_mgr.h.
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 > > > > isc::perfdhcp::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
Example 2: Access elements through sequential index
Example 3: Access elements through ordered index by hash
Definition at line 259 of file bin/perfdhcp/stats_mgr.h.
PktList::iterator isc::perfdhcp::ExchangeStats::PktListIterator |
Packet list iterator for sequential access to elements.
Definition at line 262 of file bin/perfdhcp/stats_mgr.h.
Packet list iterator queue for removal.
Definition at line 271 of file bin/perfdhcp/stats_mgr.h.
PktList::template nth_index<1>::type isc::perfdhcp::ExchangeStats::PktListTransidHashIndex |
Packet list index to search packets using transaction id hash.
Definition at line 265 of file bin/perfdhcp/stats_mgr.h.
PktListTransidHashIndex::const_iterator isc::perfdhcp::ExchangeStats::PktListTransidHashIterator |
Packet list iterator to access packets using transaction id hash.
Definition at line 268 of file bin/perfdhcp/stats_mgr.h.
isc::perfdhcp::ExchangeStats::ExchangeStats | ( | const ExchangeType | xchg_type, |
const double | drop_time, | ||
const bool | archive_enabled, | ||
const boost::posix_time::ptime | boot_time ) |
Constructor.
xchg_type | exchange type |
drop_time | maximum time elapsed before packet is assumed dropped. Negative value disables it. |
archive_enabled | if true packets archive mode is enabled. In this mode all packets are stored throughout the test execution. |
boot_time | Holds the timestamp when perfdhcp has been started. |
Definition at line 76 of file bin/perfdhcp/stats_mgr.cc.
|
inline |
Add new packet to list of received packets.
Method adds new packet to list of received packets.
packet | packet object to be added. |
isc::BadValue | if packet is null. |
Definition at line 306 of file bin/perfdhcp/stats_mgr.h.
References isc_throw.
|
inline |
Add new packet to list of sent packets.
Method adds new packet to list of sent packets.
packet | packet object to be added. |
isc::BadValue | if packet is null. |
Definition at line 292 of file bin/perfdhcp/stats_mgr.h.
References isc_throw.
|
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.
isc::InvalidOperation | if no packets for this exchange have been received yet. |
Definition at line 365 of file bin/perfdhcp/stats_mgr.h.
References isc_throw.
Referenced by getStdDevDelay(), and printRTTStats().
|
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.
isc::InvalidOperation | if there have been no unordered lookups yet. |
Definition at line 419 of file bin/perfdhcp/stats_mgr.h.
References isc_throw.
|
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.
Definition at line 408 of file bin/perfdhcp/stats_mgr.h.
Referenced by printRTTStats().
|
inline |
Return number of dropped packets.
Method returns number of dropped packets.
Definition at line 467 of file bin/perfdhcp/stats_mgr.h.
References getRcvdPacketsNum(), and getSentPacketsNum().
Referenced by printMainStats().
|
inline |
Return maximum delay between sent and received packet.
Method returns maximum delay between sent and received packet.
Definition at line 354 of file bin/perfdhcp/stats_mgr.h.
Referenced by printRTTStats().
|
inline |
Return minimum delay between sent and received packet.
Method returns minimum delay between sent and received packet.
Definition at line 347 of file bin/perfdhcp/stats_mgr.h.
Referenced by printRTTStats().
|
inline |
Return total number of non unique addresses.
Method returns total number of non unique addresses.
Definition at line 487 of file bin/perfdhcp/stats_mgr.h.
Referenced by printMainStats().
|
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).
Definition at line 446 of file bin/perfdhcp/stats_mgr.h.
|
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.
Definition at line 397 of file bin/perfdhcp/stats_mgr.h.
Referenced by printMainStats().
|
inline |
Return total number of received packets.
Method returns total number of received packets.
Definition at line 460 of file bin/perfdhcp/stats_mgr.h.
Referenced by getDroppedPacketsNum(), and printMainStats().
|
inline |
Return total number of rejected leases.
Method returns total number of rejected leases.
Definition at line 480 of file bin/perfdhcp/stats_mgr.h.
Referenced by printMainStats().
|
inline |
Definition at line 566 of file bin/perfdhcp/stats_mgr.h.
|
inline |
Return total number of sent packets.
Method returns total number of sent packets.
Definition at line 453 of file bin/perfdhcp/stats_mgr.h.
Referenced by getDroppedPacketsNum(), and printMainStats().
|
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.
isc::InvalidOperation | if number of received packets for the exchange is equal to zero. |
Definition at line 382 of file bin/perfdhcp/stats_mgr.h.
References getAvgDelay(), and isc_throw.
Referenced by printRTTStats().
|
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.
Definition at line 435 of file bin/perfdhcp/stats_mgr.h.
|
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.
packet | packet which transaction id is to be hashed. |
isc::BadValue | if packet is null. |
Definition at line 157 of file bin/perfdhcp/stats_mgr.h.
References isc_throw.
Referenced by matchPackets(), and printTimestamps().
PktPtr isc::perfdhcp::ExchangeStats::matchPackets | ( | const dhcp::PktPtr & | rcvd_packet | ) |
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.
rcvd_packet | received packet to be matched with sent packet. |
isc::BadValue | if received packet is null. |
Definition at line 156 of file bin/perfdhcp/stats_mgr.cc.
References hashTransid(), and isc_throw.
void isc::perfdhcp::ExchangeStats::printLeases | ( | ) | const |
Print the list of received leases.
Definition at line 453 of file bin/perfdhcp/stats_mgr.cc.
|
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.
Definition at line 512 of file bin/perfdhcp/stats_mgr.h.
References getDroppedPacketsNum(), getNonUniqueAddrNum(), getOrphans(), getRcvdPacketsNum(), getRejLeasesNum(), and getSentPacketsNum().
|
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 534 of file bin/perfdhcp/stats_mgr.h.
References getAvgDelay(), getCollectedNum(), getMaxDelay(), getMinDelay(), and getStdDevDelay().
void isc::perfdhcp::ExchangeStats::printTimestamps | ( | ) |
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.
isc::InvalidOperation | if found packet with no timestamp or if packets archive mode is disabled. |
Definition at line 303 of file bin/perfdhcp/stats_mgr.cc.
References hashTransid(), and isc_throw.
std::string isc::perfdhcp::ExchangeStats::receivedLeases | ( | ) | const |
Return the list of received leases in CSV format as string.
Depending exchange type, it can apply to potential leases received in offers and advertisements, committed leases received in acknowledgements and replies, renewed or released leases.
Definition at line 391 of file bin/perfdhcp/stats_mgr.cc.
References D6O_CLIENTID, D6O_IA_NA, D6O_IA_PD, D6O_IAADDR, D6O_IAPREFIX, isc::perfdhcp::dhcpVersion(), isc_throw, and isc::dhcp::IdentifierType< min_size, max_size >::toText().
void isc::perfdhcp::ExchangeStats::updateDelays | ( | const dhcp::PktPtr & | sent_packet, |
const dhcp::PktPtr & | rcvd_packet ) |
Update delay counters.
Method updates delay counters based on timestamps of sent and received packets.
sent_packet | sent packet |
rcvd_packet | received packet |
isc::BadValue | if sent or received packet is null. |
isc::Unexpected | if failed to calculate timestamps |
Definition at line 105 of file bin/perfdhcp/stats_mgr.cc.
References isc_throw.
|
inline |
Increase number of non unique addresses.
Method increases total number of non unique addresses by one.
Definition at line 497 of file bin/perfdhcp/stats_mgr.h.
|
inline |
Increase number of rejected leases.
Method increases total number of rejected leases by one.
Definition at line 492 of file bin/perfdhcp/stats_mgr.h.
|
static |
Definition at line 583 of file bin/perfdhcp/stats_mgr.h.
Referenced by isc::perfdhcp::TestControl::printRate(), isc::perfdhcp::PerfSocket::receive4(), isc::perfdhcp::PerfSocket::receive6(), and isc::perfdhcp::PktTransform::unpack().