login | register
Sat 17 of May, 2008 [06:32 UTC]

voip-info.org

Search with Google
Search this site with Google. Results may not include recent changes.
 
Google Ads
Shoutbox
  • Juan Ortega, Thu 15 of May, 2008 [10:33 UTC]: Hi everybody, I'm Juan, an ITCom student, and I need to know what basic elements I need to create a VoIP network. Can anybody helpme, please?,Thank you very much
  • gineta, Wed 14 of May, 2008 [03:58 UTC]: any here not fine the configuration of firewall juniper -screem for VOIP asterisk????
  • Anoop Prabhakaran, Tue 13 of May, 2008 [12:16 UTC]: I am developing Asterisk IVR, Whenever i make a internation call to the IVR system, the DTMF is not getting detected properly, this happens only for the first time, second call onwards system works fine. why this is happening
  • joe, Mon 12 of May, 2008 [04:27 UTC]: Is there an opensource browser based softphone, or a system like Busta where everything is not manages through their website?
  • Nick Barnes, Fri 09 of May, 2008 [11:36 UTC]: Christopher - yesterday I tried an Asterisk install on a CentOS 5.1 box with stock GUI and it all worked fine. Sorry I can't help.
  • aero, Fri 09 of May, 2008 [08:20 UTC]: can someone help me out on this, i tried to play some sound files on my asterisk box and this is the error message i got. WARNING[4429]: format_wav.c:169 check_header: Unexpected freqency 22050 May 8 11:17:39 WARNING[4433]: codec_gsm.c:194 gsmtolin_fra
  • Christopher Faust, Thu 08 of May, 2008 [14:15 UTC]: I beleive that I may have to change something in the xserver configuration. Please advise
  • Christopher Faust, Thu 08 of May, 2008 [14:14 UTC]: Everything was perfect. In the bios I have increased the memory allocated Still receive input not supported on my display.
  • Christopher Faust, Thu 08 of May, 2008 [14:13 UTC]: This would not be my main box. I am doing some testing to see if I can install zaptel and asterisk 1.4 on a full centos 5.1 box with development software Its bizzare, because before I went through the asterisk and zaptel installation everything was perfe
  • Nick Barnes, Thu 08 of May, 2008 [13:44 UTC]: Christopher - I can't see any way in which an Asterisk installation would muck your GUI, but remember that it is advised not to use a GUI on an Asterisk box anyway.
Server Stats
  • Execution time: 0.43s
  • Memory usage: 2.23MB
  • Database queries: 33
  • GZIP: Disabled
  • Server load: 0.25

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-2008 VOIP-Info.org LLC

Powered by bitweaver