Under OS X you have access to the FreeBSD traffic shaping util ipfw. First of all you need to define some rule which will work on local interactions.
sudo ipfw add 1 pipe 1 src-ip 127.0.0.1
sudo ipfw add 1 pipe 2 dst-ip 127.0.0.1After that we can set up the connection speed, and also I like to add some delay to emulate a request to a remote server
sudo ipfw pipe 1 config bw 40Byte/s delay 100msAfter that all your local requests will slow down to 40Byte/s speed with a realistic 100ms response delay.
When you have done with your tests, you can remove the rule with the following command.
sudo ipfw delete 1Now it is all interesting but lets wrap it up in a simple shell script so we didn't need to memorize all the fancy calls.
sudo touch /usr/bin/slowdown
sudo chmod +x /usr/bin/slowdownAfter that open the file with your favorite editor and write the following little script
#!/bin/bash
if [ $1 = "clear" ] ; then
ipfw delete 1
else
ipfw add 1 pipe 1 src-ip 127.0.0.1
ipfw add 1 pipe 2 dst-ip 127.0.0.1
ipfw pipe 1 config bw $1KByte/s delay 100ms
fi
Now you can create and remove pipes just like that
sudo slowdown 40And to remove the rule call it like that
sudo slowdown clearThat's all about it. Happy testing!
No comments:
Post a Comment