Created
July 24, 2012 09:04
-
-
Save peteroome/3168968 to your computer and use it in GitHub Desktop.
Creates a slow network connection
This file contains hidden or 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
#!/usr/bin/env ruby | |
print "Enter desired network speed (Kbit/s, e.g. 2000): " | |
speed = gets.strip.to_i | |
print "Enter desired latency (ms, e.g. 10): " | |
latency = gets.strip.to_i | |
print "Enter desired duration (how long do you want me to screw with your internet in seconds, e.g. 60): " | |
seconds = gets.strip.to_i | |
`sudo ipfw pipe 1 config bw #{speed}Kbits/s delay #{latency}ms` | |
`sudo ipfw add 1 pipe 1 src-port 80` | |
`sudo ipfw add 2 pipe 1 dst-port 80` | |
puts "Try your new slower network. Will destroy it in #{seconds} seconds." | |
(1..seconds).each do |s| | |
sleep(1) | |
print '.' | |
print s if s % 10 == 0 | |
end | |
`sudo ipfw delete 1` | |
`sudo ipfw delete 2` | |
`sudo ipfw pipe 1 delete` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment