<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Aptivate &#124; A Blog for ICT4D &#187; bandwidth simulations</title>
	<atom:link href="http://blog.aptivate.org/tag/bandwidth-simulations/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.aptivate.org</link>
	<description>International I.T. Development</description>
	<lastBuildDate>Thu, 02 Sep 2010 08:18:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simulating low bandwidths: how to make sure your apps work in the field</title>
		<link>http://blog.aptivate.org/2010/01/23/make-sure-your-apps-work-in-the-field/</link>
		<comments>http://blog.aptivate.org/2010/01/23/make-sure-your-apps-work-in-the-field/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 15:41:45 +0000</pubDate>
		<dc:creator>tariq</dc:creator>
				<category><![CDATA[Appropriate Technology]]></category>
		<category><![CDATA[bandwidth]]></category>
		<category><![CDATA[bandwidth simulations]]></category>
		<category><![CDATA[loband]]></category>
		<category><![CDATA[low bandwidth]]></category>
		<category><![CDATA[Sloppy]]></category>
		<category><![CDATA[YSlow]]></category>

		<guid isPermaLink="false">http://blog.aptivate.org/?p=266</guid>
		<description><![CDATA[I'm going to write about four ways to simulate a slow internet connection and a bit of background about why you'd want to do it. Simulation is great but I'll say this now: there's no substitute for testing stuff in the field. However, before you release to the team on the ground or grab your bag and hop on a plane, read this.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to write about four ways to simulate a slow internet connection and a bit of background about why you&#8217;d want to do it. Simulation is great but I&#8217;ll say this now: <strong>there&#8217;s no substitute for testing stuff in the field</strong>. However, before you release to the team on the ground or grab your bag and hop on a plane, read this.</p>
<h2>Why simulate low bandwidths?</h2>
<p>Aptivate builds online software for people in the international development sector. Our users are in places where internet connections are slow and unreliable &#8211; we need to make sure our stuff works for them.</p>
<p>More people are accessing the web using mobile handsets or mobile internet connections (3G dongles and tethered phones). The bandwidth, latency and stability characteristics of these links are very different to the &#8220;always on broadband&#8221; that most developers target.</p>
<p>Finally, we&#8217;re involved with <a href="http://wiki.crisiscommons.org/wiki/Crisis_Camp_London">CrisisCamp London</a> over the next few weeks &#8211; part of an international effort by dedicated volunteers to provide remote technical support and build tools for individuals and organisations working in Haiti. What they build needs to work in that environment &#8211; hopefully this post is going to be useful.</p>
<p>So, if you think your technology is going to be used in the scenarios above, read on. If you&#8217;re just awesome and like to know about this stuff, read on too&#8230;</p>
<h2>Four ways to simulate a slow connection</h2>
<div id="_mcePaste">
<ol>
<li>Use a profiler, your brain and some common sense (easiest)</li>
<li>Use Aptivate&#8217;s online <a href="http://www.loband.org/loband/simulator.jsp">low bandwidth simulator</a> (easy)</li>
<li>Use <a href="http://www.dallaway.com/sloppy/">Sloppy</a> a desktop Java app that simulates slow web links (pretty easy)</li>
<li>Get a machine (with maybe two network interfaces) and do some IP traffic shaping (best results, not easy)</li>
</ol>
</div>
<p>There are probably a few more but I&#8217;m on a plane from Rome to London to go the the first <a href="http://blog.aptivate.org/2010/01/22/crisis-camp-haiti-london/">CrisisCamp</a> and can&#8217;t think properly!</p>
<h2>1. A profiler + simulate it in your brain.</h2>
<p>This is particularly useful if you&#8217;re developing for the web.</p>
<div id="attachment_305" class="wp-caption aligncenter" style="width: 460px"><a href="http://blog.aptivate.org/wp-content/uploads/2010/01/Profiler_reliefweb.png"><img class="size-full wp-image-305" title="Profiler_reliefweb" src="http://blog.aptivate.org/wp-content/uploads/2010/01/Profiler_reliefweb.png" alt="" width="450" height="260" /></a><p class="wp-caption-text">YSlow Running on Reliefweb.int</p></div>
<p>There are a few online and in-browser tools that give you a breakdown of the resources your website is using.</p>
<ul>
<li>Combination of <a href="http://developer.yahoo.com/yslow/ ">Yahoo&#8217;s Yslow</a> + <a href="https://www.getfirebug.com/">Firebug</a> for Firefox</li>
<li>Safari or Google Chrome&#8217;s built-in (webkit based?) inspectors</li>
<li><a href="http://tools.pingdom.com/">Pingdom</a> tools online</li>
</ul>
<p>Three important things to get from these tools is:</p>
<div id="_mcePaste">
<ol>
<li>What&#8217;s the bandwidth usage of each of my pages and typical interactions?</li>
<li>How many individual requests are required for each page?</li>
<li>How much content is cached?</li>
</ol>
</div>
<p>The overall bandwidth is a feasibility test. We say <a href="http://www.aptivate.org/webguidelines/TopTen.html">aim for 25k per page</a>, but use your own judgement &#8211; how fast is your user&#8217;s connection, how long will it take for them to get to something useful (hint &#8211; if it&#8217;s longer than 5-10 seconds: #FAIL)</p>
<p>The number of requests also gives you an indication about performance over high latency or intermittent connections &#8211; in short, use fewer objects and cache them when you can.</p>
<p>Finally, if you&#8217;ve got a network usage meter (I have a noddy one running that comes with iStatMenus on the Mac ) you can get a rough idea of how much bandwidth an app is consuming (should work fine even if you&#8217;re developing an app in a mobile simulator). I&#8217;ve seen stuff for Windows I can&#8217;t remember, on Linux you could use BWM or get fancy with logging modes in IPTables &#8211; Google for more.</p>
<p>That&#8217;s it.</p>
<h2>2. Use Aptivate&#8217;s online Low Bandwidth Simulator</h2>
<div id="attachment_302" class="wp-caption aligncenter" style="width: 444px"><a href="http://blog.aptivate.org/wp-content/uploads/2010/01/aptivate_low_bw_sim_screenshot.png"><img class="size-full wp-image-302" title="aptivate_low_bw_sim_screenshot" src="http://blog.aptivate.org/wp-content/uploads/2010/01/aptivate_low_bw_sim_screenshot.png" alt="" width="434" height="268" /></a><p class="wp-caption-text">Aptivates Low Bandwidth Simulator</p></div>
<p>This technique is only useful if your site is accessible from a public URL. It only simulates bandwidth, not latency or packet loss.</p>
<p>We make <a href="http://www.loband.org/loband/main">Loband</a>, and online service that strips the junk out of webpages and gives you a compressed, simplified version that works better on slow links.</p>
<p>As part of the Loband code, there&#8217;s a <a href="http://www.loband.org/loband/simulator.jsp">simulator which you can access here.</a></p>
<p>You plug in the URL of your site, select the bandwidth you want to simulate and hit go. I haven&#8217;t tested it recently with any serious AJAX/HTML5/Flex/Flash stuff so your mileage may vary if you make heavy use of these tools.</p>
<p>Do what a user would do with your app and see if it&#8217;s usable.</p>
<p>That&#8217;s it.</p>
<h2>3. Use the Sloppy desktop Java app</h2>
<div id="attachment_303" class="wp-caption aligncenter" style="width: 318px"><a href="http://blog.aptivate.org/wp-content/uploads/2010/01/Sloppy_Screenshot.png"><img class="size-full wp-image-303" title="Sloppy_Screenshot" src="http://blog.aptivate.org/wp-content/uploads/2010/01/Sloppy_Screenshot.png" alt="" width="308" height="354" /></a><p class="wp-caption-text">Sloppy Java desktop bandwidth simulator</p></div>
<p>This technique is great if your site is running on a local dev box or even if it&#8217;s online. It only simulates bandwidth, not latency or packet loss.</p>
<p>Make sure Java lives on your machine. Download <a href="http://www.dallaway.com/sloppy/">Sloppy</a>. Run it, start it, point it at your app.</p>
<p>Do what you would have done with 2.</p>
<p>That&#8217;s it.</p>
<h2>4. Get a machine, (maybe two network cards) do IP traffic shaping.</h2>
<p>This technique is the best of the bunch: you can simulate bandwidth, latency and packet loss and do so for anything running on your machine or LAN. That&#8217;s anything: browser apps, mail clients, Skype, mobile simulators etc. It&#8217;s not hard but is a little fiddly. There are two broad ways you could do this: for yourself on a single machine or, for a bunch of people on a LAN.</p>
<div id="attachment_301" class="wp-caption aligncenter" style="width: 410px"><a href="http://blog.aptivate.org/wp-content/uploads/2010/01/iperf_dummynet.jpg"><img class="size-full wp-image-301  " title="iperf_dummynet_different_bw" src="http://blog.aptivate.org/wp-content/uploads/2010/01/iperf_dummynet.jpg" alt="Terminal Showing iperf measuring different bandwidths throttled by dummynet" width="400" height="244" /></a><p class="wp-caption-text">iperf showing a dummynet throttled link</p></div>
<p>Quickly,  to do it for yourself<strong>,</strong> <strong>on your own machine</strong> to do app testing: if you&#8217;re running FreeBSD / MacOSX,, follow<a href="http://www.askbjoernhansen.com/2004/09/22/mini_tutorial_f.html"> Bjørn Hansen&#8217;s tutorial.</a></p>
<p>It gets a bit trickier if you want to <strong>do it for several machines</strong> at once.</p>
<p>What we&#8217;re trying to do is turn a machine with two network interfaces (NICs) into a &#8220;router&#8221;. Traffic goes in/out of the first interface at normal speeds, but the traffic goes in/out of the second interface at user-selected levels of crapness (bandwidth, latency, packet loss)</p>
<p>Relatively speaking: this is easy on a Mac / BSD box, trickier on Linux and hard on Windows. While most laptops actually have 2 network interfaces (wifi + ethernet) &#8211; I normally do this with a desktop that&#8217;s got 2 NICs  or a laptop + a USB / CardBus/PCMCIA NIC.</p>
<p>On a Mac/BSD you&#8217;re going to be using ipfw to control the dummnynet traffic shaper. Man up to find out more. In short: ipfw&#8217;s a firewall that classifies packets (e.g. by which port or IP they&#8217;re going to) into &#8220;flows&#8221;. Dummynet takes a flow and sticks it in a &#8220;pipe&#8221;. A pipe emulates a link with given bandwidth, propagation delay, queue size and packet loss rate.</p>
<h2>&#8230;.how on earth do we get this working?</h2>
<p>There are better tutorials than I can write quickly <a href="http://cs.baylor.edu/~donahoo/tools/dummy/tutorial.htm ">here</a> and  <a href="http://www.afp548.com/article.php?story=20060214081244545&amp;mode=print">here</a>. But in brief:</p>
<div id="_mcePaste">
<ol>
<li>Get a BSD machine with dummynet (OSX 10.4+ is enabled by default, might need a kernel rebuild for FreeBSD) running with 2 NICs. Fire up a terminal, type in ifconfig and make sure you can see the two interfaces (en0 and en2 for me)</li>
<li>Make sure you can route packets between interfaces.</li>
<li>Make a pipe for the traffic between interfaces</li>
<li>Configure your pipe, stick your traffic in there and smoke it.</li>
<li>Tweak the pipe and simulate to you heart&#8217;s content.</li>
</ol>
</div>
<p>In reality, this always takes me half an hour to get right &#8211; I&#8217;ve never had this go smoothly first time.</p>
<p>First things I check if it&#8217;s not working:</p>
<ul>
<li>Is OSX / BSD doing some daft routing / automatic internet connection sharing that messing with your ipfw settings?</li>
<li>Are you routing using the right interfaces? I&#8217;ve actually got 7 network interfaces that show up in ifconfig to choose from (firewire, bt, vm, wifi, ethernet etc.)</li>
<li>bit/s and Byte/s are quite different…</li>
<li>Don&#8217;t despair, it will work, there&#8217;s pictures of me doing it <a href="http://www.flickr.com/photos/tariq_khokhar/4171817647/in/set-72157622968514464/">here</a>. <img src='http://blog.aptivate.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
</ul>
<h2>Typical bandwidth / latency / loss scenarios</h2>
<p>The key commands you&#8217;ll be running to set parameters will look like:</p>
<blockquote><p>ipfw pipe 1 config bw 50Kbit<br />
ipfw pipe 1 config delay 200ms<br />
ipfw pipe 1 config plr 0.2</p></blockquote>
<p>The three variables you have to play with are bw (bandwidth) plr (random packet loss rate) and delay (latency). Here&#8217;s a super-rough guestimate for some typical scenarios, <strong>please advise</strong> if I&#8217;m way out or there are <strong>other common scenarios</strong>:</p>
<table style="font-size: 1.4em;" border="1" cellspacing="0" cellpadding="4" width="100%" bordercolor="#000000">
<col width="64*"></col>
<col width="64*"></col>
<col width="64*"></col>
<col width="64*"></col>
<tbody>
<tr valign="TOP">
<td width="30%" bgcolor="#e6e6e6"><span style="color: #05a;"><strong>Scenario</strong></span></td>
<td width="20%" bgcolor="#e6e6e6"><span style="color: #05a;"><strong>Bw (Kbit)</strong></span></td>
<td width="20%" bgcolor="#e6e6e6"><span style="color: #05a;"><strong>delay</strong> <strong>(ms)</strong></span></td>
<td width="20%" bgcolor="#e6e6e6"><span style="color: #05a;"><strong>pr (ratio)</strong></span></td>
</tr>
<tr valign="TOP">
<td width="30%">2.5G mobile (GPRS)</td>
<td width="20%">50</td>
<td width="20%">200</td>
<td width="20%">0.2</td>
</tr>
<tr valign="TOP">
<td width="30%">3G mobile</td>
<td width="20%">1000</td>
<td width="20%">200</td>
<td width="20%">0.2</td>
</tr>
<tr valign="TOP">
<td width="30%">VSAT</td>
<td width="20%">5000</td>
<td width="20%">500</td>
<td width="20%">0.2</td>
</tr>
<tr valign="TOP">
<td width="30%">Busy LAN on VSAT</td>
<td width="20%">300</td>
<td width="20%">500</td>
<td width="20%">0.4</td>
</tr>
</tbody>
</table>
<h2>What about windows and linux?!</h2>
<p>I promise to update this bit with more info when I&#8217;ve got Linux, Windows boxes and Chris to hand.</p>
<p>In short though: with linux it&#8217;s the same idea, machine with 2 NICS, get them routing, use IPTables and the linux traffic shaper, tc. It&#8217;s not as good as dummynet (no packet loss IIRC) but gets the job done. For Windows, I&#8217;d honestly have to do some more research, last time I tried it, I just pulled out my Macbook.</p>
<p>Please add any tips and corrections of  below!</p>
<p>Tariq</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2010/01/23/make-sure-your-apps-work-in-the-field/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
