TARAXA
taraxa::network::tarcap::TimePeriodPacketsStats Class Reference

Stats for all received and sent packets of all types. More...

#include <time_period_packets_stats.hpp>

Collaboration diagram for taraxa::network::tarcap::TimePeriodPacketsStats:

Public Member Functions

 TimePeriodPacketsStats (std::chrono::milliseconds reset_time_period, const addr_t &node_addr={})
 
void addReceivedPacket (const std::string &packet_type, const dev::p2p::NodeID &node, const PacketStats &packet)
 
void addSentPacket (const std::string &packet_type, const dev::p2p::NodeID &node, const PacketStats &packet)
 
void processStats (const std::vector< std::shared_ptr< TaraxaPeer >> &all_peers)
 Logs both received as well as sent packets stats + updates max count/size and reset stats. More...
 

Private Member Functions

std::pair< bool, std::chrono::milliseconds > validMaxStatsTimePeriod (const std::chrono::system_clock::time_point &start_time) const
 Checks if now() - start_time is approximately equal to kResetTimePeriod. Stats are reset in regular interval, but it might be postponed due to lack o resources, in which case we dont want to count such stats when processing max stats. More...
 

Private Attributes

const std::chrono::milliseconds kResetTimePeriod
 
PacketsStats sent_packets_stats_
 
PacketsStats received_packets_stats_
 
MaxStats peer_max_stats_
 

Detailed Description

Stats for all received and sent packets of all types.

Constructor & Destructor Documentation

◆ TimePeriodPacketsStats()

taraxa::network::tarcap::TimePeriodPacketsStats::TimePeriodPacketsStats ( std::chrono::milliseconds  reset_time_period,
const addr_t node_addr = {} 
)

Member Function Documentation

◆ addReceivedPacket()

void taraxa::network::tarcap::TimePeriodPacketsStats::addReceivedPacket ( const std::string &  packet_type,
const dev::p2p::NodeID node,
const PacketStats packet 
)

◆ addSentPacket()

void taraxa::network::tarcap::TimePeriodPacketsStats::addSentPacket ( const std::string &  packet_type,
const dev::p2p::NodeID node,
const PacketStats packet 
)

◆ processStats()

void taraxa::network::tarcap::TimePeriodPacketsStats::processStats ( const std::vector< std::shared_ptr< TaraxaPeer >> &  all_peers)

Logs both received as well as sent packets stats + updates max count/size and reset stats.

◆ validMaxStatsTimePeriod()

std::pair< bool, std::chrono::milliseconds > taraxa::network::tarcap::TimePeriodPacketsStats::validMaxStatsTimePeriod ( const std::chrono::system_clock::time_point &  start_time) const
private

Checks if now() - start_time is approximately equal to kResetTimePeriod. Stats are reset in regular interval, but it might be postponed due to lack o resources, in which case we dont want to count such stats when processing max stats.

Returns
<true, interval_ms> in case current time is valid time point for max stats -> now() - start_time == *kResetTimePeriod, otherwise <false, interval_ms>

Member Data Documentation

◆ kResetTimePeriod

const std::chrono::milliseconds taraxa::network::tarcap::TimePeriodPacketsStats::kResetTimePeriod
private

◆ peer_max_stats_

MaxStats taraxa::network::tarcap::TimePeriodPacketsStats::peer_max_stats_
private

◆ received_packets_stats_

PacketsStats taraxa::network::tarcap::TimePeriodPacketsStats::received_packets_stats_
private

◆ sent_packets_stats_

PacketsStats taraxa::network::tarcap::TimePeriodPacketsStats::sent_packets_stats_
private

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