Category Archives: Technology

Roku Streambar Can’t Access Internet

My brother has a Roku Streambar but had difficulty getting it to work reliably. The network connection test reported that both the Wired link and the Internet link were working correctly. However, most of the streaming services wouldn’t start.

As this was tricky to figure out, I’m recording the solution here for the benefit of anyone else with the same problem. (There are quite a few posts on Roku-related forums with similar sounding symptoms.)

The Solution

An old Zyxel D1000 DSL router (supplied by Eir) had been repurposed to use as a Wi-Fi access point in one of my brother’s sheds. This was linked to the main house network via one of its LAN ports. Its built-in DHCP server had been disabled, so its only purpose was to provide Wi-Fi access.

It turns out that this Zyxel model has separate DHCP servers for IPv4 and IPv6 traffic. The IPv4 DHCP server had been successfully disabled, but the IPv6 server, which is configured on a separate page, was still enabled. In addition, IPv6 RA (Router Advertisement) was also still enabled. This meant the Zyxel router was periodically advertising itself as a good place for IPv6 clients to direct traffic. Since the router was no longer directly wired to the Internet, this didn’t work very well.

The solution was to disable both IPv6 DHCP server and IPv6 RA (Router Advertisements) on the Zyxel, and then restart the Roku.

After doing so, the Roku could connect reliably to the Internet once again and streaming services worked as expected. The Zyxel’s IPv6 configuration page looked like this after disabling the relevant IPv6 options:

(It’s also wise to disable the UPnP support on the previous tab, just to ensure it doesn’t confuse any UPnP-aware devices on the same LAN.)

Troubleshooting Approach

If you’re interested in the approach used to diagnose this issue, read on.

My brother’s home networking setup uses a Vodafone 500 Mbps FTTH connection. The Vodafone router provides Wi-Fi access in the main house and is also the main gateway to the Internet. There are four auxiliary Wi-Fi access points located in outhouses and sheds. All of these are wired back to the main router using direct Ethernet links, and all the access points use the same SSID. They all have static IP addresses on the 192.168.1.x network.

The Vodafone router is configured as the main DHCP server for the LAN and provides dynamic IP addresses to the other network devices (PCs, laptops, phones, tablets, Sonos speakers, Smart TVs, Roku Streambar).

The Roku was connected to the network using Wi-Fi; this is the only option for the Streambar out of the box as it does not include an onboard Ethernet port. Initially, I suspected an issue with the Wi-Fi connection due to the Roku’s location. The Wi-Fi connectivity check worked okay, but it seemed prudent to eliminate it.

We added a cheap USB Ethernet port from Amazon and ran a fresh Ethernet cable from the Roku to the nearest network switch. The Roku’s connection test confirmed that this had improved throughput, but it didn’t make any difference to the streaming apps — they still couldn’t connect.

After trying several things, including a full reset of the Roku, I decided to bring it back to my house to continue trouble-shooting. To my surprise, it worked perfectly when connected to my own network. I was able to update the Roku firmware to the latest version and also update the various apps. I ran it for a couple of days to make sure there were no intermittant issues, and it was flawless.

However, when I brought it back to my brother’s house, we were no further on — it still failed to connect.

Network Debugging

This time, I had come armed with my main networking debug tool: a cheap Netgear GS105E managed switch. For around €25, this compact device offers five Gigabit Ethernet ports that are individually configurable. One of the ports can be assigned as a Mirror port, which is ideal for monitoring traffic between two Ethernet devices.

This switch is small enough to fit in my networking toolkit, and I keep it permanently configured so that Port 5 automatically mirrors all the traffic in and out of Port 1. I connect the device being debugged to Port 1, with Port 2 connected to the rest of the network and Port 5 to my Windows laptop. Wireshark running on my laptop can then capture all network traffic in both directions.

(If this approach wasn’t used, Wireshark could see broadcast packets from the device, but most other traffic would be invisible as the network switch or router the device is connected to would transmit the packet directly to the Internet router, bypassing the port Wireshark is connected to.)

You can also use this setup to, for example, monitor all Wi-Fi traffic coming via an access point to the rest of the LAN, or all traffic between LAN devices and the main Internet router – it’s merely a question of where you insert the switch into the network.

For best results, it is a good idea to turn off IPv4 and IPv6 network options on the laptop’s Ethernet adapter; this cuts down on the amount of traffic caused by Windows on the laptop trying to check what is out there.

Analysing The Network Traffic

After inserting the Netgear switch between the Roku and the main LAN, I carried out a simple test: asking the Roku to check for a firmware update. This was consistently failing to connect, and I figured it would generate very little network traffic making it easy to analyse.

Initially, I accidentally created a network loop by forgetting to turn off Wi-fi on my laptop. This caused traffic from the laptop’s Ethernet adapter in promiscuous mode to be broadcast on the Wi-Fi link (I may have enabled routing on my laptop at some point in the past). Over the course of 15 seconds or so, I amassed nearly 1,000,000 packets of network traffic – quite impressive, even if almost all of them were duplicates!

Once I figured that out, and disabled the Wi-Fi temporarily, things settled down and I was able to get a more useful trace. You can download it here if interested:

Initially, I filtered by the Roku’s IP address (192.168.1.34) in order to get rid of unrelated broadcast traffic and what looked like inter-switch advertisement packets. At a first glance, I could see that DNS lookups were failing in what appeared to be an odd way:

The Roku was sending a DNS query for lagrange.sw.roku.com and it appeared the Internet gateway was responding with an appropriate response. However, when that response was delivered to the Roku, it replied with the ICMP error Destination unreachable.

I carefully checked the UDP port numbers on the original request and response packets and they matched correctly, so it seemed odd that the Roku wouldn’t accept something it had asked for a mere six milliseconds earlier!

I did some similar tests without success, and was unable to figure it out. Eventually, as it was getting late, I packed up my gear and headed home — fortunately taking with me a copy of the Wireshark trace so I could analyze it later.

Once home, I took another look. This time, I filtered on the hardware MAC address of the Roku, rather than the IP address:

Aha! The Roku was sending out two DNS queries — one from its IPv6 address, to a Zyxel device, and one from its IPv4 address, to the main Internet router. The Zyxel replied first, giving the IP address 207.69.188.186 as the IP address associated with lagrange.sw.roku.com. As the DNS enquiry had now been satisfied, it no longer needed to wait around for the result of the parallel IPv4 DNS lookup. Hence, the ‘Port unreachable’ error when that result arrived.

Further tests showed that the Zyxel was returning this IP address for any DNS lookup.

What was this Zyxel device? A quick cross-check of its MAC address against the various Wi-Fi access points on the LAN showed that it was in fact an older ADSL D1000 router supplied by Eir, the national Irish phone company & Internet provider. This had provided slow Internet access prior to the long-awaited upgrade to fiber and was now being used to provide Wi-Fi coverage in one of the sheds.

I connected to the Zyxel’s web interface and sure enough, it still had its IPv6 subsystem enabled. I disabled the IPv6 DHCP server expecting that would resolve the issue. However, it did not! It was only after I also disabled the IPv6 RA (Router Advertisement) feature and restarted the Roku that everything finally returned to normal. Finally, it could run streaming applications once more.

Making Sense Of Nonsense

Why did the Internet connection test succeed on the Roku when almost all other Internet access was failing? While I can’t say for sure, I suspect the Roku does an initial connection probe when it starts up. At this point, it has obtained an IPv4 address from the Internet router using DHCP but the Zyxel router has not yet broadcast a Router Advertisement (RA’s are broadcast approximately every 200 seconds).

So, the Roku can connect to its target server on the Internet to verify connectivity without issue, and it then caches the DNS entry it looked up. It re-uses this IP address for further connectivity tests without needing to do another DNS lookup, and as it is an IPv4 address, it uses the IPv4 gateway (the main Internet router) to connect to it.

Within a minute or two of startup, the Roku will have received an IPv6 RA from the Zyxel and it then uses this path for further DNS lookups, in addition to the IPv4 path to the Internet router. As the Zyxel always replies first (within a milisecond or so), that reply beats the one coming from the real Internet. As its reply appears legitimate, the Roku then attempts to connect to 207.69.188.186 and times out when it doesn’t receive the expected response.

So what is this IP address 207.69.188.186? It doesn’t have any connection to the real IP address associated with lagrange.sw.roku.com.

It seems that when the Zyxel has no Internet connection, it serves up this IP address by default as the response for all UDP DNS queries. This has been previously discussed by other Zyxel users, and appears to be an odd quirk of their firmware.

(After some Googling, I discovered that this IP address also appears in example network traces in some of their documentation.)

I was sure I’d heard this IP address before. After checking some old records, I realised it had turned up while I was diagnosing a network connectivity issue with Sky TV for my sister. Her house also had an old Eir D1000 router on the LAN providing Wi-Fi access. I had disabled DHCP access on that router, but had missed the IPv6 configuration. Eventually, a year or two ago, that unit had been replaced by a TP-Link dedicated Wi-Fi device and all the connectivity issues with her Sky TV box had gone away, though I hadn’t made the connection at the time.

So, mystery solved!

In summary, if you arrived here because you were wondering why 207.69.188.186 has appeared on your network traces, track down any Zyxel home routers and reconfigure them or replace them with something more modern.

Bonus Russian Explanation!

The blog post mentioned a couple of paragraphs earlier contains a link to a Russian Zyxel Knowledge Base article that goes into a lot more detail about what is happening here. That page has been offline for more than a decade, but happily archive.org kept a copy. For your convenience it is reproduced here, translated to English courtesy of Google.

(From https://web.archive.org/web/20101127161654/http://zyxel.ru/content/support/knowledgebase/KB-1228)

DNS query problem in P-660R EE

Question:
When using the P-660R EE modem, the following problem arose:

“When accessing any name, DNS starts returning only www.kimo.com.tw. The modem responds in this way to any request to any server. What is the problem and how can I solve it?”
Answer:
First of all, I would like to explain where the need for the address www.kimo.com.tw came from. This is not a hidden Trojan, but a mechanism necessary for implementing the “zero configuration” function.

Here’s how it works:

1. When you try to connect to, say, www.zyxel.ru, the PC sends a DNS query to the modem.

2. If the modem was previously reset to factory configuration, it launches the ” vc-hunting ” mechanism – it goes through the list of VPI, VCI and Internet provider encapsulations built into it until it establishes a logical connection.
At this time, www.zyxel.ru is not yet available.

3. At the same time, the modem responds from a fake IP address, as if from “207.69.188.186” (“www.kimo.com.tw”).

4. The PC tries to get an IP address by sending an HTTP request to the modem.

5. The modem, having received this IP address, responds with a corresponding HTML page with a message about the current status of the null configuration process.

This entire process is used only to display the execution of the webredirect function , while there is no real connection to the Internet, i.e. with www.zyxel.ru.If you do not want to use this mechanism, use a new firmware that has the ability to disable it.

Disabling is done via the command line, by establishing a telnet connection to the modem, in menu 24.8, with the following commands:

1. “wan atm vc dis ” (checking the current status of VC hunt and webredirect)
2. “wan atm vc webredir 1/0(1=disable;0=enable) “
3. “wan atm vc save ” (saving the configuration in non-volatile memory)

Also, don’t forget that the PC has a cache and after you disable the webredirect function, it may still be erroneously routed to “www.kimo.com.tw” for some time until the cache is cleared.

The firmware in which you can disable the webredirection function is attached to this article – http://zyxel.ru/content/support/knowledgebase/KB-1228/340UH3C0_20051101.zip
Applies to products:P-660REEP-660R EE (Annex A)

Windows 2000 0x0000007B INACCESSIBLE_BOOT_DEVICE

With luck, you’ll never need any of the information below. If you do then (a) you have my sympathy, and (b) you’re welcome!

One of my clients has an aging Microsoft IIS installation comprising a variety of Windows 2000 & 2003 servers (SQL, IIS, Domain Controller, File Server, Linux VMWare) running on a mixture of Dell server hardware.

The main IIS installation runs on Windows 2000 Server on a Dell Poweredge 1950 using a Dell SAS 5/iR disk controller, to which are connected two SATA drives running independently (not RAID-ed). In July, the controller card failed catastrophically, rendering the server useless.

Fortunately, though this is old hardware, we were able to source a replacement controller card on eBay. Less fortunately, when I installed the new controller and attempted to boot from it, the server crashed a few seconds after displaying the Win2K splash screen with the dreaded blue screen of death:

Not great. After some investigation, I realised that though the replacement looked identical in all respects to the failed card (even the discrete components were positioned identically on the PCB), it had a slightly newer BIOS. This, it appeared, was sufficient for Windows to treat the controller card as a new, unrecognised device.

If you have to replace a disk controller on a Windows server, the usual advice is to install the new controller first, allow Windows to detect it, install any needed drivers, then — and only then — shut down, remove the old controller, and connect the hard drives to the new controller. Windows then has the needed drivers installed to allow it to boot Windows successfully.

Of course, in this scenario we didn’t have that luxury – the old controller was dead, so Windows wouldn’t boot at all. We needed to somehow install the updated drivers on the Windows system disk offline.

This turned out to be … tricky! Here are a few of the things I tried before figuring it out. (Needless to say, I copied the disk onto a fresh drive and performed my experiments on the copy. This ensured the original was always available if I needed to start over.)

1. Update controller drivers – FAIL

I downloaded updated drivers for SAS 5/iR controller from Dell’s website (here), extract drivers, manually copy driver files to Windows c:\winnt\system32\drivers folder, overwriting the older versions with the same name. This made no difference at all.

Then I discovered the C:\WinNT\NLDRVS sub-folder which holds the core third-party drivers used by Windows before the whole plug & play subsystem is up and running. This contains a series of numbered sub-folders, one for each driver. Again, I updated this to use the latest versions of the driver files, and again it made no difference.

2. Repair Windows Installation – FAIL

Next, I attempted a Windows 2000 repair, which was a lot harder than I expected.

After tracking down the original Windows 2000 installation CD, I was unable to press F6 to install additional drivers from floppy (remember that?) because the PowerEdge 1950 has no floppy drive. Windows won’t recognise a USB flash drive at this point either.

There are hardware floppy emulators around that will accept a USB memory stick and present the contents as a floppy drive using the old 34-pin floppy cable standard. Unfortunately, the PowerEdge doesn’t have an internal header to connect such a device to. You can also buy floppy drives with a USB interface but I didn’t have one of those to hand (or any floppy disks to use with such a device).

Eventually, I discovered nLite, an excellent utility that lets you build a custom Windows installation CD which includes your selection of third-party drivers, service packs, and other customisations. I also found WinSetupFromUSB which lets you install a Windows installation CD on a USB stick in such a way that even the Windows 2000 Installer can successfully boot from it. (Some deep magic is used to make this work).

Between these, I was able to create a slip-streamed Windows 2000 SP4 installation CD with the latest Dell SAS 5/iR drivers pre-installed. Booting with this, I could get to the Repair Windows menu, find my Windows installation, and let the automatic repair try and fix it.

This was also unsuccessful – the automatic repair didn’t notice that the drivers it had booted with were different to the ones pre-installed on the original Windows disk, so it didn’t update them.

3. Perform an in-place Windows upgrade – Partial Success

By now, having spent a lot of effort trying various things, I figured there was only one thing for it – perform an in-place upgrade of Windows 2000 using the process outlined by this TechRepublic article. This is essentially a new Windows installation on top of the existing install. Windows is smart enough to replace the system files with fresh versions while preserving all existing third-party software and user profiles.

In principle, this allows you to resolve any hardware-related Windows glitches without having to re-install all your application software. This sounded good, because the mission-critical software running on this particular server is complex and the original designers and implementers were long since gone, leaving no documentation behind them. Recreating it from scratch on a clean Windows installation would have been unthinkable.

The re-install process went smoothly, albeit slowly, and once completed, Windows booted successfully. Hurray! Job done, right?

Well, not quite. The original installation had somehow ended up with the WINNT folder on E:\ while the tiny 2 GB FAT16 boot partition was on C:\. After the re-install, WINNT was located on C:\, along with Program Files and other system folders. This, of course, broke lots of things.

I was able to fix most of them by adding a scheduled task to SUBST drive E:\ to drive C:\ at startup, which made most of the system much happier. A few services started before this remapping occurred, and I located those in the Registry and updated their path references by hand. Yes, this is all ugly and horrible, but by this point, I just needed to get things working by any means!

(Word to the wise: be careful with removable USB backup drives, which usually grab the first available drive letter. If that happens to be E:, it stops the drive letter mapping working correctly and you’re back to square one.)

Microsoft Office was still a little unhappy, but became much happier after I carried out a Repair Install. I also had to re-assign appropriate drive letters to some of the data partitions.

Finally, after all of this …. IIS started correctly, websites were accessible, and all was right with the world! Hurray, again!

4. When is a success not a success?

Not so fast. One of the critical components of the website was the ability to upload formatted Word documents which were then automatically converted to XML for processing by the content management system. This wasn’t working correctly; in fact, it wasn’t working at all.

The issue seemed to be related to a custom COM object that had been developed for the project, and a method in this object was failing during the conversion of the Word document. Everything I could see indicated it was somehow connected to the Microsoft Office installation (since presumably Word itself was involved in the conversion).

I spent more than a week trying to get to the bottom of this. I re-registered all COM objects and relevant DLLs, checked the system and application logs for errors, enabled IIS debugging, etc – all the usual things you would expect. When I dug deeper, using Microsoft’s ProcMon tool, the issue seemed to be related to an instance of Internet Explorer that was launched during the conversion.

After many hours pouring over ProcMon, IIS and Event logs, checking for unexpected failures buried in the midst of the many, many expected failures, I had to admit defeat. The server was working, but it wasn’t working reliably. It also had a tendency to hang random services during startup, and Windows Update refused to start, neither of which inspired confidence.

5. The Easy Way

By this stage, and with the client’s patience starting to reach its limits, I decided to use the knowledge gained working through the above to have another go, starting from scratch with the original disk again.

A chance remark on a discussion forum about SCSI adapter BIOS signatures being used by Windows to help identify the correct drive led me to a rarely visited part of the Windows 2000 registry known as the CriticalDeviceDatabase.(This no longer exists on modern versions of Windows).

Further research brought me to Michael Albert’s invaluable page on manually adding a mass storage device to an existing Windows installation. As one commenter rightly said, “Never delete this page!” The information it contains is invaluable, and not easily found elsewhere. So, thank you Michael!

The registry key HKEY_LOCAL_MACHINE / System / Control / CurrentControlSet / CriticalDeviceDatabase contains a series of sub-keys for all the devices needed to boot Windows. Third-party controller cards are referenced here by their PCI vendor, device and (crucially) subsystem code.

First, I needed to get the PCI code for the SAS 5/iR controller. On most Windows installations, you can visit Device Manager, open the Properties pages for the controller, and under the Details pane select Hardware IDs. However, on Windows 2000 this information isn’t so easily available. Instead, you need to run MSINFO32 and find the controller there, usually under SCSI devices.

When I ran MSINFO32 on my flakey Windows re-installation, the SAS 5/iR entry looked like this:

Checking Regedit on the same machine, I could see the following matching entry in the registry:

[HKEY_LOCAL_MACHINE\CurrentControlSet\Control\CriticalDeviceDatabase\pci#ven_1000&dev_0054&subsys_1f091028]
"Service"="SYMMPI"
"ClassGUID"="{4D36E97B-E325-11CE-BFC1-08002BE10318}"

However, there was a second, almost identical, entry:

[HKEY_LOCAL_MACHINE\CurrentControlSet\Control\CriticalDeviceDatabase\pci#ven_1000&dev_0054&subsys_1f061028]
"Service"="SYMMPI"
"ClassGUID"="{4D36E97B-E325-11CE-BFC1-08002BE10318}"

The only difference is the subsystem code, which has changed from 0x1f061028 to 0x1f091028. I concluded that the additional entry was the one used by the old controller card, and that it had survived the in-place Windows upgrade. For reasons best known to themselves, Dell must have revised the sub-function code when they updated the controller’s BIOS, possibly to provide an easy way for the driver to identify hardware with additional capability or some obscure hardware fix.

I went back to the original disk and copied the registry System hive from \WINNT\SYSTEM32\CONFIG\SYSTEM to my work computer, then loaded it into RegEdit by selecting HKEY_LOCAL_MACHINE, then using Load Hive and entering a temporary sub-key name (W2K-Recovery) to allow me to access it.

Drilling down there, I could see registry keys for ControlSet001 and CurrentControlSet002 but no CurrentControlSet. This is normal when editing an offline registry hive — CurrentControlSet is created dynamically by the operating system but is not part of the hive itself. Instead, I checked under the Select key which confirmed that the ‘Current‘ selection was set to 1 (indicating CurrentControlSet001). And sure enough, under CurrentControlSet001 / Control / CriticalDeviceDatabase, there was an entry for subsystem 0x1f061028 but not 0x1f091028.

I made a fresh clone of the original Windows drive, then manually added the CriticalDeviceDatabase entry for 0x1f091028 without changing anything else. (Again, I performed this by loading the System hive offline into RegEdit on my main work PC, making the modifications, then unloading it again and copying it back to the WINNT folder on the target disk.)

After this, the new drive booted straight into Windows with no issue. As it was the original Windows installation, everything was back to exactly the way it was before the disk controller died.

As with everything Windows related, an ounce of knowledge is worth a pound (or stone!) of experimenting! If you’ve made it this far, hopefully the information above will save you some wasted time and effort.

How big is the Eircode database?

Ireland’s new postcode scheme, Eircode is officially launched today. It’s been a long time coming and like it or lump it, we’ll all be using it soon.

Eircode logoThere’s been plenty of debate and criticism of Eircode in recent months, some of it valid, some of it misplaced. However, I did read one thing that caught my attention — the suggestion that Eircode was impractical for use with portable GPS navigators because the full country-wide database would require 2 GB storage and exhaust their flash storage.

That sounds like a lot. Let’s see if it holds up to scrutiny. Continue reading How big is the Eircode database?

From b2Evolution to WordPress

In January 2005, I wrote my first blog entry. b2Evolution was my tool of choice to manage my blog — it was free, simple to install, and more than adequate for my needs. I’d never heard of WordPress back then, though it shares a common origin with b2Evolution – they were both forks of b2/cafelog, one of the original blogging systems.

Fast forward ten years, and WordPress rules the world. I’ve used it on countless projects for clients and friends, and it’s an extremely flexible and powerful CMS. I’m also now far more familiar and comfortable using it than I ever was with b2Evolution.

Which is why, finally, I’ve migrated this blog  to the latest version of Wordpress, version 4.1. (If you’re wondering, the photo in the banner is Pan’s Rock in Ballycastle, Co Antrim, taken last April. Here are some more Antrim photos from the same trip.)

For those interested, the nitty gritty steps required are below; everyone else can stop reading now.

Database Migration

The biggest challenge was transferring the existing blog contents from b2Evolution’s database to WordPress’s database. Since many bloggers have travelled this path in the past, I expected this to be straightforward. However, most of them appeared to (a) be running a much newer version of b2evolution than me, and (b) have made the move long ago, to a much older version of WordPress.

No matter. First step was to find a script close to what I needed, in this case a script called import-b2evolution-wp2.php.txt at themikecam.com, referenced by Christian Cawley’s helpful b2evolution migration guide. Unfortunately, themikecam.com is no longer online, but luckily, archive.org still has a copy of the most recent import-b2evolution-wp2.php.txt available for download, along with all the older copies.

Although it should go without saying, now is a good time to backup your b2evolution database! Just in case…

While the script didn’t work right away, it was certainly a good start. I made a few tweaks to it and managed to get it working properly on my installation. You can download my copy here – make sure to remove the trailing .txt suffix after downloading.

I installed WordPress as usual, specifically WordPress 2.7 from the WordPress archives since I wanted a fairly old version. I configured it to use b2evolution’s database —  Wordpress uses different table names, so they don’t conflict with each other. Plus, the migration script expects this, so you don’t really have a choice.

Next, I uploaded the migration script to my WordPress wp-admin folder, then invoked it directly (e.g. http://yourblogaddress/wp-admin/import-b2evolution-wp2.php) and filled in the relevant values in the form presented.

It took me a couple of goes to get it right, so after the first failure, I installed the WordPress Reset plug-in; this makes it very easy to reset the WordPress database ready for another try, without having to do a full WordPress re-install, and without altering the b2evolution entries.

I highly recommend checking your database with phpAdmin afterwards to make sure the posts appear correct!

Even with the script, I still had to manually update the categories – my version of the script didn’t migrate them across properly. Since I only had 100 entries or so, it was easy enough to sort them on b2Evolution using phpAdmin. I could then select multiple posts by hand in WordPress and assign them to each category using the bulk update option.

(If I’d had many more posts, I might have spent some more effort getting the category migration working correctly.)

Finally, once I was confident everything was working okay, I updated WordPress from 2.7 to 4.1, which is MUCH nicer.

And all done!

Legacy URL support

Well, not quite done it turned out. There are plenty of links out there to my old b2evolution posts, and it would be nice if they could magically redirect to the new WordPress equivalent, to keep both the search engines and users happy.

This turns out to require a little .htaccess magic, and some PHP scripting. I added the following to WordPress’s .htaccess (I’ve reproduced the entire file for reference):

# BEGIN WordPress

RewriteEngine On
RewriteBase /blog/

# Check for references to the old b2evolution blog and send them
# to our redirect script where they'll be properly handled.
#
RewriteRule b2redirect.php - [L]
RewriteCond %{QUERY_STRING} ^(m=|.*cat=|.*blog=5|.*author=|pb=1|title=)
RewriteRule .* /blog/b2redirect.php [L,R=301]

# Normal WordPress rules
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

# END WordPress

(Watch out for word wrap on the QUERY_STRING line – the bracketed items are part of the same line.)

Essentially, this says that any query strings passed in to the blog of the form m=xxx (date reference), cat=xxx (category reference), blog=5 (my old Blog’s internal ID), author=xxx (show author posts), title=xxx (title reference) or pb=xx (b2evolution specific) should be directed to my custom script b2redirect.php without further ado and everything else should be handled by WordPress as usual.

(We use a 301 Redirect to indicate to browsers and search engines that this is a permanent redirection, and the new URL should be used in future.)

I learnt a couple of useful things about mod_rewrite figuring this out. I hadn’t fully appreciated that RewriteRules can only match against physical disk filenames from the URL; if you need to match parameter names or values, you must use RewriteCond in conjunction with the QUERY_STRING parameter.

And of course, I got caught out by having the parameters in my redirected URL immediately trigger another redirect when the page was refetched, until eventually it gave up. This is why the very first rule says that references to b2redirect.php should be passed through without any rewriting at all.

So what is b2redirect.php? It’s a small script I wrote that interprets the old b2Evolution parameters and figures out a WordPress equivalent. Here it is:

<?php
// Redirect b2evolution blog URLs to WordPress
$baseurl = "http://www.snoopdos.com/blog";

$catmap = array();

$catmap[14] = "observation";
$catmap[15] = "technology";
$catmap[16] = "random-thoughts";
$catmap[17] = "networking";
$catmap[18] = "windows";
$catmap[19] = "rant";
$catmap[20] = "useful-links";

$title  = $_GET["title"];
$m      = $_GET["m"];
$cat    = $_GET["cat"];
$author = $_GET["author"];

// Set default URL
$url = "$baseurl/";

if (!empty($title) && !strpos($title, ":"))
{
$url = "$baseurl/$title";
}
else if (!empty($cat) && !empty($catmap[$cat]))
{
$url = "$baseurl/category/$catmap[$cat]";
}
else if (!empty($m) && (strlen($m) == 4 || strlen($m) == 6))
{
$year  = substr($m, 0, 4);
$month = substr($m, 4, 2);
if ($year >= 2005 && $year <= 2013)
{
$url = "$baseurl/$year/";
if (strlen($month) > 0)
$url .= "$month/";
}
}
else if (!empty($author))
{
$url = "$baseurl/author/eddy/";
}
// Now issue the permanent redirect to the new location
header("HTTP/1.1 301 Moved Permanently");
header("Location: $url");

?>

Once again, the categories needed some special handling. Otherwise, it was straightforward – month references get changed to WordPress archive format (year/month); titles are mapped to the equivalent WordPress direct URL; category numbers go to the new WordPress equivalent name; author references show the WordPress author page; and everything else goes to the home page of the blog – better than a 404 Page Not Found.

So that’s that job done. Now let’s see what the next 10 years brings…

Telepresence in the air

Marc Andreessen’s blog today mentioned this cool demo:

This uses video goggles with a head-tracking sensor to remotely control the orientation of a camera mounted on a pilot-less plane, letting you virtually explore the heavens.

Apart from the general wow-factor of flying around the sky without ever leaving the ground, it reminded me of another piece of impressive technology I came across recently: quad-copters.

Here, a high-speed DSP is used to combine realtime feedback from gyros and sensors on position, wind direction, etc. to control four rotating blades independently allowing for stationary hovering in a wide range of conditions with no pilot input required. Great for remote video surveillance etc.

Combining these two pieces of technology seems like a perfect opportunity. Has anyone done it yet?

And a missing piece of the puzzle: even using stereo cameras to feed the video goggles, the image will still be flat since there is no way to remotely focus it (other than relying on auto-focus). Has anyone developed a set of video goggles that can track the eye’s ability to focus on specific objects? Combine that with a pair of remote cameras that can track the eye’s focus in that way and you could have REAL telepresence (once the latency isn’t too high, of course).

Isn’t it great that we live in an age where such amazing technology is affordable enough to let people devise interesting hacks in their spare time…?

Turn any surface into a touchscreen

Thanks to Kieran for pointing me towards this impressive Wii Remote hack, covered by Engadget here.

Johnny Chung Lee has done a marvellously simple hack which uses the standard Wii remote controller, plus some ballpoint pens modified to emit infra red, to convert any surface into an interactive touch-screen. With multiple pens, you can support multi-touch effects (as seen on the iPhone and iPod Touch), and previously mentioned on this blog back in March 2006.

Here’s an example of his technique in use:

(Make sure you watch the video long enough to see the technique in action; it’s very impressive, especially when combined with a video projector.)

Johnny’s software to make all this work is free, and available here.

Tilt-Shift Photography

When I had a film camera 15 years ago, I took almost no photographs with it: about one roll of film per year, on average. Then I got a digital camera, and since then I’ve taken a ridiculous number of photos – currently around 36,000 and climbing.

So, while I wouldn’t call myself a big photography buff, I do have a passing interest in photography techniques and methods.

No doubt that’s why my friend Steve sent me a link to this website, which describes Tilt-Shift photography, a style that makes normal scenes look like they are in miniature:

We’re used to looking at photos where everything is in focus (to infinity) so when the depth of field is restricted, the brain is tricked into it’s a model scene. The effect is quite surreal!

Check out the website mentioned above for more information.

Some cool CES things

There were lots of impressive products at CES 2007, most of which have been covered in detail elsewhere.

Here are some that impressed me but haven’t received much coverage:

LG’s 3D Television

Buried deep within LG’s massive stand was a 42″ high-definition LCD screen displaying genuine 3D video. This has apparently been around for a few months, but it was the first I’d heard of it.

The effect is stunning – proper 3D with no special glasses required. As with traditional 3D displays (such as IMAX and motion simulator rides), it takes your eyes a second or two to adjust – then everything jumps into focus.

Of course, there are some limitations. The optimal viewing range is 3M-7M from the display, with a maximum viewing angle of around 30 degrees. All the video on display was computer generated; I’d have liked to see some live video as well.

The screen works by integrating 25 separate LCD panels, each of which produces a display with a very narrow viewing angle. The 25 views are positioned around the objects being viewed, so that standing in any position, your eyes will see only two views at a time (one for each eye). The panel is thicker than a normal flat panel, but not overly so – about 6-8″ deep.

Capturing live video to work with this system will require some advanced cameras, since it would need to record 25 images simultaneously, each at a slightly different perspective.

Regardless, this is deeply impressive technology – some day, no doubt, all TVs will look like this.

Smyth Research’s Surround Sound Headphones

If 3D television wasn’t enough, we stumbled upon 3D sound in the form of Smyth Research’s new virtual surround sound headphones. These aim to allow headphone users to experience a surround sound movie or album in all its glory, without alienating their neighbours.

While most DVD players and A/V receivers offer some form of downmixing to let you listen to surround sound movies on headphones, this new system is in a completely different class. A sensor mounted on the headphones identifies the position and orientation of the headphones in space, and the sound is adjusted accordingly.

When you turn your head to the left or right, audio coming from each speaker appears to stay at the same location within the room, rather than moving with your head as normally happens with headphones. The effect is amazing – the first time I heard it, I immediately took the headphones off to confirm that the soundtrack hadn’t simply been routed back to the main speakers again.

The system we saw used an infra-red transmitter positioned above the TV to send out a reference signal which a reciever on the headphones picked up, analysed, and then transmitted back to the sound processor via the audio cable. This approach allows several headphones to be used at once in a single room.

With the infra-red solution, listeners must not turn their head more than 60 degrees away from the TV, or the effect is lost. This can be overcome using an alternate RF positioning system.

Smyth Research don’t sell hardware products themselves; instead, they are licensing the technology to manufacturers for inclusion in their audio equipment. The demo we heard was using Yahama equipment; expect products to be on the market by the end of 2007.

As an aside, Smyth Research are based in Bangor, Northen Ireland – it was nice to see some Irish representation at the show. They were previously involved in the development of the DTS Surround Sound system, so their audio pedigree is well established.

The Laser Mouse That Works On glass

A4Tech had a stand in the international section over at the Hilton, where they were showing their laser mouse that works on glass.

Most optical mice fail dismally when moving over a shiny or glass surface; not the A4Tech mouse. I spent some time playing with their demo setup, and can confirm that it worked just as well on glass as on other surfaces. A simple trick, no doubt, but extremely useful.

Apparently the mouse is already on sale in Korea – hopefully it will make it to Europe soon.

CNET’s Next Big Thing

Alongside the main CES convention, there were numerous seminars and panel sessions to discuss issues of interest to the consumer electronics industry. Most of these cost money to attend, but some were open to all CES participants.

The first session we attended (on Monday afternoon) was CNET’s Next Big Thing, a discussion about three hot areas of debate in the industry at the moment:

  • Whether there is a genuine market for displaying video on mobile phones and other small-screen devices
  • Whether streamed online content will lead to the death of the DVD
  • How Digital Rights Management for movies & music can evolve into something less customer hostile.

Several industry panelists (including a CNET reader flown in from the UK to represent the consumer) discussed these items at length; the audience then voted electronically on how they thought things would develop in the future.

CNET's Next Big Thing was a popular session

Mobile video

On mobile video, the verdict was: yes, there is a new and growing market for media playback on mobile devices, but access needs to become far less restrictive (both in price, and range of media available) before it will take off. Mobile video will supplement existing markets rather than replacing them.

Dynamic content like news clips, music videos, and short length TV programs are more suited to these devices than feature length movies. One panelist predicted that the production style of programs will change to match the constraints of the mobile devices – more talking heads, fewer panoramic landscapes, etc.

All reasonable points. However, the most important point was only briefly mentioned: mobile video need not be streamed. People use it to fill time when they would otherwise be bored (standing in a queue, waiting for something to complete), and it suffices to have pre-loaded content available on their mobile device; it’s not a big deal if it’s several days old.

With modern video codecs and ever-increasing flash capacities, it’s quite feasible to store multiple movies or (more likely) TV programs on your portable device. I think this trend is just beginning to gather stream.

The death of DVD?

The panel were (eventually) united in their view that DVD wouldn’t be going away anytime soon – certainly not by 2010, as had been suggested. The tangible nature of a DVD, which makes it collectable, suitable for gifts, easy to use and distribute, etc. all combine to make it unlikely to disappear.

However, the panel did did agree that online streaming media will gain significant following as well. (No surprises there.)

I’m broadly in agreement with this view. It takes a long time for a given technology to die out; after all, there are still plenty of VHS tapes around, even though it is now difficult to buy a VHS recorder.

I also doubt we’ll see broad acceptance of streamed video until most households have a fast broadband connection (where ‘fast’ means 10 MBps or higher, with no contention).

Digital Rights Management

Digital Rights Management (DRM) was the most contenious discussion, with representation from the legal profession, movie industries, and consumers, as well as several industry observers. Everyone agreed that some sort of rights management was essential, but making it transparent enough so that consumers were not unduly restricted when they tried to use media they believed they owned was judged difficult.

Apple’s ITunes was given as an example of how to make DRM straightforward, so that customers are not always even aware that any special restrictions apply.

The biggest hinderance to existing DRM technology is that it goes against the grain of what consumers are used to. If you buy a CD, you can take it to a friend’s house to share with them or loan to them. You can play the same CD in your living room, your bedroom, your car, on your laptop, and anywhere else that has a CD player.

This is almost never true for media protected with DRM, especially where that media has been downloaded rather than delivered in some sort of physical packaging. While providers are entitled to protect their content, they need to find a less onerous way to do so than has currently been attempted.

I have no doubt that this problem will be solved; until then though, consumers will continue to be highly suspicious of anything resembling DRM.

How big is that hard disk?

Seagate had a cute visual exhibit at CES 2007 – a typical laptop hard disk, represented as an equivalent number of CDs (assuming you only store MP3s, of course.)

Lost: 1 Laptop. Also lost: 52,716 MP3s.

Seagate’s point, of course, is that you might want to think about backing up that hard disk … and naturally, they had a product designed to do exactly that.