Wednesday, August 29, 2012

Asterisk (VoIP PBX) on the cloud with Amazon EC2 (NAT)

In my continuing effort to eliminate the need for a server at my home, I took on moving my Asterisk installation (of just about 10 years) locally run on a Linux server to the cloud using an Amazon EC2 micro-instance.

Background:  Home automation has always been my hobby and a part of that has extended into my phones.  What started off as a simple task of announcing Caller ID over the home intercom, turned in to  an elaborate Session Initiation Protocol (SIP) based Private Branch eXchange (PBX) using Interactive Voice Response (IVR) menus.    (If anyone is interested in what is all automated let me know and Ill write up the use cases.)

My setup was using an x86 based Linux server running Asterisk with various SIP devices as extensions; Zyxel WiFi Handsets, Seimans Gigaset, Grandsteam, Obi100 FXS -> POTS Dect 5.0 phones, and Android Handsets.   I have a VoIP provider giving me Plain Old Telephone Service (POTS) access with standard phone numbers via a SIP trunk.     This was all running on residential internet with a Dynamic IP address, behind a standard Wireless firewall / router (Asus RTN-16), and running Network Address Translation (NAT) on a private internal network.

For the most part this was a typical personal installation of Asterisk with the trunk connection going through NAT and  all of the clients connecting directly on the local private network.

Protocols Involved: What helps is a general understanding of how the SIP / Real-time Transport Protocol (RTP) works.  SIP is a text based protocol that coordinates communications between devices using User Datagram Protocol (UDP) generally on port 5060.  This handles authentication, routing, registry, status, and more importantly the port numbers established for RTP to commence.

RTP sends the actual voice data between devices also using UDP but its ports need to be allocated at time of transmission and generally range between 10,000 and 20,000.

Due to both of these protocols technically being stateless, NAT alone does not sufficiently allow these to route correctly without help.

On the cloud:  The Asterisk server is now running on a Amazon EC2 Microinstance with the clients still on my private network locally (for obvious reasons of needed to use my handsets at my house ;) )   

Here is what I needed to make this happen:
  • EC2 Server: Asterisk config remains setup to talk with my VoIP provider through a NAT,  as Amazon EC2 instances do not get a real IP address mapped locally to an interface. 
    • (sip.conf) [provider] nat=yes
    • (sip.conf) [provider] canreinvite=no
  • EC2 Server: Because clients will be connecting through the Wide Area Network (WAN) interface now, I need to tell Asterisk what its IP address and local network is
    • (sip.conf) [general] externalip=54.54.54.54
    • (sip.conf) [general] localnet=192.168.0.0/255.255.255.0
  • EC2 Server: Clients need to be configured as NAT devices as well
    • (sip.conf) [kitchen phone] nat=yes | canreinvite=no [den phone] nat=yes | canreinvite=no, etc
  • EC2 Firewall:  Ports need to be opened for SIP / RTP:
    • Security Policy -> (Allow) UDP 5060-5083
    • Security Policy -> (Allow) UDP 10000-20000
  • Client Router: NAT needs to be "helped" and configured:
    • (Tomato Firmware) Advanced -> Tracking / NAT Helpers -> SIP (enable) / RTSP (enable)
  • Client Handsets: The internal private network will not be recognized (or useful) to the Asterisk server so they need to register under a common domain:
    • [Domain] 54.54.54.54 (External IP of the server)
Woila, now we have a PBX system on the cloud.



***Trouble shooting tips:
  • Asterisk "set sip debug on" and "rtp set debug on" are your friends.
  • If your handsets register but you cannot hear / transmit sound, RTP is not routing to either the correct IP address or your firewall / nat is not allowing it to pass correctly.  Check domain and your router firmware for supporting SIP and RTP "helpers".
  • If your phones ring at 1:21am in the morning the following night, you may have forgotten to restrict the 5060 port to just your EC2 server / client IPs and you are being hacked.  Not a good night ;)






Wednesday, July 4, 2012

New Opensourced Home Automation Offering - Pytomation


After more than a decade of using and contributing to Misterhouse, I have decided to startup a new open-sourced Home Automation platform - Pytomation.    There is a ton of legacy design with MH that needs to be refactored and unfortunately there isnt any unit testing to help with that.  To assist with reliability / maintainability in the future I started from scratch with a Test-Driven Development  (TDD) approach.

Hit the link up above to get the Python library code (should be multiplatform: Linux, Windows, Mac)  to drive basic ON/OFF functionality for Insteon, UPB, and X10 interfaces.   Most of the hardware with threading / communication / binary wrangling has been complete and am looking for feedback / any contributions at this point.  There should be enough there for even novices to Python to be able to help out and welcome any questions / requests for assistance / comments you may have (jasonatsharpeedotcom)

My goal is to replace my Misterhouse Installations by the end of the year, so you can expect some of the same functionality to be added over the next few months (LOMP, Tiggers, Web, Floorplan, Notifications, etc)

www.pytomation.com

The Slow Fall of RIM - Blackberry

David Miller wrote in his blog about why he thinks Thorsten Heins has the toughest job in tech.   I wanted to share my thoughts as well.


Postulation: All smartphones can accomplish the same general types of tasks, only vary by the feature set (thus complexity) of accomplishing them and the computer literacy of the marketplace.  Thus I believe there are TWO market segments of smartphones: Computer literates demanding features, and "Newbies" demanding simple limited experiences. 

Theory:  As computers permeate the world computer literacy is increasing, thus the market for phone features is increasing.  RIM has stayed focused too long on "Newbie" limited simple experiences of email and BlackBerry messaging thus losing customers in mass in todays world.

Background:
In order to understand what is happening currently you need to look back to the Pager where it all started.   Everyone that needed to be "connected" had a pager before anything else and Motorola was the original key player here.

Motorola (Pagers, StarTac , Razor): Created both hardware and software for their first devices.  They  were extremely featured limited and very simple to use for the "non-computer literate" crowd of the 80's and 90's and were successful.   

As the world passed and the cost of developing software declined they had the wherewithal to pull out of the software market, partner with other companies (J2ME, Android), and focus on their established hardware development segment.  While Motorola is no longer a giant in the connected device market, they do still stay relevant ("DROID!") and are still in a great position.

PalmOS (Kyocera, Visor, Treo):  Allowed a very small segment of people who were very computer literate in the late 90s, to access Web, Email, Calendar, Tasks list and sync them with their desktop computers.   If you were a Realtor you had one of these and loved it because _nothing_ gave you the same functionality in those days.   

Their devices were very intimidating to non computer literate people.   Palm saw their market as only limited to those comfortable with technology and drove features even further (Windows CE / Mobile hit the scene).   

IT did finally occur to them in 2007 the "newbie" market may be a big success (Hello iPhone) and tried to retool their devices and marketing (Centro / PalmPre) but was too late.

Microsoft (Windows CE / Mobile ): Like Palm drove for ever increasingly amount of features trying to appeal to the computer literate, all the while ignoring the "newbie" segment.   As with most, have realized that there is money in limited phone experiences and are pouring tons of cash into "dumbing down" their user experience.   Unfortunately for them trying to "catch down" to iPhone levels is the opposite of what the current market is starting to want.

RIM (Inter@ctive Pager, Blackberry):  Competitors initally to Motorola in the paging markets and they too created hardware and software for their devices.  They flourished in the "Newbie" market and rode that wave as long as they could.  Unfortunately for them people are driving for more features out of their smartphones and are realizing too late they need to go beyond BBM.  

They could make a comeback but only if they do it "Motorola Style" by giving up the Mobile OS market and partnering with Android to bring BES, BBM as an integrated experience with their awesome keyboard based hardware.






Saturday, June 30, 2012

Apple wakens the sleeping Android giant - Google

After years of Apple taking legal potshots at various Android device manufacturers for specific devices, they have finally landed a legal success against the mothership Google.  Google is now prevented from selling their very own Android phone (Galaxy Nexus) for the specific reason of having a unified search experience!  No less than a couple of days from their annual marketing blitz surrounding the device and the ecosystem.   Undoubtedly this is going to finally trigger a return fire.

What can Google return fire with?  Plenty.  For instance they acquired Motorolla Mobility which holds a bunch of very important mobile device patents that Apple has initially been found to be violating.   Google will be forced to become a legal expert now and Im sure this and many future filings from them will sting Apple at its core revenue stream this summer / fall. 

If Google cannot sell their Android appliances, it will hurt their ego but not dent their revenue.  If Apple cannot sell their iOS devices, they lose almost everything.



Tuesday, June 19, 2012

Microsoft Surface PC announced... A third time?

Yesterday Microsoft announced its new Tablet Surface PC!   Looks pretty nice  and has some interesting input / navigation opportunities.  Havent we seen this before?

So I have some trivia for you.   What do the following years have in common; 1992, 2002, 2012?   10years?  Not the answer I was looking for....   It is the years in which Microsoft tried pitching the Tablet PC!


Will the third round be successful this time?  It seems this concept is as tired as the look on Blamer's face introducing it.   If Microsoft pitches the productivity market again it will likely suffer the fate of its two predecessors.  I still firmly believe tablets are only ideal for consumption and Apple currently owns that domain, so this will be a tough market for them yet again.


2002

1992


Change any setting for Mouse / Touchpad / Pointstick / Keyboard in Ubuntu

For the last couple of years I have been using an IBM Ultranav Keyboard, Logitech Mouse with a laptop that itself has a touchpad / pointstick.  This poses quite a bit of a headache as Ubuntu's gnome settings doesnt quite handle settings for multiple input devices (2 keyboards, 2 pointsticks, 2 touchpads, 1 mouse)

Here is how to configure any input device in X windows from command line:
  • Get a list of input devices and their ID's:
    • $ xinput list
  • See all of the properties available to a particular device ID
    • $ xinput list-props 14
  • Set property of device by ID (disable input device entirely)
    • $ xinput set-prop 14 'Device Enabled' 0
And that is all!

Saturday, June 16, 2012

First Foray into Balloon Photography

With the help of my daughter, we managed to build and fly our first photography balloon! 


I got the idea from reading an blog post months ago about people using balloons to get aerial pictures to enhance maps.  My daughter and I put our heads together and came up with a simple prototype with the materials we had on hand.  I have since found this site that gives a really good overview of a design:  http://publiclaboratory.org/tool/balloon-mapping.

From the prototype we flew today we discovered the following issues and thus our next design changes:

  • Wind drag - Reduce to just one large balloon as the two were catching turbulence from each other as well as from the wind.   The balloon didnt make it all that high due to it being constantly pushed away from us.
  • Stability issues - Follow the design from the Public Laboratory link to add stability arms and a better center of gravity.
  • String Management - Using a simple spool made it difficult to deploy / retrieve.  Definition going to get a hold of a cable reel.
  • Height - Definitely need more than 200 ft of string to get a better angle on the ground