Skip to content

Vlad2000Andrei/DistributedSystems-Traffic-Shaper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

Distributed Systems Traffic Limiter Tools

Contents

Using PowerShell Scripts for Quality of Service (QoS) Policies

Quick Start

To run these scripts, you'll need to enable PowerShell script execution on your machine, or manually bypass the restricted execution policy when running the scripts.

If you want to change the script execution policy, open PowerShell as administrator and run the command below. This opens you up to any scripts being run and has security implications.

Set-ExecutionPolicy Unrestricted

If you instead prefer to keep your policy settings, you can run the scripts as follows from a shell:

powershell.exe -executionpolicy bypass <path-to-script>

Setting Upload Limit

You can limit the upload bandwidth of a specific application by using the create-upload-limit.ps1 script. The script will cap the upload rate of the script to a specified value. The script can be run multiple times to impose several caps on different apps concurrently.

Note: The ApplicationName parameter is optional. Not specifying a value will limit the upload rate of the entire system.

Usage

.\create-upload-limit -ApplicationName <name-of-application> -Bps <bits-per-second-limit>

Example: Limiting Speedtest.exe to 1 Mbps

To limit the (upload) speed of Ookla's speedtest software to 1Mbps, you can run:

.\create-upload-limit.ps1 -ApplicationName speedtest.exe -Bps 1000000

Example: Limiting all programs to 100 Kbps

To limit all programs running on the machine to a combined 100 Kbps, you can run:

.\create-upload-limit.ps1 -ApplicationName speedtest.exe -Bps 100000

Clearing Network Limits

To clear all policies that have been applied, use the remove-policies.ps1 script.

Usage

.\remove-policies.ps1

Checking Active Policies

You can view all active policies using list-policies.ps1. Note that applied policies are stored in the windows ActiveStore Policy Store, meaning that they do not persist through system reboots.

Usage

.\list-policies.ps1

Using Clumsy

Quick Start

PowerShell Scripts

To use the powershell scripts that interact with clumsy, you will need to enable script running in windows. Refer back to this README section for that.

Clumsy.exe

Clumsy is a free, open-source tool for Windows. It can be compiled from source or downloaded as an executable (which is the easier option). You can download it from here. Once downloaded, unzip it and place the files into a folder of your choice. We'll refer to this folder as the clumsy_folder in the remainder of this README.

General Arguments

The provided start-clumsy.ps1 script supports several arguments. Some are targeted at bandwidth throttling, packet delays, and packet drop chance, while others are general.

ClumsyPath

The argument is provided as:

./start-clumsy.ps1 -ClumsyPath "<path to clumsy_folder>"

It tells the script where it can find the directory containing the clumsy.exe executable which you downloaded previously.

AffectUpload

The argument is provided as:

./start-clumsy.ps1 -AffectUpload $true

or:

./start-clumsy.ps1 -AffectUpload $false

It decides whether packet delays and packet drop chance affect outgoing traffic or not.

NOTE: Bandwidth limits set with clumsy are not affected by this (for the reasoning, ask the clumsy devs not me).

AffectDownload

The argument is provided as:

./start-clumsy.ps1 -AffectDownload $true

or:

./start-clumsy.ps1 -AffectDownload $false

It decides whether packet delays and packet drop chance affect incoming traffic or not.

NOTE: Bandwidth limits set with clumsy are not affected by this (for the reasoning, ask the clumsy devs not me).

Setting a Bandwidth Limit

Clumsy does support limiting the bandwidth but, anecdotally, is bad at doing it. To limit the bandwidth, we recommend using the PowerShell QoS Option. However, for the sake of completeness, the wrapper script supports it.

The bandwidth limit is symmetric and not affected by the -AffectUpload or -AffectDownload arguments.

A bandiwdth cap can be specified in KB/s:

./start-clumsy.ps1 -ClumsyPath "<path to clumsy_folder>" -BandwidthKBps <Limit>

Note: The Limit argument must be an integer. This is enforced by PowerShell.

Example: Limiting Bandwidth to 1MB/s

./start-clumsy.ps1 -ClumsyPath "C:\Program Files\Clumsy\" -BandwidthKBps 5000

Setting a Delay

Clumsy supports delaying packets with a set time Delay in milliseconds. This is specified as an argument:

./start-clumsy.ps1 -ClumsyPath "<path to clumsy_folder>" -Delay <Delay>

Note: The Delay argument must be an integer number of miliseconds.

Example: Delaying Incoming and Outgoing Packets by 5ms.

./start-clumsy.ps1 -ClumsyPath "C:\Program Files\Clumsy\" -Delay 5 -AffectUpload $true -AffectDownload $true

Example: Delaying Outgoing Packets by 30ms.

./start-clumsy.ps1 -ClumsyPath "C:\Program Files\Clumsy\" -Delay 30 -AffectUpload $true

Setting a Drop Chance

Clumsy supports randomly dropping packets with a given DropChance. This can be specified as an argument:

./start-clumsy.ps1 -ClumsyPath "<path to clumsy_folder>" -DropChance <DropChance>

Note: The DropChance must be a floating point number between 0 and 1. The powershell script will convert it into a number between 0 and 100 for clumsy. Up to 4 decimal positions are supported in your input, further ones will be rounded away.

Example: Dropping 25% of Outgoing Packets

./start-clumsy.ps1 -ClumsyPath "C:\Program Files\Clumsy\" -DropChance 0.25 -AffectUpload $true

Example: Dropping 5% of All Packets

./start-clumsy.ps1 -ClumsyPath "C:\Program Files\Clumsy\" -DropChance 0.05 -AffectUpload $true -AffectDownload $true

Stopping Clumsy

You can stop a running clumsy process using the stop-clumsy.ps1 script:

./stop-clumsy.ps1

Note: If clumsy is not running, this script is a No-Op, nothing will happen.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published