TARAXA
Loading...
Searching...
No Matches
time_period_packets_stats.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "common/types.hpp"
4#include "logger/logging.hpp"
7
9
10class PeersState;
11class TaraxaPeer;
12
17 public:
18 TimePeriodPacketsStats(std::chrono::milliseconds reset_time_period);
19
20 void addReceivedPacket(const std::string& packet_type, const dev::p2p::NodeID& node, const PacketStats& packet);
21 void addSentPacket(const std::string& packet_type, const dev::p2p::NodeID& node, const PacketStats& packet);
22
26 void processStats(const std::vector<std::shared_ptr<TaraxaPeer>>& all_peers);
27
28 private:
37 std::pair<bool, std::chrono::milliseconds> validMaxStatsTimePeriod(
38 const std::chrono::system_clock::time_point& start_time) const;
39
40 private:
41 // Interval during which are the peer stats supposed to be collected
42 const std::chrono::milliseconds kResetTimePeriod;
43
44 // Collected packets stats during time period
47
48 // Max stats for all received packets combined per peer
50
52};
53
54} // namespace taraxa::network::tarcap
MAx stats data holder class.
Definition max_stats.hpp:12
Stats single packet type.
Definition packet_stats.hpp:13
Stats for all packet types.
Definition packets_stats.hpp:13
Stats for all received and sent packets of all types.
Definition time_period_packets_stats.hpp:16
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.
Definition time_period_packets_stats.cpp:40
logger::Logger logger_
Definition time_period_packets_stats.hpp:51
const std::chrono::milliseconds kResetTimePeriod
Definition time_period_packets_stats.hpp:42
PacketsStats received_packets_stats_
Definition time_period_packets_stats.hpp:46
void addSentPacket(const std::string &packet_type, const dev::p2p::NodeID &node, const PacketStats &packet)
Definition time_period_packets_stats.cpp:19
void addReceivedPacket(const std::string &packet_type, const dev::p2p::NodeID &node, const PacketStats &packet)
Definition time_period_packets_stats.cpp:13
PacketsStats sent_packets_stats_
Definition time_period_packets_stats.hpp:45
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 i...
Definition time_period_packets_stats.cpp:25
MaxStats peer_max_stats_
Definition time_period_packets_stats.hpp:49
std::shared_ptr< spdlog::logger > Logger
Definition logging.hpp:12
Definition vote_manager.hpp:24