diff --git a/docs/manual.html b/docs/manual.html index 3adb105e8..7961af322 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -688,6 +688,9 @@ struct session_status size_type total_download; size_type total_upload; + size_type total_redundant_bytes; + size_type total_failed_bytes; + size_type total_payload_download; size_type total_payload_upload; @@ -710,6 +713,12 @@ versions is the payload download only.

total_download and total_upload are the total number of bytes downloaded and uploaded to and from all torrents. total_payload_download and total_payload_upload are the same thing but where only the payload is considered.

+

total_redundant_bytes is the number of bytes that has been received more than once. +This can happen if a request from a peer times out and is requested from a different +peer, and then received again from the first one. To make this lower, increase the +request_timeout and the piece_timeout in the session settings.

+

total_failed_bytes is the number of bytes that was downloaded which later failed +the hash-check.

num_peers is the total number of peer connections this session has. This includes incoming connections that still hasn't sent their handshake or outgoing connections that still hasn't completed the TCP connection. This number may be slightly higher diff --git a/docs/manual.rst b/docs/manual.rst index 9b8995e03..0943cc5f7 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -503,6 +503,9 @@ struct has the following members:: size_type total_download; size_type total_upload; + size_type total_redundant_bytes; + size_type total_failed_bytes; + size_type total_payload_download; size_type total_payload_upload; @@ -528,6 +531,14 @@ versions is the payload download only. uploaded to and from all torrents. ``total_payload_download`` and ``total_payload_upload`` are the same thing but where only the payload is considered. +``total_redundant_bytes`` is the number of bytes that has been received more than once. +This can happen if a request from a peer times out and is requested from a different +peer, and then received again from the first one. To make this lower, increase the +``request_timeout`` and the ``piece_timeout`` in the session settings. + +``total_failed_bytes`` is the number of bytes that was downloaded which later failed +the hash-check. + ``num_peers`` is the total number of peer connections this session has. This includes incoming connections that still hasn't sent their handshake or outgoing connections that still hasn't completed the TCP connection. This number may be slightly higher diff --git a/examples/client_test.cpp b/examples/client_test.cpp index e9fe80206..4269299e2 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1319,7 +1319,9 @@ int main(int ac, char* av[]) << " (" << esc("32") << add_suffix(sess_stat.total_download) << esc("0") << ") " " up: " << esc("31") << add_suffix(sess_stat.upload_rate) << "/s " << esc("0") << " (" << esc("31") << add_suffix(sess_stat.total_upload) << esc("0") << ")" - " unchoked: " << sess_stat.num_unchoked << " / " << sess_stat.allowed_upload_slots + " waste: " << add_suffix(sess_stat.total_redundant_bytes) + << " fail: " << add_suffix(sess_stat.total_failed_bytes) + << " unchoked: " << sess_stat.num_unchoked << " / " << sess_stat.allowed_upload_slots << " bw queues: (" << sess_stat.up_bandwidth_queue << " | " << sess_stat.down_bandwidth_queue << ") " " write cache hits: " << ((cs.blocks_written - cs.writes) * 100 / cs.blocks_written) << "% " diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 57da44b4a..e1345fab6 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -319,6 +319,18 @@ namespace libtorrent int next_port(); + void add_redundant_bytes(size_type b) + { + TORRENT_ASSERT(b > 0); + m_total_redundant_bytes += b; + } + + void add_failed_bytes(size_type b) + { + TORRENT_ASSERT(b > 0); + m_total_failed_bytes += b; + } + // handles delayed alerts alert_manager m_alerts; @@ -608,6 +620,10 @@ namespace libtorrent std::map m_as_peak; #endif + // total redundant and failed bytes + size_type m_total_failed_bytes; + size_type m_total_redundant_bytes; + // the main working thread boost::scoped_ptr m_thread; }; diff --git a/include/libtorrent/session_status.hpp b/include/libtorrent/session_status.hpp index 4e42dba5f..6f74f5ff4 100644 --- a/include/libtorrent/session_status.hpp +++ b/include/libtorrent/session_status.hpp @@ -53,6 +53,9 @@ namespace libtorrent size_type total_payload_download; size_type total_payload_upload; + size_type total_redundant_bytes; + size_type total_failed_bytes; + int num_peers; int num_unchoked; int allowed_upload_slots; diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index b1c2cc541..7475e0a36 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -524,8 +524,8 @@ namespace libtorrent // this is done when a piece fails void restore_piece_state(int index); - void received_redundant_data(int num_bytes) - { TORRENT_ASSERT(num_bytes > 0); m_total_redundant_bytes += num_bytes; } + void add_redundant_bytes(int b); + void add_failed_bytes(int b); // this is true if we have all the pieces bool is_seed() const diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index fce7f1999..a67f27ec5 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -1509,7 +1509,7 @@ namespace libtorrent // just ignore it if (t->is_seed()) { - t->received_redundant_data(p.length); + t->add_redundant_bytes(p.length); return; } @@ -1541,7 +1541,7 @@ namespace libtorrent (*m_logger) << " *** The block we just got was not in the " "request queue ***\n"; #endif - t->received_redundant_data(p.length); + t->add_redundant_bytes(p.length); request_a_block(*t, *this); send_block_requests(); return; @@ -1578,7 +1578,7 @@ namespace libtorrent // if the block we got is already finished, then ignore it if (picker.is_downloaded(block_finished)) { - t->received_redundant_data(p.length); + t->add_redundant_bytes(p.length); m_download_queue.erase(b); m_timeout_extend = 0; diff --git a/src/session_impl.cpp b/src/session_impl.cpp index c2a87c73d..4b5669a5c 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -185,6 +185,8 @@ namespace aux { , m_asnum_db(0) , m_country_db(0) #endif + , m_total_failed_bytes(0) + , m_total_redundant_bytes(0) { m_tcp_mapping[0] = -1; m_tcp_mapping[1] = -1; @@ -2017,6 +2019,9 @@ namespace aux { s.num_unchoked = m_num_unchoked; s.allowed_upload_slots = m_allowed_upload_slots; + s.total_redundant_bytes = m_total_redundant_bytes; + s.total_failed_bytes = m_total_failed_bytes; + s.up_bandwidth_queue = m_upload_channel.queue_size(); s.down_bandwidth_queue = m_download_channel.queue_size(); diff --git a/src/torrent.cpp b/src/torrent.cpp index afd792984..3d88c3c34 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1363,7 +1363,7 @@ namespace libtorrent m_ses.m_alerts.post_alert(hash_failed_alert(get_handle(), index)); // increase the total amount of failed bytes - m_total_failed_bytes += m_torrent_file->piece_size(index); + add_failed_bytes(m_torrent_file->piece_size(index)); std::vector downloaders; m_picker->get_downloaders(downloaders, index); @@ -4208,6 +4208,20 @@ namespace libtorrent return st; } + void torrent::add_redundant_bytes(int b) + { + TORRENT_ASSERT(b > 0); + m_total_redundant_bytes += b; + m_ses.add_redundant_bytes(b); + } + + void torrent::add_failed_bytes(int b) + { + TORRENT_ASSERT(b > 0); + m_total_failed_bytes += b; + m_ses.add_failed_bytes(b); + } + int torrent::num_seeds() const { INVARIANT_CHECK;