Simulating Low Bandwidth For Local Web Development

It is important to know how a webpage would load on another person's computer, especially when it involves AJAX and page scripting. It may work properly and load as fast as it is, this is not the case on another machine with another configuration. Therefore, it is essential to be able to simulate network loadtimes, latencies and packet losses. Here I will be giving simple examples and how to setup a low-bandwidth environment on Mac OS X and other Unix/Linux systems.

OS X is equipped with some powerful tools. Not to mention that it comes with a built-in Apache and PHP, it also comes with a number of security tools including IPFW. IPFW is a tool that is essential to control the inflow and the outflow of traffic on your machine. When you access the firewall settings from your System Preferences application, it configures IPFW to monitor the network. System Preferences is the front-end GUI for IPFW, so to speak. Since System Preferences is not powerful enough, we will be using the Terminal.

Setup

The plan of action is the following:
open port 8080 with a limited bandwidth and redirect requests made to it to the local web server (port 80).

The following command would open port 8080 and redirect its requests to our webserver, which runs on port 80:

sudo ipfw add 200 forward 127.0.0.1,80 ip from any to any 8080 in

Now, we have to run the requests made to port 8080 through a pipe:

sudo ipfw add 205 pipe 50 ip from any to 127.0.0.1 dst-port 8080

and configure the pipe to lower bandwidth at 64Kbps:

 sudo ipfw pipe 50 config bw 64Kbit/s

With these three easy commands, we have created port 8080, which will serve the same content as the default webserver, but at a lower rate. If you direct your browser to

http://localhost:8080/
, you will notice a significant web page load time change compared to
http://localhost/
(assuming your web server runs on port 80).

Latency and Packet Loss

In terms of having a more realistic simulation, there are two other aspects to networking: latency and packet loss. And it is a matter of how you configure your pipe. The following command will add 300ms latency with 10% packet loss on a 64Kbps pipe:

sudo ipfw pipe 50 config delay 300ms bw 64Kbit/s plr 0.1

Removing Rules

To remove your port 80, you simply have to remove the rules you have set. Rule # 200 and 205 will be removed with the following commands:

sudo ipfw delete 200
sudo ipfw delete 205

Once deleted, the browser will give you an error when you try accessing port 8080 because it will no longer redirect your traffic. If you want to see that the rule was actually deleted, type in the following:

sudo ipfw list

and you will see that rule 200 and 205 have been baleeted.

Also note: If you are loading jQuery or other scripts from external sites, this simulation will not work because you are not putting any restrictions on outside sources.

Please leave a comment if you know of a better, cooler way to simulate loading on your local machine.

Read more...

Talking Piano

Using different keys of the piano, Peter Ablinger plays a digitized sound recording of a child on a Talking Piano:

Read more...

Cycling down the Capitol steps, 1885

The original BMX:

Will-Robertson-of-the-Washington-Bicycle-Club-riding-an-American-Star-Bicycle-down-the-steps-of-the-United-States-Capitol-in-1885-520x806.jpg

Cycling down the Capitol steps, 1885 | Retronaut:

Will Robertson of the Washington Bicycle Club riding an American Star Bicycle down the steps of the United States Capitol in 1885</p>

Read more...

Javascript MVC Frameworks

After careful consideration, I have decided to stick with Ember.js for my new Javascript MVC experiment.

The Top 10 Javascript MVC Frameworks Reviewed - CodeBrief:

At the end of the day, Ember.js is the only framework which has everything I desire.</p>

Read more...

Portfolio on Rails

Finished upgrading my portfolio website to Rails -- hosted on Heroku. Photo content is hosted on Flickr and is directly fetched from there by the client. This should tell you more about how appreciative I am of GoDaddy.

Read more...

Mark Gonzales vs THPS

Stumbled upon a character named Mark Gonzales; known for revolutionizing street skating. What used to be a flatland arena, has been overturned to become more acrobatic with Mark's invention of Grinds.

Got linked to a video of some of his contemporaries skating in various locations, and found some similarities with THPS level designs. This would be interesting to know what the inspiration was for those games.

Here is a 3-part documentary:

Blind ~ Video Days

Side note: Mark was born the same year as Tony Hawk (1968)

Read more...

Casssius: Original Obsession

I Love You So

Feeling For You

Read more...

Authlogic in Rails 3

Most tutorials you find on Authlogic assume Rails 2. Here is somewhat useful Authlogic setup walkthrough for Rais 3 by Logan Bailey.

Read more...

iPad promotion in Hiroshima Dialect

Read more...

Oenophile

oenophile - a lover of wine.

The word did not exist in the wine lexicon until 1977 when Shirley Copperman coined it for her new bring-your-own-wine restaurant she and her husband dubbed "Oenophilia", located on the upper West Side of Manhattan

http://en.wikipedia.org/wiki/Oenophilia

Read more...