| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{Introduction} | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | The Asterisk Realtime Architecture is a new set of drivers and | 
					
						
							| 
									
										
										
										
											2005-12-01 22:17:35 +00:00
										 |  |  | functions implemented in Asterisk. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | The benefits of this architecture are many, both from a code management | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | standpoint and from an installation perspective. | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | The ARA is designed to be independent of storage. Currently, most | 
					
						
							|  |  |  | drivers are based on SQL, but the architecture should be able to handle | 
					
						
							|  |  |  | other storage methods in the future, like LDAP. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | The main benefit comes in the database support. In Asterisk v1.0 some | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | functions supported MySQL database, some PostgreSQL and other ODBC. | 
					
						
							|  |  |  | With the ARA, we have a unified database interface internally in Asterisk, | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | so if one function supports database integration, all databases that has a | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | realtime driver will be supported in that function. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Currently there are three realtime database drivers: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{itemize} | 
					
						
							|  |  |  |   \item ODBC: Support for UnixODBC, integrated into Asterisk | 
					
						
							|  |  |  |         The UnixODBC subsystem supports many different databases, | 
					
						
							| 
									
										
										
										
											2007-07-26 14:49:51 +00:00
										 |  |  |         please check \url{www.unixodbc.org} for more information. | 
					
						
							| 
									
										
										
										
											2009-08-01 23:33:31 +00:00
										 |  |  |   \item MySQL: Native support for MySQL, integrated into Asterisk | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  |   \item PostgreSQL: Native support for Postgres, integrated into Asterisk | 
					
						
							|  |  |  | \end{itemize} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | \subsubsection{Two modes: Static and Realtime} | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | The ARA realtime mode is used to dynamically load and update objects. | 
					
						
							|  |  |  | This mode is used in the SIP and IAX2 channels, as well as in the voicemail | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | system. For SIP and IAX2 this is similar to the v1.0 MYSQL\_FRIENDS | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | functionality. With the ARA, we now support many more databases for | 
					
						
							|  |  |  | dynamic configuration of phones. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The ARA static mode is used to load configuration files. For the Asterisk | 
					
						
							|  |  |  | modules that read configurations, there's no difference between a static | 
					
						
							|  |  |  | file in the file system, like extensions.conf, and a configuration loaded | 
					
						
							|  |  |  | from a database. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-05 21:19:06 +00:00
										 |  |  | You just have to always make sure the var\_metric values are properly set and | 
					
						
							|  |  |  | ordered as you expect in your database server if you're using the static mode | 
					
						
							|  |  |  | with ARA (either sequentially or with the same var\_metric value for everybody). | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | If you have an option that depends on another one in a given configuration | 
					
						
							|  |  |  | file (i.e, 'musiconhold' depending on 'agent' from agents.conf) but their | 
					
						
							|  |  |  | var\_metric are not sequential you'll probably get default values being assigned for | 
					
						
							|  |  |  | those options instead of the desired ones. You can still use the same | 
					
						
							|  |  |  | var\_metric for all entries in your DB, just make sure the entries | 
					
						
							|  |  |  | are recorded in an order that does not break the option dependency. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | That doesn't happen when you use a static file in the file system. Although | 
					
						
							|  |  |  | this might be interpreted as a bug or limitation, it is not. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{Realtime SIP friends} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | The SIP realtime objects are users and peers that are loaded in memory | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | when needed, then deleted. This means that Asterisk currently can't handle | 
					
						
							|  |  |  | voicemail notification and NAT keepalives for these peers. Other than that, | 
					
						
							|  |  |  | most of the functionality works the same way for realtime friends as for | 
					
						
							|  |  |  | the ones in static configuration. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | With caching, the device stays in memory for a specified time. More | 
					
						
							| 
									
										
										
										
											2006-06-27 17:30:14 +00:00
										 |  |  | information about this is to be found in the sip.conf sample file. | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-14 14:33:17 +00:00
										 |  |  | If you specify a separate family called "sipregs" SIP registration | 
					
						
							|  |  |  | data will be stored in that table and not in the "sippeers" table. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{Realtime H.323 friends} | 
					
						
							| 
									
										
										
										
											2007-02-15 12:10:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-02 18:59:03 +00:00
										 |  |  | Like SIP realtime friends, H.323 friends also can be configured using | 
					
						
							| 
									
										
										
										
											2006-09-19 17:07:22 +00:00
										 |  |  | dynamic realtime objects. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{New function in the dial plan: The Realtime Switch} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | The realtime switch is more than a port of functionality in v1.0 to the | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | new architecture, this is a new feature of Asterisk based on the | 
					
						
							| 
									
										
										
										
											2005-10-13 23:19:37 +00:00
										 |  |  | ARA. The realtime switch lets your Asterisk server do database lookups | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | of extensions in realtime from your dial plan. You can have many Asterisk | 
					
						
							|  |  |  | servers sharing a dynamically updated dial plan in real time with this | 
					
						
							|  |  |  | solution. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | Note that this switch does NOT support Caller ID matching, only | 
					
						
							|  |  |  | extension name or pattern matching. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | \subsubsection{Capabilities} | 
					
						
							| 
									
										
										
										
											2005-10-13 23:19:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | The realtime Architecture lets you store all of your configuration in | 
					
						
							|  |  |  | databases and reload it whenever you want. You can force a reload over | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | the AMI, Asterisk Manager Interface or by calling Asterisk from a | 
					
						
							|  |  |  | shell script with | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-07-24 18:19:18 +00:00
										 |  |  |   asterisk -rx "reload" | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | You may also dynamically add SIP and IAX devices and extensions | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | and making them available without a reload, by using the realtime | 
					
						
							|  |  |  | objects and the realtime switch. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{Configuration in extconfig.conf} | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | You configure the ARA in extconfig.conf (yes, it's a strange name, but | 
					
						
							|  |  |  | is was defined in the early days of the realtime architecture and kind | 
					
						
							| 
									
										
										
										
											2007-07-24 18:19:18 +00:00
										 |  |  | of stuck). | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | The part of Asterisk that connects to the ARA use a well defined family | 
					
						
							|  |  |  | name to find the proper database driver. The syntax is easy: | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | \begin{verbatim} | 
					
						
							|  |  |  |     <family> => <realtime driver>,<db name>[,<table>] | 
					
						
							|  |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | The options following the realtime driver identified depends on the | 
					
						
							|  |  |  | driver. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Defined well-known family names are: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{itemize} | 
					
						
							|  |  |  |   \item sippeers, sipusers - SIP peers and users | 
					
						
							|  |  |  |   \item iaxpeers, iaxusers - IAX2 peers and users | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  |   \item voicemail - Voicemail accounts | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  |   \item queues - Queues | 
					
						
							|  |  |  |   \item queue\_members - Queue members | 
					
						
							|  |  |  |   \item extensions - Realtime extensions (switch) | 
					
						
							|  |  |  | \end{itemize} | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | Voicemail storage with the support of ODBC described in file | 
					
						
							|  |  |  | \path{docs/odbcstorage.tex} (\ref{odbcstorage}). | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{Limitations} | 
					
						
							| 
									
										
										
										
											2005-02-25 17:41:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-03 19:05:06 +00:00
										 |  |  | Currently, realtime extensions do not support realtime hints.  There is | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | a workaround available by using func\_odbc.  See the sample func\_odbc.conf | 
					
						
							| 
									
										
										
										
											2006-08-03 19:05:06 +00:00
										 |  |  | for more information. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{FreeTDS supported with connection pooling} | 
					
						
							| 
									
										
										
										
											2006-08-03 19:05:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-03 13:16:00 +00:00
										 |  |  | In order to use a FreeTDS-based database with realtime, you need to turn | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | connection pooling on in res\_odbc.conf.  This is due to a limitation within | 
					
						
							| 
									
										
										
										
											2006-08-03 13:16:00 +00:00
										 |  |  | the FreeTDS protocol itself.  Please note that this includes databases such | 
					
						
							|  |  |  | as MS SQL Server and Sybase.  This support is new in the current release. | 
					
						
							| 
									
										
										
										
											2009-08-01 23:33:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | You may notice a performance issue under high load using UnixODBC. The UnixODBC | 
					
						
							|  |  |  | driver supports threading but you must specifically enable threading within the | 
					
						
							|  |  |  | UnixODBC configuration file like below for each engine: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Threading = 2 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This will enable the driver to service many requests at a time, rather than | 
					
						
							|  |  |  | serially. |