Care and feeding of your wireless router

This morning I went to check my email from my iPad and had a unpleasant surprise.  No Internet.  I have the Wi-Fi only version of the iPad and it usually has a nice solid connection to my wireless router.  On the iPad, I fired up the Settings app and sure enough, under “Wi-Fi”, it displayed not connected. I tapped “Wi-Fi” and let it scan for networks.  No sign of mine.  I tried my iPod Touch, same thing.

That pretty much rules out the iPad as being the problem, time to move up the chain of command.  My router is an ancient (by home router standards) Linksys, the WRT54GS.  It’s your basic work horse router with 802.11b (11 Mbit/s) and 802.11g (54 Mbit/s) support.  I run a 3rd party firmware on it called DD-WRT.  DD-WRT greatly enhances the functionality of the router and lets you do a lot of cool things.  It’s about 99.9% cool and 0.1% flakey.  The flakey bit means that I need to reboot it every now and then.  I don’t know if it’s a memory leak, or something is getting confused, but a reboot every once in a while clears the cobwebs out.

From my PC with a wired connection to the router, I was able to access both the Internet and the administrative web pages on the router.  So the router wasn’t completely borked, just the wireless part.  From the admin pages on the router, I could get the router to do a wireless scan.  That’s where the router goes looking to see what other wireless hotspots are nearby.  This is very useful for picking the right channel

With 802.11b and 802.11g, the router uses a narrow range of frequencies at 2.4ghz.  In the US, this range is divided up into 11 channels.  It’s kind of fuzzy how they divided the channels, they all overlap the next channel on each side.  So you really want to think of it as 3 channels, 1, 6, and 11.  Since channel 1 only bleeds up with channel 2, and channel 11 only bleeds down with 10, you really want to use channel 1 or 11 if you can.  Most routers default to channel 6, in a crowded neighborhood so you should see less traffic on 1 or 11 than on 6.

So I unplugged the router and waited about 20 seconds.  It came back up and my PC could hit the Internet.  But still no Wi-Fi.  Since a power cycle didn’t fix it, I moved up to the nuclear option: the 30/30/30 reset.  The 30/30/30 reset is the best way to clear out all of the router settings to the firmware default values.  When you upgrade the firmware on the router, you should do the 30/30/30 before you flash the router and one more time again after you have flashed the router to the new firmware.

There are 3 steps to the 30/30/30 reset:

  1. Press and hold the reset button on the router and wait 30 seconds.
  2. While keeping the reset button pressed, unplug the power from the router and wait 30 more seconds
  3. Plug the power back in while keeping the reset button pressed and wait for another 30 seconds.

Before you do the reset, you’ll want to write down any custom settings that you have performed. I use the following features added by DD-WRT:

  1. Configured the http://www.dyndns.com/ client.  This assigns the current IP address of the router to domain name provided by DynDNS.  When my ISP changes the IP address assigned to the router, DD-WRT passes the new IP address to DynDNS and they update the record for that domain name.  This makes it easy to use my VPN to connect to my home network.
  2. Configured the VPN server.  DD-WRT provides both PPTP and OpenVPN.  PPTP is simpler the configure and works for me, so that’s what I use. I’ll use the VPN if I’m a location that blocks sites that I want to access from my iPad.  I can also use the VPN if I need to open a Remote Desktop (RDP) connection to my home PC.
  3. Changed the default login account on the router.  Most routers let you change just the admin password, DD-WRT lets you change the login name as well.
  4. Set the router to use OpenDNS.  This isn’t a DD-WRT feature, most routers will let you set the DNS servers.  I use OpenDNS for their fast DNS servers and for their content filtering.
  5. Sell the router to reboot itself once a week.  In a perfect world, your computer would never need to be rebooted. In this world, it doesn’t hurt for the router to get rebooted automatically once a week.  Mine is set to reboot ever Wednesday at 5:30am.  Not much is going on at that hour.
  6. Enable UPnP.  I missed that one at first.  Windows Home Server uses UPnP to punch a secure hole through your firewall to allow remote access to your network through Windows Home Server.  I have a HP Media Smart Server and I will access my home network from work by going through it’s Remote Access.

After the reset, I set the Wi-Fi settings and after a few seconds, my iPad was back on the Internet.  Since I had already reset the settings, I decided to update the DD-WRT version on my router.  The DD-WRT web site has an interactive Router Database, where you can pick your router and it will tell you which versions of DD-WRT will work with your router.  It’s pretty handy, there are multiple versions of DD-WRT available, and different builds of each versions.

Unless you have a large pile of routers to play with, you really want to use the suggested version of DD-WRT.  If you install the wrong version or get an unstable development build, you could brick the router.  I grabbed the standard set and installed it without blowing anything up.  Then I put back my custom settings.

So now I have full Wi-Fi back, but I don’t know why it failed.  It was working the evening before, but stopped sometime last night.  MY WRT45GS is about 4 years old and has been on 24/7 the entire time.  It could be just wearing out.  My iPad supports 802.11n, it may be time to upgrade to a newer router.  The Buffalo Technology Nfiniti Wireless-N High Power Router (WZR-HP-G300NH) works very well with DD-WRT and the people at SmallNetBuilder like itJeff Atwood just picked one up too, and he’s programmer with the hardware tweak bit set to on.  It would also be nice to have a router that supports gigabit speed WAN connections for the small set of the devices that I own that support gigabit. 

The Nfiniti is a single band router, everything is broadcast over the 2.4ghz range.  I may look at a dual band router, like the Netgear WNR3500L.  With a dual band router, you can have 802.11g devices on the 2.4ghz band and the 802.11n devices on the 5ghz band.  As far as I can tell, my iPad supports 802.11a/b/g/n on either band. It may be worth it to get the heavy duty Netgear router over the Buffalo one.

Some additional notes:
Resetting the router evidently disabled my Windows Home Server’s Remote Access functionality.  I was able to repair that by performing the following steps:

  1. Launch the Windows Home Console
  2. Click on “Settings”
  3. Click on “Remote Access”
  4. Click on the “Repair…” button.  This launched the “Repairing Remote Access Configuration” wizard. Which told me that UPnP was not enabled on the router. Sure enough, I went into the UPnP page (under NAT / QoS) in dd-qrt and saw that UPnP was not enabled.  I enabled UPnP, rebooted the router, and let the wizard repair the Remote Access settings. 

The fun part was that I did this from my office PC.  I created opened a VPN connection to my router and changed the UPnP settings remotely.

There was a problem sending the command to the program

I hate error messages like that. It’s both detailed and vague at the same. What command was being sent and what was the problem? Let me back up a few steps. A family member bought a new PC running Windows 7, for his home office. He works from home and accesses his work email account through Internet Explorer.  His email based on Domino Web Access, which I’m assuming is the web bit for Lotus Notes email.

When ever he was sent a document like an Excel file or Word file as an email attachment, he was unable to open the file.  He would double-click on the icon for the file, and Domino web page would spit out “There was a problem sending the command to the program”.  He has Office 2007 installed and we verified that it was working just fine.

If he tried to save the file from Domino, he would get prompted for a folder to store the file and he would try to save it is his documents folder. It went through the motions of saving the file.  No error messages, but the file wasn’t there. I repeat, there was no error message. I took a peek at the file system and found the file in an odd location. All the files that he had been trying to launch were in “c:\users\hisname\AppData\Local\Temp\Low\Domino Web Access\80\”. The “Low” part of the folder name tells us that Internet Explorer was redirected by Windows.

Starting with Vista, IE 7 runs with “low” privileges. The temporary files, cookies, and history folders are now in “low privilege” folders. Access to protected locations (root folder, documents, “my programs”, etc) is redirected by the operating system to the %LocalAppData%\Temp\Low folder. The folder virtualization that Vista/Win7 uses is pretty transparent the application. Unless the application checks for the file after it writes it (or knows about folder virtualization), it will not know that the file is in a different location. That explains why the files were not in the right location, but we still needed to figure out why they couldn’t be launched by the browser.

After a bit of searching, I figured out the problem. He just needed to add the webmail server site as a “Trusted Site” in the Internet Explorer security options. With Windows 7, he needed to do the following steps in Internet Explorer 8:

  1. From “Tools” menu, select “Internet Options”.
  2. On the “Security” tab, click “Trusted site” in the “Select a zone to view or change security settings.” panel.
  3. Click the “Sites” button.
  4. Under the “Add this website to the zone:”, enter the URL for the web mail site and click the “Add” button.
  5. If the URL starts with HTTP instead of HTTPS, make sure that the “Require server verification (https:) for all sites in this zone.” check box is cleared.
  6. Press the “Close” button.
  7. Press the “OK” button.

That will tell Internet Explorer that it’s safe to launch binary applications from the web mail application. It’s sounds annoying, but it’s just Microsoft trying to keep rogue web sites from running nasty programs.

All about “F# and You”

Last night at our monthly Tech Valley .NET User Group (TVUG) meeting, we had Rick Minerich come in and do a presentation on F#.  It was a very good presentation.  Rick was enthusiastic and knows F# cold.  One of the cool things that he showed in his presentation were examples in both F# and C#.  It looked like you could replace every 5-10 lines of C# code with F# code.

F# isn’t for everyone, but if you are doing serious number crunching and want to process data in parallel, then you seriously want to look at using F#.  It’s a full fledged member of Visual Studio 2010, it’s not just something bolted on to the architecture.

With F#, asynchronous programming is much simpler.  This useful for performing operations that require asynchronous I/O.  A common example would be collecting data from multiple, non-related web pages.  With F#’s asynchronous workflows, you define a set of operations to be performed in parallel.  The following example from MSDN shows one way that you can implement this.

open System.Net
open Microsoft.FSharp.Control.WebExtensions

let urlList = [ "Microsoft.com", "http://www.microsoft.com/"
"MSDN", "http://msdn.microsoft.com/"
"Bing", "http://www.bing.com"
]

let fetchAsync(name, url:string) =
async {
try
let uri = new System.Uri(url)
let webClient = new WebClient()
let! html = webClient.AsyncDownloadString(uri)
printfn "Read %d characters for %s" html.Length name
with
| ex -> printfn "%s" (ex.Message);
}

let runAll() =
urlList
|> Seq.map fetchAsync
|> Async.Parallel
|> Async.RunSynchronously
|> ignore

runAll()

This code will process each URL in urlList in parallel, and will wait until each sequence has been processed before continuing.  The wait state management and thread housekeeping are handled by F#, the programmer doesn’t have to worry about that at all.

If you want to know more about F#, Rick is a great source.  In addition to his web site, you can find him on Twitter as @Rickasaurus.