Monday, December 12, 2011

"Operator. How may I direct your call?"

Disclaimer: Flying through Linux and OpenSource. You might experience Freedom along with plenty of awesomeness.

I am a curious being and I love the freedom that is offered by Linux. Because of this, you will occasionally find me spending hours on pet projects that have nothing to do with what I do for a living.

In past couple posts, I shared my desire and my efforts to set up my own PBX in my home network. I also shared the discussion I had with a colleague who had successfully setup an intercom system that he used to talk with his family abroad. After spending numerous hours on this feat over past few days, last night I finished my setup and I now have all the functionality that I needed from this setup.

I installed FreeSWITCH on a Debian server that I have on my home network. It had to be compiled from source since PogoPlug houses an ARM processor and Debian repositories didn't have a packages for FreeSWITCH for arm architecture. But the instructions were easily available and installation was a piece of cake. Like I had mentioned in the previous post, the installation came pre-configured with 20 extensions for internal use, an demo IVR menu, and plenty of other features.

I was now able to register soft phone softwares running on our Linux desktops and laptops and my Android phone over WiFi within our home network and test the calling from one soft phone extension to another.
I now needed a sip gateway router that would allow me to connect my home phone line to the FreeSWITCH setup. I found a great deal on a Cisco/Linksys SPA 3102 sip gateway router. SPA 3102 allowed me to connect my incoming phone line on one jack and my home phone unit on the other.
I now had a PBX setup which was accessible to be via the home network for internal calling. I was also connected to my home phone line, which allowed me to make outbound calls and receive incoming calls.
Now one thing to keep in mind that even though SPA 3102 has a jack for phone line (FXO) and a jack to connect a physical phone (FXS) they operate on two separate extensions. However, now that we are in SIP/PBX territory, calls can be bridged and transferred from one extension to another. I was able to configure FreeSWITCH and SPA 3102 so that the calls received on the PSTN line (FXS) would be forwarded to Line 1 (FXO) where my phone was attached. I also configured FreeSWITCH to send the calls originating on internal extensions - Line 1 on SPA 3102 also being one of them - that are not handled internally, to send them outbound via PSTN line. My basic phone setup was restored and I now had the capability to make outbound calls from any computer from within my home network. Think Skype Out without paying an addition cent.

I mentioned earlier that I was able to register and test soft phone on my Android phone to my home FreeSWITCH server. This was done over WiFi. I was able to open ports on my home firewall for FreeSWITCH so that I could connect from an outside network. And I was successfully able to test this by getting on a different WiFi network that had Internet access. The next thing naturally was to do a quick test over 3G we'd be in business. Yeah, right. This was not as quick as I had anticipated it to be. I was able to originate outbound calls and receive incoming calls successfully, but there was no audio. After spending hours researching it, I found the answer hidden in plain sight, mocking me all this time.

SIP Servers and phones use what is called a STUN service to help with port discovery when connecting to other servers and phones behind NAT/firewall. I had already read about it briefly and had configured my server to use stun.freeswitch.org as the STUN service url. From the reviewing the logs, I discovered that the url was not reliable and down most of the time. There are however a number of free STUN services available and I found a webpage that listed quiet a few of those. FreeSWITCH comes with a STUN server testing utility and I was able to find one of the STUN servers that was indeed online. I configured my FreeSWITCH server to use it, and now I had audio on my Android phone over 3G.

All this was a fun and exciting experience overall. Besides the time I put in it, it cost me $43 that I paid for the SPA 3102. What are the practical applications you'd ask. There are plenty, and I plan to dedicate the next article discussing those.


Progress on this topic can be following in the following articles:

4 comments:

  1. Truly, today the world belongs to open source. You have full independence and control on what you have and what you want to do with it. Prior to open source, IT world was controlled mainly by some giants whose name can be counted on fingers. Open source is more reliable and feature full because programmers from all over the world contribute to it. Especially when talking VoIP open source has taken world by storm. True Voip is totally free. You can configure some open source free pbx software, Asterisk being a true legend in the regard, and configure it on both ends and enjoy free communication in any corner of world. However there is only a minimal cost of bandwidth included. Today there are lots of VoIP service providers available to choose from. Based on quality, some of the top Internet Phone Service Providerslike Axvoice, Vonage, Packet 8 etc. you can easily call to landline and mobile numbers on cheap rates anywhere in the world. I haven't used Linksys SPA 3102 but would like to try it. Hope it can be connected to a system running Asterisk on it.

    ReplyDelete
  2. You are absolutely correct, @brannakessler.
    Open source is truly powerful. Not only does it foster innovation, you also end up with solid applications that can either meet or beat the benchmarks set by proprietary applications doing the same tasks in terms of stability, security, and functionality. For example, just look at Linux, FreeBSD server technologies, Apache, Lighttpd Web Servers, Firefox, Chromium Web browsers, and Asterisk, FreeSWITCH IP PBX servers etc.

    SPA 3102 should work with Asterisk. I've seen a few articles online that talk about setting up SPA 3102 with Asterisk and other PBX systems.

    ReplyDelete
    Replies
    1. Hi,Karim,
      Can you please explain how to compile freeswitch from source for arm. Although I did find someting on there website, it still wasn't clear to me (I'm no linux expert).
      Thanks

      Delete
    2. Freeswitch should compile using instructions from accompanied readme file on arm as well. What distro are you using on arm? Arch for arm for instance provides the package from AUR. You may look at the PKGCONFIG file there for specific commands that may be necessary to install freeswitch on arm.

      Delete