Skip to content

Instantly share code, notes, and snippets.

@focusaurus
Created September 17, 2015 13:25
Show Gist options
  • Save focusaurus/4c5add54cffda43a82d9 to your computer and use it in GitHub Desktop.
Save focusaurus/4c5add54cffda43a82d9 to your computer and use it in GitHub Desktop.
using the "comcast" utility to throttle network traffic to a specific application
# https://github.com/tylertreat/Comcast
# In this example, the application I want to throttle is on TCP port 9110
comcast="${HOME}/projects/comcast/bin/comcast"
throttle() {
local profile="${1-wifi}"
local bandwidth=30000
local latency=40
local packet_loss=0.2
case "${profile}" in
wifi)
;;
dsl)
bandwidth=2000
latency=70
packet_loss=2
;;
*)
echo "Usage: $0 [wifi|dsl]" 1>&2
return 1
;;
esac
"${comcast}" --stop
"${comcast}" \
-target-port 9110 \
-target-proto tcp \
-target-bw "${bandwidth}" \
-latency "${latency}" \
-packet-loss "${packet_loss}"
}
unthrottle() {
"${comcast}" --stop
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment