Skip to content

MrBoog/Limiting-bandwidth-on-MacOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Limiting-bandwidth-on-MacOS

Yosemite下 模拟低速网络

之前一直在终端使用 ipfw脚本命令,来模拟低速网络,不过在Yosemite 之后Apple移除了ipfw 命令,but now IPFW is gone, Moving to PF

GUI工具:

这是IO工具包,下载后,双击“Network Link Conditioner.prefPane” 进行安装。

启用后,配置一下very bad network,重新启动模拟器,我们就可以使用调整我们的模拟器网络环境了,模拟低速网络。(目前没办法对特定的地址限速,会降低电脑中所有请求的速度)

Terminal PF命令:

当然,如果使用终端,还是可以使用 PF命令,来替换 ipfw,下面是一断脚本


#!/bin/bash

# Reset dummynet to default config
dnctl -f flush

# Compose an addendum to the default config: creates a new anchor
(cat /etc/pf.conf &&
echo 'dummynet-anchor "my_anchor"' &&
echo 'anchor "my_anchor"') | pfctl -q -f -

# Configure the new anchor
cat <<EOF | pfctl -q -a my_anchor -f -
no dummynet quick on lo0 all
dummynet out proto tcp from any to any pipe 1
EOF

# Create the dummynet queue
dnctl pipe 1 config bw 4100byte/s

# Activate PF
pfctl -E

# to check that dnctl is properly configured: sudo dnctl list

检查配置列表

sudo dnctl list

最后的最后。。使用后别忘记重置。。

sudo dnctl -f flush
sudo pfctl -f /etc/pf.conf
sudo dnctl list

如果不起作用,可能是PF默认没有开启,使用 sudo pfctl -E 开启。

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages