diff --git a/docs/manual.rst b/docs/manual.rst index 12cb30ec3..118cebf77 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -2365,6 +2365,10 @@ It contains the following fields:: int receive_quota; int rtt; + + int download_rate_peak; + int upload_rate_peak; + }; The ``flags`` attribute tells you in which state the peer is. It is set to @@ -2567,6 +2571,9 @@ from the bandwidth manager. ``rtt`` is an estimated round trip time to this peer, in milliseconds. It is estimated by timing the the tcp ``connect()``. It may be 0 for incoming connections. +``download_rate_peak`` and ``upload_rate_peak`` are the highest download and upload +rates seen on this connection. They are given in bytes per second. This number is +reset to 0 on reconnect. session_settings ================ diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 1ebac5894..1cdc07484 100755 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -781,6 +781,11 @@ namespace libtorrent // they sent us size_type m_downloaded_at_last_unchoke; + // max transfer rates seen on this peer + int m_download_rate_peak; + int m_upload_rate_peak; + + #ifndef NDEBUG public: bool m_in_constructor; diff --git a/include/libtorrent/peer_info.hpp b/include/libtorrent/peer_info.hpp index 8ea29ef25..1560717d3 100755 --- a/include/libtorrent/peer_info.hpp +++ b/include/libtorrent/peer_info.hpp @@ -174,6 +174,10 @@ namespace libtorrent // estimated rtt to peer, in milliseconds int rtt; + + // the highest transfer rates seen for this peer + int download_rate_peak; + int upload_rate_peak; }; } diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index f6c5a973d..f208bfed1 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -120,6 +120,8 @@ namespace libtorrent , m_fast_reconnect(false) , m_rtt(0) , m_downloaded_at_last_unchoke(0) + , m_download_rate_peak(0) + , m_upload_rate_peak(0) #ifndef NDEBUG , m_in_constructor(true) #endif @@ -199,6 +201,8 @@ namespace libtorrent , m_fast_reconnect(false) , m_rtt(0) , m_downloaded_at_last_unchoke(0) + , m_download_rate_peak(0) + , m_upload_rate_peak(0) #ifndef NDEBUG , m_in_constructor(true) #endif @@ -2202,6 +2206,8 @@ namespace libtorrent { TORRENT_ASSERT(!associated_torrent().expired()); + p.download_rate_peak = m_download_rate_peak; + p.upload_rate_peak = m_upload_rate_peak; p.rtt = m_rtt; p.down_speed = statistics().download_rate(); p.up_speed = statistics().upload_rate(); @@ -2334,6 +2340,15 @@ namespace libtorrent m_statistics.second_tick(tick_interval); + if (m_statistics.upload_payload_rate() > m_upload_rate_peak) + { + m_upload_rate_peak = m_statistics.upload_payload_rate(); + } + if (m_statistics.download_payload_rate() > m_download_rate_peak) + { + m_download_rate_peak = m_statistics.download_payload_rate(); + } + if (!t->valid_metadata()) return; // calculate the desired download queue size