*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-01-31 10:20:19 +00:00
parent 03561913df
commit 5b7100656e
10 changed files with 119 additions and 65 deletions

View File

@ -597,11 +597,13 @@ struct torrent_status
boost::posix_time::time_duration next_announce;
boost::posix_time::time_duration announce_interval;
std::size_t total_download;
std::size_t total_upload;
std::string current_tracker;
std::size_t total_payload_download;
std::size_t total_payload_upload;
size_type total_download;
size_type total_upload;
size_type total_payload_download;
size_type total_payload_upload;
float download_rate;
float upload_rate;
@ -609,7 +611,7 @@ struct torrent_status
int num_peers;
const std::vector<bool>* pieces;
std::size_t total_done;
size_type total_done;
};
</pre>
<p><tt class="literal"><span class="pre">progress</span></tt> is a value in the range [0, 1], that represents the progress of the
@ -649,6 +651,8 @@ is a pure seeder.</td>
<p><tt class="literal"><span class="pre">next_announce</span></tt> is the time until the torrent will announce itself to the tracker. And
<tt class="literal"><span class="pre">announce_interval</span></tt> is the time the tracker want us to wait until we announce ourself
again the next time.</p>
<p><tt class="literal"><span class="pre">current_tracker</span></tt> is the URL of the last working tracker. If no tracker request has
been successful yet, it's set to an empty string.</p>
<p><tt class="literal"><span class="pre">total_download</span></tt> and <tt class="literal"><span class="pre">total_upload</span></tt> is the number of bytes downloaded and
uploaded to all peers, accumulated, <em>this session</em> only.</p>
<p><tt class="literal"><span class="pre">total_payload_download</span></tt> and <tt class="literal"><span class="pre">total_payload_upload</span></tt> counts the amount of bytes
@ -1146,38 +1150,52 @@ struct hash_failed_alert: alert
<div class="section" id="peer-error-alert">
<h2><a name="peer-error-alert">peer_error_alert</a></h2>
<p>This alert is generated when a peer sends invalid data over the peer-peer protocol. The peer
will be disconnected, but you get its peer-id from the alert. This alert is generated
as severity level <tt class="literal"><span class="pre">debug</span></tt>.</p>
will be disconnected, but you get its ip address from the alert, to identify it. This alert
is generated as severity level <tt class="literal"><span class="pre">debug</span></tt>.</p>
<pre class="literal-block">
struct peer_error_alert: alert
{
peer_error_alert(const peer_id&amp; pid, const std::string&amp; msg);
peer_error_alert(const address&amp; pid, const std::string&amp; msg);
virtual std::auto_ptr&lt;alert&gt; clone() const;
peer_id id;
address ip;
};
</pre>
</div>
<div class="section" id="invalid-request-alert">
<h2><a name="invalid-request-alert">invalid_request_alert</a></h2>
<p>This is a debug alert that is generated by an incoming invalid piece request. It is
generated as severity level <tt class="literal"><span class="pre">debug</span></tt>.</p>
<p>This is a debug alert that is generated by an incoming invalid piece request. The <tt class="literal"><span class="pre">handle</span></tt>
is a handle to the torrent the peer is a member of. <tt class="literal"><span class="pre">ìp</span></tt> is the address of the peer and the
<tt class="literal"><span class="pre">request</span></tt> is the actual incoming request from the peer. The alert is generated as severity level
<tt class="literal"><span class="pre">debug</span></tt>.</p>
<pre class="literal-block">
struct invalid_request_alert: alert
{
invalid_request_alert(
const peer_request&amp; r
, const torrent_handle&amp; h
, const peer_id&amp; send
, const address&amp; send
, const std::string&amp; msg);
virtual std::auto_ptr&lt;alert&gt; clone() const;
torrent_handle handle;
peer_id sender;
address ip;
peer_request request;
};
struct peer_request
{
int piece;
int start;
int length;
bool operator==(const peer_request&amp; r);
};
</pre>
<p>The <tt class="literal"><span class="pre">peer_request</span></tt> contains the values the client sent in its <tt class="literal"><span class="pre">request</span></tt> message. <tt class="literal"><span class="pre">piece</span></tt> is
the index of the piece it want data from, <tt class="literal"><span class="pre">start</span></tt> is the offset within the piece where the data
should be read, and <tt class="literal"><span class="pre">length</span></tt> is the amount of data it wants.</p>
</div>
<div class="section" id="torrent-finished-alert">
<h2><a name="torrent-finished-alert">torrent_finished_alert</a></h2>
@ -1203,7 +1221,7 @@ This alert is generated when you receive a chat message from another peer. Chat
are supported as an extension ("chat"). It is generated as severity level ``critical``,
even though it doesn't necessarily require any user intervention, it's high priority
since you would almost never want to ignore such a message. The alert class contain
a torrent_handle_ to the torrent in which the sender-peer is a member and the peer_id
a torrent_handle_ to the torrent in which the sender-peer is a member and the ip
of the sending peer.
::
@ -1211,13 +1229,13 @@ of the sending peer.
struct chat_message_alert: alert
{
chat_message_alert(const torrent_handle& h
, const peer_id& sender
, const address& sender
, const std::string& msg);
virtual std::auto_ptr<alert> clone() const;
torrent_handle handle;
peer_id sender;
address ip;
}; -->
</div>
<div class="section" id="dispatcher">

View File

@ -595,11 +595,13 @@ It contains the following fields::
boost::posix_time::time_duration next_announce;
boost::posix_time::time_duration announce_interval;
std::size_t total_download;
std::size_t total_upload;
std::string current_tracker;
std::size_t total_payload_download;
std::size_t total_payload_upload;
size_type total_download;
size_type total_upload;
size_type total_payload_download;
size_type total_payload_upload;
float download_rate;
float upload_rate;
@ -607,7 +609,7 @@ It contains the following fields::
int num_peers;
const std::vector<bool>* pieces;
std::size_t total_done;
size_type total_done;
};
``progress`` is a value in the range [0, 1], that represents the progress of the
@ -643,6 +645,9 @@ current task is in the ``state`` member, it will be one of the following:
``announce_interval`` is the time the tracker want us to wait until we announce ourself
again the next time.
``current_tracker`` is the URL of the last working tracker. If no tracker request has
been successful yet, it's set to an empty string.
``total_download`` and ``total_upload`` is the number of bytes downloaded and
uploaded to all peers, accumulated, *this session* only.
@ -1190,25 +1195,27 @@ peer_error_alert
----------------
This alert is generated when a peer sends invalid data over the peer-peer protocol. The peer
will be disconnected, but you get its peer-id from the alert. This alert is generated
as severity level ``debug``.
will be disconnected, but you get its ip address from the alert, to identify it. This alert
is generated as severity level ``debug``.
::
struct peer_error_alert: alert
{
peer_error_alert(const peer_id& pid, const std::string& msg);
peer_error_alert(const address& pid, const std::string& msg);
virtual std::auto_ptr<alert> clone() const;
peer_id id;
address ip;
};
invalid_request_alert
---------------------
This is a debug alert that is generated by an incoming invalid piece request. It is
generated as severity level ``debug``.
This is a debug alert that is generated by an incoming invalid piece request. The ``handle``
is a handle to the torrent the peer is a member of. ``ìp`` is the address of the peer and the
``request`` is the actual incoming request from the peer. The alert is generated as severity level
``debug``.
::
@ -1217,17 +1224,30 @@ generated as severity level ``debug``.
invalid_request_alert(
const peer_request& r
, const torrent_handle& h
, const peer_id& send
, const address& send
, const std::string& msg);
virtual std::auto_ptr<alert> clone() const;
torrent_handle handle;
peer_id sender;
address ip;
peer_request request;
};
struct peer_request
{
int piece;
int start;
int length;
bool operator==(const peer_request& r);
};
The ``peer_request`` contains the values the client sent in its ``request`` message. ``piece`` is
the index of the piece it want data from, ``start`` is the offset within the piece where the data
should be read, and ``length`` is the amount of data it wants.
torrent_finished_alert
----------------------
@ -1256,7 +1276,7 @@ torrent in question. This alert is generated as severity level ``info``.
are supported as an extension ("chat"). It is generated as severity level ``critical``,
even though it doesn't necessarily require any user intervention, it's high priority
since you would almost never want to ignore such a message. The alert class contain
a torrent_handle_ to the torrent in which the sender-peer is a member and the peer_id
a torrent_handle_ to the torrent in which the sender-peer is a member and the ip
of the sending peer.
::
@ -1264,13 +1284,13 @@ torrent in question. This alert is generated as severity level ``info``.
struct chat_message_alert: alert
{
chat_message_alert(const torrent_handle& h
, const peer_id& sender
, const address& sender
, const std::string& msg);
virtual std::auto_ptr<alert> clone() const;
torrent_handle handle;
peer_id sender;
address ip;
};

View File

@ -370,6 +370,7 @@ int main(int argc, char* argv[])
boost::posix_time::time_duration t = s.next_announce;
out << "next announce: " << boost::posix_time::to_simple_string(t) << "\n";
out << "tracker: " << s.current_tracker << "\n";
out << "___________________________________\n";

View File

@ -72,35 +72,33 @@ namespace libtorrent
struct peer_error_alert: alert
{
peer_error_alert(const peer_id& pid, const std::string& msg)
peer_error_alert(const address& pip, const std::string& msg)
: alert(alert::debug, msg)
, id(pid)
, ip(pip)
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new peer_error_alert(*this)); }
// TODO: use address instead of peer_id
peer_id id;
address ip;
};
struct chat_message_alert: alert
{
chat_message_alert(
const torrent_handle& h
, const peer_id& send
, const address& sender
, const std::string& msg)
: alert(alert::critical, msg)
, handle(h)
, sender(send)
, ip(sender)
{}
virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new chat_message_alert(*this)); }
torrent_handle handle;
// TODO: use address instead of peer_id
peer_id sender;
address ip;
};
struct invalid_request_alert: alert
@ -108,11 +106,11 @@ namespace libtorrent
invalid_request_alert(
const peer_request& r
, const torrent_handle& h
, const peer_id& send
, const address& sender
, const std::string& msg)
: alert(alert::debug, msg)
, handle(h)
, sender(send)
, ip(sender)
, request(r)
{}
@ -120,8 +118,7 @@ namespace libtorrent
{ return std::auto_ptr<alert>(new invalid_request_alert(*this)); }
torrent_handle handle;
// TODO: use address instead of peer_id
peer_id sender;
address ip;
peer_request request;
};

View File

@ -50,7 +50,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <exception>
#include <string>
// TODO: support QoS
// TODO: support ToS
namespace libtorrent
{

View File

@ -100,7 +100,7 @@ namespace libtorrent
boost::posix_time::time_duration next_announce;
boost::posix_time::time_duration announce_interval;
// TODO: add name of tracker that is currently used
std::string current_tracker;
// transferred this session!
// total, payload plus protocol

View File

@ -601,7 +601,7 @@ namespace libtorrent
m_torrent->alerts().post_alert(invalid_request_alert(
r
, m_torrent->get_handle()
, m_peer_id
, m_socket->sender()
, "peer sent an illegal request, ignoring"));
}
}
@ -715,7 +715,7 @@ namespace libtorrent
{
m_torrent->alerts().post_alert(
peer_error_alert(
m_peer_id
m_socket->sender()
, "got a block that was not requested"));
}
#ifndef NDEBUG
@ -885,8 +885,10 @@ namespace libtorrent
if (m_torrent->alerts().should_post(alert::critical))
{
m_torrent->alerts()
.post_alert(chat_message_alert(m_torrent->get_handle(), m_peer_id, str));
m_torrent->alerts().post_alert(
chat_message_alert(
m_torrent->get_handle()
, m_socket->sender(), str));
}
}
@ -1750,12 +1752,8 @@ namespace libtorrent
send_buffer_updated();
}
// TODO: this could be implemented more efficient
// by maintaining a counter of the number of pieces
// the peer has
bool peer_connection::is_seed() const
{
return std::count(m_have_piece.begin(), m_have_piece.end(), true)
== (int)m_have_piece.size();
return m_num_pieces == m_have_piece.size();
}
}

View File

@ -93,15 +93,29 @@ namespace
namespace
{
int to_seconds(const boost::posix_time::time_duration& d)
float to_seconds(const boost::posix_time::time_duration& d)
{
return d.hours() * 60 * 60 + d.minutes() * 60 + d.seconds();
return d.hours() * 60.f * 60.f
+ d.minutes() * 60.f
+ d.seconds()
+ d.fractional_seconds() / 1000.f;
}
}
void request_a_block(torrent& t, peer_connection& c)
{
int desired_queue_size = max_request_queue + 1 - to_seconds(c.last_piece_time()) / 4;
float time_for_last_piece = to_seconds(c.last_piece_time());
if (time_for_last_piece == 0) time_for_last_piece = 0.001f;
const float rate = 1.f / time_for_last_piece;
// this will make the number of requests linearly dependent
// on the rate in which we download from the peer. 2.5kB/s and
// less will make the desired queue size 2 and at about 70 kB/s
// it will reach the maximum of 16 requests.
// matlab expression to plot:
// x = 1:100:100000; plot(x, round(min(max(x ./ 5000 + 1.5, 2), 16)));
int desired_queue_size = rate / 5000.f + 1.5f;
if (desired_queue_size > max_request_queue) desired_queue_size = max_request_queue;
if (desired_queue_size < min_request_queue) desired_queue_size = min_request_queue;
@ -624,7 +638,7 @@ namespace libtorrent
{
assert(!c.is_local());
// TODO: make an exception if the incoming connection
// TODO: have an exception if the incoming connection
// is from the tracker
if(m_torrent->num_peers() >= m_max_connections)
throw protocol_error("too many connections, refusing incoming connection"); // cause a disconnect
@ -720,7 +734,7 @@ namespace libtorrent
if (m_torrent->alerts().should_post(alert::debug))
{
m_torrent->alerts().post_alert(
peer_error_alert(id, e.what()));
peer_error_alert(remote, e.what()));
}
}
catch(protocol_error& e)
@ -728,7 +742,7 @@ namespace libtorrent
if (m_torrent->alerts().should_post(alert::debug))
{
m_torrent->alerts().post_alert(
peer_error_alert(id, e.what()));
peer_error_alert(remote, e.what()));
}
}
}

View File

@ -547,7 +547,7 @@ namespace libtorrent
if (m_alerts.should_post(alert::debug))
{
m_alerts.post_alert(
peer_error_alert(p->second->get_peer_id(), e.what()));
peer_error_alert(p->first->sender(), e.what()));
}
m_selector.remove(*i);
@ -629,7 +629,7 @@ namespace libtorrent
if (m_alerts.should_post(alert::debug))
{
m_alerts.post_alert(
peer_error_alert(p->second->get_peer_id(), e.what()));
peer_error_alert(p->first->sender(), e.what()));
}
// the connection wants to disconnect for some reason, remove it
// from the connection-list
@ -659,7 +659,7 @@ namespace libtorrent
{
m_alerts.post_alert(
peer_error_alert(
p->second->get_peer_id()
p->first->sender()
, "socket received an exception"));
}

View File

@ -228,7 +228,7 @@ namespace libtorrent
, m_ses(ses)
, m_picker(torrent_file.piece_length() / m_block_size,
static_cast<int>((torrent_file.total_size()+m_block_size-1)/m_block_size))
, m_last_working_tracker(0)
, m_last_working_tracker(-1)
, m_currently_trying_tracker(0)
, m_time_scaler(0)
, m_priority(.5)
@ -715,6 +715,12 @@ namespace libtorrent
torrent_status st;
if (m_last_working_tracker >= 0)
{
st.current_tracker
= m_torrent_file.trackers()[m_last_working_tracker].url;
}
st.total_done = bytes_done();
// payload transfer