mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
calculate bandwidth every 1 and 15 seconds
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
a902d68669
commit
8943200ffa
5 changed files with 74 additions and 27 deletions
|
@ -124,6 +124,9 @@ namespace transport
|
|||
uint32_t GetInBandwidth () const { return m_InBandwidth; };
|
||||
uint32_t GetOutBandwidth () const { return m_OutBandwidth; };
|
||||
uint32_t GetTransitBandwidth () const { return m_TransitBandwidth; };
|
||||
uint32_t GetInBandwidth15s () const { return m_InBandwidth15s; };
|
||||
uint32_t GetOutBandwidth15s () const { return m_OutBandwidth15s; };
|
||||
uint32_t GetTransitBandwidth15s () const { return m_TransitBandwidth15s; };
|
||||
bool IsBandwidthExceeded () const;
|
||||
bool IsTransitBandwidthExceeded () const;
|
||||
size_t GetNumPeers () const { return m_Peers.size (); };
|
||||
|
@ -155,8 +158,8 @@ namespace transport
|
|||
void SetPriority (Peer& peer) const;
|
||||
void HandlePeerCleanupTimer (const boost::system::error_code& ecode);
|
||||
void HandlePeerTestTimer (const boost::system::error_code& ecode);
|
||||
void HandleUpdateBandwidthTimer (const boost::system::error_code& ecode);
|
||||
|
||||
void UpdateBandwidth ();
|
||||
void DetectExternalIP ();
|
||||
|
||||
private:
|
||||
|
@ -167,6 +170,7 @@ namespace transport
|
|||
boost::asio::io_service * m_Service;
|
||||
boost::asio::io_service::work * m_Work;
|
||||
boost::asio::deadline_timer * m_PeerCleanupTimer, * m_PeerTestTimer;
|
||||
boost::asio::steady_timer * m_UpdateBandwidthTimer;
|
||||
|
||||
SSU2Server * m_SSU2Server;
|
||||
NTCP2Server * m_NTCP2Server;
|
||||
|
@ -176,9 +180,15 @@ namespace transport
|
|||
X25519KeysPairSupplier m_X25519KeysPairSupplier;
|
||||
|
||||
std::atomic<uint64_t> m_TotalSentBytes, m_TotalReceivedBytes, m_TotalTransitTransmittedBytes;
|
||||
uint32_t m_InBandwidth, m_OutBandwidth, m_TransitBandwidth; // bytes per second
|
||||
|
||||
// Bandwidth per second
|
||||
uint32_t m_InBandwidth, m_OutBandwidth, m_TransitBandwidth;
|
||||
uint64_t m_LastInBandwidthUpdateBytes, m_LastOutBandwidthUpdateBytes, m_LastTransitBandwidthUpdateBytes;
|
||||
uint64_t m_LastBandwidthUpdateTime;
|
||||
|
||||
// Bandwidth every 15 seconds
|
||||
uint32_t m_InBandwidth15s, m_OutBandwidth15s, m_TransitBandwidth15s;
|
||||
uint64_t m_LastInBandwidth15sUpdateBytes, m_LastOutBandwidth15sUpdateBytes, m_LastTransitBandwidth15sUpdateBytes;
|
||||
uint64_t m_LastBandwidth15sUpdateTime;
|
||||
|
||||
/** which router families to trust for first hops */
|
||||
std::vector<i2p::data::FamilyID> m_TrustedFamilies;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue