Skip to content

Instantly share code, notes, and snippets.

@shad
Created March 7, 2013 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shad/5108968 to your computer and use it in GitHub Desktop.
Save shad/5108968 to your computer and use it in GitHub Desktop.
Simulate a really poor network connection on your mac (with support for pow.cx backend). Ex. If you expect your users to use your app in a place with poor network (like the meat department of your local grocery store), then this is a way for you to test that sort of connection. This is not scientific in anyway, just a guess.
# Simulate a really poor network connection on your mac (with support for pow.cx backend)
namespace :network do
task :status do
sh 'sudo ipfw show'
end
task :bad => [:good] do
# Add a new pipe
sh 'sudo ipfw add pipe 1 all from any to any'
# Configure the pipe to only do 50Kbit/s, with typical delays of 2000ms and 90% packet drop rate!
sh 'sudo ipfw pipe 1 config bw 50Kbit/s delay 2000ms plr 0.9'
end
task :poor => [:good] do
# Add a new pipe
sh 'sudo ipfw add pipe 1 all from any to any'
# Configure the pipe with typical delays of 20ms and 10% packet drop rate!
sh 'sudo ipfw pipe 1 config delay 20ms plr 0.1'
end
task :good do
# reset
sh 'sudo ipfw flush'
# Turn POW back on... cause the flush will seriously flush it...
sh 'sudo ipfw add 100 fwd 127.0.0.1,20559 tcp from any to me dst-port 80 in'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment