• >Home
    • Main Page
  • >Quick Links
    • Main Page
    • Asterisk
    • VOIP PBX and Servers
    • Open Source VOIP Software
    • VOIP Service Providers
    • VOIP Phones
    • What is VOIP?
    • VOIP Event Calendar
    • PBX
    • Internet Speed Test
    • About Voip-info.org
  • >Business VOIP
    • Business Voip Providers
    • IP PBX
    • Asterisk Based PBX
    • Hosted PBX
    • Virtual PBX
    • VOIP Billing
    • PBX Phone System
    • VOIP Wholesale
    • VOIP Hardware
    • VOIP Fax
    • VOIP Job Postings
  • >Residential VOIP
    • Residential Voip Providers
    • Internet Phone
  • >SIP
    • Sip Providers
    • About Sip
    • SIP Trunking
  • >Call Center Software
    • Automatic Call Distributor
    • IVR
    • Predictive Dialer
  • >Web Hosting
    • Web Hosting Providers
  • >Forums
    • List Forums
    • Asterisk
    • FreeSWITCH
    • GrandStream
    • Polycom Phones
    • VOIP Questions and Help
    • Hardware For Sale
    • Minutes For Sale or Wanted
    • Zycoo Tech

  • View
  • Discussion (16)
  • History

Asterisk RealTime

Business PBX Solution spacer
Provider Solution Details
spacer Become an ITSP Now!
  • Become a serious competitor in VoIP Immediately
  • FULL Consultancy, Installation, Training & Support
  • Sell Hosted IP PBXs, Biz Lines, Call Centre
  • Turnkey Provisioning at your data center
Details
spacer Kolmisoft solves softswitch problems
  • Class 4/5 softswitch with billing and routing
  • Excellent solution for softswitch problems
  • Calling card and business solutions available
Details

The Asterisk RealTime Architecture


ARA, the Asterisk Realtime Architecture is one of the major new features in Asterisk version 1.2.

Background Information

From docs/README.extconfig


The Asterisk external configuration engine is the result of work by Anthony Minessale II, Mark Spencer and Constantine Filin It is designed to provide a flexible, seamless integration between Asterisk's internal configuration structure and external SQL other databases (maybe even LDAP one day).

External configuration is configured in /etc/asterisk/extconfig.conf allowing you to map any configuration file (static mappings) to be pulled from the database, or to map special runtime entries which permit the dynamic creation of objects, entities, peers, etc. without the necessity of a reload.

Olle explains the world

In the new RealTime architecture, all database specific code is moved to database specific drivers. The channel just calls a generic routine to do database lookup. Much cleaner, simpler and manageable from a coding standpoint.

The database is accessed with three functions:
  • STATIC: This is used to load static configuration when a module is loaded
  • REALTIME: This is used to lookup objects during a call (or another event)
  • UPDATE: This is used to update objects

The database support in the channel is not changed. There are "normal" static peers/users and database peers/users. The static ones, regardless if these are loaded from a text file or a database configuration, are kept in-memory and in the SIP channel we provide them with NAT traversal support and message waiting indication if needed.

The database peers/users are not kept in memory. These are only loaded when we have a call and then deleted, so there's no support for NAT keep-alives (qualify=) or voicemail indications for these peers.
NOTE: If you enable RealTime caching in your sip.conf, Voicemail MWI works and so does 'sip show peers' - see rtcachefriends=yes. The downside to this is that if you change anything in the database, you need to do a 'sip reload' (for major changes) or 'sip prune realtime PEERNAME' (for single peer changes) before they become active.


In laymans terms

In the Stable 1.0.X branch of Asterisk, database storage of configuration files and parameters was done mostly by hardcoding connection and query code directly into the application. The best example of this is in app_voicemail, where you can see MySQL code and PostgreSQL code all meshed with the app_voicemail code.

This method of database retrevial proves to be ugly as all the asterisk code is now crammed with database specific code that is irrelevant to the function of the application at hand. Thus RealTime was developed as a means to remove the code and replace it with a unified (abstracted) database retrevial method.

Terminology/Files

  • Driver - A compiled module containing database specific code that accepts the generalized function calls that RealTime makes. As of this writing, only ODBC, MySQL (via asterisk-addons) and LDAP (see free.oxymium.net/Asterisk/ and bugs.digium.com/view.php?id=5768) drivers are available.
  • Family - A name associated with a RealTime call. Examples: sippeers, sipusers, voicemail.
  • extconfig.conf - The configuration file that contains the information necessary to bind specific families to specific drivers.
  • res_odbc.conf - The configuration file for ODBC RealTime.
  • res_mysql.conf - The configuration file for MySQL RealTime.
  • res_ldap.conf - The configuration file for LDAP RealTime.
  • ODBC - Open DataBase Connectivity
  • MySQL - the world's most popular open source database
  • OpenLDAP - Open source implementation of the Lightweight Directory Access Protocol

There are 2 methods of using RealTime: ODBC and MySQL. Yes, you can use ODBC to connect to MySQL and many other ODBC supported databases. (Being an avid MySQL user and advocate, I didn't want to bother with ODBC so I wrote the RealTime MySQL driver over the weekend.)


How to configure RealTime - ODBC Method

(This paragraph assumes you have ODBC already running and installed on your box.)
When you start to compile Asterisk, the Makefile inside res/ should detect if you have ODBC properly installed and if so compile the res_config_odbc.so module for you (as long as you have the unixODBC-dev libraries installed - sourceforge.net/project/showfiles.php?group_id=1544&package_id=122072).
Go into /etc/asterisk/res_odbc.conf and configure your ODBC connections. Some sample configs are supplied in asterisk/configs/res_odbc.conf.sample NOTE: res_config_odbc.conf is deprecated and will not be loaded.

Skip to 'Extconfig'

How to configure RealTime - MySQL Method

(This page assumes you have the MySQL client libraries/headers installed on your box.)
Check out asterisk-addons from CVS:

cd /usr/src/
svn co svn.digium.com/svn/asterisk-addons/trunk asterisk-addons


Go into asterisk-addons and run the following commands


configure
make
make install (This will also compile and install the other stuff in addons so if you don't want/need it, just run 'make' and manually copy res_config_mysql.so to your modules directory.)



Copy asterisk-addons/configs/res_mysql.conf.sample to /etc/asterisk/res_mysql.conf
Edit this file to your liking. At this time, the MySQL drivers supports multiple databases on only one server.

Now edit /etc/asterisk/extconfig.conf


Extconfig - Static Configs

Static configuration is where you can store regular *.conf files into the database. These configurations are read at Asterisk startup/reload. Some modules may also re-read this info upon their own reload (Ex. sip reload).
Here is the format for a static config:


[settings]

<conf filename> => <driver>,<databasename>~np~[~/np~,table_name~np~]~/np~
queues.conf => odbc,asterisk,ast_config
sip.conf => mysql,asterisk
iax.conf => ldap,MyBaseDN,iax


Above we have 3 examples. The first example will bind 'queues.conf' to the table 'ast_config' located in the database context 'asterisk' using the ODBC driver. — NOTE (LN): this is NOT the database you specified in /etc/odbc.ini, rather it's the context in /etc/asterisk/res_odbc.conf that you are using to connect to the ODBC driver!
The second example will bind 'sip.conf' to the table 'sip.conf' (because we ommited the table name, it defaults to the file name) in the database 'asterisk' using the MySQL driver.
The 3rd one will bind iax.conf to the 'table' iax.conf in the ldap database using LDAP driver; MyBaseDN is the base DN for the query.
Using the above examples, now, when app_queue.so loads, the RealTime ODBC driver will execute a query and get the information it needs. The same is true for chan_sip.so, but with MySQL and chan_iax.so with LDAP.



Extconfig - RealTime

RealTime configuration is where configuration values are read/updated in real time.

Example: Lets say you have 2 SIP users defined in your sip.conf and you want to add a 3rd. You add them to the file then execute the command 'sip reload'. This re-reads your sip.conf and allows the 3rd to register.
With RealTime, all you do is add 1 new record to the table that sipusers has been bound to. No reloading necessary.

RealTime maps take the following fomat:


[settings]

<family name> => <driver>,<database name>~np~[~/np~,table_name~np~]~/np~
sippeers => mysql,asterisk,sip_peers
sipusers => mysql,asterisk,sip_users
queues => mysql,asterisk,queue_table
queue_members => mysql,asterisk,queue_member_table
meetme => mysql,asterisk,meetme_table
voicemail => mysql,asterisk^


Above we have four examples. The first example will bind the family name "sippeers" to the table "sip_peers" in the database "asterisk" using the MySQL driver. The last example will bind the family name "voicemail" to the table "voicemail" (because we ommited the table name, it defaults to the family name) in the database "test" using the MySQL driver.

It is worth noting that sipusers and sippeers may both refer to the same table, if you wish.

NOTE: extconfig.conf is parsed each time you connect to the asterisk CLI.


Now that you have created all the necessary binds, it is time to create the tables. Since the tables are different to each family, I've broken the Wiki pages down to eliminate 1 huge RealTime page. Scroll down to the bottom to find the individual family pages.



:: NOTE: If you are setting up only IAX users (no peers), both iaxusers and iaxpeers entries in the above file need to be either included (uncommented) for iax users/peers to be loaded from the database.



Conclusions

RealTime is great. With a nice web interface you can allow customers limited ability to edit their own dialplan without needing a reload.

RealTime support is currently available for the following families:
  • sippeers
  • sipusers
  • iaxpeers
  • iaxusers
  • voicemail
  • musiconhold
  • queues and queue_members (used together for the Queue application).
  • extensions NOTE: The family name for RealTime extensions can be whatever you want. Please read Asterisk RealTime Extensions for more info.

More information will be posted as more apps become RealTime enabled.

Notes

Q: Does anyone know how to send * a semi-colon from a realtime database. I know that * uses the semi-colon as a 'seperator' - but I need to be able to use one in a command. I know I can use \; in the non-realtime configs, but this doesn't work in realtime.

A:
in /etc/asterisk/extensions.conf

globals
SEMICOLON=\;

Then use ${SEMICOLON} in realitime.... Hacky, but it's what I'm using at
the moment..

If you use SVN (upcoming 1.4.37, 1.6.2.14, or 1.8.0), you can encode semicolons in the database as the literal string "^3B".

See Also

  • Asterisk RealTime Static
  • Asterisk RealTime Sip
  • Asterisk RealTime IAX
  • Asterisk RealTime H323
  • Asterisk RealTime Voicemail
  • Asterisk RealTime Queue
  • Asterisk RealTime Extensions
  • Asterisk RealTime LDAP
  • Asterisk RealTime MeetMe
  • Asterisk RealTime chan_sccp2 - Coming soon
  • Asterisk configuration from database
  • Asterisk RealTime PostgreSQL - Working tables for PostgreSQL 8.1
  • Asterisk RealTime - Ruby on Rails Migrations and Models
  • The Asterisk Realtime Architecture

Go back to Asterisk
Created by: utdrmac, Last modification: Tue 26 of Oct, 2010 (10:41 UTC) by admin


Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+

spacer Page Changes | spacer Comments