Author: ninehills
Labels: blog
Created: 2022-01-29T14:22:52Z
Link and comments: https://github.com/ninehills/blog/issues/88
https://github.com/ninehills/p2pfile
做种:
Creates and seeds a torrent from file paths. Usage:
p2pfile serve <FILE_PATH>
Usage:
p2pfile serve [flags]
Flags:
--tracker-ip string Set tracker ip. (default: default route ip)
--tracker-port int Set tracker port. (default: random port in port-range, See --port-range)
--tracker-port-range string Set tracker random port range. (default: 42070-42099) (default "42070-42099")
-h, --help help for serve
Global Flags:
--config string config file (default is $HOME/.p2pfile.yaml)
--debug Debug mode.
--download-limit float Set download limit, MiB. (default: 0.0)
--upload-limit float Set upload limit, MiB. (default: 0.0)
下载:
Download file from magnet uri. Usage:
p2pfile download <MAGNET_URI>
Usage:
p2pfile download [flags]
Flags:
--seeding Seeding after download
--seeding-max-time int Seeding after download finish max time in seconds. default: 600(10min) (default 600)
--seeding-auto-stop Stop seeding after all nodes download finish. default: true (default true)
--dir string Set download dir. (default: .)
-h, --help help for download
Global Flags:
--config string config file (default is $HOME/.p2pfile.yaml)
--debug Debug mode.
--download-limit float Set download limit, MiB. (default: 0.0)
--upload-limit float Set upload limit, MiB. (default: 0.0)
测试条件:
测试结果:
1GiB 文件使用 pscp 从做种节点 10 并发拷贝到所有下载节点
pscp -t 0 -p 10 -O StrictHostKeyChecking=no -h hosts -l root -w "xxxxxx" 1Gi /root/
# 启动时间:16:08:10
# 完成时间:16:10:14
# 耗时:4min4s = 244s,单节点平均下载速度为4.2MB/s
1GiB 文件使用 P2P分发(没有计算做种时间和命令分发启动时间)
14:59:24 - 14:59:54 30s,单节点平均下载速度为34.1MB/s
10GiB 文件使用 P2P分发(没有计算做种时间和命令分发启动时间)
15:04:00 - 15:13:00 7min = 420s,单节点平均下载速度为24.4MB/s
发现还是有一定的长尾,比如在6分钟的时候,有的节点已经下载完成,但是还有的节点才33%。