我使用以下命令来添加延迟,netem
然后使用命令从网络下载文件wget
。当我毫不延迟地下载文件时,它类似于226k
(0.09s
下载所需的时间),但是当我添加延迟时100ms
,现在再次从同一目的地下载相同的文件,但这次我得到的文件大小与105k
一样0.2s
。我收到了预期的延迟,但为什么我收到的文件较小?
添加延迟的命令:-
tc qdisc add dev eth0 root netem delay 100ms
下载文件的命令:-
wget -P . https://www.excentis.com/sites/excentis/files/styles/full-width/public/linux_tc_configs.png 2>&1 | tee -a wget_log
添加延迟后的日志:-
--2018-03-27 08:58:50--
https://www.excentis.com/sites/excentis/files/styles/full-width/public/linux_tc_configs.png
Resolving www.excentis.com (www.excentis.com)... IP_address
Connecting to www.excentis.com (www.excentis.com)|IP_address|:<PORT>... connected.
HTTP request sent, awaiting response... 200 OK
Length: 20016 (20K) [image/png]
Saving to: ‘./linux_tc_configs.png.3’
0K .......... ......... 100% 226K=0.09s
2018-03-27 08:58:51 (226 KB/s) - ‘./linux_tc_configs.png.3’ saved [20016/20016]
添加延迟后的日志:-
--2018-03-27 08:58:23--
https://www.excentis.com/sites/excentis/files/styles/full-width/public/linux_tc_configs.png
Resolving www.excentis.com (www.excentis.com)... IP_address
Connecting to www.excentis.com (www.excentis.com)|IP_address|:<PORT>... connected.
HTTP request sent, awaiting response... 200 OK
Length: 20016 (20K) [image/png]
Saving to: ‘./linux_tc_configs.png.2’
0K .......... ......... 100% 105K=0.2s
2018-03-27 08:58:24 (105 KB/s) - ‘./linux_tc_configs.png.2’ saved [20016/20016]
答案1
使用netem suite时不会发生文件大小压缩。当您使用所使用的命令下载时,文件不会在任何地方被压缩或更改,因此文件大小保持不变。参考您的详细输出,
> --2018-03-27 08:58:50-- https://www.excentis.com/sites/excentis/files/styles/full-width/public/linux_tc_configs.png
> Resolving www.excentis.com (www.excentis.com)... IP_address Connecting
> to www.excentis.com (www.excentis.com)|IP_address|:<PORT>...
> connected. HTTP request sent, awaiting response... 200 OK Length:
> **20016 (20K)** [image/png] Saving to: ‘./linux_tc_configs.png.3’
>
> 0K .......... ......... 100%
> 226K=0.09s
>
> 2018-03-27 08:58:51 (226 KB/s) - ‘./linux_tc_configs.png.3’ saved
> [20016/20016]
该 png 图像的文件大小在输出的第 5 行中提到 - 20K。
日志中提到的226K=0.09s表明吞吐量为226 KB/s,下载20K文件花了0.09s。
如果需要检查可以使用以下命令。
wget --progress=bar:force -P . https://www.excentis.com/sites/excentis/files/styles/full-width/public/linux_tc_configs.png 2>&1 | tee -a wget_log
Resolving www.excentis.com (www.excentis.com)... 77.235.46.234
Connecting to www.excentis.com (www.excentis.com)|77.235.46.234|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 20016 (20K) [image/png]
Saving to: ‘./linux_tc_configs.png.6’
100%[======================================>] 20,016 74.3KB/s in 0.3s
2018-03-27 05:47:19 (74.3 KB/s) - ‘./linux_tc_configs.png.6’ saved [20016/20016]