login | register
Fri 05 of Sep, 2008 [23:42 UTC]

voip-info.org

Discuss [10] History

Asterisk billing

Created by: oej,Last modification on Thu 29 of May, 2008 [09:53 UTC] by JustRumours

Asterisk CDR Fields


Asterisk generates a CDR (Call Detail Record) for each call. By default, records are stored in comma-separated value file will be created in /var/log/asterisk/cdr-csv. You can specify account codes and AMA (Automated Message Accounting) flags on a per-channel (Zaptel et al) or per-user (IAX, SIP) basis to help with accounting. Look at the top of cdr/cdr_csv.c to see the format for the records.



Fields

  1. accountcode: What account number to use: Asterisk billing account, (string, 20 characters)
  2. src: Caller*ID number (string, 80 characters)
  3. dst: Destination extension (string, 80 characters)
  4. dcontext: Destination context (string, 80 characters)
  5. clid: Caller*ID with text (80 characters)
  6. channel: Channel used (80 characters)
  7. dstchannel: Destination channel if appropriate (80 characters)
  8. lastapp: Last application if appropriate (80 characters)
  9. lastdata: Last application data (arguments) (80 characters)
  10. start: Start of call (date/time)
  11. answer: Anwer of call (date/time)
  12. end: End of call (date/time)
  13. duration: Total time in system, in seconds (integer), from dial to hangup
  14. billsec: Total time call is up, in seconds (integer), from answer to hangup
  15. disposition: What happened to the call: ANSWERED, NO ANSWER, BUSY, FAILED (on some CDR backends, e.g. ODBC, these may be integers; note that more detailed info can be found in the dialplan variable $HANGUPCAUSE)
  16. amaflags: What flags to use: see amaflags: DOCUMENTATION, BILLING, IGNORE etc, specified on a per channel basis like accountcode.
  17. user field: A user-defined field, maximum 255 characters

In some cases, uniqueid is appended:
  • uniqueid: Unique Channel Identifier (32 characters)


Asterisk CDR Storage Methods



Account codes and flags are set in the various channel configuration files or in the extension definition in extensions.conf.

Applications



Limitations

  • A CDR record will not be created if you use a .call file that calls an application instead of an extension. Workaround: Use an extension that then starts the desired application. See also: Bug report 240
  • You can't use exten => h, if you have any hope of getting accurate billing info. Its wise to call ResetCDR(w) in your exten => h, or not use it at all.

Important note on transfers

In general: As soon as transfers (or parked calls that were resumed) come into play, be it attended, blind or through SIP REFER, it is very likely that you will end up with incorrect and misleading CDR data; see bug 11093 and CDR behaviour changes in 1.4.

IAX: If you are trying to collect records on IAX to IAX calls you need to be aware that by default, IAX will attempt to transfer calls in this situation (if DTMF is not required). When the transfer is completed the call is dumped from the middle machine and thus the call detail records will report a short call time. If you want detailed records you must turn off IAX transfer (transfer=no in 1.4 or notransfer=yes in 1.2), but unless your servers are very close together, you will definitely get a latency hit from doing so.

Background info on confusing CDRs

The core of Asterisk is a threading model but a very conservative one. Only origination channels and channels executing an application have threads. The B leg of any call operate only within the same thread as the A leg and when something happens like a call transfer the channel must first be transferred to a threaded mode which often times includes a practice called channel masquerade, a process where all the internals of a channel are torn from one dynamic memory object and placed into another. A practice that was once described in the code comments as being “nasty”.

The same went for the opposite operation the thread was discarded by cloning the channel and letting the original hang-up which also required hacking the cdr structure to avoid seeing it as a new call. One will often see 3 or 4 channels up for a single call during a call transfer because of this.

For Asterisk 1.6 (or later) we might see a completely re-designed method to generate and store CDR data.

Least cost routing (LCR)

Especially for EU countries and small offices/home offices: Since the introduction of Call-By-Call (and Carrier Pre-selection) things have become both a lot cheaper and more complicated. The VoIP providers that offer IP-to-phone services add to the complexity of finding the cheapest route for a call. Finally there's the emerging ENUM system.
Implementing LCR functionality in Asterisk can be accomplished without too much effort using AGI and a mySQL backend
  • Application LCDial Asterisk third-party add-on. Adds LCDial() command, which is just like Dial() but looks up the dialed number in a database, to find a dial-string for that destination.
  • LCR tool for i4l: Collection of LCR a variety of LCR tools for Asterisk, i4l etc
  • cnum.info realtime Call-by-Call rates for the german market provided as ENUM service
  • ZIDial Adds ZIDial() command.Low cost routing with multiple redial (on each route), also multiple redial for multiple provider.


Pre-paid applications

If you have users that you have little or no contact with, or where fraudulent usage can be an issue, it might be worth looking at Pre-paid solutions. With the pre-paid model we need to access a users funds before the call is made in order to see how much cash is available for the call to be made. Next, once the call destination is known, we should start a timer to disconnect the call (or more userfriendly, interrupt the call with an announcement) and finally close the deal.

Some considerations when creating a calling card application:
  • take care of multiple calls using the same credentials (PIN or username)
  • the SIP protocol does not allow for recognition of a client that was disconnected
  • cut off the call when the credit has dropped to 0
  • the hard part is to correctly rate a call, e.g. attaching the correct tariff

See: Asterisk Prepaid Applications

Post-paid (billing)


The Call Detail Record
Asterisk generates CDR (Call Detail Records) that contain data about which extension made or received calls to or from which number for how long. These records are generally stored in plaintext logfiles located in /var/log/asterisk/cdr-csv, but can also be stored in PostgreSQL or (with the asterisk-addon package) MySQL databases.

Rating the CDR
Since Asterisk does not know about its location or the deals the machine has with Telco providers (your PSTN line or perhaps a VoipJet, NuFone, VoicePulse or IConnectHere account), so it cannot know the cost of each call. To solve this problem the CDR's need to be 'rated'. On each combination of parameters you could technically assign a buyers price and a sellers price. This process is generally called 'rating'.

Billing the users
Only when we have neatly rated CDR's the billing process can start, but this is now a reasonably simple process of accounting all prices linked to an account code or source or destination.

Software out there
There are probably some very decent commercial rating/billing packages out there, but only very few open source ones. Most notably there is Trabas Billing, however the Trabas company seems to be taking further development on the software back from the community.


PayPal - IPN - Subscription VoIP Billing Solutions


Asterisk Billing Resources

Free information, guides, and resources to help locate the best Asterisk Billing software for your company.


Streamco Switchboard

Free routing+billing VoIP system based on Asterisk. Suites well for reseller/wholesale and pc2phone business. User-friendly web interface. Flexible routing(lcr, code length, time of the  week, priorities...). Financial Module allows to automatically disable customers or end users basing on their balance. Accounting(payments,invoices) is tightly coupled with billing/routing. 
Real-time billing. Web interface allows to configure, check dialplan, view active calls and view statistics with selected granularity. High performance. Written in C++.



astCDRview:

astCDRview is an open source, licensed under GNU/GPL, lightweight, Web-based, multi-language Asterisk SQLite CDR viewer that supports multiple outgoing carriers, multiple incoming numbers, billing, an address book, and extensions



AstPP:

AstPP is not only a web-based, user friendly billing interface for Asterisk and VOIP. It is also provides a gui editor for REALTIME devices and dialplans. AstPP is Open Source and under constant development. Prepaid, Postpaid and Calling Cards supported as well as resellers, lcr, callbacks,etc.



CenIP SoftSwitch:

CenIP VirtualServer is a full-featured platform for VoIP billing. It provides routes/customers/devices gui manager with support for prepaid, postpaid, callingcard, resellers, lcr, dids and a lot more.


Cybex Development VoIP Billing System

Prepaid & PostPaid Included. Wholesale, End-User, Calling Cards.
We provide the lowest price.



MOR - advanced billing solution for Asterisk

User friendly/presentable billing. Huge amount of functions. LiveCD available.

Omniware Billing System

Operates a hosted billing system services for ITSPs and ISPs. Also offered as standalone product. Used in two deployments by Bell Canada, and designed to be very flexible.


YakaVOIP- Integrated web billing solution for Asterisk

YakaVOIP is a fully integrated, open-source -NOT FREE-, web-based, user friendly billing and administration interface for Asterisk and Voice-Over-IP. It leverages existing open-source technologies (Joomla, PHP, MySQL) and ecompases 3rd party payment gateways like Paypal, MyGate, Moneybookers & Google Pay.



Datatex Dynamics


Datatex has been developing software solutions for the telephony industry since 1999.
Topaz Next Generation (TNG)

TNG is the latest Telephone Management System (TMS) or billing system released.
The Asterisk version of TNG has the following features:
  • Generates a call record for each part of a transferred call. (e.g. call transferred 5 times will show 5 call records
with each party reported)
  • Calls transferred or forwarded to queues will properly show the extension the call ended up on.
  • Transferred unanswered calls properly identified.
  • Runs on Windows or Linux.
  • Connects to the standard Asterisk Manager Interface.
  • Report drill down from summary level to detailed calls.
  • Report scheduling to email reports automatically.

Super Technologies - VOIP Billing Solutions

^ Super Technologies has been in VOIP service since 1999. Was the first company
in the world to offer a DID number on a IP Device similar to vonage, and got an award
on the service from Internet Telephony Magazine and in the Internet Wrold Show in 2001.
With this experience and software in use for over 5 years now, they are now offering
the same software that they use for their own services, to the world to offer billing to their clients.

They have software for VONAGE Type Service, Net2phone and ip centrex services, sample are all working and live
you can check them out on www.phoneopia.com www.superphoneunlimited.com and ip-pabx.com

Web site for software is www.supertec.com/solutions/

Vidanetwork Technologies - VOIP Billing Solutions

http://www.vidanetwork.net - Powerful billing system that allows you to setup Pre-pay, Post-pay, metered Flat Rate billing plans for residential and Cooperations. Their scalable network management and billing system integrate multiple Asterisk call servers together to work like one system. The web-based solution has 4 levels of access interfaces: Administrator, Operator, VPBX admin, and End User Portal. It also offers Hosted Virtual PBX and Virtual Call Center solutions for offering services to business users. If you already have a Web page and a payment gateway account (like Paypal), they can also integrate them with their software, so that your customers could sign up your services from your web page and make payments online.

If you are service providers and would like to offer services to residential and business users, this is definitely the right solution for you!

Calls Professional for Asterisk PBX - InterAkt Co.

Calls Professional for Asterisk PBX - Calls Professional is a program suite, which is designed to manage call statistics and greater review in telephone network. It includes programs Asterisk CDR server and Calls Professional. CDR Server is used to collect data of calls from Asterisk PBX, user settings and program activity, Calls Professional is multi purpose / multi user program for reviewing, making print outs and export call reports. The latter possibility is to create own phone book, and includes a whole palette of other useful settings. Program packet is ideal expedient for traffic control in telephone network and control of expence in company or any other organization.


vspPanel - Integrated Asterisk Billing Solution & Control Panel

vspPanel - Asterisk Control Panel - vspPanel is a full control panel system for the Asterisk PBX and has been designed as a "VSP In A Box" solution, much like it's counterpart CPanel in the Web Hosting Industry vspPanel allows users to control all aspects of their Asterisk server from a web interface, along with call routing, adding of providers and customers and most importantly billing (Both Pre-paid and Post-Paid). vspPanel does not require any additional hardware and is already begining to be offered in Data Centers around the world as a VOIP Provider Hosted Solution, however it may be installed on any Linux Server along with Asterisk. vspPanel has been designed to allow any entreprenuer to become a VSP and offer VSP services to their customers and alleviates the need for an operator to be a "technical guru".

Current Status: Free Beta Available.

Screenshots of vspPanel in Action: http://www.vsppanel.com/screenshots.html

See also






Comments

Comments Filter
222

333Call Forwarding and CDRs

by chipus, Monday 23 of April, 2007 [14:13:36 UTC]

I have the same problem like with transfer when Call Forwarding is used.

Here is extract from my extensions.conf

macro-stdexten<br>
;
Standard extension macro (with call forwarding)
; ${ARG1} - Extension(we could have used ${MACRO_EXTEN} here as well
; ${ARG2} - Device(s) to ring
;

   exten => s,1,Set(temp=${DB(CFIM/1${MACRO_EXTEN})})
   ; Chech Unconditional Forward
   exten => s,n,GotoIf(${temp}?cfim:nocfim)
   exten => s,n(cfim),SetVar(CALLERID(num)=1${MACRO_EXTEN}) ; change CallerID
   exten => s,n,SetVar(CALLERID(name)=${MACRO_EXTEN}) ;
   exten => s,n,Dial(local/${temp}@${MACRO_CONTEXT}/n)   ; Unconditional
forward
   exten => s,n(nocfim),NoOp
   ; Check No Answer Forward
   exten => s,n,Set(temp=${DB(CFNOANS/1${MACRO_EXTEN})})
   exten => s,n,GotoIf(${temp}?cfnoans:nocfnoans)
   exten => s,n(nocfnoans),Dial(SIP/${MACRO_EXTEN},,tT)
   exten => s,n(cfnoans),Dial(SIP/${MACRO_EXTEN},15) ; 15sec timeout
   exten => s,n,GotoIf($${DIALSTATUS}=NOANSWER?noanswer:another)
   exten => s,n(noanswer),NoOp
   exten => s,n,Dial(local/${temp}@${MACRO_CONTEXT}/n) ; Forward on noanswer

A calls to B. On B is Call Forwarding Unconditional to C. A and C converse.
A: 13401539
B: 13401538
C: 3328130
In CDR I get two strings:

1."","13401538","3401538","full","""3401538""
<13401538>","SIP/3401539-08703000","Local/3328130@full-3b95,1","Dial","local/332
8130@full/n","2007-04-11 15:47:58",,"2007-04-11 15:48:00",2,0,"NO
ANSWER","DOCUMENTATION"
Like B called to B.
2. "","13401538","3328130","full","""3401538""
<13401538>","Local/3328130@full-3b95,2","SIP/217.199.224.24-0870d000","Dial","SI
P/3328130@217.199.224.24|90","2007-04-11 15:47:58",,"2007-04-11
15:48:00",2,0,"NO ANSWER","DOCUMENTATION"
Like B called to C

But really I want to get such strings:
1. A called to B.
2. B called to C.
222

333blind transfers and CDRs

by darencrew, Monday 12 of February, 2007 [18:29:00 UTC]
it seems that asterisk cdrs are inaccurate where using transfers

for example A calls B, B transfer the call to C, A and C converse then hang up

in CDR you have only one call from A to C, so if A and B are outside your network, and B is inside, so you should bill him, its transfered calls won't be billed because you have no trace of such calls; according to CDR these calls are outside calls to outside...

Do somebody have any idea on how to get rid of such problems

Thanks
222

333BILLING

by bader, Tuesday 13 of December, 2005 [01:13:38 UTC]
Can asterisk do billing??? For example, for a small telephone company in small town or a company providing a telephone service for a large apartment complex. ( about 1000 - 1500 clients)
222

333sunsaturn

by syle, Tuesday 15 of November, 2005 [10:27:27 UTC]
  • I would keep a close eye on this site:
  • Sunsaturn Asterisk Module
  • Its going to blow the socks off any of these other billing solutions.
  • This is being embedded directly into asterisk, No agi's, no overhead, complete speed!
  • Coder is very well known in the asterisk community.

222

333Hold Time

by , Friday 07 of January, 2005 [20:40:15 UTC]
Is there a way to see how long the call was holding for? For instance I would like to klnow how long a call has sat in my tech support queue before being answered.
222

333call quotas

by , Thursday 09 of December, 2004 [03:56:53 UTC]
My client (a students union0 needed to control calls from the students. The followng is a first cut at the dial plan...it works. The quotas are stored in mysql via a web app...

exten => 888,1,Playback(astcc-tone) ;
exten => 888,2,Authenticate(9955,a)
exten => 888,3,NoOp(${ACCOUNTCODE})
exten => 888,4,MYSQL(Connect connid localhost myusername xxxxxx astcc_user)
exten => 888,5,MYSQL(Query resultid ${connid} select\ bal-time_used\ "bal"\ from\ user\ where\ id\ ="${ACCOUNTCODE}")
exten => 888,6,MYSQL(Fetch more ${resultid} bal)
exten => 888,7,GotoIf($${more} != 1?8:6)
exten => 888,8,MYSQL(Clear ${resultid})
exten => 888,9,GotoIf($[${bal} 888,10,Dial(IAX2/guest@misery.digium.com/s@default,,gL(${bal}:6000:3000))
exten => 888,11,GotoIf($"${ANSWEREDTIME}" != ""?13) ;skip over next line if ANSWEREDTIME not null
exten => 888,12,SetVar(ANSWEREDTIME=0); if ANSWEREDTIME is null set it to 0
exten => 888,13,MYSQL(Query resultid ${connid} update\ user\ set\ time_used\ =time_used+${ANSWEREDTIME}\ where\ id\ ="${ACCOUNTCODE}")
exten => 888,14,Goto(16); skip over next line from here
;got to this line only if not enough minutes
exten => 888,15,Playback(astcc-notenough) ; not enough to make call
exten => 888,16,MYSQL(Disconnect ${connid})



222

333Mysql with Asterisk

by , Thursday 08 of July, 2004 [14:25:59 UTC]
Hi, I`m from Brazil, and I have a Red Hat 9 instaled in my server, and I install the Asterisk, but I would like to use the MySQL for autentication, how can I do this????

I have instaled the Mysql 4.0, mysql-devel, mysql-client, phpmyadmin2.5.7.

Please urgent!!!
222

333How to enable storing of the field UniqueID

by , Wednesday 10 of December, 2003 [19:08:19 UTC]
What would I need this for? For example you are running an AGI script and would like to be able to related AGI data with the CDR table. The problem is that the AGI script will lose connection to the call as soon as the caller hangs up, so you'll need a way to find the correct cdr entry (that'll also be created only after the call has been completed).

Q: It would appear that the "uniqueid" field is not being populated in the MySQL CDR DB.. Is this an obsolete field or is a bug?

A: You need to define MYSQL_LOGUNIQUEID at compile time for it to use that field.

You have two options in /usr/src/asterisk-addons:
1. Add a CFLAGS+=-DMYSQL_LOGUNIQUEID to the Makefile.
2. Add a #define MYSQL_LOGUNIQUEID to the top of the sourcefile.

Finally perform the usual make clean, make, make install. Be sure to check the Makefile for the presence of this flag after having done a CVS update!

222

333AMAFLAGS values

by , Tuesday 02 of December, 2003 [12:31:59 UTC]
AMA flags affects the recording of Call Detail Records. If specified it may be:

default
omit
billing
documentation

222

333See also: Authenticate()

by , Tuesday 02 of December, 2003 [12:29:48 UTC]
Authentiacte offers the a option to set an account code, example:

Authenticate(1234|a)