Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering FreeSWITCH

You're reading from   Mastering FreeSWITCH Advanced tips and tricks for advanced multimedia communication

Arrow left icon
Product type Paperback
Published in Jul 2016
Publisher Packt
ISBN-13 9781784398880
Length 300 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Authors (8):
Arrow left icon
Darren Schreiber Darren Schreiber
Author Profile Icon Darren Schreiber
Darren Schreiber
Russell Treleaven Russell Treleaven
Author Profile Icon Russell Treleaven
Russell Treleaven
Kalyani Kulkarni Kalyani Kulkarni
Author Profile Icon Kalyani Kulkarni
Kalyani Kulkarni
Seven Du Seven Du
Author Profile Icon Seven Du
Seven Du
Charles Bujold Charles Bujold
Author Profile Icon Charles Bujold
Charles Bujold
Ken Rice Ken Rice
Author Profile Icon Ken Rice
Ken Rice
Florent Krieg Florent Krieg
Author Profile Icon Florent Krieg
Florent Krieg
Mike Jerris Mike Jerris
Author Profile Icon Mike Jerris
Mike Jerris
+4 more Show less
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Typical Voice Uses for FreeSWITCH 2. Deploying FreeSWITCH FREE CHAPTER 3. ITSP and Voice Codecs Optimization 4. VoIP Security 5. Audio File and Streaming Formats, Music on Hold, Recording Calls 6. PSTN and TDM 7. WebRTC and Mod_Verto 8. Audio and Video Conferencing 9. Faxing and T38 10. Advanced IVR with Lua 11. Write Your FreeSWITCH Module in C 12. Tracing and Debugging VoIP 13. Homer, Monitoring and Troubleshooting Your Communication Platform Index

Accounting and billing

In telecommunications (and probably everywhere), accounting and billing are two separate logical entities, although there are cases (for example, real-time prepaid accounts) where they happen together and are strictly intertwined.

Accounting is keeping a tab on who gets what, for example, what metered services a user accessed, when the user accessed them, for how much time, and so on. Particularly, in telephony, which calls were made to what numbers, for how long, for each customer. This process involves generating and managing Call Detail Records (CDRs) for each and every call, where all the above details and much more are stored and can be retrieved. CDRs are also a precious source of debugging and troubleshooting information, allowing for the identification of which problems affected failed or low quality calls.

On the other hand, billing involves operating on the customer account, adding or subtracting "credits" related to the cost of the services accessed, with costs calculated based on unitary prices that can depend on multiple variables (from which prefix to which prefix a call was made, how long it lasted, at which time of day it was made, which route was chosen to connect it to the remote party, and so on). Also, in the case of prepaid credits and calling cards, there is often a requirement to not allow customers to access services after their credits expire, for example, if they have 10USD on account and the call costs 2USD/min, then after 5 mins the call has to be interrupted (perhaps with a message about how to top up the account). Cost calculation is often referred to as "rating," while the gathering of CDRs and their conversion into a uniform format ready to be rated is called "mediation."

Call Detail Records (CDRs)

FreeSWITCH has plenty of flexibility for CDR generation, in subtle and varied ways so as to accommodate all kind of operations, and provide this foundation layer for every business model.

Default CDRs are generated by FS's mod_cdr_csv as rows in files containing Comma Separated Values (CSVs). We can choose to keep track of the caller side (A leg), the callee side (B leg), or both (AB). For each leg we can have a row in the Master.csv, one in the specific caller CSV file, and/or one row in the specific callee CSV file.

The format and contents of those rows are defined by templates that allow us to record whatever mix of variables is suitable for our operation and business model, from any kind of timers (total duration, duration after answer, billable duration, and so on), to origination and destination numbers, time of day / day of week, individual account ID, company account ID, and so on.

There are various templates ready made in the FS distribution, among them one that generates CDRs in the same format generated by Asterisk (so to leverage legacy billing systems), and another one that generates files containing rows of SQL inserts, ready to be piped to a database client for further usage.

Another possibility for CDR generation (instead of or in addition to CSV files) is implementing mod_cdr_xml. Using XML allows for much more structured information to be put in the records, and can be sent real live via POST or GET to an HTTP server (which may itself enter rows into various database tables).

Mod_nibblebill / CGrateS

FreeSWITCH contains built-in modules to assist in real-time rating and credit management. Unique to FreeSWITCH is the ability to provide these services real time in a lightweight manner. With its multi-threaded design, billing and rating can be done on each leg of a call easily with different rates for each party, in addition to rates which might vary based on the selected carrier, time of day, number of calls currently active, or other such data.

One such module within FreeSWITCH that assists in this process is mod_nibblebill. A simple module at its core, nibblebill hooks into the heartbeat features FreeSWITCH provides for every leg of a call. On each heartbeat, nibblebill provides quick mathematical calculations about whether there are enough funds remaining to continue the call and logs to a database that the call has continued and to immediately deduct additional credit. This module is fairly lightweight for small to medium system capacity and can be expanded in larger systems by using basic database technologies already available. In addition, anyone who can program a database can program an interface to manage adding, subtracting, and tracking monetary value from a customer's account in conjunction with mod_nibblebill. This makes implementing the basics of a billing system easy. You can find many more details about mod_nibblebill in another Packt Publishing book, FreeSWITCH 1.2.

When combined with CDRs, you can also pair accounting and historical data with each call. This allows for a complete picture of billed services to a customer.

Other real-time tools exist such as Carrier-Grade Rating System, CGRateS, which links to FreeSWITCH and watches calls real time as they progress. Using FreeSWITCH's powerful event system, CGRateS monitors and manages calls as they happen and records data about the calls for reconciliation. CGRateS is an independent, open-source project, but is linked closely to the FreeSWITCH system for real-time handling of events happening on the switch, both as billing, anti-fraud, LCR, and thousands other features. CGRateS project developers are available for custom installation and implementation of complete solutions. On top of CGRateS engine, VoIPtology has developed CGRBilling, a commercial packaged solution with Web interface.

Other billing options (open source - commercial)

Many rating and billing systems exist out there, designed for the whole telecommunication market, or specifically for FreeSWITCH. That's because the entire telecom industry, since inception, has been the buyer and the research sponsor on billing systems. You can say that many computer advancements as a whole where targeted to advance telecom's billing systems.

Most of the industry relies on offline management of CDR files that are normalized, inserted into a database, and then massaged following business rules to obtain the single customer's bill for the period. With the advent of web interfaces that allow the customer to verify their own account in almost real time, the management flow cycle for CDRs has been shortened to be almost instantaneous, albeit still file-based. An open source, mature, and industrial grade example of this approach is JBilling.

On the other side, real-time billing open source applications are, in addition to the aforementioned CGRateS, ASTPP (complete solution, billing, rating, crm, lcr, and so on), Vbilling (complete solution, integrated with switch management), Viking (expanded from wholesale to cover retail too).

All of these open- source solutions are available with commercial support and backing, and by the time you're reading this book, a billing solution will probably be available for FusionPBX, the open source GUI for the management of FreeSWITCH.

Many pure commercial solutions and services are available, both as software install and as cloud services. Please check FreeSWITCH online documentation for an updated list.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at R$50/month. Cancel anytime