Bayonne logo

Using Bayonne2 SIP

Contents

Introduction

GNU Bayonne2 is the telecommunications application server of the GNU project. It's a powerful software that makes it easy to develop IVR applications through a simple scripting language. GNU Bayonne2 supports various telephony hardware (VoiceTronix, Dialogic and more) and, since version 1.x it supports also VoIP based on the GNU oSIP stack.

In this mini-howto, we'll address a basic configuration using the SIP driver.

I'll suggest to read VoIP HOWTO before you begin.

Software Required

In my test environment, I used the following software compiled on x86-32bit architecture:

For Bayonne

For SIP Proxy

For testing, you can use any generic softphone. For this article, we'll use CounterPath X-Lite that is available for Linux, Microsoft Windows® and Mac OSX®. You can get your free copy here: http://www.counterpath.com/index.php?menu=download (archived). [In 2017, the latest version of X-Lite is only available for Windows and MacOS.]

Software Installation

The software is quite simple to install.

The first step is to compile and install GNU Bayonne2. To complete this job, You can follow this tutorial.

The second step is to compile and install PartySIP. On a GNU/Linux Gentoo system you can give this command:

 $ ACCEPT_KEYWORDS="~x86" emerge partysip

On other Linux distros, you can compile PartySIP following the steps from: http://www.nongnu.org/partysip/FAQ-partysip.html#compilation5

Once all the software is installed, we can review the configuration files.

Software Configuration

The first thing we'll configure is PartySIP. A short introduction to PartySIP from the PartySIP FAQ: “Partysip is a SIP proxy server. A proxy server has to find routes for SIP requests. In addition to the standard routing rules, PartySIP can get the routes from additional plugins. It can also start services when a dedicated plugin has been built for this service.”

So, PartySIP will register our SoftPhone and Bayonne scripts, assigning them a “Phone Number”: then it'll route SoftPhone calls to Bayonne.

PartySIP is quite simple to configure: you've to edit a single configuration file, usually located in /etc/partysip/partysip.conf. Here my partysip.conf:

 # partysip.conf file
 serverip = 10.0.1.116   <- replace with your server ip address
 servername = telserver  <- replace with your server hostname
 serverport_udp = 5060
 transport = udp


 plugins = udp syntax auth filter rgstrar ls_localdb ls_sfull
 plugins_config = udp syntax auth filter_internal rgstrar ls_localdb ls_sfull


 serverrealm = "telserver"   <- replace with your hostname or realm
 authentication = on

 <syntax>
     allowed_schemes sip,sips
 </syntax>

 <filter_internal>
     dialingplan internal
     mode statefull
 </filter_internal>

 <filter_external>
     dialingplan external
     mode statefull
 </filter_external>
 
 <ls_sfull>
     record-route off
 </ls_sfull>

 <ls_localdb>
     mode sf_forking
     mode sf_sequential
     record-route off
 </ls_localdb>

 <userinfo>
 #  <user>    <sip:NAME@DOMAINNAME>  <auth_login>   <auth_passwd>
     user sip:200@telserver 200 200        <- replace with your servername
     user sip:dtmf_say@telserver 202 202   <- replace with your servername
 </userinfo>

Here some other useful informations. In the test I've made, I noticed that Bayonne will register on the SIP Proxy the scripts using their names. This means that if in /usr/share/bayonne/scripts you have two SIP-enabled scripts script1.scr and script2.scr, Bayonne will register as sip:script1@yourrealm and sip:script2@yourrealm.

For SIP-enabled scripts I mean scripts that contain a SIP registration command like this:

 register.sip proxy=10.0.1.116 uri=sip:201@telserver \
         userid=201 secret=201 timeout=3600

In PartySIP, you see that <userinfo> section. We put two registration, one for a script named 201.scr and the other for a script named dtmf_say.scr. You can put as many registrations you need using the right syntax.

OK! Now you can start your PartySIP Proxy Server. On Gentoo GNU/Linux, you can launch it from init with this command:

 $ rc-config start partysip

On other systems, you can start PartySIP with your init script or simply from the command line:

 $ partysip -f /etc/partysip/partysip.conf &

Other command-line switches (for verbose debug information or logging file) are available.

Now, we'll proceed to configure GNU Bayonne2. Before to begin, be sure to have a group “bayonne” and a user “bayonne” on your system, and that the user bayonne has the rights to access audio devices on your system. Now, edit the following configuration files:

1) /etc/bayonne/server.conf

 [server]
 user = bayonne
 group = bayonne
 language = en_us
 voice = en/deborah

 [engine]
 driver = sip

2) /etc/bayonne/driver.conf

 [sip]
 inband = true
 dtmf = 101
 interface = 10.0.1.116:5070   <- replace with your server ip address
 ;rtp = 5074

In this way, we put bayonne listening on port 5070/UDP because we installed, on the same machine, also PartySIP that listens on port 5060/UDP. Two SIP Stacks on a single machine made easy :)

For our purpose, you've to put the following script in /usr/share/bayonne/scripts/dtmf_say.scr (replace on the first line telserver with your realm:

 register.sip proxy=10.0.1.116 uri=sip:dtmf_say@telserver \
        userid=202 secret=202 timeout=3600


 clear %session.digits
     play o k
     goto ::mytest


 program mytest
     sleep 15
     goto ::mytest


 ^dtmf
     string.1 %keyp
     collect %keyp count=1
     slog "DTMF %keyp detected"
     play &number %keyp
     goto ::mytest

OK, now you can start Bayonne with the command:

 $ bayonne -vvv 

Please, check on the console if some error occurs. In this case, check and re-check your configuration files for errors or difference from what you read above.

Remember that, in Bayonne2, you can also start your scripts directly with the soundcard driver for debugging:

 $ bayonne -vvv -d soundcard /path/to/your/script.scr

SoftPhone Configuration

We assume that you've already successfully installed X-Lite, that your soundcard is properly configured. The first thing we've to configure is our accounting informations for successfully login on the PartySIP Proxy.

From the Preferences dialog, go in System Settings->SIP Proxy, double-click on the [Default] entry and change the following parameters:

 Enabled: Yes

 Display Name: 200
 Username: 200             <- match user@realm in partysip <userinfo>
 Authorization User: 200   <- match auth_login in partysip <userinfo>
 Password: 200   <- match auth_passwd in partysip.conf <userinfo> section
 Domain/Realm: telserver   <- change with your realm
 SIP Proxy: 10.0.1.116     <- change with the address of your server

Now the X-Lite should make a successful login on the PartySIP Proxy. You can check the new status from X-Lite main window when it says Logged In - Enter Phone Number. Your number is: 200.

Now, go again in the Preferences Dialog, and then in Advanced System Settings -> DTMF Settings and change the following parameters:

 DTMF Force Send In Band: Yes
 DTMF Tone Length in Samples: 2720
 DTMF Magic Number: 101

From Advanced System Settings -> Codec Settings -> g711u, change the following parameters:

 Enabled: Yes 
 Magic Number: 0
 Samples Per Frame: 160
 DTMF Samples Per Frame: 160

From Advanced System Settings -> SIP Settings, change the following parameter:

 Register Proxy (s): 3600

The settings end with a Phonebook entry. Open the Phonebook and click on New Entry item and insert the following parameters:

 Name: dtmf_say@telserver              <- replace to match your realm
 Phone number or SIP URL: sip:[email protected]   <- ip address of server
 Proxy ID: telserver                   <- change to the realm of your proxy
 Speed No.: 1                          <- number of the speed dial

Final Test

OK, let's go with the test. Check that PartySIP and Bayonne are in execution.

From the numeric keypad of X-Lite, press the "1" key and then click on the green call button. You should hear the simple dtmf_say script running.