Giter Club home page Giter Club logo

throttle's Introduction

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 and route for Throttle to work.

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

This is an early release, so please help us find potential bugs.

Install

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"

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:

--profile         Premade profiles, set to one of the following
                     3g: up:768 down:1600 rtt:150
                     3gfast: up:768 down:1600 rtt:75
                     3gslow: up:400 down:400 rtt:200
                     2g: up:32 down:35 rtt:650
                     cable: up:1000 down:5000 rtt:14

You can start throttle with one of the premade profiles:

throttle --profile 3gslow

Stop simulate the network

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

throttle --stop

Add delay on your localhost (Linux only at the moment)

This is useful if you run WebPageReplay and want to add som latency to your tests.

throttle --rtt 200 --localhost

Stop adding delay on localhost (Linux only)

throttle --stop --localhost

Use directly in NodeJS

const throttle = require('@sitespeed.io/throttle');
// Returns a promise
throttle.start({up: 360, down: 780, rtt: 200}).then(() => ...

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

throttle's People

Contributors

soulgalore avatar tobli avatar keerthik avatar paulz avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.