如何从 BitTorrent 群中收集统计数据?
我想收集新的 BitTorrent 群中文件传播的统计数据,而不实际下载任何内容(或尽可能少地下载)。我需要知道哪个对等点有哪些部分(以进行基于文件的统计),仅了解播种者和水蛭的数量或百分比是不够的。后来当有很多同行时我需要下载数据来确定它是什么。这部分可以使用常规的 torrent 客户端来完成。
我不打算自己实现该协议,因此我查看了 libtorrent 和 ktorrent 的 libbtcore 的 2 个实现。两者都无法在不下载时收集数据,当没有任何内容可下载时,根本就没有连接的对等点。 Libtorrent 更简单,但 ktorrent 看起来评论更好。
我看到了 3 种可能性:
- 使用一些专门用于此目的的应用程序。有吗?
- 修改 torrent 实现来执行我想要的操作。有人认识他们吗?从哪里开始?
- 实现协议的一小部分。只需定期询问同伴他们有什么。这是可行的还是该程序需要支持几乎完整的协议?
你有什么建议吗?
I want to collect statistics from the spreading of a file in a new bittorrent swarm without actually downloading anything (or as little as possible). I need to know which peer has which pieces (to make file based statistics) knowing the number of seeders and leechers or percentages is not enough. Later when there are many peers I need to download the data to determine what it is. This part can be done with a regular torrent client.
I do not plan to implement the protocol myself so I looked at 2 implementations libtorrent and ktorrent's libbtcore. Neither is capable of collecting data while not downloading there are simply no connected peers when there is nothing to download. Libtorrent is simpler but ktorrent looks better commented.
I see 3 possibilities:
- Use some application exactly for this. Are there any?
- Modify a torrent implementation to do what I want. Is anyone familiar with them? Where to start?
- Implement a small subset of the protocol. Just periodically ask the peers what they have. Is this feasible or would the program need to support almost the full protocol?
What do you recommend?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个老问题,但也许这个答案对其他人有用。
据我所知没有。
我只熟悉 BitTornado 核心(例如 ABC 中使用的)。它是用 Python 编写的,但架构混乱。
但是,您可以采用任何实现并开始将其从不必要的功能中剥离。
请注意,您不能“询问”同伴他们拥有什么。另一个对等点会在需要其拥有的片段时通知您(因此是推而不是拉)。 BitTorrent 握手后,对等方可以发送 位域 它拥有的片段。之后它可能会发送 HAVE 消息,通知您它已经获得了一件新作品。另请注意,同行可能会对他们拥有的作品撒谎。示例包括超级播种节点和像 BitThief 这样的搭便车客户端。
如果您想实现协议的一小部分,您至少需要实现 BitTorrent 握手消息,最好是扩展握手消息。后者允许您接收(和发送)uTorrent PEX 消息。 PEX 对于快速发现群中的其他对等点很有用。
为了收集统计数据,您还需要支持位字段和 HAVE 消息。
This is an old question, but perhaps this answer might be useful for others.
Not that I know of.
I'm only familiar with the BitTornado core (that is used in e.g. ABC). It is written in Python, but it's an architectural mess.
However, you could just take any implementation and start stripping it from unnecessary functionality.
Note that you cannot "ask" a peer what they have. The other peer informs you whenever it wants about the pieces it has (so it's push instead of pull). After the BitTorrent handshake, a peer may send a bitfield of pieces it has. Afterwards it may send HAVE messages informing you it has acquired a new piece. Also note that peers may lie about the pieces they have. Examples include superseeding peers and freeriding clients like BitThief.
If you want to implement a small subset of the protocol, you'd need at the bare minimum implement the BitTorrent handshake message and preferably the extended handshake message. The latter allows you to receive (and send) uTorrent PEX messages. PEX is useful to quickly discover other peers in the swarm.
For your statistics gathering purposes, you additionally need to support the bitfield and HAVE messages.