Tag Archive for Advice

Raspberry Pi as a WOL server

My electricity supplier in the UK recently sent me a electricity consumption meter which tracks energy use in real time and displays in on a small LCD panel. This has proved to be a real eye opener for me and has helped me to see how much power is used by a variety of devices in the house. I’ve found myself checking the meter at regular intervals and I’m getting good at working out which things are powered on just by checking the meter!

Electricity Consumption Meter

Electricity Consumption Meter

I’m one of those geeky types that likes to leave my home PC on all the time. This means that when I’m away from home, I can connect to the PC remotely and pick up files or refer to old email archives that I don’t keep on my laptop. I haven’t given this much thought until now but I checked the power consumption of my PC and saw that it draws 250W – 300W whenever it’s powered on. I did some rough calculations to see what this was costing me and I was surprised.

Daily power use for my PC = 0.275 KW x 24 = 6.6 KWh
Annual power use for my PC = 6.6 KWh x 365 = 2409 KWh
Average cost in the UK for 1 KWh = £0.14

Annual cost for running my PC all the time = £0.14 x 2409 KWh = £337.26

This made me think about turning my PC off more (as my wife has been suggesting for years) ;-)   But I don’t want to lose the ability to turn it on remotely and get access to files….. hence my use of WOL (Wake on Lan).

I recently bought a Raspberry Pi and I’ve been tinkering with it for a while, I’ve used it for time lapse photography and general experimentation. I’ve also put one in the Trust IV office in Manchester which operates a webcam. I thought that I could use the low-powered Raspberry Pi to wake up my high-powered PC when I need it and I’d enable power management on the PC to put the PC to sleep when it isn’t in use.

Here’s how I did it.

  • Installed a base build of Raspbian on my Pi
  • Installed “wakeonlan” on the Pi, using the command [sudo apt-get install wakeonlan]
  • Installed Apache on the Pi, using the command [sudo apt-get install apache2]
  • Installed PHP5 on the Pi using the command [sudo apt-get install php5]
  • Wrote a small PHP script that sends the wakeonlan command to my PC.
  • Changed the default port for the webserver
  • Enabled port forwarding on my router to forward HTTP requests from outside to the Pi.
RPi screenshot

RPi screenshot

The PHP script (above) is pretty straightforward and uses the “exec” command to simply execute the wakeonlan command. I may improve this to give myself some visual feedback to show that the magic packet has been sent to the PC. For now I’m just happy that I can reduce my energy consumption and still access my PC remotely whenever I want to.

Assuming that  this gives me a 50% energy saving, this should reduce the electricity bill by more than £150 per annum.

Bristol Pound – a great concept but a flawed web launch

I was drawn to the Bristol Pound project by a tweet that I spotted at lunchtime today.

The concept is simple:

  • Launch a local currency to help support the local economy in Bristol.
  • Encourage people to support local businesses.
  • Boost local spending power and lock money into the Bristol economy.

This all sounds great, but I just went to their website at  http://bristolpound.org  and the page took more than 3 minutes to download. Now I’m not blessed with the world’s fastest Internet connection in the office, but that’s a lot longer than most people are prepared to wait.

I was reminded of a couple of StrangeLoop infographics:

The first one describes web user’s boredom thresholds and shows that people abandon slow sites quickly, many never return and even worse, they tell their friends about their bad experience. This can be very damaging for a brand that puts so much effort into their day 1 launch.

 

User boredom thresholds - infographic

 

The second infographic documents the increasing size of pages over time. I know that we all use high speed internet connections nowadays, but if a lot of people start to hit your site, you’re going to run out of bandwidth to serve the requests pretty quickly.

 

I think that the Bristol Pound website is suffering from “page bloat” and here’s why…

Using a Firefox browser with an empty cache and Firebug, I connected to http://bristolpound.org and saw that it took almost 3 minutes for the page to download completely. The page looks great and is graphically rich, but it doesn’t perform well for those first-time visitors hitting the site today.

The image below which is taken from the HAR (HTTP archive) file that I created shows a single image taking 2.33 (139 seconds) minutes to download. The large/slow image is called FINAL_Launch_POSTER_copy.jpg , and it is advertising tonight’s launch party for the Bristol Pound.

 

 

The main problem with this image is that somebody has uploaded the full size image to the website and rescaled it using HTML. The original image size is 3,508 x 4,966 pixels which is huge, but it is displayed at only 338 x 495 pixels. Serving a scaled-down image could save 1.8MB of bandwidth for each page request (a 99% size reduction). This would reduce the download time for this component from about 139 seconds to less than 2 seconds. This alone would significantly improve user’s first impressions of the site.

This screenshot shows the “offending image” highlighted in red.

 

There are other improvements that could be made, but to improve performance for now, I’d simply resize the image in an image editor (MSPAINT would do) and then keep my fingers crossed…..

DMA2200 Media Center problem – resolved

DMA2200For the last few weeks, I’ve been having problems with my Linksys Media Extender. This has been causing me a great deal of grief because this is the only method currently of watching TV in bed (I have a Windows 7 Media Center PC in the front room and serve recorded TV as well as the satellite feeds up to the extender in the bedroom).

I’ve noticed that occasionally the Media Center Extender freezes up and becomes unresponsive to the remote control. I replaced the batteries in the remote (twice) but the problem remained. The Extender would happily continue displaying the channel that I had started watching but wouldn’t allow me to change. Occasionally I’d come back to the Extender to find that the screen was blank and the extender was unresponsive.

Restarting the Extender has always temporarily resolved this issue, but in the last few days, the problem has become more acute and the extender has generally only remained stable for a few minutes before crashing again. Since nobody is manufacturing extenders any more (until Ceton releases their new media center later this year) , this could have meant that I needed to drop an aerial into the bedroom and lose the ability to watch recorded TV.

Trawling the Internet for clues to the problem I came across this article, which although it was 2 years old and written in the US, gave me a nugget of information which fixed my problem.
http://experts.windows.com/frms/windows_entertainment_and_connected_home/f/116/p/95097/496301.aspx

It appears that the extender tries to connect to a Cisco or Linksys server to obtain an update. Since support for this product has now been withdrawn it is likely that the server is now offline. My theory is that the problem hit US users a few years ago and perhaps only recently has the same problem surfaced in my region when the UK/European regional servers were decommissioned.

My connection was wired, but I presume that the same steps could be used to fix a problem with a wired DMA2200 (or DMA2100) extender.

Steps taken:

  • Set a static IP address for the media center extender.
  • Enter 0.0.0.0 for both primary and secondary DNS servers.DMA2200

This prevents the extender from accessing the internet and then crashing when it fails to find the relevant update servers.

 

Finding the MAC address of a device

I always for get how to do this, so I’m putting it on my website as a kind of aide memoire for myself.

Basics:
Every hardware device that connects to a network has a unique hardware address known as a Media Access Control (MAC) address. This MAC address is used by network hardware such as routers and switches to send traffic to the correct device on the network.

Part of the TCP/IP network stack is the ARP service (Address Resolution Protocol) which resolves and tracks the TCP/IP and MAC address of the remote devices that you’re communicating with.

To find out the MAC address of a remote device:

  1. Open the MS-DOS prompt.
  2. Ping a remote device that you want to find the MAC address. e.g. “PING 192.168.1.253″

    PING

  3. Type “ARP -A”, and press Enter.
    (Returns all the entries in your ARP address translation table).
  4. Alternatively, type “ARP -A | FIND “192.168.1.253″ and press Enter.
    (Returns just the entry that you’re looking for).

    ARP

  5. The MAC address is in the format xx-xx-xx-xx-xx-xx

A lesson in not leaping to conclusions

Gadgets

 

I have a pretty decent quad-core PC at home with 8GB RAM and performance generally isn’t an issue for me. This spec is more than adequate to run the occasional virtual machine for testing and evaluation purposes as well as handle standard business applications such as word processing, email, video conferencing etc.

 

At the moment, my performance counters are reasonably healthy; under normal use, I typically use between 10-25% of my processing capacity and about 2/3 of my available memory. This is normal for me and has been consistent for more than 12 months. The only exception to this tends to be when I edit HD videos or do other things such as saving recorded TV shows to DVD using media centre.

 

 

The problem
I work as an application performance tester which means that I’m pretty inquisitive when it comes to how computers perform. This may be the reason that I tend to leave Windows Gadgets on my desktop reporting CPU and memory use in real-time.

For some time, I’d been noticing that the third core of my quad core processor (an Intel i5 750) was busier than the other cores. I thought that I’d have a look at Windows Task Manager to see what was using my CPU cycles. When I looked at Task Manager I was surprised to see that the total amount of CPU in use was consistently less than that shown by my desktop gadget.

 

I tried the usual tricks, including choosing “show processes from all users” to see whether a system account was using CPU.

 

In short I was stumped…..

 

 

Diagnosis

I decided that perhaps I should dig a little deeper, so I installed Process Explorer.

Process Explorer shows you more detailed information about currently running processes and I was pleased to see that it showed me the increased activity on core 3. As well as showing me this extra activity it also showed that the bulk of activity was down to interrupts, rather than context switches or deferred procedure calls.

Process Explorer showing large number of interrupts

15-17% of all CPU activity was handling hardware interrupts so one core was almost fully occupied.

Process Explorer - CPU chart, core 3 busy

The (wrong) conclusion

I knew that I shouldn’t have any hardware device generating this large number of interrupts, so I thought that I’d work out what was causing the problem by a process of elimination. I decided to check external devices first because this was easier and I suspected that these devices were more likely to be faulty. I disconnected the scanner, printer, external USB hub, speakers, drawing pad etc. but the problem remained.

This meant that the problem had to be inside the PC, so I started to disconnect internal components such as my DVD drive, after disconnecting everything that I could, I rechecked and the problem still remained. Because my graphics card passed a diagnostic check and I was running out of other options, I decided that it must be my hard drive.

This was both right AND wrong.

The (correct) conclusion

After replacing my hard drive at first the problem seemed to have resolved itself. I’m not sure how this problem seemed to be fixed for a short while, but after a couple of days the problem came back.

I decided to overhaul the PC from a software perspective. I performed a Windows update to upgrade any drivers that were out of date, and then I decided to check for new drivers for my hard disk.
In device manager I right-clicked on the hard disk and chose the option to “Update Driver Software”. I didn’t really expect this to work but after a reboot the problem had gone.

Device Manager - showing option to update driver software

After several months, I’m happy to report that my PC is still working normally.

All cores have similar utilisation levels.

Process Explorer - showing four cores with similar utilisation

Interrupts is no longer visible in the top of the list of active processes.

Process Explorer

 

If only I checked for updated drivers before I spent the best part of £80 on a new drive.
Ah well, at least I learnt something new, and I now have a spare hard drive for backups!