{"id":13549610,"url":"https://github.com/sitespeedio/throttle","last_synced_at":"2025-05-15T17:04:00.889Z","repository":{"id":37396506,"uuid":"103982558","full_name":"sitespeedio/throttle","owner":"sitespeedio","description":"Throttle your network connection [Linux/Mac OS X]","archived":false,"fork":false,"pushed_at":"2024-08-26T15:10:14.000Z","size":263,"stargazers_count":355,"open_issues_count":20,"forks_count":27,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-07T01:34:34.840Z","etag":null,"topics":["bandwith","latency","throttle"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sitespeedio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-09-18T19:29:29.000Z","updated_at":"2025-05-02T08:21:23.000Z","dependencies_parsed_at":"2023-09-24T07:16:07.967Z","dependency_job_id":"76d54b7c-5419-4a70-b53a-20f7c60a3c42","html_url":"https://github.com/sitespeedio/throttle","commit_stats":{"total_commits":182,"total_committers":11,"mean_commits":"16.545454545454547","dds":0.09890109890109888,"last_synced_commit":"2311755c4122c809f18d9aa633633bc36f1691e2"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitespeedio%2Fthrottle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitespeedio%2Fthrottle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitespeedio%2Fthrottle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitespeedio%2Fthrottle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sitespeedio","download_url":"https://codeload.github.com/sitespeedio/throttle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384983,"owners_count":22062422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bandwith","latency","throttle"],"created_at":"2024-08-01T12:01:23.639Z","updated_at":"2025-05-15T17:04:00.873Z","avatar_url":"https://github.com/sitespeedio.png","language":"JavaScript","readme":"# Simulate slow network connections on Linux and Mac OS X\n\n![Linux](https://github.com/sitespeedio/throttle/workflows/Linux/badge.svg)\n![OSX](https://github.com/sitespeedio/throttle/workflows/OSX/badge.svg)\n![Docker](https://github.com/sitespeedio/throttle/workflows/Run%20Docker/badge.svg)\n\nInspired by [tylertreat/Comcast](https://github.com/tylertreat/Comcast), the [connectivity setting in the WPTAgent](https://github.com/WPO-Foundation/wptagent/blob/master/internal/traffic_shaping.py) and [sltc](https://github.com/sitespeedio/sltc).\n\nThrottle 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`).\n\nYou can set the download/upload speed and/or RTT. Upload/download is in kbit/s and RTT in ms.\n\nUse with [latest NodeJS LTS](https://nodejs.org/en/).\n\n## Install\n\n```\nnpm install @sitespeed.io/throttle -g\n```\n\nOn 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\n\n```\npf_enable=\"YES\"\npflog_enable=\"YES\"\n```\n\nOn Linux you need to make sure *ip* and *route* is installed (install using `sudo apt-get install -y net-tools`).\n\n## Start simulate a slower network connection\n\nHere is an example for running with 3G connectivity. Remember: Throttle will use sudo so your user will need sudo rights.\n\n```\nthrottle --up 330 --down 780 --rtt 200\n```\n\n## Pre made profiles\nTo make it easier we have pre made profiles, check them out by *throttle --help*:\n\n```\n--profile         Premade profiles, set to one of the following\n                     3g: up:768 down:1600 rtt:150\n                     3gfast: up:768 down:1600 rtt:75\n                     3gslow: up:400 down:400 rtt:200\n                     2g: up:256 down:280 rtt:400\n                     cable: up:1000 down:5000 rtt:14\n                     dsl: up:384 down:1500 rtt:14\n                     3gem: up:400 down:400 rtt:200\n                     4g: up:9000 down:9000 rtt:85\n                     lte: up:12000 down:12000 rtt:35\n                     edge: up:200 down:240 rtt:35\n                     dial: up:30 down:49 rtt:60\n                     fois: up:5000 down:20000 rtt:2\n```\n\nYou can start throttle with one of the premade profiles:\n\n```\nthrottle --profile 3gslow\n```\n\nor even simpler\n```\nthrottle 3gslow\n```\n\n## Add packet loss\n\nBy 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.\n\n```\nthrottle --profile 3gslow --packetLoss 5\n```\n\n\n## Use a configuration file\nYou can also use a configuration file with your settings. Use `--config` to map your config file to throttle.\n\nconfig.json\n```json\n{\n    \"up\": 330 ,\n    \"down\": 200,\n    \"rtt\": 1000\n}\n```\n\nAnd then run:\n```\nthrottle --config config.json\n```\n\n## Stop simulate the network\nStopping is as easy as giving the parameter *stop* to throttle.\n\n```\nthrottle --stop\n```\n\nor\n\n```\nthrottle stop\n```\n\n## Add delay on your localhost \nThis is useful if you test a local web server or run [WebPageReplay](https://github.com/catapult-project/catapult/blob/master/web_page_replay_go/README.md) and want to add some latency to your tests.\n\n```\nthrottle --rtt 200 --localhost\n```\n\n## Stop adding delay on localhost\n\n```\nthrottle --stop --localhost\n```\n\n## Use directly in NodeJS\n\n```javascript\nimport throttle from '@sitespeed.io/throttle'\n// Returns a promise\nthrottle.start({up: 360, down: 780, rtt: 200}).then(() =\u003e ...\n```\n\nor \n\n```javascript\nimport throttle from '@sitespeed.io/throttle'\n// Returns a promise\nconst options = {up: 360, down: 780, rtt: 200};\nawait throttle.start(options);\n// Do your thing and then stop\nawait throttle.stop();\n\n```\n\n## Log all commands\nYou can log all the commands that sets up the throttling by setting `LOG_THROTTLE=true`.\n\n```\nLOG_THROTTLE=true throttle 3gslow\n```\n\nor \n\n```\nthrottle 3gslow --log\n```\n\n## Run in Docker (on Linux)\n\nMake sure to run ```sudo modprobe ifb numifbs=1``` before you start the container.\n\nAnd then when you actually start your Docker container, give it the right privileges with ```--cap-add=NET_ADMIN```.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsitespeedio%2Fthrottle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsitespeedio%2Fthrottle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsitespeedio%2Fthrottle/lists"}