Created
December 14, 2010 18:19
-
-
Save blister/740829 to your computer and use it in GitHub Desktop.
Bash script to add a delay to the localhost interface on Linux machines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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