AsteriskNOW — Save 50%
A practical guide for deploying and managing an Asterisk-based telephony system using the AsteriskNOW Beta 6 software appliance
Philosophy: A route of many roads leading from nowhere to nothing.
While it appears that Ambrose Bierce has a little respect for Philosophy in general, he would surely refer to calling routing as—roads leading from a single point to multiple points, or something similar. The purpose of the "Calling Rules" is to define the methodology by which calls are routed from the PBX to the outbound world.
This article by Nir Simionovich deals with the routing rules in AsteriskNOW and the Calling Rules tables.
An interesting feature of a PBX is the ability to support multiple dial plans, meaning that you are able to create various dial-plan logics, associate different calling rules to each dial plan, and assign users to specific dial plan. Schematically speaking, the relation between the three can be illustrated as follows:
Essentially, from AsteriskNOW's point of view, any dial attempt that doesn't match a Calling Rule will be considered an internal call, and thus, AsteriskNOW will try to route the call to an internal AsteriskNOW resource—e.g. another extension or an AsteriskNOW feature code.
Most telephony engineers and carrier support engineers refer to "Calling Rules" as "Routing Rules". From this point onwards in the book "Calling Rules" will be referred to as "Routing Rules".
Managing Routing Rules with AsteriskNOW
At this point, after initially configuring your service providers and initial routing rules, your "Routing Rules" table should look as follows:
Edit one of these rules to get acquainted with the call rule dialog box. Click the Edit link of the all_outbound rule (rule 1). The following dialog box should appear on your screen:
Every call made from an IP phone connected to the PBX is processed by the routing rules. The processing is performed in the following order:
- AsteriskNOW grabs the dialed number and tries to match it to the prefix defined in the Routing Rule. In this dialog, the prefix is 9.
- It then verifies the number of digits suffixing the prefix. In this example, any number of digits that is 3 or more is considered a valid number to be assigned to this route.
- Now, before actually routing the call to the designated service provider, AsteriskNOW can remove prefixes and/or prefix numbers to the dialed number. In this example it will only remove a single prefixing digit (9) and then pass the call to your service provider–Ports 1,2,3.
The above process happens for every call that is made by a phone connected to the PBX. If the process fails all the rules defined in the Routing Table, AsteriskNOW assumes that the call is supposed to be routed internally. If internal routing fails, the call will fail and a fast-busy tone will be heard from your IP phone.
Some IP phones also indicate the SIP error message that was received. If routing fails, the normal error that you may encounter would be error 404 – NOT FOUND.
Manually Editing Dial-Plan Logic
Additional information about Asterisk configuration files
While this book deals with AsteriskNOW—aimed to provide a simple, fast solution for managing the Asterisk Open Source PBX—it does so without getting into the inner workings of Asterisk's configuration files. Additional information about the configuration files, their format, usage, and various available options is available at the voip-info wiki, located at: http://www.voip-info.org/wiki/view/Asterisk+config+files.
Manually editing AsteriskNOW dial-plan files isn't recommended; however, in some extreme situations it can't be avoided (especially while creating special applications with AsteriskNOW). For this specific reason, AsteriskNOW includes a facility to edit the configuration files manually. Click the File Editor menu option; the following screen should appear:
The extensions.conf file should interest you. Using the drop-down file selector, select the extensions.conf file for editing. The following screen should be observed:
Now, if you were to click one of the lightly-shaded areas (light green on your screen); a text editing box will open to enable you to edit the file.
You're probably wondering at this point—"where is routing logic located?" Scroll down the file and seek the section designated as numberplan-custom-1, which designates your DialPlan1 dial plan. If you were to create an additional dial plan using the GUI, its designation in the extensions.conf file would be numberplan-custom-2.
Examine the following section:
In the above section lines indicated by the exten directive, indicate a dial-plan activity. The exten directive is then followed by some form of well formatted number string, followed by a number indicating the sequence number of the directive, then followed by an Asterisk operational command—in our case, the Macro command.
Asterisk and AsteriskNOW include over 150 different applications; explanation of each and every application is beyond the scope of this book. Visit the Asterisk Wiki page at http://www.voip-info.org/wiki/index.php?page=Asterisk for more information about Asterisk and AsteriskNOW applications.
The way the dial plan analyzes dialed numbers is explained next. Consider one of the dialing rules:
The interesting portion of this line is the _9XXX!. The following is an extract from an Asterisk documentation:
; Extension names may be numbers, letters, or combinations
; thereof. If an extension name is prefixed by a ‘_'
; character, it is interpreted as a pattern rather than a
; literal. In patterns, some characters have special meanings:
; X - any digit from 0-9
; Z - any digit from 1-9
; N - any digit from 2-9
; [1235-9] - any digit in the brackets (in this example, 1,2,3,5,6,7,8,9)
; . - wildcard, matches anything remaining (e.g. _9011. matches
; anything starting with 9011 excluding 9011 itself)
; ! - wildcard, causes the matching process to complete as soon as
; it can unambiguously determine that no other matches are possible
; For example the extension _NXXXXXX would match normal 7 digit dialings,
; while _1NXXNXXXXXX would represent an area code plus phone number
; preceded by a one.
; Each step of an extension is ordered by priority, which must
; always start with 1 to be considered a valid extension. The priority
; "next" or "n" means the previous priority plus one, regardless of whether
; the previous priority was associated with the current extension or not.
; The priority "same" or "s" means the same as the previously specified
; priority, again regardless of whether the previous entry was for the
; same extension. Priorities may be immediately followed by a plus sign
; and another integer to add that amount (most useful with ‘s' or ‘n').
; Priorities may then also have an alias, or label, in
; parenthesis after their name which can be used in goto situations
As this text suggest, the underscore marking (_) indicates the start of a pattern matching rule. This is then followed by a form of expression indicating the pattern to match. In the example, the pattern match is _9XXX!, so, interpreting this according to the documentation:
- _9: Indicates any number that is prefixed with the digit 9. This corresponds to the first routing rule.
- XXX: Indicates 3 digits, ranging from 0 to 9. This corresponds to the second portion of the routing rule.
- !: Indicates to match as soon as there is no other rule that may apply, thus closing the matching process.
For example, in accordance to the above points, the number 912345 will match the rule indicated above and will simply activate the Macro application. However, bearing in mind that the routing requires at least 3 digits to follow the prefix, the number 912 will not match our above routing rule.
At this point, the working of the Macro application is not explained; however, the empirical knowledge of its existence is enough.
In this article you learned what routing rules are and how they are processed within the AsteriskNOW operational model. Understanding the way routing rules work is imperative to configure your PBX for optimal usage of outbound connections.
|A practical guide for deploying and managing an Asterisk-based telephony system using the AsteriskNOW Beta 6 software appliance|
eBook Price: $23.99
Book Price: $39.99
About the Author :
Nir Simionovich has been involved with the Open Source community in Israel since 1997. His involvement with the Open Source community started back in 1997, when he was a student in the Technion—Israel’s Technology Institute—in Haifa. Nir quickly became involved in organizing Open Source venues and events, promoting the usage of Linux and Open Source technologies in Israel.
In 1998, Nir started working for an IT consulting company (artNET experts Ltd), where he began to introduce Linux-based solutions for enterprises and banks. By the year 2000, Nir had become a SAIR/GNU certified Linux trainer and administrator, slowly educating the future generations of Linux admins.
In 2001, Nir moved to the cellular content market, working for a mobile content delivery company (m-Wise Inc.—OTC.BB: MWIS.OB). During his commission at m-Wise, Nir successfully migrated a company that was built purely on Windows 2000 and ColdFusion to open source technologies, such as Mandrake Linux (today Mandriva), Apache Tomcat, and Kannel (open source SMS/WAP gateway).
Coming to 2006, Nir had co-founded Atelis (Atelis PLC—AIM: ATEL). Atelis is a Digium distributor and integrator. During the course of 2006, Nir developed an Asterisk-based international operator services platform for Bezeq International, which replaced a Nortel DMS-300 switch. This platform is currently in use by Bezeq International in Israel, serving over 4000 customer a day.
In mid 2007, Nir left Atelis to become a freelance Asterisk promoter and consultant. Nir is currently providing Asterisk consulting and development services for various companies, ranging from early-stage start-up companies, through VoIP service providers and VoIP equipment vendors. In his spare time, Nir is the founder of the Israeli Asterisk users group, the website maintainer of the group, and an Asterisk developer, dealing mainly with the localization aspects of Asterisk to Israel.
Coming to 2008, Nir's company (Greenfield Technologies Ltd) won the Digium Innovation award at AstriCon 2008, in the pioneer division—for its implementation of a phone-based prayer system, allowing people from around the world to pray at the western wall in Jerusalem.
Books From Packt