Monero
Loading...
Searching...
No Matches
epee::net_utils::network_throttle Class Reference

#include <network_throttle-detail.hpp>

Inheritance diagram for epee::net_utils::network_throttle:
Collaboration diagram for epee::net_utils::network_throttle:

Classes

struct  packet_info

Public Member Functions

 network_throttle (const std::string &nameshort, const std::string &name, int window_size=-1)
virtual ~network_throttle ()
virtual void set_name (const std::string &name)
virtual void set_target_speed (network_speed_kbps target)
virtual network_speed_kbps get_target_speed ()
virtual void handle_trafic_exact (size_t packet_size)
 count the new traffic/packet; the size is exact considering all network costs
virtual void handle_trafic_tcp (size_t packet_size)
 count the new traffic/packet; the size is as TCP, we will consider MTU etc
virtual void tick ()
 poke and update timers/history (recalculates, moves the history if needed, checks the real clock etc)
virtual double get_time_seconds () const
 timer that we use, time in seconds, monotionic
virtual void calculate_times (size_t packet_size, calculate_times_struct &cts, bool dbg, double force_window) const
 MAIN LOGIC (see base class for info).
virtual network_time_seconds get_sleep_time_after_tick (size_t packet_size)
 increase the timer if needed, and get the package size
virtual network_time_seconds get_sleep_time (size_t packet_size) const
 gets the Delay (recommended Delay time) from calc. (not safe: only if time didnt change?) TODO
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 Member Functions

virtual network_time_seconds time_to_slot (network_time_seconds t) const
virtual void _handle_trafic_exact (size_t packet_size, size_t orginal_size)
virtual void logger_handle_net (const std::string &filename, double time, size_t size)

Private Attributes

network_speed_bps m_target_speed
size_t m_network_add_cost
size_t m_network_minimal_segment
size_t m_network_max_segment
const size_t m_window_size
network_time_seconds m_slot_size
boost::circular_buffer< packet_infom_history
network_time_seconds m_last_sample_time
network_time_seconds m_start_time
bool m_any_packet_yet
uint64_t m_total_packets
uint64_t m_total_bytes
std::string m_name
std::string m_nameshort

Constructor & Destructor Documentation

◆ network_throttle()

epee::net_utils::network_throttle::network_throttle ( const std::string & nameshort,
const std::string & name,
int window_size = -1 )

◆ ~network_throttle()

epee::net_utils::network_throttle::~network_throttle ( )
virtual

Member Function Documentation

◆ _handle_trafic_exact()

void epee::net_utils::network_throttle::_handle_trafic_exact ( size_t packet_size,
size_t orginal_size )
privatevirtual

◆ calculate_times()

void epee::net_utils::network_throttle::calculate_times ( size_t packet_size,
calculate_times_struct & cts,
bool dbg,
double force_window ) const
virtual

MAIN LOGIC (see base class for info).

Implements epee::net_utils::i_network_throttle.

◆ get_current_speed()

double epee::net_utils::network_throttle::get_current_speed ( ) const
virtual

◆ get_recommended_size_of_planned_transport()

size_t epee::net_utils::network_throttle::get_recommended_size_of_planned_transport ( ) const
virtual

what should be the size (bytes) of next data block to be transported

Implements epee::net_utils::i_network_throttle.

◆ get_recommended_size_of_planned_transport_window()

size_t epee::net_utils::network_throttle::get_recommended_size_of_planned_transport_window ( double force_window) const
virtual

ditto, but for given windows time frame

◆ get_sleep_time()

network_time_seconds epee::net_utils::network_throttle::get_sleep_time ( size_t packet_size) const
virtual

gets the Delay (recommended Delay time) from calc. (not safe: only if time didnt change?) TODO

Implements epee::net_utils::i_network_throttle.

◆ get_sleep_time_after_tick()

network_time_seconds epee::net_utils::network_throttle::get_sleep_time_after_tick ( size_t packet_size)
virtual

increase the timer if needed, and get the package size

Implements epee::net_utils::i_network_throttle.

◆ get_stats()

void epee::net_utils::network_throttle::get_stats ( uint64_t & total_packets,
uint64_t & total_bytes ) const
virtual

◆ get_target_speed()

network_speed_kbps epee::net_utils::network_throttle::get_target_speed ( )
virtual

◆ get_time_seconds()

double epee::net_utils::network_throttle::get_time_seconds ( ) const
virtual

timer that we use, time in seconds, monotionic

Implements epee::net_utils::i_network_throttle.

◆ handle_trafic_exact()

void epee::net_utils::network_throttle::handle_trafic_exact ( size_t packet_size)
virtual

count the new traffic/packet; the size is exact considering all network costs

Implements epee::net_utils::i_network_throttle.

◆ handle_trafic_tcp()

void epee::net_utils::network_throttle::handle_trafic_tcp ( size_t packet_size)
virtual

count the new traffic/packet; the size is as TCP, we will consider MTU etc

Implements epee::net_utils::i_network_throttle.

◆ logger_handle_net()

void epee::net_utils::network_throttle::logger_handle_net ( const std::string & filename,
double time,
size_t size )
privatevirtual

◆ set_name()

void epee::net_utils::network_throttle::set_name ( const std::string & name)
virtual

◆ set_target_speed()

void epee::net_utils::network_throttle::set_target_speed ( network_speed_kbps target)
virtual

◆ tick()

void epee::net_utils::network_throttle::tick ( )
virtual

poke and update timers/history (recalculates, moves the history if needed, checks the real clock etc)

Implements epee::net_utils::i_network_throttle.

◆ time_to_slot()

virtual network_time_seconds epee::net_utils::network_throttle::time_to_slot ( network_time_seconds t) const
inlineprivatevirtual

Member Data Documentation

◆ m_any_packet_yet

bool epee::net_utils::network_throttle::m_any_packet_yet
private

◆ m_history

boost::circular_buffer< packet_info > epee::net_utils::network_throttle::m_history
private

◆ m_last_sample_time

network_time_seconds epee::net_utils::network_throttle::m_last_sample_time
private

◆ m_name

std::string epee::net_utils::network_throttle::m_name
private

◆ m_nameshort

std::string epee::net_utils::network_throttle::m_nameshort
private

◆ m_network_add_cost

size_t epee::net_utils::network_throttle::m_network_add_cost
private

◆ m_network_max_segment

size_t epee::net_utils::network_throttle::m_network_max_segment
private

◆ m_network_minimal_segment

size_t epee::net_utils::network_throttle::m_network_minimal_segment
private

◆ m_slot_size

network_time_seconds epee::net_utils::network_throttle::m_slot_size
private

◆ m_start_time

network_time_seconds epee::net_utils::network_throttle::m_start_time
private

◆ m_target_speed

network_speed_bps epee::net_utils::network_throttle::m_target_speed
private

◆ m_total_bytes

uint64_t epee::net_utils::network_throttle::m_total_bytes
private

◆ m_total_packets

uint64_t epee::net_utils::network_throttle::m_total_packets
private

◆ m_window_size

const size_t epee::net_utils::network_throttle::m_window_size
private

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