throttle 网络限速测试工具

Summary: Author: 张亚飞 | Read Time: 1 minute read | Published: 2023-03-30
Filed under Categories: LinuxTags: Note,

Network 限速

需要测试升级 http3 后对 http2 在弱网条件下的表现和提升空间,需要模拟弱网环境,可以使用 throttle 工具进行测试。

安装 throttle 限速工具

npm install @sitespeed.io/throttle -g

pf 新增以下配置

/etc/pf.conf

pf_enable="YES"
pflog_enable="YES"

配置如下所示

scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
rdr-anchor "com.apple/*"
dummynet-anchor "com.apple/*"
anchor "com.apple/*"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
pf_enable="YES"
pflog_enable="YES"

以下命令为本机网卡限制上行 200kb,下行 300kb,rtt 时延 50ms,丢包率 80%.

throttle --up 200 --down 300 --rtt 50 --packetLoss 80

关闭限速

throttle stop

throttle

Comments

Cor-Ethan, the beverage → www.iirii.com