login | register
Wed 01 of Aug, 2007 [09:21 UTC]

voip-info.org

Search with Google
Search this site with Google. Results may not include recent changes.

Web www.voip-info.org
Shoutbox
  • Aykut, Wed 01 of Aug, 2007 [07:53 UTC]: Hi all, does anybody know about Thomson ST2030 SIP phone. I have upgraded it to latest version (1.56) but "Hold" and "Conf" features are not working after the upgrade ?? Do you know any solution or do you have Ver. 1.52 ?? Where can I find it?
  • Edward J Brown, Tue 31 of Jul, 2007 [23:33 UTC]: Has anybody experienced Choppy voice quality when using a Linksys SPA942 in an Asterisk Conference bridge? It works fine with my polycom and Cisco, but sucks with my Linksys.
  • www.astawerks.com, Fri 27 of Jul, 2007 [18:00 UTC]: does anyone use asterisk on top of clark connect? does it work good?
  • simon, Fri 27 of Jul, 2007 [14:16 UTC]: Hi All, Has anyone here managed to get the Cisco79x1 to successfully fail over to the backup proxy. I have 2 asterisk servers , handsets all register and function, except that backup proxy function doesn't work. Any working example would be very apprecia
  • Matthew Richmond, Thu 26 of Jul, 2007 [03:40 UTC]: using the page() application to page across our building...often the meetme conferences don't disconnect after the caller hangs up. Anyone else having this problem. (using Polycom phones)
  • Matthew Richmond, Wed 25 of Jul, 2007 [02:58 UTC]: thanks Nicholas Blasgen! I haven't worked with AGI before, but there's always a first! Thanks again!
  • Nicholas Blasgen, Tue 24 of Jul, 2007 [19:18 UTC]: Matthew Richmond, AGI will handle all that for you.
  • sam, Mon 23 of Jul, 2007 [16:39 UTC]: need help - certain voicemail extension will stop working and recording voicemail on asterisk - anyone know why and how to fix it? Thanks
  • john haji, Mon 23 of Jul, 2007 [14:55 UTC]: free calls to pakistan
  • bong, Sat 21 of Jul, 2007 [19:09 UTC]: hi good day to all can anyone help me how to configured the nortel sip to the signaling server and how to activate in mobile w/ sip compatible without mcs
Server Stats
  • Execution time: 0.39s
  • Memory usage: 2.22MB
  • Database queries: 29
  • GZIP: Disabled
  • Server load: 2.28

Application LCDial

Application LCDial() - Least Cost Dial

Synopsis

Does a mysql Database lookup to find the cheapest Provider for a given destination number, and than it invokes the dial command. If the channel is unavailable then it will fall back to the next configured Provider.

Description

  • LCDial(number to dial,timeout,options,URL) — dial one channel

Parameters:

  • number to dial specifes the number which should get dial.
  • all other options are the same as within the standard Asterisk cmd dial command (the are directly passed to the dial comand)

Return codes

Behaves exactly like Asterisk cmd dial

Example:
exten => 4000,1,LCDial(${EXTEN},15)

mysql Database Layout

tabledescription
providerInformations about each Provider (name,id,dialstr,status)
providerdestinationWhich destinations (countryprefixid) are available with which provider
providerrateThe tariffrate for the given provider / destination
countryprefixTable with dial codes
countryoptional - not really needed - but if you want to have nice names for the countries



CREATE TABLE `countryprefix` (
 `countryprefixid` int(11) NOT NULL auto_increment,
 `prefix` text NOT NULL,
 `countrycode` char(3) default NULL,
 `subcode` varchar(10) NOT NULL default '',
 PRIMARY KEY  (`countryprefixid`)
) TYPE=MyISAM;

CREATE TABLE `provider` (
 `providerid` int(11) NOT NULL auto_increment,
 `providername` text NOT NULL,
 `dialstr` varchar(200) NOT NULL default '',
 `status` tinyint(3) unsigned NOT NULL default '0',
 PRIMARY KEY  (`providerid`)
) TYPE=MyISAM;

CREATE TABLE `providerdestination` (
 `providerdestinationid` int(11) NOT NULL auto_increment,
 `countryprefixid` int(11) NOT NULL default '0',
 `providerid` int(11) NOT NULL default '0',
 PRIMARY KEY  (`providerdestinationid`)
) TYPE=MyISAM;

CREATE TABLE `providerrate` (
 `providerrateid` int(11) NOT NULL auto_increment,
 `providerid` int(11) NOT NULL default '0',
 `countryprefixid` int(11) NOT NULL default '0',
 `rate` double NOT NULL default '0',
 PRIMARY KEY  (`providerrateid`)
) TYPE=MyISAM;

CREATE TABLE `country` (
 `countrycode` char(3) default NULL,
 `countryname` text NOT NULL,
 `countryid` int(11) default NULL
) TYPE=MyISAM;


Configuration

LCDial needs a configuration file called lcdial.conf in the standard asterisk configuration directory.
Example Configuration:

global
hostname=localhost
dbname=asterisk
user=asterisk
password=asterisk
port=3306

sql
getproviders=SELECT providerrate.rate, dialstr, countryprefix.countryprefixid, provider.providerid, provider.providername FROM countryprefix LEFT JOIN providerdestination USING ( countryprefixid ) LEFT JOIN provider USING ( providerid ) LEFT JOIN providerrate ON concat( provider.providerid, countryprefix.countryprefixid ) = concat( providerrate.providerid, providerrate.countryprefixid ) WHERE prefix = substring( '%s', 1, length( prefix ) ) AND provider.status=0 ORDER BY length( prefix ) DESC , providerrate.rate ASC


Get it

Here <- Here you will find the new version which is now based on MysqlPool - please take a look at the documentation.

Compile It

It assumes that the asterisk sources can be found at /usr/src/asterisk, that the asterisk modules directory is at /usr/lib/asterisk/modules and that the asterisk configuration is at /etc/asterisk/.
For compiling it you need to have already installed asterisk ;-) - and the mysql client libary and header files.
From asterisk stable to asterisk cvs head the channel structure has changed a little bit - so if you want to compile against asterisk stable then you have to comment this "CFLAGS+=-DUSE_CVS" line to get it to compile (else you would get an error like "error: structure has no member named `cid'"

Help

If you are having trouble getting the application up and running and need professional help, feel free to drop us a line at support@yosd.at

Management Interface

If you are looking for a management frontend or a turn-key-solution please get in touch with us: support@yosd.at



A modified version of LCDial() which uses REGEXP prefix and only 2 simple tables

LCDial is very powerful and versatile solution for least cost routing, because it get information about routing from database using only one SQL statement which is defined in lcdial.conf configuration file.
I've modified the original SQL query to use only two tables:
  • lcdial_providers, within the provider name, dial string, and a flag to enable/disable it
  • lcdial_rates, within the regexp prefix, provider name, rate, and a comment
In this way is very very simple to compile the LCR database by hand, using phpmyadmin or other tool: you can compile a complete lcdial_rates table with several provider costs, and enable only the providers you want into lcdial_providers table.
lcdial_providers table structure/example
id provider dialstr enabled
1fastwebZap/g1/%s|401
2freevoipIAX2/freevoip/%s|200
3wind-leonardoSIP/%s@100|401
4voipvoiceIAX2/voipvoicenumber/%s|401

lcdial_rates table structure/example
prefixproviderratenote
^005521freevoip0.03brazil rio de janeiro
^32.......wind-leonardo0wind cellulars
^3[3469].......wind-leonardo0.06italian cellulars (not wind)


When LCDial(number,options) is called, the LCDial application perform a regular expression search into lcdial_rates, and order all records by expression length, taking only one record per provider, then sort by cost.
In this way I can, for example, add records like
^00393[234689] to match italian cellular phones
^0039 to match all italian phones but not italian cellulars, because they will match the previous rule

You'll find this customized version of LCDial() into www.creasol.it/unix/lcdial-psubiaco.tgz within an example of database (file doc/sample2.sql).
If you add rates information to the provided database, please send the modification to psubiaco@creasol.it so they will be added to the lcdial-psubiaco.tgz archive.



See also


Asterisk | Asterisk cmd dial
Created by wuwu, Last modification by wuwu on Thu 07 of Dec, 2006 [10:13 UTC]

Comments Filter

very wrong code

by Dringme on Saturday 10 of June, 2006 [02:17:28 UTC]
  1. 1 the sql command in the distro is bad.. talks about tarrif's instead of providers.

then #2..

un 9 22:11:40 DEBUG58317 config.c: Parsing /usr/local/etc/asterisk/lcdial.conf
Jun 9 22:11:40 DEBUG58317 app_lcdial.c: LCDial: got hostname of localhost
Jun 9 22:11:40 DEBUG58317 app_lcdial.c: LCDial: got port of 3306
Jun 9 22:11:40 DEBUG58317 app_lcdial.c: LCDial: got user of bob
Jun 9 22:11:40 DEBUG58317 app_lcdial.c: LCDial: got dbname of cdr
Jun 9 22:11:40 DEBUG58317 app_lcdial.c: LCDial: got password of SOMETHINGSECRETIWOTPOSTHERE
Jun 9 22:11:40 DEBUG58317 app_lcdial.c: LCDial: got getproviders query of 'somecustomized SQL string'
Jun 9 22:11:40 WARNING58317 app_lcdial.c: LCDIAL using database 'cdr'.
Jun 9 22:11:40 DEBUG58317 app_lcdial.c: LCDial: Successfully connected to database 'cdr@localhost'.


right ?

WRONG.. LCD still tryed asterisk DB..

check this log.


Jun  9 22:16:24 DEBUG58317 app_lcdial.c: LCDial:  FATAL DB ERROR AT QUERY: SELECT THISISJUSTTHESQLSTRING - 
(Table 'asterisk.cdr' doesn't exist)


NOW.. WHY it tries asterisk DB is out of hands.. the defaults have been changed.. no where in code i see reference to it.. it still does..


by Dringme on Friday 09 of June, 2006 [21:29:27 UTC]

Re: No time-based tarriffs

by C. on Saturday 03 of June, 2006 [18:05:01 UTC]
I've got complete and 95% production ready patches for this if anyone is running PostgreSQL :) I'm also willing to tweak for those who need time-based and or other features/more performance. cbergstrom {åt] netsyncro döt com

How to deal with LCDial not finding a provider

by Gabriel Afana on Saturday 11 of March, 2006 [23:48:00 UTC]
In the event a number is dialed and LCDial cannot find a provider, it skips to n+101. However, there is no direct info indicating the problem (DIALSTATUS is always blank in this case). Here is a little snippet that will set DIALSTATUS to "NOPROVIDER" if the call fails because LCDial could not find a provider:

exten => s,s+101,Set(DIALSTATUS=${IF($ ${ISNULL(${DIALSTATUS})}=1 ?"NOPROVIDER":${DIALSTATUS})})


Compiling on Fedora Core 4

by Digi on Friday 13 of January, 2006 [13:30:33 UTC]
Just a note when compiling LCDial on FC4 you will need to move the line #include <stdio.h> to be the first include above #include <asterisk/lock.h> in the filename app_lcdial.c file otherwise LCDial will not compile.

Compiling on Fedora Core 4

by Digi on Friday 13 of January, 2006 [13:29:42 UTC]
Just a note when compiling LCDial on FC4 you will need to move the line #include <stdio.h> to be the first include above #include <asterisk/lock.h> in the filename app_lcdial.c file otherwise LCDial will not compile.

No time-based tarriffs

by Matthias Urlichs on Saturday 09 of April, 2005 [14:13:59 UTC]
In Germany, "which provider is cheapest" changes, depending on which day it is (or even time-of-day).

Unfortunately this tool can't process this.

Please update this page with new information, just login and click on the "Edit" or "Add Comment" button above. Get a free login here: Register Thanks! - support@voip-info.org

Page Changes | Comments

Sponsored by:

Terms of Service Privacy Policy
© 2003-2007 Arte Marketing, Inc.

Powered by bitweaver