Thursday, November 22, 2012

Raspberry Pi


A colleague recently told me about Raspberry Pi originally developed for educational purposes. 

It is a credit card low cost computer running on a stripped down version of Debian. Considering its price and it is running on open source operating system, it definitely caught my attention.



Herewith one of the reviews on this product. 

Applications
There are several articles written about cool ideas to use this hardware (such as here, and here), including remote security camera, media streamer, internet radio etc.

Based on what I have read so far, this board should be able to deliver any applications or functions that is not overly CPU demanding. 

On a personal note, I am particularly fond of its low-noise aspect, such that it can sit pretty well anywhere in my home without generating too much disturbances. 

Cost
I did a quick calculation on the cost of building one of these including casing and flash drive, which works out to be less than $75.00 (but I have not considered the delivery cost of Pi itself): 

Item
Cost ($)
Remarks
Pi
42
Case
10
Ebay AU
32GB SD card
21.90
Ebay AU
Total
73.90


Getting started
To have it up and running, there are several getting started guides available online, and here is a quite comprehensive one with pictures illustrating the steps. 

In summary, it is as simple as preparing the operating system on the SD card (from either a windows or linux machine), plug it in, power it up and off you go. 

Others Tech References
- Design Spark provides a schematics capture and PCB layout tool for free. 
- I found a guide detailing building GNU/Linux on ARM machine from the ground up. 
Gooseberry - an alternative to Raspberry Pi.


It's definitely on my agenda. 

Monday, November 19, 2012

OwnCloud on Ubuntu. Media Server (miniDLNA). Remote Access


Incentive
Recently I took a half an hour video using my Samsung S3. The video was approximately 3.6GB, which is  close to the upper limit offered by several publicly available cloud/ online storage services such as Dropbox, Google Drive, or Ubuntu One.

That is enough incentive for me to build my own private cloud, considering my 1.5TB harddrive is the only storage limitation and I have full ownership over its security.

OwnCloud Server

I came across OwnCloud, an open source, php web based software.

Owncloud is a centralized storage solution: the software automatically stores your files onto its server.

It also has its own clients for linux, windows, android etc, so it's quite flexible in my opinion.

Installation
On my ubuntu server running on 12.04.1 LTS (with LAMP stack), it's installation is simply:

root@ubuntu:/opt# apt-get install owncloud


At the time of writing, this gives you ownCloud version 3 (the latest version is owncloud 4), so keep in mind the compatible sync clients's version is 1.05

Upon successful installation, OwnCloud can be accessed via web interface http://server-ip-address/owncloud. All file upload, download and folder creation can be done here: 


OwnCloud Sync Clients
OwnCloud's web interface allows for max of 2MB upload, I understand this as a PHP limitation. 

OwnCloud has several sync clients available for different OSes, which don't have such limitations. So far I have tried two clients (both version 1.05 for Windows and Linux respectively) with the following findings:

1. Windows 8

Upon first setting up owncloud clientsync account, I encountered this client and server timing out of sync error. This prohibits the server and client to synchronize their files.

As a work around, I have set up the Ubuntu server as an NTP server. Then I pointed my windows machine towards it. 

For reference:
Install
# apt-get install ntp

Start/ stop NTP
# /etc/init.d/ntp --help
Usage: /etc/init.d/ntp {start|stop|restart|try-restart|force-reload|status}

As client
# ntpdate au.pool.ntp.org

(In all fairness, it turned out the Windows machine was configured to the incorrect timezone, hence prohibiting it from synchronizing with the times.windows server).


2. Ubuntu Laptop LTS 12.04
Having installed the ownCloud sync client on my netbook, I have encountered no synchronization issues (apparently the netbook already has a public NTP working properly). 


I have left my netbook switched on allowing it to be sync for the entire day. Did a tcpdump to confirm there are https traffic being exchanged between the client and server.

The sync is finally successful. I suspect the initial sync took longer than the subsequent incremental updates. 


Home Access (miniDLNA)

Leveraging the Ethernet over Power setup I previously posted, it makes sense to enable DLNA on my OwnCloud server. This essentially converts my server to become a centralized storage, which allows for access from all devices via DLNA.

MiniDLNA is a light weight DLNA server software, which installation is as simple as running "apt-get install minidlna". A google search of "dlna ubuntu" returns this quick tip as its first result covering all the essential configurations. 

For my setup, by default, OwnCloud stores its client files in the following directory:
/var/lib/owncloud/data/root/files/ clientsync

In addition, I have also created a "music" and "photos" folders under the same directory. These directories are added to the media directories of minidlna (/etc/minidlna.conf)

# set this to the directory you want scanned.
# * if have multiple directories, you can have multiple media_dir= lines
# * if you want to restrict a media_dir to a specific content type, you
# can prepend the type, followed by a comma, to the directory:
# + "A" for audio (eg. media_dir=A,/home/jmaggard/Music)
# + "V" for video (eg. media_dir=V,/home/jmaggard/Videos)
# + "P" for images (eg. media_dir=P,/home/jmaggard/Pictures)
media_dir=A,/var/lib/owncloud/data/root/files/music
media_dir=P,/var/lib/owncloud/data/root/files/photos

Notice I have set them as "A" for audio and "P" for images. 

At this point, if I run minidlna, the server returns an “Media directory not accessible!" error .

There is a post on the owncloud community forum describing the fix - by adding both root and minidlna users to the group www-data:
root@ubuntu:/opt# usermod -a -G www-data root
root@ubuntu:/opt# usermod -a -G www-data minidlna

Now, apply -R option to force a full rescan, before restarting minidlna:
root@ubuntu:/opt# minidlna -R

root@ubuntu:/opt# /etc/init.d/minidlna force-reload
* Restarting DLNA/UPnP-AV media server minidlna [ OK ]

/var/log/minidlna.log confirms file scan is successful:

[2012/11/17 14:23:26] minidlna.c:155: warn: received signal 15, good-bye
[2012/11/17 14:23:26] minidlna.c:907: warn: Starting MiniDLNA version 1.0.21 [SQLite 3.7.9].
[2012/11/17 14:23:26] minidlna.c:935: warn: Creating new database...
[2012/11/17 14:23:26] minidlna.c:1002: warn: HTTP listening on port 8200
[2012/11/17 14:23:26] scanner.c:719: warn: Scanning /var/lib/owncloud/data/root/files/music
[2012/11/17 14:23:26] scanner.c:790: warn: Scanning /var/lib/owncloud/data/root/files/music finished (166 files)!
[2012/11/17 14:23:26] scanner.c:719: warn: Scanning /var/lib/owncloud/data/root/files/photos
[2012/11/17 14:23:28] scanner.c:790: warn: Scanning /var/lib/owncloud/data/root/files/photos finished (1359 files)!

Remote Access
As mentioned earlier, there are largely two methods for ownCloud clients to access OwnCloud server - web access and sync client. 

There are some useful tweaks which enhance the security and ease of remote access:

1. Enhance security by enabling SSL (and redirecting all HTTP to HTTPS)

2. Enabling remote access by utilizing free dynamic dns services as covered in my earlier post

For example, rather than configuring https://Server-LAN-IP/owncloud, configure https://dynamicDNS-URL:some-random-port/owncloud as the owncloud server's address.

Stating the obvious, the dynamicDNS-URL is intended to be accessible via the public internet. That also means you can access your ownCloud from anywhere in the world with internet connectivity. 

Further notes
I recall enabling SSL on my Apache2 server involved a couple of steps, from creating SSL certificate to enabling the corresponding module in Apache2 software.
It is a worthwhile topic which I may write another post on when I get around to it. 

HP mini 1000 - Ubuntu 12.04 LTS

A quick post on my HP mini 1000 network, which I first blogged (post) in the beginning of this year.

First time I started it up in ten months, the software manager automatically offered to upgrade it to 12.04 LTS. The rest was point and click and a couple of hours of waiting - which has been really worthwhile:


Giving credit to Ubuntu, the latest LTS version has fixed at least two bugs:
1. The wireless connection is functioning properly and its icon correctly reflects its status.
2. The little blue LED button which enables/ disables the wireless connection now functions properly.

Not bad for a three years old Intel atom netbook as I am planning to do more things with it.

Dynamic DNS - dnsdynamic and no-ip


Dynamic DNS (ddns) allows for remote access to publicly hosted server with dynamic IP address, using a pre-defined URL. 

I am covering two dynamic DNS providers offering free services, and how to setup their ddns clients respectively:

1. No-IP
No-IP comes with its own linux ddns client, which can be installed using "apt-get noip2". 
To manually setup your details, run noip2 with the "-C" option. 

root@web-host:# noip2 -h

USAGE: noip2 [ -C [ -F][ -Y][ -U #min]
        [ -u username][ -p password][ -x progname]]
        [ -c file][ -d][ -D pid][ -i addr][ -S][ -M][ -h]

Version Linux-2.1.9
Options: -C               create configuration data
         -F               force NAT off
         -Y               select all hosts/groups
         -U minutes       set update interval
         -u username      use supplied username
         -p password      use supplied password
         -x executable    use supplied executable
         -c config_file   use alternate data path
         -d               increase debug verbosity
         -D processID     toggle debug flag for PID
         -i IPaddress     use supplied address
         -I interface     use supplied interface
         -S               show configuration data
         -M               permit multiple instances
         -K processID     terminate instance PID
         -z               activate shm dump code
         -h               help (this text)


Note: the /usr/local/etc/noip2.conf returns some seemly encrypted text, so it's not meant to be changed. 

DNSdynamic service uses ddclient in ubuntu. Herewith my configuration for reference:

root@ubuntu:# cat /etc/ddclient.conf
# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf

daemon=60
protocol=dyndns2
use=web, web=checkip.dyndns.org
server=www.dnsdynamic.org
login= (username)
password=(password)
(domain).dnsdynamic.com

Replace the corresponding fields with your own account details.

P.S. Remember to set up port forwarding if your servers are sitting behind NAT.


Belkin DSL Modem Router Port Forwarding

I have replaced my Netgear wireless router with Belkin FD 2401 v1 (Wirelss modem router), I think it is worth bit over $60 on Ebay off the top of my head. It is overall more stable and reliable, so far so good.

While setting its port forwarding feature (Firewall > Virtual Servers), I noticed if the inbound port is a well known port number (0 - 1024) then it simply doesn't work i.e. no access.

However, any port outside this range (including registered ports) functions well - as shown in the examples beneath:



P.S. the Belkin is running on firmware 1.00.38(Jul 1 2010 13:40:12).

Monday, November 12, 2012

Moving to Ethernet over Power


It has been awhile since I last posted, been busy with other commitments.
In this post, I would like to share some recent modifications I made to my home networking.
Motivation
The original intention was to improve the Wifi performance at home. 
Originally, my laptop (in the study) is covered by the living room's Wifi coverage. 
Whenever I watch online TV or backup its files, my whole place's Wifi connection grinds to a halt. Also, the iPad is rendered useless.
The logical approach would be upgrading all my devices to 802.11n, but it is quite a substantial investment considering my laptop is a four years old Sony VAIO and I still use my iPhone 3GS, both supporting  only 802.11g. 
Also, I tried enabling DLNA on a 802.11n smartphone and streamed it to the WDTV media player. It just repeatingly halted. 
I felt there has to be a better option. 
Setup and two use cases
In large, there are three areas being connected: living area (wifi router), study and the storage room. The idea is to dedicate the Wifi signals to the portable devices (e.g. iPad, iPhone with no SIM).
In parallel, all the "non-internet" traffic are to be carried across the home's power line.
  • (1) For example, I am using ownCloud to backup my photos and personal documents from my laptop (as illustrated by the blue line, "Use Case 1")
  • (2) Likewise, if I would like to display my photos on the LED TV via WDTV media player, then I can share it from either my Laptop or ownCloud (DLNA enabled) – once again, all traffic through the Power line ("Use Case 2".
While all these happen. I can still use my iPad to happily browse the internet (red line), simply because the Belkin Wifi Router is not involved in these use cases.
Some details
If you look at the diagram more closely, there are several small boxes attached to the “Home Power Line” cloud in the center. These are the EoPs' plugs. Their models are Belkin Powerline AV (F5D4070) and TP-Link TL PA-201 respectively. 

This Belkin's support page article describes powerline adapters compatibility. By large, there two standards in the market today. HP 1.0 and HP AV. 

My working combination of Belkin and TP-Link are running on the older Home Plug 1.0 standard. This standard supports up to 85Mbps throughput. 

Originally, I bought a newer pair of Belkins Homeplug AV running on HPAV standard. Unfortunately, these newer plugs cannot detect other HP1.0 devices over the power line.

Further technical details
  • The people on Whirlpool forum have done a much better job than myself analyzing Ethernet over Power products available in the market. It’s worth a read if you are considering using it for your home.
  • I am no electrical engineer, but I do suspect my results may have to do with multiple phases and circuits, as detailed in this Intellon Whitepaper. Cross phase coupling is still good technical information.

Glad to hear what you think or your experiences.