report tracker bandwidth usage and include it in rate limiter
This commit is contained in:
@@ -74,6 +74,11 @@ namespace libtorrent
|
||||
size_type total_dht_download;
|
||||
size_type total_dht_upload;
|
||||
|
||||
float tracker_upload_rate;
|
||||
float tracker_download_rate;
|
||||
size_type total_tracker_download;
|
||||
size_type total_tracker_upload;
|
||||
|
||||
size_type total_redundant_bytes;
|
||||
size_type total_failed_bytes;
|
||||
|
||||
|
@@ -126,12 +126,28 @@ namespace libtorrent
|
||||
{
|
||||
TORRENT_ASSERT(bytes >= 0);
|
||||
m_stat[download_dht_protocol].add(bytes);
|
||||
// assuming IPv4 and UDP headers
|
||||
m_stat[download_ip_protocol].add(28);
|
||||
}
|
||||
|
||||
void sent_dht_bytes(int bytes)
|
||||
{
|
||||
TORRENT_ASSERT(bytes >= 0);
|
||||
m_stat[upload_dht_protocol].add(bytes);
|
||||
// assuming IPv4 and UDP headers
|
||||
m_stat[upload_ip_protocol].add(28);
|
||||
}
|
||||
|
||||
void received_tracker_bytes(int bytes)
|
||||
{
|
||||
TORRENT_ASSERT(bytes >= 0);
|
||||
m_stat[download_tracker_protocol].add(bytes);
|
||||
}
|
||||
|
||||
void sent_tracker_bytes(int bytes)
|
||||
{
|
||||
TORRENT_ASSERT(bytes >= 0);
|
||||
m_stat[upload_tracker_protocol].add(bytes);
|
||||
}
|
||||
|
||||
void received_bytes(int bytes_payload, int bytes_protocol)
|
||||
@@ -176,6 +192,8 @@ namespace libtorrent
|
||||
int download_ip_overhead() const { return m_stat[download_ip_protocol].counter(); }
|
||||
int upload_dht() const { return m_stat[upload_dht_protocol].counter(); }
|
||||
int download_dht() const { return m_stat[download_dht_protocol].counter(); }
|
||||
int download_tracker() const { return m_stat[download_tracker_protocol].counter(); }
|
||||
int upload_tracker() const { return m_stat[upload_tracker_protocol].counter(); }
|
||||
|
||||
// should be called once every second
|
||||
void second_tick(float tick_interval)
|
||||
@@ -207,7 +225,8 @@ namespace libtorrent
|
||||
return m_stat[upload_payload].total()
|
||||
+ m_stat[upload_protocol].total()
|
||||
+ m_stat[upload_ip_protocol].total()
|
||||
+ m_stat[upload_dht_protocol].total();
|
||||
+ m_stat[upload_dht_protocol].total()
|
||||
+ m_stat[upload_tracker_protocol].total();
|
||||
}
|
||||
|
||||
size_type total_download() const
|
||||
@@ -215,7 +234,8 @@ namespace libtorrent
|
||||
return m_stat[download_payload].total()
|
||||
+ m_stat[download_protocol].total()
|
||||
+ m_stat[download_ip_protocol].total()
|
||||
+ m_stat[download_dht_protocol].total();
|
||||
+ m_stat[download_dht_protocol].total()
|
||||
+ m_stat[download_tracker_protocol].total();
|
||||
}
|
||||
|
||||
float upload_payload_rate() const
|
||||
@@ -265,10 +285,12 @@ namespace libtorrent
|
||||
upload_protocol,
|
||||
upload_ip_protocol,
|
||||
upload_dht_protocol,
|
||||
upload_tracker_protocol,
|
||||
download_payload,
|
||||
download_protocol,
|
||||
download_ip_protocol,
|
||||
download_dht_protocol,
|
||||
download_tracker_protocol,
|
||||
num_channels
|
||||
};
|
||||
|
||||
|
@@ -70,6 +70,7 @@ namespace libtorrent
|
||||
class tracker_manager;
|
||||
struct timeout_handler;
|
||||
struct tracker_connection;
|
||||
namespace aux { struct session_impl; }
|
||||
|
||||
// returns -1 if gzip header is invalid or the header size in bytes
|
||||
TORRENT_EXPORT int gzip_header(const char* buf, int size);
|
||||
@@ -197,6 +198,8 @@ namespace libtorrent
|
||||
virtual void start() = 0;
|
||||
virtual void close();
|
||||
address const& bind_interface() const { return m_bind_interface; }
|
||||
void sent_bytes(int bytes);
|
||||
void received_bytes(int bytes);
|
||||
|
||||
protected:
|
||||
boost::weak_ptr<request_callback> m_requester;
|
||||
@@ -210,8 +213,8 @@ namespace libtorrent
|
||||
{
|
||||
public:
|
||||
|
||||
tracker_manager(session_settings const& s, proxy_settings const& ps)
|
||||
: m_settings(s)
|
||||
tracker_manager(aux::session_impl& ses, proxy_settings const& ps)
|
||||
: m_ses(ses)
|
||||
, m_proxy(ps)
|
||||
, m_abort(false) {}
|
||||
|
||||
@@ -228,6 +231,9 @@ namespace libtorrent
|
||||
void remove_request(tracker_connection const*);
|
||||
bool empty() const;
|
||||
int num_requests() const;
|
||||
|
||||
void sent_bytes(int bytes);
|
||||
void received_bytes(int bytes);
|
||||
|
||||
private:
|
||||
|
||||
@@ -237,7 +243,7 @@ namespace libtorrent
|
||||
typedef std::list<boost::intrusive_ptr<tracker_connection> >
|
||||
tracker_connections_t;
|
||||
tracker_connections_t m_connections;
|
||||
session_settings const& m_settings;
|
||||
aux::session_impl& m_ses;
|
||||
proxy_settings const& m_proxy;
|
||||
bool m_abort;
|
||||
};
|
||||
|
Reference in New Issue
Block a user