<p>Can you suggest how to create a test environment to simulate various types of bandwidths and traffic in a web app?</p>
<p>Or maybe an open source program which does this against localhost?</p>
<p>I think this is a very important subject when programming web apps but it is not a usual topic, the only way i can imagine to create such kind of environment is to use some kind of proxy in a local network but before start looking into the squid documentation i would like to hear your suggestions.</p>

The closest I can think of is doing something similar with
VEDekstop
from Shunra..
Simulating High Latency and Low Bandwidth in Testing of Database Applications
Shunra VE Desktop Standard is a Windows-based client software solution that simulates a wide area network link so that you can test applications under a variety of current and potential network conditions – directly from your desktop.