Showing posts with label Asterisk. Show all posts
Showing posts with label Asterisk. Show all posts

Thursday, March 8, 2012

Shared Line Appearance/Bridged Line Appearance in Asterisk

1.    Design Overview:

When someone calls Boss’ line, it will ring Boss’ as well as Assistants’ phone (Asterisk SLA/conference function and Line Trunking allows this feature).
Assistants can see the presence of their Boss’ line (Presence feature on Polycom phone and Asterisk HINT allows this).  Assistants can pick up the call by pressing the line button. Boss can join the conversation by pressing the line button as well (Barge In function, Asterisk Conference and Line Trunking allows us to do this)
You can simply put a call on hold from one phone and pick it up from another. Also, if multiple phones press the key for the shared extension, they will all be bridged into the same call(Asterisk SLA/conference function allows this feature).

2.    Terminologies:
  • Asterisk Technologies/Channels/Devices: There are various technologies/channels/devices available in Asterisk.
                Local
                SIP
                Agent
                & more ….

           Examples:
                 device=Local/disa@SLA_Outbound
           Defined  Local channel that lands the call in ‘disa’ extension of context [SLA_Outbound] in extensions.conf
  • DISA:  DISA (Direct Inward System Access) allows someone calling in from outside the telephone switch(PBX) to obtain an “internal” system dialtone and dial calls as if from one of the extensions attached to the telephone switch.  Check more @ http://www.voip-info.org/wiki/view/Asterisk+cmd+DISA
  • SLA: Shared Line Appearance
  • BLA: Bridged Line Appearance
  • Station: It is any SIP phone that will be using SLA
  • Trunk:  It is a literal trunk or shared extension that will be appearing on two or more stations
  • SLAStation() : Shared Line Appearance Station application. It should be executed by an SLA station. The argument to this application depends on how the call was initiated. If the phone was just taken off hook, then the argument ‘station’ should be just the station name. If the call was initiated by pressing a line key, then the station name should be preceded by an underscore and the trunk name associated with that line button.
      exten =>20000, n,SLAStation(20000)
      exten => 20000_line1,1,SLAStation(20000_line1)
  •  SLATrunk(): Shared Line Appearance Trunk application. This application takes care of ringing of all the appropriate stations.   

exten => 20000,1,Verbose(1,### Dialing trunk line1)
        same => n,Goto(sla,1)

exten => sla,1,SLATrunk(line1)


3.    Implementation:
  • Check if all the required Asterisk applications are installed properly
SLA application uses two key technologies: Device State Processing and Conferencing. Conferencing uses MeetMe() application. MeetMe() application is offered by app_meetme module. App_meetme module requires DAHDI to be installed (even if you don’t use PRIs).
Warning!!!
You have to load dahdi and dahdi_dummy before you start asterisk. You can check if those are loaded or not.
# lsmod|grep dahdi
dahdi                 210879  0
crc_ccitt               1651  1 dahdi


If you don’t get output like above, you might want to load it manually
#modprobe dahdi
#modprobe dahdi_dummy

Now check if app_meetme module is loaded or not.
*CLI> module show like app_meetme.so
Module                         Description                              Use Count
app_meetme.so                  MeetMe conference bridge                 0
1 modules loaded


[If it says 0 modules loaded, double check if dahdi and dahdi_dummy are loaded successfully or not. You might also get “WARNING[15929]: app_meetme.c:1228 build_conf: Unable to open DAHDI pseudo device” for not having dahdi_dummy]
Check if SLAStation() and SLATrunk() applications are available
*CLI> core show applications like SLA
    -= Matching Asterisk Applications =-
            SLAStation:
              SLATrunk:
    -= 2 Applications Matching =-


  • Asterisk Configuration
You have to understand and edit sla.conf, extensions.conf and sip.conf.

Trunks and Stations are defined in sla.conf. Mapping of devices to trunks and stations are also done here.
Station: It is any SIP phone that will be using SLA
Trunk:  It is a literal trunk or shared extension that will be appearing on two or more stations

#sla.conf
[general]
attemptcallerid=yes

[line1]
type=trunk
device=Local/disa@SLA_Outbound

[line2]
type=trunk
device=Local/disa@SLA_Outbound

[station](!)  ;Template for stations 
type=station
trunk=line1
;trunk=line2

[20000](station)   ;Note:section name do not need to match SIP device name
device=SIP/20000

[20001](station)
device=SIP/20001


Warning!!!
Trunk must be tied up with a device. Otherwise it will crash asterisk.

Here, we defined
•    two trunks [line1] and [line2]
•    two stations [20000] and [20001]   

If you watch very closely on above configuration, you will see that
•    trunk [line1] is tied up with device=Local/disa@SLA_Outbound
•    stations [20000] and [20001] are tied up with  device=SIP/20000
and device=SIP/20001 and will use trunk [line1] as defined in [station](!)  template

In our current scenario, we will not be using trunk [line2] to simplify the demonstration.

You can verify those by executing ‘sla’ commands in asterisk
*CLI> sla show trunks

=============================================================
=== Configured SLA Trunks ===================================
=============================================================
===
=== ---------------------------------------------------------
=== Trunk Name:       line1
=== ==> Device:       Local/disa@SLA_Outbound
=== ==> AutoContext:  (none)
=== ==> RingTimeout:  (none)
=== ==> BargeAllowed: Yes
=== ==> HoldAccess:   Open
=== ==> Stations ...
===    ==> Station name: 20000
===    ==> Station name: 20001
===    ==> Station name: 20002
=== ---------------------------------------------------------
===
=== ---------------------------------------------------------
=== Trunk Name:       line2
=== ==> Device:       Local/disa@SLA_Outbound
=== ==> AutoContext:  (none)
=== ==> RingTimeout:  (none)
=== ==> BargeAllowed: Yes
=== ==> HoldAccess:   Open
=== ==> Stations ...
=== ---------------------------------------------------------
===
=============================================================



*CLI> sla show stations

=============================================================
=== Configured SLA Stations =================================
=============================================================
===
=== ---------------------------------------------------------
=== Station Name:    20000
=== ==> Device:      SIP/20000
=== ==> AutoContext: (none)
=== ==> RingTimeout: (none)
=== ==> RingDelay:   (none)
=== ==> HoldAccess:  Open
=== ==> Trunks ...
===    ==> Trunk Name: line1
===       ==> State:       SLA_TRUNK_STATE_IDLE
===       ==> RingTimeout: (none)
===       ==> RingDelay:   (none)
=== ---------------------------------------------------------
===
=== ---------------------------------------------------------
=== Station Name:    20001
=== ==> Device:      SIP/20001
=== ==> AutoContext: (none)
=== ==> RingTimeout: (none)
=== ==> RingDelay:   (none)
=== ==> HoldAccess:  Open
=== ==> Trunks ...
===    ==> Trunk Name: line1
===       ==> State:       SLA_TRUNK_STATE_IDLE
===       ==> RingTimeout: (none)
===       ==> RingDelay:   (none)
=== ---------------------------------------------------------
===

Asterisk dialplan (extensions.conf) allows to setup extension state hints and extensions that define how calls get into and out of an SLA setup.
#extensions.conf

[SLA_Stations]
exten => 20000,1,Verbose(1,### Incoming Call to extension${EXTEN})
        same => n, Dial(SIP/${EXTEN})

exten => 20000_line1,hint,SLA:20000_line1

exten => 20000_line1,1,SLAStation(20000_line1)) ;This puts the call thru' disa@SLA_Outbound as it forces the call thru' the trunk
    
exten => 20001,1,Verbose(1,### Incoming Call to SLAStation)
        same => n, Dial(SIP/${EXTEN})

exten => _X.,1,Verbose(1,### Incoming Call from ${CALLERID(name)} : ${CALLERID(num)}) 


CUSTOMIZE YOUR DIALPLAN ACCORDING TO YOUR ENVIRONMENT



[SLA_Outbound]
exten => disa,1,DISA(no-password,SLA_Outbound)

exten => _X.,1,Verbose(1,### Incoming Call from ${CALLERID(name)} : ${CALLERID(num)})
CUSTOMIZE YOUR DIALPLAN ACCORDING TO YOUR ENVIRONMENT
[External]
exten => 20000,1,Verbose(1,### Dialing trunk line1)
        same => n, SLATrunk(line1)

exten => _X.,1,Verbose(1,### Incoming Call from ${CALLERID(name)} : ${CALLERID(num)}) 


CUSTOMIZE YOUR DIALPLAN ACCORDING TO YOUR ENVIRONMENT

SIP users are defined in sip.conf. SIP users for SLA stations are assigned [SLA_Stations] context.

#sip.conf
context=External

[SLA-sip-phone](!) ;Template
type=friend
host=dynamic
secret=mysecretpassword
context=SLA_Stations

[20000](SLA-sip-phone)
callerid= "Boss" <20000>
mailbox=20000

[20001](SLA-sip-phone)
callerid= "Secretary" <20001>
mailbox=20001

[sip-phone](!) ;Template
type=friend
host=dynamic
secret=mysecretpassword
context=External

[20002](sip-phone)
callerid= "John Doe" <20002>
mailbox=20002




Here 20000 and 20001 are using SLA-sip-phone template, thus they land in [SLA_Stations] of dialplan
And 20002 is using sip-phone template and it lands in [External] context

  • Polycom phone configuration
For phone with extension 20001
Make sure that directories, buddies and presence features are enabled.
Then define the directory for the phone.

#[MAC-ADDRESS]-directory.xml

   
      
         
         Boss Line1
         20000_line1@mysipserver.phones
         1
         1
      
   


Similar configuration for phone with extension 20000

You can now start testing. Please remember that you have to customize your dialplan according to your environment. Good Luck!


Friday, January 20, 2012

Integrate Asterisk with SIP enabled Wireless phone: Polycom SpectraLink 8030

If you are looking for SIP and 802.11a/b/g compatible wireless phone, SpectraLink 8030 can be one of your choices. It is compatible with Asterisk.  It has also Push-To-Talk (PTT) functionality that allows group communication just like Walky Talky.

Product information of SpectraLink 8030 can be found at
http://www.polycom.com/products/voice/wireless_solutions/wifi_communications/handsets/spectralink_8030_wireless.html

Software and documents for SpectraLink 8030 can be downloaded from following link from Polycom
http://support.polycom.com/PolycomService/support/us/support/voice/wi-fi/spectralink_8030_wireless.html

If you are using Polycom SpectraLink VIEW certified Wireless Access Point, you can call 1-800-Polycom and get the support. If not, there is no luck to get any kind of support from them.

In my case, we have
  • DHCP , DNS, NTP and TFTP server running on Linux
  • Xirrus Array - XN4, XN8   (Make sure your wireless AP supports WMM- Wi-Fi Multimedia; sometime you might have to upgrade to the latest firmware. Contact your  Wireless AP vendor if your AP doesn't have WMM enabled)
  • Asterisk Server (SIP server + PBX) : IP address 192.168.1.10
  • SpectraLink 8030 ( one has an extension 2000 and other has an extension 3000)
  • Voicemail (Extension 2100)
In this article, I am not going to show you how to configure DHCP, DNS, NTP, TFTP server. If you need any help, contact your Server Administrator or look for online help.

Step1: Publish the required firmwares and configs to  TFTP server
Download SIP software of SpectraLink 8030 from above link  
Unzip it and publish the content to TFTP server

You will see various .bin files and .cfg files.

In my case, I have following files
#tftpshare
 MIBs
 pd14csi.bin
 pd14odsi.bin
 pd14shim.bin
 pd14shsi.bin
 pd14udsi.bin
 pi1400si.bin
settings.txt
slnk_cfg.cfg
sip_allusers.cfg
sip_2000.cfg
sip_3000.cfg

You don't have to touch .bin files.  You don't even have to touch slnk_cfg.cfg file

All you need to do is edit sip_allusers.cfg and create the config files for individual extensions (in my case I have two SpectraLink. I want to extensions: 2000 and 3000)


#vi sip_allusers.cfg
#--------Configuration for Asterisk based system-------------
PROXY1_TYPE            = Asterisk
PROXY1_ADDR            = 192.168.1.10:5060  #IP address of Asterisk Server
PROXY1_KEYPRESS_2833   = enable
PROXY1_KEYPRESS_INFO   = disable
PROXY1_HOLD_IP0        = disable
PROXY1_PRACK           = enable
PROXY1_REREG_SECS      = 3600
PROXY1_KEEPALIVE_SECS  = 14
PROXY1_CALLID_PER_LINE = disable
PROXY1_MAIL_ACCESS     = 2100



Create a config file for an extension 2000
#vi sip_2000.cfg
LINE1         = 2000
LINE1_PROXY   = 1
LINE1_CALLID  = Spectralink x2000
LINE1_AUTH    = 2000; myp@ssw0rd


#Note- Password follows extension in LINE1_AUTH line


Similarly create a config file for an extension 3000

#vi sip_3000.cfg
LINE1         = 3000
LINE1_PROXY   = 1
LINE1_CALLID  = Spectralink x3000
LINE1_AUTH    = 3000; myp@ssw0rd

#Note- Password follows extension in LINE1_AUTH line


Step2: Configure Asterisk Server

Spectralink 8030 wouldn't register to Asterisk server. I have to go thru' rigorous troubleshooting before I could figure out the fact that SpectraLink 8030's latest SIP software is still based on the original SIP RFC 2543. [ Polycom support didn't want to talk about anything as I wasn't using their VIEW certified AP. ]

[Please read about fundamental SIP request header if you haven't done so far]

However Asterisk is designed on the basis of latest SIP RFC 3261. Asterisk server drops the REGISTER request coming from SpectraLink 8030 because as per RFC 2543 standard SpectraLink doesn't send tag id in SIP REQUEST FROM header.

Thus you have to tell Asterisk to ignore the tags in SIP request headers. You can do that by using global option in sip.conf

Asterisk 1.8 has pedantic=yes by default

;pedantic=yes ; Enable checking of tags in headers,
                                ; international character conversions in URIs
                                ; and multiline formatted headers for strict
                                ; SIP compatibility (defaults to "yes")


You have to use   pedantic=no  for SpectraLink 8030 to work with Asterisk


#vi sip.conf
[general]
bindport=5060
bindaddr=192.168.1.10
canreinvite=no
dtmfmode=auto
pedantic=no

 [2000]
type=friend
host=dynamic
context=YourContextinDialplan
username=2000
callerid="Dave One" <2000>
secret=myp@ssw0rd
mailbox=2000

 [3000]
type=friend
host=dynamic
context=YourContextinDialplan
username=3000
callerid="John One" <3000>
secret=myp@ssw0rd
mailbox=3000




Step3: Configure AP 
Different APs have different tools for wireless configuration. Make sure you are using 802.11a/b/g wireless APs. AP must be configured as WMM-PowerSave. Please go thru' the product guide that came along with your AP to enable WMM-PowerSave.

Create a SSID for your voice network. [You many not want to broadcast this SSID to minimize easy access to SSID by intruders]

You can use any kind of encryption you want to. I prefer WPA2 as it uses Pre-Shared Key(PSK) and it allows user to manually enter keys to initiate WPA security.

Example: 
SSID: spectralinknetwork
WPA2 passphrase: myp@ssword

Make sure various Radio bands are available  for use. I have enabled a/g band and I am going to use '802.11a standard'  for my SpectraLink phones. 

BONUS INFORMATION: Brief introduction on various wireless standards:
  • 802.11a standard operates in 5GHz band with maximum data rate of 54Mbps. It's range is lower than the range of 802.11b but offers higher number of channels and also higher data rate.
  • 802.11b standard operates in 2.4GHz band with maximum data rate of 11Mbps. It's range is higher range than 802.11a but it suffers interference from other devices like Bluetooth, cordless telephonesc etc operating at 2.4 GHz. Data rate offered is less than 802.11a.
  • 802.11g standard operates in 2.4GHz just like 802.11b, but operates at maximum data rate of 54Mbps. 
  • 802.11n standard operates in 5GHz and/or 2.4GHz using MIMO technology. 



Step4: Use SIP HAT(Handset Administration Tool) provided by Polycom to configure the initial configuration for SpectraLink 8030. You can download SIP HAT from above provided link 





Network Configuration of SpectraLink via SIP HAT Tool
  • Enable DHCP
  • Use SSID:spectralinknetwork  and WPA2 passphrase: myp@ssword and click on 'Generate PSK from Passphrase + SSID' button
  • Use QoS Type 'Wi-Fi Standard'
  • Admission Control: Optional
  • 802.11 Config: a
  • Enable the bands you want to use





SIP configuration and others via SIP HAT Tool
  • Change the TimeZone as required
  • Enter the SIP username: 3000 and password: myp@ssword
Follow the procedure as per instructed by SIP HAT Software to write the settings to SpectraLink 8030 handset. It might prompt for the password before you can write the settings to the handset. Default password is '123456'. Ignore any minor errors while writing the settings to handset as handset will download the latest firmware from your TFTP server anyway.

 Step5: Powercycle the handset. If your ducks are in row, it will work without hassle. If come across any issues, follow the SpectraLink 8020/8030 Wireless Telephone Administration Guide for SIP.

SpectraLink 8030 displays Startup Sequence: 1 thru' 9.  Let's say your handset is stuck at '1234567', it means it has successfully gone thru '8' and '9', but it is stuck at '7'. If you look on the administrative guide, '1234567' means DHCP response with bad DNS server configuration. So, you have to fix possible DNS/DHCP server issue.


If you need further help, you can email me at erdevendra@gmail.com or simply post the comment.