
<?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>New Bright Idea</title>
	<atom:link href="http://newbrightidea.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://newbrightidea.com</link>
	<description>peripatetic creativity</description>
	<lastBuildDate>Fri, 06 Jan 2012 07:28:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Slow iTunes Downloads on TELUS Optik</title>
		<link>http://newbrightidea.com/2012/01/06/slow-itunes-downloads-on-telus-optik/</link>
		<comments>http://newbrightidea.com/2012/01/06/slow-itunes-downloads-on-telus-optik/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 07:28:51 +0000</pubDate>
		<dc:creator>Russ Weeks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://newbrightidea.com/?p=184</guid>
		<description><![CDATA[If you&#8217;re experiencing really slow downloads from the iTunes store on TELUS Optik, it could be a problem with your DNS servers.  I think by default the DHCP server on the Optik router configures the clients to use the router &#8230; <a href="http://newbrightidea.com/2012/01/06/slow-itunes-downloads-on-telus-optik/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re experiencing really slow downloads from the iTunes store on TELUS Optik, it could be a problem with your DNS servers.  I think by default the DHCP server on the Optik router configures the clients to use the router as their DNS server.  The router is configured to use the servers:</p>
<ul>
<li>75.153.176.1  (ns1.dns.telus.com)</li>
<li>75.153.176.9 (ns2.dns.telus.com)</li>
</ul>
<p>I think that either the Optik router or the TELUS DNS servers are a bottleneck here.  I guess  that for some reason, iTunes needs to do a lot of DNS lookups when it transfers data?</p>
<p>Anyways I changed my clients to use the following DNS servers:</p>
<ul>
<li>8.8.8.8</li>
<li>8.8.4.4</li>
<li>208.67.222.222</li>
<li>208.67.220.220</li>
</ul>
<p>The first two are provided by Google, the last two are provided by OpenDNS.  iTunes download speed went from ~200KB/sec to ~1.5MB/sec.  On Mac OS X, change the setting in System Preferences → Network → (Select your Network Connection) → Advanced → DNS.</p>
]]></content:encoded>
			<wfw:commentRss>http://newbrightidea.com/2012/01/06/slow-itunes-downloads-on-telus-optik/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Corporate (Mis?)Management</title>
		<link>http://newbrightidea.com/2011/12/29/corporate-mismanagement/</link>
		<comments>http://newbrightidea.com/2011/12/29/corporate-mismanagement/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 02:36:56 +0000</pubDate>
		<dc:creator>Russ Weeks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://newbrightidea.com/?p=178</guid>
		<description><![CDATA[Via Gruber, an article about the business anti-pattern of maximizing shareholder value.  I don&#8217;t disagree in principle with the idea that CEOs should have better things to do than negotiate expectations with market analysts.  But I think that the article&#8217;s &#8230; <a href="http://newbrightidea.com/2011/12/29/corporate-mismanagement/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Via <a title="Daring Fireball: Shareholder Value" href="http://daringfireball.net/linked/2011/12/28/shareholder-value" target="_blank">Gruber</a>, an article about the <a title="Forbes: Fixing the Game" href="http://www.forbes.com/sites/stevedenning/2011/11/28/maximizing-shareholder-value-the-dumbest-idea-in-the-world/" target="_blank">business anti-pattern of maximizing shareholder value</a>.  I don&#8217;t disagree in principle with the idea that CEOs should have better things to do than negotiate expectations with market analysts.  But I think that the article&#8217;s central analogy, that of a CEO to a football coach and a business to a football match, is fundamentally invalid.</p>
<p>A football match is time-bound.  This rightly requires that a football coach focus on winning the game in the required timeframe, not on beating the spread.  I can&#8217;t think of any type of business that&#8217;s similarly time-bound (in fact, I think a competent economist could argue that in an efficient market, all corporations are <a title="Lean Startup" href="http://theleanstartup.com/" target="_blank">growth-bound</a>).  In an environment that isn&#8217;t time-bound, it makes sense that the best metric of a corporation&#8217;s value is not its position or &#8220;score&#8221;, but the first and second derivatives of its position (that is, velocity and acceleration).  And isn&#8217;t this what market analysts are really getting at when they try to define expectations for a corporation?</p>
<p>Bonus amateur economist theorizing: there&#8217;s been a lot of talk lately about executive pay and the perverse incentives it creates.  For what it&#8217;s worth, I think the best rationalization of executive pay comes from tournament theory applied to the workplace.  This is probably best explained by Tim Harford in various places, including this <a title="Logic of Life: Executive Pay" href="http://www.youtube.com/watch?v=FZUqb5U_vSs" target="_blank">YouTube video from the Logic of Life</a>.  To summarize: lavish CEO pay is not only a reward for the CEO&#8217;s labour, it&#8217;s an incentive for his underlings to aspire to the top position.  This creates its own set of perverse incentives, prioritizing individual success over the success of the corporation.</p>
]]></content:encoded>
			<wfw:commentRss>http://newbrightidea.com/2011/12/29/corporate-mismanagement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixed RTree, added Graham&#8217;s Scan</title>
		<link>http://newbrightidea.com/2011/09/25/fixed-rtree-added-grahams-scan/</link>
		<comments>http://newbrightidea.com/2011/09/25/fixed-rtree-added-grahams-scan/#comments</comments>
		<pubDate>Sun, 25 Sep 2011 22:12:11 +0000</pubDate>
		<dc:creator>Russ Weeks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://newbrightidea.com/?p=171</guid>
		<description><![CDATA[I just updated my Util package on github, which is just a place where I keep various odds and ends.  The RTree implementation was broken in a bunch of ways: thanks to Fred Long, Simon Probst and 屈伟 for contributing fixes. &#8230; <a href="http://newbrightidea.com/2011/09/25/fixed-rtree-added-grahams-scan/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just updated my <a href="https://github.com/rweeks/util">Util package on github</a>, which is just a place where I keep various odds and ends.  The RTree implementation was broken in a bunch of ways: thanks to Fred Long, Simon Probst and 屈伟 for contributing fixes.</p>
<p>I also added a Java implementation of <a href="http://en.wikipedia.org/wiki/Graham_scan">Graham&#8217;s Scan</a> to find the convex hull of a 2-D coordinate set.</p>
]]></content:encoded>
			<wfw:commentRss>http://newbrightidea.com/2011/09/25/fixed-rtree-added-grahams-scan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse jUnit Huh?</title>
		<link>http://newbrightidea.com/2011/09/24/eclipse-junit-huh/</link>
		<comments>http://newbrightidea.com/2011/09/24/eclipse-junit-huh/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 04:55:32 +0000</pubDate>
		<dc:creator>Russ Weeks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://newbrightidea.com/?p=163</guid>
		<description><![CDATA[Eclipse!  You done me wrong!  Why on earth, when you recognize a Run Configuration as a jUnit test suite, would you not enable assertions by default?!?]]></description>
			<content:encoded><![CDATA[<p><a href="http://eclipse.org">Eclipse</a>!  You done me wrong!  Why on earth, when you recognize a Run Configuration as a jUnit test suite, would you <span style="text-decoration: underline;"><strong>not</strong></span> enable assertions by default?!?</p>
]]></content:encoded>
			<wfw:commentRss>http://newbrightidea.com/2011/09/24/eclipse-junit-huh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hacking the Touchpad, Part 1</title>
		<link>http://newbrightidea.com/2011/08/26/hacking-the-touchpad-part-1/</link>
		<comments>http://newbrightidea.com/2011/08/26/hacking-the-touchpad-part-1/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 08:50:16 +0000</pubDate>
		<dc:creator>Russ Weeks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://newbrightidea.com/?p=149</guid>
		<description><![CDATA[I just picked up a discounted HP TouchPad from my man Greg Chan (via a real stand-up guy who would probably prefer to remain anonymous).   Haven&#8217;t even played around with WebOS; it doesn&#8217;t interest me in the slightest.  We &#8230; <a href="http://newbrightidea.com/2011/08/26/hacking-the-touchpad-part-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just picked up a discounted HP TouchPad from my man <a href="http://50ftware.com/">Greg Chan</a> (via a real stand-up guy who would probably prefer to remain anonymous).   Haven&#8217;t even played around with WebOS; it doesn&#8217;t interest me in the slightest.  We need to get Android on this contraption!  Here are my modest contributions to the effort. First: an attempt to get an SSH client and server running.</p>
<h3>Preparing for the Worst</h3>
<p>First, establish a backup plan!  Once you register the device, you&#8217;ll have access to the <a href="https://ps.palmws.com/palmcsext/console/pages/LoginPage.iface">HP WebOS site</a>.  From there you can download WebOS Doctor, a Java app that will let you restore your TouchPad should something untoward happen to it.</p>
<p>I haven&#8217;t used WebOS Doctor yet and I hope I never have to.  But as a backup-backup plan, let&#8217;s make a copy of the filesystem.  Follow the instructions <a href="http://wiki.rootzwiki.com/index.php/HP_Touchpad">here</a> to get terminal (root) access to the TouchPad. After logging in, I ran this command:</p>
<pre>tar cvfz /media/internal/downloads/backup.tar.gz / --exclude '/media/internal/downloads/*</pre>
<p>to backup the filesystem.  It&#8217;s far from a perfect backup, and it may never be useful, but I like having it around just in case.  Let me know if you need a copy, it&#8217;s about 300MB.</p>
<h3>Setting up a Cross-Compiler</h3>
<p>Wow, setting up a cross compiler has gotten a lot easier since the last time I checked.  All I had to do was download the ARM cross-compiler from <a href="http://www.codesourcery.com/sgpp/lite/arm/portal/release1803">here</a> and install it.</p>
<p>The cross-compiler build tools are set up with weird names like &#8220;arm-none-linux-gnueabi-ar&#8221;.  There&#8217;s got to be an easier way to configure this but I just ran this command to set up shortened symlinks:</p>
<pre>rweeks@faithless:/bitsafe/CodeSourcery/Sourcery_G++_Lite/bin$ for CMD in *; do CMD_TRIM=`echo $CMD | sed -e 's/arm-none-linux-gnueabi-//'`; ln -s $CMD $CMD_TRIM; done</pre>
<p>Then you can control whether you&#8217;re using your native buildtools or the cross-compiler buildtools just by setting your $PATH.</p>
<h3>Building OpenSSH</h3>
<p>I figure a good first-day milestone is to get OpenSSH running on the TouchPad.  I&#8217;ll try to work my way up to a full-on Android distro <img src='http://newbrightidea.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .  I pretty much followed the instructions <a href="http://www.unixwiz.net/techtips/openssh.html">here</a> with some minor changes for the cross-compiler.</p>
<p>First I defined a directory where I want to put all the build output:</p>
<pre>mkdir /bitsafe/arm-openssh-server/output</pre>
<p>The commands I used to build zLib:</p>
<pre>./configure --prefix=/bitsafe/arm-openssh-server/output</pre>
<pre>make &amp;&amp; make install</pre>
<p>The commands I used to build openSSL (this will take a while):</p>
<pre>./Configure --prefix=/bitsafe/arm-openssh-server/output linux-armv4</pre>
<pre>make &amp;&amp; make install</pre>
<p>The commands I used to build openSSH:</p>
<pre>./configure --host=arm-none-linux-gnueabi --prefix=/bitsafe/arm-openssh-server/output --with-zlib=$PWD/../zlib-1.2.5 --with-ssl-dir=../openssl-1.0.0d</pre>
<pre>make &amp;&amp; make install</pre>
<p>The OpenSSH build will fail to install due to the cross-compiler (it can&#8217;t strip the output files).  But that should be OK.</p>
<h3>Deploying OpenSSH to the TouchPad</h3>
<p>OK, everything should be built at this point.  You can double-check that you&#8217;re using the cross-compiler by, eg.</p>
<pre>find . -type f -print0 | xargs -0 file</pre>
<p>Where you see executable files, it should indicate that they have been built for the ARM architecture.  I wrapped up everything in a tarball:</p>
<pre>tar cvfz openssh-server.tar.gz arm-openssh-server/</pre>
<p>This grabbed my &#8220;output&#8221; directory, as well as the source directories for zLib, openSSL and openSSH (in case any files failed to install correctly into output/)</p>
<p>I had a vastly complicated procedure in mind to copy the tarball to my TouchPad, but it turns out that the TouchPad just mounts as a vfat file system which was mounted automatically by my build machine.  The whole thing was just a drag-and-drop, which was nice.</p>
<p>Extract the tar file like so:</p>
<pre>tar xvfz openssh-server.tar.gz --no-same-owner</pre>
<p>You&#8217;ll get a bunch of errors on the extraction because it can&#8217;t create symbolic links: I think this is because you&#8217;re extracting to a filesystem that doesn&#8217;t support symlinks.  No big deal.</p>
<p>Test that the cross-compiler worked!</p>
<pre>cd /media/internal/downloads/arm-openssh-server/zlib-1.2.5
./example
zlib version 1.2.5 = 0x1250, compile flags = 0x55
uncompress(): hello, hello!
gzread(): hello, hello!
gzgets() after gzseek:  hello!
inflate(): hello, hello!
large_inflate(): OK
after inflateSync(): hello, hello!
inflate with dictionary: hello, hello!</pre>
<h3>Starting OpenSSH Server</h3>
<p>Harder than it sounds!  The root filesystem is mounted read-only by default, but you can hack your way around that with:</p>
<pre>mount -w -o remount /</pre>
<p>Then, add the sshd user and group to /etc/passwd and /etc/group</p>
<p>Setup an ssh key using ssh-keygen and set the &#8220;HostKey&#8221; property in sshd_config to point to the private key.</p>
<p>If you didn&#8217;t remount the root FS as read-write, you need to set UsePrivilegeSeparation to true.</p>
<p>Start sshd like so:</p>
<pre>root@RussHPTouchPad:/media/internal/downloads/arm-openssh-server/openssh-5.8p2# $PWD/sshd -f sshd_config -ddd</pre>
<p>(This is required because by setting up the &#8220;prefix&#8221; properties during the SSH build, all the commands will now be looking for their config in /bitsafe/&#8230;)</p>
<p>Last thing is to undo all the custom iptables config:</p>
<pre>iptables -F</pre>
<pre>iptables -P INPUT ACCEPT</pre>
<pre>iptables -X ALLOWED_PACKETS</pre>
<pre>iptables -X ICMPFLOOD</pre>
<pre>iptables -X INVALID_PACKETS</pre>
<h3>OpenSSH 5.8 Running on TouchPad:</h3>
<pre>backfire:bin rweeks$ ssh -p 2222 root@192.168.10.128
The authenticity of host '[192.168.10.128]:2222 ([192.168.10.128]:2222)' can't be established.
RSA key fingerprint is de:c2:1f:6a:30:e9:33:cc:85:f6:28:07:62:f9:8b:9b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[192.168.10.128]:2222' (RSA) to the list of known hosts.
root@192.168.10.128's password:
lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
debug1: permanently_set_uid: 0/0
Environment:
  USER=root
  LOGNAME=root
  HOME=/home/root
  PATH=/usr/bin:/bin:/usr/sbin:/sbin:/bitsafe/arm-openssh-server/output/bin
  MAIL=/var/mail/root
  SHELL=/bin/sh
  TZ=:/var/luna/preferences/localtime
  SSH_CLIENT=192.168.10.107 52206 2222
  SSH_CONNECTION=192.168.10.107 52206 192.168.10.128 2222
  SSH_TTY=/dev/pts/1
  TERM=xterm-color
root@RussHPTouchPad:/var/home/root#</pre>
]]></content:encoded>
			<wfw:commentRss>http://newbrightidea.com/2011/08/26/hacking-the-touchpad-part-1/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>RTree implementation in Java</title>
		<link>http://newbrightidea.com/2011/01/24/rtree-implementation-in-java/</link>
		<comments>http://newbrightidea.com/2011/01/24/rtree-implementation-in-java/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 06:11:42 +0000</pubDate>
		<dc:creator>Russ Weeks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://newbrightidea.com/?p=146</guid>
		<description><![CDATA[An RTree is a data structure for spatial indexing.  If you have a bunch of objects with associated coordinates (or associated rectangles, or hyperrectangles, etc.) you can use an RTree for queries like, &#8220;find all objects overlapping with this search &#8230; <a href="http://newbrightidea.com/2011/01/24/rtree-implementation-in-java/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>An RTree is a data structure for spatial indexing.  If you have a bunch of objects with associated coordinates (or associated rectangles, or hyperrectangles, etc.) you can use an RTree for queries like, &#8220;find all objects overlapping with this search rectangle&#8221; or &#8220;find the N closest objects to this object&#8221;.</p>
<p><a href="http://www-db.deis.unibo.it/courses/SI-LS/papers/Gut84.pdf">This</a> is the original paper describing the RTree and its implementation.  I&#8217;ve built a Java implementation based on it, <a href="https://github.com/rweeks/util">here</a>.</p>
<p>I used this RTree implementation to generate the simulated network topologies shown <a href="http://newbrightidea.com/?p=129">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://newbrightidea.com/2011/01/24/rtree-implementation-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simulated Network Topologies</title>
		<link>http://newbrightidea.com/2011/01/16/simulated-network-topologies/</link>
		<comments>http://newbrightidea.com/2011/01/16/simulated-network-topologies/#comments</comments>
		<pubDate>Sun, 16 Jan 2011 00:30:16 +0000</pubDate>
		<dc:creator>Russ Weeks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://newbrightidea.com/?p=129</guid>
		<description><![CDATA[I&#8217;ve been doing a lot of work in the network management space recently (on account of that&#8217;s my job) and I&#8217;ve found it really helpful to use a few randomly-generated network topologies.  So I wrote a little tool which takes &#8230; <a href="http://newbrightidea.com/2011/01/16/simulated-network-topologies/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing a lot of work in the network management space recently (on account of that&#8217;s my job) and I&#8217;ve found it really helpful to use a few randomly-generated network topologies.  So I wrote a little tool which takes as input a slightly-massaged version of the <a href="http://download.geonames.org/export/dump/cities15000.zip">cities database</a> from <a href="http://geonames.org">geonames.org</a> and produces as output a graph where cities are vertices and edges are defined in a pseudo-realistic fashion.  The graph is defined in XML.  I&#8217;ll probably get around to open-sourcing the tool, eventually.</p>
<p>By &#8220;pseudo-realistic&#8221; I mean that cities are much more likely to be adjacent to nearby cities, and the edges are weighted such that a shortest-path algorithm will prefer many short hops over a few long hops.  Specifically, the weight of an edge is n*log(n) where n is the great-circle distance between the two incident cities.</p>
<p>This algorithm tends to produce disconnected graphs.  It often doesn&#8217;t define any edges between the Americas and Africa or Europe.  Usually I just go and insert those edges manually.</p>
<p>Comments are extremely welcome re. how to make this simulated topology more realistic.  One thing I&#8217;m thinking of is defining a set of vertices as &#8220;aggregation nodes&#8221; and then auto-generating a certain number of devices adjacent to each aggregation node, where the number of aggregated devices per aggregation node is proportional to the population of the aggregation node city.</p>
<ul>
<li><a href="http://newbrightidea.com/downloads/network-16384.xml.gz">network-16384.xml.gz</a></li>
<li><a href="http://newbrightidea.com/downloads/network-8192.xml.gz">network-8192.xml.gz</a></li>
<li><a href="http://newbrightidea.com/downloads/network-4096.xml.gz">network-4096.xml.gz</a></li>
<li><a href="http://newbrightidea.com/downloads/network-2048.xml.gz">network-2048.xml.gz</a></li>
<li><a href="http://newbrightidea.com/downloads/network-1024.xml.gz">network-1024.xml.gz</a></li>
<li><a href="http://newbrightidea.com/downloads/network-512.xml.gz">network-512.xml.gz</a></li>
<li><a href="http://newbrightidea.com/downloads/network-256.xml.gz">network-256.xml.gz</a></li>
<li><a href="http://newbrightidea.com/downloads/network-128.xml.gz">network-128.xml.gz</a></li>
<li><a href="http://newbrightidea.com/downloads/network-64.xml.gz">network-64.xml.gz</a></li>
<li><a href="http://newbrightidea.com/downloads/network-32.xml.gz">network-32.xml.gz</a></li>
</ul>
<div id="attachment_142" class="wp-caption alignleft" style="width: 310px"><a href="http://newbrightidea.com/wp-content/uploads/2011/01/network-16384.jpg"><img class="size-medium wp-image-142" title="network-16384" src="http://newbrightidea.com/wp-content/uploads/2011/01/network-16384-300x150.jpg" alt="" width="300" height="150" /></a><p class="wp-caption-text">network-16384</p></div>
<div id="attachment_141" class="wp-caption alignleft" style="width: 310px"><a href="http://newbrightidea.com/wp-content/uploads/2011/01/network-8192.jpg"><img class="size-medium wp-image-141" title="network-8192" src="http://newbrightidea.com/wp-content/uploads/2011/01/network-8192-300x150.jpg" alt="" width="300" height="150" /></a><p class="wp-caption-text">network-8192</p></div>
<div id="attachment_140" class="wp-caption alignleft" style="width: 310px"><a href="http://newbrightidea.com/wp-content/uploads/2011/01/network-4096.jpg"><img class="size-medium wp-image-140" title="network-4096" src="http://newbrightidea.com/wp-content/uploads/2011/01/network-4096-300x150.jpg" alt="" width="300" height="150" /></a><p class="wp-caption-text">network-4096</p></div>
<div id="attachment_139" class="wp-caption alignleft" style="width: 310px"><a href="http://newbrightidea.com/wp-content/uploads/2011/01/network-2048.jpg"><img class="size-medium wp-image-139" title="network-2048" src="http://newbrightidea.com/wp-content/uploads/2011/01/network-2048-300x150.jpg" alt="" width="300" height="150" /></a><p class="wp-caption-text">network-2048</p></div>
<div id="attachment_138" class="wp-caption alignleft" style="width: 310px"><a href="http://newbrightidea.com/wp-content/uploads/2011/01/network-1024.jpg"><img class="size-medium wp-image-138" title="network-1024" src="http://newbrightidea.com/wp-content/uploads/2011/01/network-1024-300x150.jpg" alt="" width="300" height="150" /></a><p class="wp-caption-text">network-1024</p></div>
<div id="attachment_137" class="wp-caption alignleft" style="width: 310px"><a href="http://newbrightidea.com/wp-content/uploads/2011/01/network-512.jpg"><img class="size-medium wp-image-137" title="network-512" src="http://newbrightidea.com/wp-content/uploads/2011/01/network-512-300x150.jpg" alt="" width="300" height="150" /></a><p class="wp-caption-text">network-512</p></div>
<div id="attachment_136" class="wp-caption alignleft" style="width: 310px"><a href="http://newbrightidea.com/wp-content/uploads/2011/01/network-256.jpg"><img class="size-medium wp-image-136" title="network-256" src="http://newbrightidea.com/wp-content/uploads/2011/01/network-256-300x150.jpg" alt="" width="300" height="150" /></a><p class="wp-caption-text">network-256</p></div>
<div id="attachment_135" class="wp-caption alignleft" style="width: 310px"><a href="http://newbrightidea.com/wp-content/uploads/2011/01/network-128.jpg"><img class="size-medium wp-image-135" title="network-128" src="http://newbrightidea.com/wp-content/uploads/2011/01/network-128-300x150.jpg" alt="" width="300" height="150" /></a><p class="wp-caption-text">network-128</p></div>
<div id="attachment_134" class="wp-caption alignleft" style="width: 310px"><a href="http://newbrightidea.com/wp-content/uploads/2011/01/network-64.jpg"><img class="size-medium wp-image-134" title="network-64" src="http://newbrightidea.com/wp-content/uploads/2011/01/network-64-300x150.jpg" alt="" width="300" height="150" /></a><p class="wp-caption-text">network-64</p></div>
<div id="attachment_133" class="wp-caption alignleft" style="width: 310px"><a href="http://newbrightidea.com/wp-content/uploads/2011/01/network-32.jpg"><img class="size-medium wp-image-133" title="network-32" src="http://newbrightidea.com/wp-content/uploads/2011/01/network-32-300x150.jpg" alt="" width="300" height="150" /></a><p class="wp-caption-text">network-32</p></div>
]]></content:encoded>
			<wfw:commentRss>http://newbrightidea.com/2011/01/16/simulated-network-topologies/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java brute-force Knight&#8217;s Tour</title>
		<link>http://newbrightidea.com/2010/12/31/brute-force-knights-tour/</link>
		<comments>http://newbrightidea.com/2010/12/31/brute-force-knights-tour/#comments</comments>
		<pubDate>Fri, 31 Dec 2010 22:34:00 +0000</pubDate>
		<dc:creator>Russ Weeks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://newbrightidea.com/?p=125</guid>
		<description><![CDATA[Wikipedia today featured an animated picture of a Knight&#8217;s Tour, which got me thinking about algorithms to find Knights Tours.  I put this together really quickly, it&#8217;s just a brute-force approach and its running time varies (depending on the start &#8230; <a href="http://newbrightidea.com/2010/12/31/brute-force-knights-tour/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Wikipedia today featured an animated picture of a <a href="http://en.wikipedia.org/wiki/File:Knight%27s_tour_anim_2.gif">Knight&#8217;s Tour</a>, which got me thinking about algorithms to find Knights Tours.  I put <a href="https://github.com/rweeks/KnightsTour">this</a> together really quickly, it&#8217;s just a brute-force approach and its running time varies (depending on the start square) from &#8220;wow that was fast&#8221; to &#8220;time to ctrl-c this thing&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://newbrightidea.com/2010/12/31/brute-force-knights-tour/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Monty Hall Problem Simulator</title>
		<link>http://newbrightidea.com/2010/12/13/java-monty-hall-problem-simulator/</link>
		<comments>http://newbrightidea.com/2010/12/13/java-monty-hall-problem-simulator/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 05:48:20 +0000</pubDate>
		<dc:creator>Russ Weeks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://newbrightidea.com/?p=120</guid>
		<description><![CDATA[For a long time now I&#8217;ve been meaning to build a simulator for the Monty Hall Problem, which is kind of a bizarre statistical thought experiment.  I finally got around to it.  It&#8217;s here.]]></description>
			<content:encoded><![CDATA[<p>For a long time now I&#8217;ve been meaning to build a simulator for the <a href="http://en.wikipedia.org/wiki/Monty_Hall_problem">Monty Hall Problem</a>, which is kind of a bizarre statistical thought experiment.  I finally got around to it.  It&#8217;s <a href="https://github.com/rweeks/MontyHall">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://newbrightidea.com/2010/12/13/java-monty-hall-problem-simulator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Home NAS with BTRFS</title>
		<link>http://newbrightidea.com/2010/12/13/home-nas-with-btrfs/</link>
		<comments>http://newbrightidea.com/2010/12/13/home-nas-with-btrfs/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 02:05:59 +0000</pubDate>
		<dc:creator>Russ Weeks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://newbrightidea.com/?p=106</guid>
		<description><![CDATA[I just finished building a Network Attached Storage server for home use.  Backups, mostly, but also kind of as a media hub.  Here&#8217;s a run-down of the setup, with an exploration of some of the pitfalls of RAID and of &#8230; <a href="http://newbrightidea.com/2010/12/13/home-nas-with-btrfs/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just finished building a Network Attached Storage server for home use.  Backups, mostly, but also kind of as a media hub.  Here&#8217;s a run-down of the setup, with an exploration of some of the pitfalls of RAID and of the cool features of modern file systems.</p>
<p>Firstly, a couple pics:</p>

<a href='http://newbrightidea.com/2010/12/13/home-nas-with-btrfs/img_8606/' title='IMG_8606'><img width="150" height="150" src="http://newbrightidea.com/wp-content/uploads/2010/12/IMG_8606-150x150.jpg" class="attachment-thumbnail" alt="IMG_8606" title="IMG_8606" /></a>
<a href='http://newbrightidea.com/2010/12/13/home-nas-with-btrfs/img_8608/' title='IMG_8608'><img width="150" height="150" src="http://newbrightidea.com/wp-content/uploads/2010/12/IMG_8608-150x150.jpg" class="attachment-thumbnail" alt="IMG_8608" title="IMG_8608" /></a>

<p>Shown above is the new, small NAS (&#8220;faithless&#8221;) and the old one (&#8220;backfire&#8221;).  The old one had a few disadvantages: it was huge, noisy and power-hungry.  For storage, I had 3x250GB SATA drives, each set up with EXT4.  Two of the drives were removable (one is shown partly removed in the photo).  In theory, one of the drives would be kept off-site.  I would rsync from client machines (mostly my laptop) to the fixed internal drive, and then rsync from there to the removable drive in the chassis.  Then, I would swap the removable drive with the off-site drive.</p>
<p>It&#8217;s a great theory but in practice I didn&#8217;t back-up to the file server as often as I should have and I practically never swapped the off-site drive.  Finally, I was worried (maybe unreasonably) about latent sector error with EXT4 due to its limited checksumming.</p>
<h3>A Word About Latent Sector Error</h3>
<p>So, the SATA spec tells us that we should <a href="http://research.microsoft.com/pubs/64599/tr-2005-166.pdf">expect an error every 10<sup>13</sup> bits</a>.  10<sup>13</sup> works out to about 2<sup>43</sup> bits, or 2<sup>40</sup> bytes.  That&#8217;s 1TB<sup>1</sup>.  It&#8217;s a little worrying to me that, if I fill up my 1TB drive, there&#8217;s a good chance of at least one error lurking somewhere.</p>
<p>EXT4 checksums its journal, which AFAIK will protect against errors caused by sync failures (ie. power failure during disk I/O).  But it&#8217;s not going to protect against latent sector errors.  To do that, you need checksumming on all the file data, along the lines of what ZFS or BTRFS provides.</p>
<h3>Oh, ZFS, We Hardly Knew Ye</h3>
<p>ZFS is an amazing filesystem.  I don&#8217;t think the <a href="http://www.phoronix.com/scan.php?page=article&amp;item=zfs_ext4_btrfs&amp;num=1">benchmarks at Phoronix</a> give it enough credit: ZFS&#8217;s default behaviour is to flush to persistent storage on every sync, which is the <span style="text-decoration: underline;"><strong>only</strong></span> way to guarantee data consistency in the absence of battery-backed on-disk cache.  Further, the one/two punch of the intent log and the adaptive read cache mean that, if you&#8217;ve set up your hybrid storage pools correctly, you can get some mind-boggling performance without sacrificing the fault-tolerance of your storage pool.</p>
<p>The problem with ZFS is that it runs best in Solaris.  I don&#8217;t like where Solaris is heading, and I have no reason to believe that it supports the hardware platform I&#8217;m using for the new NAS.  There have been a few attempts to port ZFS to Linux, but the <a href="http://www.phoronix.com/scan.php?page=news_item&amp;px=ODU1MA">most promising effort</a> is still in its infancy.  So it&#8217;s not an option for this project.</p>
<p>BTRFS is a good option.  Its performance numbers are impressive and it offers the same RAID-0 and RAID-1 configurations as ZFS, plus redundant data checksums.  It&#8217;s got snapshot capabilities similar to ZFS.  I&#8217;ll miss the ZFS send/recv functionality, rsync will get me part of the way but it&#8217;s not a great solution.  I&#8217;m eagerly anticipating a proper fsck utility for BTRFS.</p>
<h3>RAID-1 Fault Tolerance</h3>
<p>If you look at the <a href="http://en.wikipedia.org/wiki/RAID">Wikipedia article on RAID</a>, it claims that N-way mirroring (RAID-1) offers a Hamming distance of N.  This is a bit of an exaggeration, to me, because it assumes that checksumming is being done at a higher level.  What I mean is, if you have a 2-disk mirror and one of the disks has a latent sector error, to my knowledge there is no clear way to figure out which disk has gone bad, because you have no way of telling what the data should have looked like.  In an N-way mirror, your RAID controller (if it is clever) could probably find agreement between the other N-1 disks in the volume and reset the bad sector (isolate it, more likely), but even if that functionality exists I don&#8217;t think it would be present in a consumer grade $20 controller.  In my opinion, RAID-1 offers no fault tolerance at all because there is no checksum to verify against.  You effectively get a checksum when you go with RAID-5 or RAID-6, which is pretty much the route that ZFS/BTRFS has taken.</p>
<h3>Enough With The Preamble, Already</h3>
<p>There are 5 disks inside the NAS: 1x128GB OCZ Vertex SSD and 4x1TB WD Caviars.  The SSD is set up as the boot drive (Ubuntu 10.10); it also hosts all the application software.  As an aside, I will never again build a computer without an SSD.  The performance boost is incredible.  Boot time is sub-10-seconds.</p>
<p>The CPU is a dual-core Intel Atom D525 (1.8GHz).  I maxxed out the motherboard with 4GB of DDR3-1333.</p>
<p>The four 1TB drives are set up in a multi-device BTRFS filesystem, RAID-10 with redundant metadata.  I&#8217;ve disabled write caching (sudo hdparm -W 0 /dev/sd[b,c,d,e]).  With write caching enabled, I can do sequential writes up to 120MB/sec from SSD to the BTRFS filesystem.  With write caching enabled, that drops to a still-respectable 60MB/sec.  I expect that single-threaded sequential I/O, heavily biased towards writes, will be the primary use of this system.</p>
<p>I originally shared the filesystem through NFS but I&#8217;m accessing it mostly from OS X devices, and it seems like the OS X NFS client really, really sucks.  I couldn&#8217;t do better than about 10MB/sec over NFS and large sequential writes cause the client to become unresponsive for long periods of time.  Anyways, it&#8217;s still exported over NFS with the &#8216;sync&#8217; option but I mostly access it via rsync+SSH.  In that mode of operation, I can get about 20MB/sec sequential write over my home network.</p>
<p>To solve the off-site backup problem, I think I&#8217;ll get a 1TB external drive and rsync from the BTRFS filesystem to the external drive.  eSATA would be really convenient here, but I&#8217;ll probably have to stick with USB due to hardware limitations.  ZFS send/receive would also be really useful to incrementally transfer the fileystem to an external disk.  The absence of this functionality in BTRFS means I&#8217;ll probably stick with rsync.</p>
<p>1: Useful to remember: 2<sup>10</sup>=1KB, 2<sup>20</sup>=1MB, 2<sup>30</sup>=1GB, 2<sup>40</sup>=1TB.  If you&#8217;re going to complain about how 1GB=1000MB, please, don&#8217;t.  We&#8217;re approximating here.</p>
]]></content:encoded>
			<wfw:commentRss>http://newbrightidea.com/2010/12/13/home-nas-with-btrfs/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

