Libtorrent设置download_limit/upload_limit不起作用 [英] Libtorrent setting download_limit/upload_limit is not working

查看:271
本文介绍了Libtorrent设置download_limit/upload_limit不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对我的libtorrent客户端中的下载/上传速度进行速率限制.我为此使用了以下代码.

I want to rate limit my download/upload speed in my libtorrent client. I am using the following code for this.

params = { 'save_path': '.', \
           'storage_mode': lt.storage_mode_t.storage_mode_sparse, \
           'ti': info, 'flags': 0x020 }

h = ses.add_torrent(params)
h.set_download_limit(100)
h.set_upload_limit(100)
h.resume()

它应该以0.1 kb/sec的速度下载数据,但是仍然以大约1500 kb/sec的速度下载数据.

It should download the data at 0.1 kb/sec, but still it is downloading the data at the speed of around 1500 kb/sec.

100.00% complete (down: 1576.0 kb/s up: 55.0 kB/s)

我想念什么吗?

推荐答案

也许您的同龄人与您所在的本地网络相同.默认情况下,本地对等方不受速率限制(如此处所述).

Perhaps your peers are on the same local network as yourself. By default, local peers are not subject to the rate limit (as documented here).

不幸的是,缺少有关如何将速率限制应用于本地对等方的文档.我已尝试在此拉动请求中对此进行补救.

Unfortunately the documentation on how to make rate limits apply to local peers is a bit lacking. I've tried to remedy that in this pull request.

基本上,要使全局速率限制适用于所有对等端,而不管它们具有哪个IP,请执行以下操作:

Basically, to make the global rate limit apply to all peers, regardless of which IP they have, do this:

std::uint32_t const mask = 1 << lt::session::global_peer_class_id;
ip_filter f;

// for every IPv4 address, assign the global peer class
f.add_rule(address_v4::from_string("0.0.0.0")
    , address_v4::from_string("255.255.255.255")
    , mask);

// for every IPv6 address, assign the global peer class
f.add_rule(address_v6::from_string("::")
    , address_v6::from_string("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
    , mask);
ses.set_peer_class_filter(f);

这篇关于Libtorrent设置download_limit/upload_limit不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆