本文介绍了优化洪流下载序列使用libtorrent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有2+个客户端(由我开发)全部使用libtorrent()

Suppose I have 2+ clients (developed by me) ALL using libtorrent ( http://www.rasterbar.com/products/libtorrent/manual.html#queuing )

我可以有效地优先从其他客户端下载文件他们从文件的开头向它的结尾下载文件的块/块(这里是torrent术语),而不是完全按照随机顺序?

Can I prioritize download of a file from other clients effectively so that they download the file's pieces/chunks (whatever is torrent terminology here) from beginning of the file towards its end and not quite in random order?

由于可用性和性能的原因,允许一些复用/交织片段,但是这里的目标是从文件的开始到结束尽可能线性地和快速地下载)

(of course I'm allowing some "multiplexing" / "intertwining" pieces for reasons of availability and performance, but the goal here is to download as linearly and quickly from the start of the file towards the end as possible)

我在这里想的目标显然是快速预览文件。如何最有效地使用libtorrent /可能其他C + +洪流库?

The goal I'm thinking about here is obviously previewing the file quickly. How to do this most effectively using libtorrent / possibly other C++ torrent library?

(我不太感兴趣的torrent实现使用非二进制语言,如Java或Python - 我需要机器代码,因为性能和安全性的原因,所以,C,C ++或可能D都适合账单)

(I'm not quite interested in torrent implementations using non-binary languages, like Java or Python - I need machine code for reasons of performance and security, so, C, C++ or possibly D would all fit the bill)

推荐答案

你一定可以优先使用 torrent_handle :: prioritize_pieces() torrent_handle :: prioritize_files()。请参阅。

You can certainly prioritize pieces and files with torrent_handle::prioritize_pieces() and torrent_handle::prioritize_files(). See the documentation.

这不足以按顺序下载。为此,您可以使用 torrent_handle :: set_sequential_download()启用顺序下载。这将按顺序发出新的片段请求。请记住,请求被满足的时间取决于与你谈话的同伴。按顺序提出请求并不一定意味着按顺序接收这些片段。

This won't be enough to download in-order though. To do that, you can enable sequential download with torrent_handle::set_sequential_download(). This will issue new piece requests in-order. Keep in mind that the time a request take to be satisfied varies a lot depending on which peer you talk to. Making the requests in-order does not necessarily mean receiving the pieces in order.

有另一种机制尝试这样做。 torrent_handle :: set_piece_deadline()用于设置一个片段的目标完成时间。这些片段被认为是时间关键的片段,并且它们在截止日期之前排序,并且最快的同位体用于从这些片段请求块,试图以期限顺序下载它们。

There is another mechanism to attempt to do that. torrent_handle::set_piece_deadline() is used to set a target completion time for a piece. Such pieces are considered time-critical pieces, and they are ordered by their deadline and the fastest peers are used to request blocks from those pieces, attempting to download them in deadline-order.

现在,我还得到一个印象,你想要两个单独的客户端(大概运行在不同的机器),以协调他们下载哪些片段。是对的吗?

Now, I also get the impression that you want two separate clients (presumably running on different machines) to coordinate which pieces they download. Is that right? It's not entirely clear what you're asking about, but there's no simple way of asking libtorrent to do that.

你可以为libtorrent编写一个插件来实现一个新的扩展,这是一个非常简单的方法来请求libtorrent来做这件事。消息,这些客户端可以通过将其优先级设置为0来取消选择其他客户端正在下载的某些片段。

You could write a plugin for libtorrent that implements a new extension message for these clients to chat and coordinate, which could de-select certain pieces the other client is downloading by setting their priority to 0.

这篇关于优化洪流下载序列使用libtorrent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-10 22:25