百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
T

throttle

> 编程语言
开源

限制网络连接 [Linux/Mac OS X]

382 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

限制网络连接 [Linux/Mac OS X]

Simulate slow network connections on Linux and Mac OS X

Inspired by tylertreat/Comcast, the connectivity setting in the WPTAgent and sltc.

Throttle uses pfctl on Mac and tc on Linux to simulate different network speeds. On Linux you also need ip for Throttle to work (install using sudo apt-get install -y net-tools).

You can set the download/upload speed and/or RTT. Upload/download is in kbit/s and RTT in ms.

Use with latest NodeJS LTS.

Install

bash
npm install @sitespeed.io/throttle -g

On OSX, add these lines to /etc/pf.conf if they don't exist, to prevent the pfctl: Syntax error in config file: pf rules not loaded error when you try to run throttle

pf_enable="YES"
pflog_enable="YES"

On Linux you need to make sure ip and route is installed (install using sudo apt-get install -y net-tools).

Start simulate a slower network connection

Here is an example for running with 3G connectivity. Remember: Throttle will use sudo so your user will need sudo rights.

throttle --up 330 --down 780 --rtt 200

Pre made profiles

To make it easier we have pre made profiles, check them out by throttle --help:

…

You can start throttle with one of the premade profiles:

throttle --profile 3gslow

or even simpler

throttle 3gslow

Add packet loss

By default there's no packet loss. That is by design: If you want to use Throttle and have the same network speed, packet loss is no good. However if you want to simalate a really crappy network you probably want to add packet loss. You do that with the --packetLoss option. You set the packet loss in percent.

throttle --profile 3gslow --packetLoss 5

Use a configuration file

You can also use a configuration file with your settings. Use --config to map your config file to throttle.

config.json

json
{
    "up": 330 ,
    "down": 200,
    "rtt": 1000
}

And then run:

throttle --config config.json

Stop simulate the network

Stopping is as easy as giving the parameter stop to throttle.

throttle --stop

or

throttle stop

Add delay on your localhost

This is useful if you test a local web server or run WebPageReplay and want to add some latency to your tests.

throttle --rtt 200 --localhost

Stop adding delay on localhost

throttle --stop --localhost

Use directly in NodeJS

javascript
import { start, stop } from '@sitespeed.io/throttle'
// Returns a promise
start({up: 360, down: 780, rtt: 200}).then(() => ...

or

javascript
import { start, stop } from '@sitespeed.io/throttle'
const options = {up: 360, down: 780, rtt: 200};
await start(options);
// Do your thing and then stop
await stop();

Log all commands

You can log all the commands that sets up the throttling by setting LOG_THROTTLE=true.

LOG_THROTTLE=true throttle 3gslow

or

throttle 3gslow --log

Run in Docker (on Linux)

Make sure to run sudo modprobe ifb numifbs=1 before you start the container.

And then when you actually start your Docker container, give it the right privileges with --cap-add=NET_ADMIN.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScriptbandwithlatencythrottle

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言