Skip to content

Instantly share code, notes, and snippets.

@infynyxx
Forked from blister/gist:740829
Created December 14, 2010 22:39
Show Gist options
  • Save infynyxx/741249 to your computer and use it in GitHub Desktop.
Save infynyxx/741249 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Copyright 2010 Eric Ryan Harrison <[email protected]>
# Inspired by:
# http://daniel.haxx.se/blog/2010/12/14/add-latency-to-localhost/
if [ -n "$1" ]
then
if [ "$1" = "off" ]
then
tc qdisc del dev lo root
else
tc qdisc add dev lo root handle 1:0 netem delay $1msec
fi
else
echo 'Usage: localdelay [TIME_IN_MILLISECONDS|off]'
echo 'Example:'
echo ' localdelay 20'
echo ' This will add a 20 millisecond delay to localhost'
echo ' and pings will take 40+ms to respond.'
echo ' localdelay off'
echo ' Turns off delay.'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment