expose more info through peer_info
This commit is contained in:
parent
9fca960d3c
commit
3a727e99ff
|
@ -2242,6 +2242,14 @@ struct peer_info
|
|||
int upload_limit;
|
||||
int download_limit;
|
||||
|
||||
time_duration last_request;
|
||||
time_duration last_active;
|
||||
|
||||
int send_buffer_size;
|
||||
int used_send_buffer;
|
||||
|
||||
int num_hashfails;
|
||||
|
||||
char country[2];
|
||||
|
||||
size_type load_balancing;
|
||||
|
@ -2249,6 +2257,8 @@ struct peer_info
|
|||
int download_queue_length;
|
||||
int upload_queue_length;
|
||||
|
||||
int failcount;
|
||||
|
||||
int downloading_piece_index;
|
||||
int downloading_block_index;
|
||||
int downloading_progress;
|
||||
|
@ -2383,6 +2393,12 @@ peer every second. It may be -1 if there's no local limit on the peer. The globa
|
|||
limit and the torrent limit is always enforced anyway.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">download_limit</span></tt> is the number of bytes per second this peer is allowed to
|
||||
receive. -1 means it's unlimited.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">last_request</span></tt> and <tt class="docutils literal"><span class="pre">last_active</span></tt> is the time since we last sent a request
|
||||
to this peer and since any transfer occurred with this peer, respectively.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">send_buffer_size</span></tt> and <tt class="docutils literal"><span class="pre">used_send_buffer</span></tt> is the number of bytes allocated
|
||||
and used for the peer's send buffer, respectively.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">num_hashfails</span></tt> is the number of pieces this peer has participated in
|
||||
sending us that turned out to fail the hash check.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">country</span></tt> is the two letter <a class="reference" href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166 country code</a> for the country the peer
|
||||
is connected from. If the country hasn't been resolved yet, both chars are set
|
||||
to 0. If the resolution failed for some reason, the field is set to "--". If the
|
||||
|
@ -2398,6 +2414,9 @@ download.</p>
|
|||
that hasn't been answered with a piece yet.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">upload_queue_length</span></tt> is the number of piece-requests we have received from this peer
|
||||
that we haven't answered with a piece yet.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">failcount</span></tt> is the number of times this peer has "failed". i.e. failed to connect
|
||||
or disconnected us. The failcount is decremented when we see this peer in a tracker
|
||||
response or peer exchange message.</p>
|
||||
<p>You can know which piece, and which part of that piece, that is currently being
|
||||
downloaded from a specific peer by looking at the next four members.
|
||||
<tt class="docutils literal"><span class="pre">downloading_piece_index</span></tt> is the index of the piece that is currently being downloaded.
|
||||
|
|
|
@ -2231,6 +2231,14 @@ It contains the following fields::
|
|||
int upload_limit;
|
||||
int download_limit;
|
||||
|
||||
time_duration last_request;
|
||||
time_duration last_active;
|
||||
|
||||
int send_buffer_size;
|
||||
int used_send_buffer;
|
||||
|
||||
int num_hashfails;
|
||||
|
||||
char country[2];
|
||||
|
||||
size_type load_balancing;
|
||||
|
@ -2238,6 +2246,8 @@ It contains the following fields::
|
|||
int download_queue_length;
|
||||
int upload_queue_length;
|
||||
|
||||
int failcount;
|
||||
|
||||
int downloading_piece_index;
|
||||
int downloading_block_index;
|
||||
int downloading_progress;
|
||||
|
@ -2357,6 +2367,15 @@ limit and the torrent limit is always enforced anyway.
|
|||
``download_limit`` is the number of bytes per second this peer is allowed to
|
||||
receive. -1 means it's unlimited.
|
||||
|
||||
``last_request`` and ``last_active`` is the time since we last sent a request
|
||||
to this peer and since any transfer occurred with this peer, respectively.
|
||||
|
||||
``send_buffer_size`` and ``used_send_buffer`` is the number of bytes allocated
|
||||
and used for the peer's send buffer, respectively.
|
||||
|
||||
``num_hashfails`` is the number of pieces this peer has participated in
|
||||
sending us that turned out to fail the hash check.
|
||||
|
||||
``country`` is the two letter `ISO 3166 country code`__ for the country the peer
|
||||
is connected from. If the country hasn't been resolved yet, both chars are set
|
||||
to 0. If the resolution failed for some reason, the field is set to "--". If the
|
||||
|
@ -2378,6 +2397,10 @@ that hasn't been answered with a piece yet.
|
|||
``upload_queue_length`` is the number of piece-requests we have received from this peer
|
||||
that we haven't answered with a piece yet.
|
||||
|
||||
``failcount`` is the number of times this peer has "failed". i.e. failed to connect
|
||||
or disconnected us. The failcount is decremented when we see this peer in a tracker
|
||||
response or peer exchange message.
|
||||
|
||||
You can know which piece, and which part of that piece, that is currently being
|
||||
downloaded from a specific peer by looking at the next four members.
|
||||
``downloading_piece_index`` is the index of the piece that is currently being downloaded.
|
||||
|
|
|
@ -306,7 +306,7 @@ int peer_index(libtorrent::tcp::endpoint addr, std::vector<libtorrent::peer_info
|
|||
void print_peer_info(std::ostream& out, std::vector<libtorrent::peer_info> const& peers)
|
||||
{
|
||||
using namespace libtorrent;
|
||||
out << "IP down (total) up (total) sent-req recv flags source fail hshf sndb inactive wait disk quota block-progress "
|
||||
out << "IP down (total) up (total) sent-req recv flags source fail hshf sndb inactive wait disk quota block-progress "
|
||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
"country "
|
||||
#endif
|
||||
|
@ -340,11 +340,13 @@ void print_peer_info(std::ostream& out, std::vector<libtorrent::peer_info> const
|
|||
<< ((i->flags & peer_info::seed)?'s':'.')
|
||||
<< ((i->flags & peer_info::on_parole)?'p':'.')
|
||||
<< ((i->flags & peer_info::optimistic_unchoke)?'O':'.')
|
||||
<< ((i->flags & peer_info::reading)?'R':(i->flags & peer_info::waiting_read_quota)?'r':'.')
|
||||
<< ((i->flags & peer_info::writing)?'W':(i->flags & peer_info::waiting_write_quota)?'w':'.')
|
||||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||
<< ((i->flags & peer_info::rc4_encrypted)?'E':
|
||||
(i->flags & peer_info::plaintext_encrypted)?'e':'.')
|
||||
#else
|
||||
<< " "
|
||||
<< ".."
|
||||
#endif
|
||||
<< " "
|
||||
<< ((i->source & peer_info::tracker)?"T":"_")
|
||||
|
@ -354,10 +356,10 @@ void print_peer_info(std::ostream& out, std::vector<libtorrent::peer_info> const
|
|||
<< ((i->source & peer_info::resume_data)?"R":"_") << " "
|
||||
<< to_string(i->failcount, 2) << " "
|
||||
<< to_string(i->num_hashfails, 2) << " "
|
||||
<< to_string(i->send_buffer_size, 6) << " "
|
||||
<< to_string(i->used_send_buffer, 6) << " ("<< add_suffix(i->send_buffer_size) << ") "
|
||||
<< to_string(total_seconds(i->last_active), 8) << " "
|
||||
<< to_string(total_seconds(i->last_request), 4) << " "
|
||||
<< to_string(i->pending_disk_bytes, 6) << " "
|
||||
<< add_suffix(i->pending_disk_bytes) << " "
|
||||
<< to_string(i->send_quota, 5) << " ";
|
||||
|
||||
if (i->downloading_piece_index >= 0)
|
||||
|
|
|
@ -669,10 +669,8 @@ namespace libtorrent
|
|||
// request is in progress.
|
||||
bool m_writing;
|
||||
bool m_reading;
|
||||
#ifndef NDEBUG
|
||||
bool m_requested_write_quota;
|
||||
bool m_requested_read_quota;
|
||||
#endif
|
||||
|
||||
// if set to non-zero, this peer will always prefer
|
||||
// to request entire n pieces, rather than blocks.
|
||||
|
|
|
@ -57,7 +57,11 @@ namespace libtorrent
|
|||
queued = 0x100,
|
||||
on_parole = 0x200,
|
||||
seed = 0x400,
|
||||
optimistic_unchoke = 0x800
|
||||
optimistic_unchoke = 0x800,
|
||||
writing = 0x1000,
|
||||
reading = 0x2000,
|
||||
waiting_write_quota = 0x4000,
|
||||
waiting_read_quota = 0x8000
|
||||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||
, rc4_encrypted = 0x100000,
|
||||
plaintext_encrypted = 0x200000
|
||||
|
@ -96,8 +100,10 @@ namespace libtorrent
|
|||
// time since last download or upload
|
||||
time_duration last_active;
|
||||
|
||||
// the size of the send buffer for this peer
|
||||
// the size of the send buffer for this peer, in bytes
|
||||
int send_buffer_size;
|
||||
// the number bytes that's actually used of the send buffer
|
||||
int used_send_buffer;
|
||||
|
||||
// the number of failed hashes for this peer
|
||||
int num_hashfails;
|
||||
|
|
|
@ -107,6 +107,8 @@ namespace libtorrent
|
|||
, m_queued(true)
|
||||
, m_writing(false)
|
||||
, m_reading(false)
|
||||
, m_requested_write_quota(false)
|
||||
, m_requested_read_quota(false)
|
||||
, m_prefer_whole_pieces(false)
|
||||
, m_request_large_blocks(false)
|
||||
, m_non_prioritized(false)
|
||||
|
@ -135,8 +137,6 @@ namespace libtorrent
|
|||
#endif
|
||||
#ifndef NDEBUG
|
||||
piece_failed = false;
|
||||
m_requested_read_quota = false;
|
||||
m_requested_write_quota = false;
|
||||
#endif
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
|
@ -190,6 +190,8 @@ namespace libtorrent
|
|||
, m_queued(false)
|
||||
, m_writing(false)
|
||||
, m_reading(false)
|
||||
, m_requested_write_quota(false)
|
||||
, m_requested_read_quota(false)
|
||||
, m_prefer_whole_pieces(false)
|
||||
, m_request_large_blocks(false)
|
||||
, m_non_prioritized(false)
|
||||
|
@ -234,8 +236,6 @@ namespace libtorrent
|
|||
|
||||
#ifndef NDEBUG
|
||||
piece_failed = false;
|
||||
m_requested_read_quota = false;
|
||||
m_requested_write_quota = false;
|
||||
#endif
|
||||
std::fill(m_peer_id.begin(), m_peer_id.end(), 0);
|
||||
}
|
||||
|
@ -2224,6 +2224,11 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
p.send_buffer_size = m_send_buffer.capacity();
|
||||
p.used_send_buffer = m_send_buffer.size();
|
||||
p.flags |= m_reading ? peer_info::reading : 0;
|
||||
p.flags |= m_writing ? peer_info::writing : 0;
|
||||
p.flags |= m_requested_write_quota ? peer_info::waiting_write_quota : 0;
|
||||
p.flags |= m_requested_read_quota ? peer_info::waiting_read_quota : 0;
|
||||
}
|
||||
|
||||
void peer_connection::cut_receive_buffer(int size, int packet_size)
|
||||
|
@ -2496,22 +2501,14 @@ namespace libtorrent
|
|||
m_bandwidth_limit[channel].assign(amount);
|
||||
if (channel == upload_channel)
|
||||
{
|
||||
TORRENT_ASSERT(m_writing);
|
||||
m_writing = false;
|
||||
#ifndef NDEBUG
|
||||
TORRENT_ASSERT(m_requested_write_quota);
|
||||
m_requested_write_quota = false;
|
||||
#endif
|
||||
setup_send();
|
||||
}
|
||||
else if (channel == download_channel)
|
||||
{
|
||||
TORRENT_ASSERT(m_reading);
|
||||
m_reading = false;
|
||||
#ifndef NDEBUG
|
||||
TORRENT_ASSERT(m_requested_read_quota);
|
||||
m_requested_read_quota = false;
|
||||
#endif
|
||||
setup_receive();
|
||||
}
|
||||
}
|
||||
|
@ -2537,7 +2534,7 @@ namespace libtorrent
|
|||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_writing) return;
|
||||
if (m_writing || m_requested_write_quota) return;
|
||||
|
||||
shared_ptr<torrent> t = m_torrent.lock();
|
||||
|
||||
|
@ -2559,11 +2556,8 @@ namespace libtorrent
|
|||
|
||||
TORRENT_ASSERT(!m_writing);
|
||||
// peers that we are not interested in are non-prioritized
|
||||
m_writing = true;
|
||||
#ifndef NDEBUG
|
||||
TORRENT_ASSERT(!m_requested_write_quota);
|
||||
m_requested_write_quota = true;
|
||||
#endif
|
||||
t->request_bandwidth(upload_channel, self()
|
||||
, !(is_interesting() && !has_peer_choked())
|
||||
, m_send_buffer.size());
|
||||
|
@ -2604,7 +2598,7 @@ namespace libtorrent
|
|||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << "setup_receive: reading = " << m_reading << "\n";
|
||||
#endif
|
||||
if (m_reading) return;
|
||||
if (m_reading || m_requested_read_quota) return;
|
||||
|
||||
shared_ptr<torrent> t = m_torrent.lock();
|
||||
|
||||
|
@ -2618,11 +2612,8 @@ namespace libtorrent
|
|||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << "req bandwidth [ " << download_channel << " ]\n";
|
||||
#endif
|
||||
m_reading = true;
|
||||
#ifndef NDEBUG
|
||||
TORRENT_ASSERT(!m_requested_read_quota);
|
||||
m_requested_read_quota = true;
|
||||
#endif
|
||||
t->request_bandwidth(download_channel, self(), m_non_prioritized
|
||||
, m_download_queue.size() * 16 * 1024 + 30);
|
||||
}
|
||||
|
@ -3039,6 +3030,9 @@ namespace libtorrent
|
|||
|| m_bandwidth_limit[i].throttle() == bandwidth_limit::inf);
|
||||
}
|
||||
|
||||
TORRENT_ASSERT(int(m_reading) + int(m_requested_read_quota) <= 1);
|
||||
TORRENT_ASSERT(int(m_writing) + int(m_requested_write_quota) <= 1);
|
||||
|
||||
std::set<piece_block> unique;
|
||||
std::copy(m_download_queue.begin(), m_download_queue.end(), std::inserter(unique, unique.begin()));
|
||||
std::copy(m_request_queue.begin(), m_request_queue.end(), std::inserter(unique, unique.begin()));
|
||||
|
|
|
@ -2301,6 +2301,8 @@ namespace libtorrent
|
|||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
TORRENT_ASSERT(amount > 0);
|
||||
m_bandwidth_limit[channel].expire(amount);
|
||||
queue_t tmp;
|
||||
|
|
Loading…
Reference in New Issue