scp、paramiko、rsync上传下载限流、限速、速度控制方法

1、scp限速
 scp -l 800 a.txt  user@ip:/home/admin/downloads
此时的传输速率就是800/8=100KB左右
man -a scp查看参数含义。注意单位是bit

2、rsync是用来同步更新的,也可以用来上传文件,但是不建议这样使用

man -a rsync查看参数帮助信息

使用rsync实现限速100KB/s
  rsync -auvzP --bwlimit=100 本地文件 远程文件
参数说明:
 v:详细提示 
 a:以archive模式操作,复制目录、符号连接,等价于 -rlptgoD 。
 z:压缩
 u:只进行更新,防止本地新文件被重写,注意两者机器的时钟的同时
 P:是综合了--partial --progress两个参数,
 此时的rsync支持了断点续传
 
3、paramiko限速使用的是http://docs.paramiko.org/en/latest/api/sftp.html里的 classmethod from_transport(t, window_size=None, max_packet_size=None)。官方发文称:
etting the window and packet sizes might affect the transfer speed. The default settings in the Transport class are the same as in OpenSSH and should work adequately for both files transfers and interactive sessions.
只是可能起到限速的左右,而且正确用法是:window_size有个最大值和最小值、默认值,你必须选择其间的值。
默认值是64*2**15字节,也就是2M。最小值是32K,最大值是2的32次方减去1。
但是测试的时候发现,限速其实没有起作用
 

测试代码:

4、但是网上倒是给了个加速上传和下载的方法:http://1codelife.com/2017/11/30/paramiko-larger-file-update/

 
原文地址:https://www.cnblogs.com/shengulong/p/9018968.html