mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
Merge pull request #5327
c23ea796
New interactive daemon command 'print_net_stats': Global traffic stats (rbrunner7)
This commit is contained in:
commit
1ed6441925
13 changed files with 181 additions and 1 deletions
|
@ -66,6 +66,8 @@ class network_throttle : public i_network_throttle {
|
|||
network_time_seconds m_last_sample_time; // time of last history[0] - so we know when to rotate the buffer
|
||||
network_time_seconds m_start_time; // when we were created
|
||||
bool m_any_packet_yet; // did we yet got any packet to count
|
||||
uint64_t m_total_packets;
|
||||
uint64_t m_total_bytes;
|
||||
|
||||
std::string m_name; // my name for debug and logs
|
||||
std::string m_nameshort; // my name for debug and logs (used in log file name)
|
||||
|
@ -95,6 +97,7 @@ class network_throttle : public i_network_throttle {
|
|||
virtual size_t get_recommended_size_of_planned_transport() const; ///< what should be the size (bytes) of next data block to be transported
|
||||
virtual size_t get_recommended_size_of_planned_transport_window(double force_window) const; ///< ditto, but for given windows time frame
|
||||
virtual double get_current_speed() const;
|
||||
virtual void get_stats(uint64_t &total_packets, uint64_t &total_bytes) const;
|
||||
|
||||
private:
|
||||
virtual network_time_seconds time_to_slot(network_time_seconds t) const { return std::floor( t ); } // convert exact time eg 13.7 to rounded time for slot number in history 13
|
||||
|
|
|
@ -152,7 +152,8 @@ class i_network_throttle {
|
|||
virtual size_t get_recommended_size_of_planned_transport() const =0; // what should be the recommended limit of data size that we can transport over current network_throttle in near future
|
||||
|
||||
virtual double get_time_seconds() const =0; // a timer
|
||||
virtual void logger_handle_net(const std::string &filename, double time, size_t size)=0;
|
||||
virtual void logger_handle_net(const std::string &filename, double time, size_t size)=0;
|
||||
virtual void get_stats(uint64_t &total_packets, uint64_t &total_bytes) const =0;
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -136,6 +136,8 @@ network_throttle::network_throttle(const std::string &nameshort, const std::stri
|
|||
m_target_speed = 16 * 1024; // other defaults are probably defined in the command-line parsing code when this class is used e.g. as main global throttle
|
||||
m_last_sample_time = 0;
|
||||
m_history.resize(m_window_size);
|
||||
m_total_packets = 0;
|
||||
m_total_bytes = 0;
|
||||
}
|
||||
|
||||
void network_throttle::set_name(const std::string &name)
|
||||
|
@ -192,6 +194,8 @@ void network_throttle::_handle_trafic_exact(size_t packet_size, size_t orginal_s
|
|||
calculate_times_struct cts ; calculate_times(packet_size, cts , false, -1);
|
||||
calculate_times_struct cts2; calculate_times(packet_size, cts2, false, 5);
|
||||
m_history.front().m_size += packet_size;
|
||||
m_total_packets++;
|
||||
m_total_bytes += packet_size;
|
||||
|
||||
std::ostringstream oss; oss << "["; for (auto sample: m_history) oss << sample.m_size << " "; oss << "]" << std::ends;
|
||||
std::string history_str = oss.str();
|
||||
|
@ -352,6 +356,12 @@ double network_throttle::get_current_speed() const {
|
|||
return bytes_transferred / ((m_history.size() - 1) * m_slot_size);
|
||||
}
|
||||
|
||||
void network_throttle::get_stats(uint64_t &total_packets, uint64_t &total_bytes) const {
|
||||
total_packets = m_total_packets;
|
||||
total_bytes = m_total_bytes;
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue