CGRates RALs Service

CGRateS Rating Services (RALS)

This is a quick introduction to the CGRates RALs service.

As the primary purpose of CGRateS is telecoms rating, this is probably the most important service on the system. This service performs rating and applies the results of that rating to balances. For instance, for prepaid calls, it can rate the calls and deduct customer balances.


RALs supports both pre-paid and postpaid rating, and can be used for online, real-time rating, or for offline rating.

It can perform rating using CDRs, in conjunction with the CDR Server service, or it can be driven directly from external systems in real time using a Session Manager service. There are pre-defined session managers to support real-time rating from the following products:

  • Kamailio
  • Asterisk
  • Freeswitch
  • OpenSIPs
  • Generic

There is also a Diameter agent that supports interfacing Diameter Credit Control clients to CGRateS. Rating can also be driven by directly calling the CGRateS API.


CGRateS maintains accounts and balances. Multiple balances can be maintained for an account, and these can be unit based or monetary based, and can support different types. As an example, one balance could be monetary and used for calls, whilst another could be unit based for SMSs. This flexibility allows complex bundles and packages to be defined.

When calls are rated, they are matched to an account and the appropriate balance is then debited. For prepaid billing CGRateS will not allow the balance to go below zero. If a request is made which would result in the balance going below zero, the request will fail and CGRates will pass this back to the calling client (e.g Asterisk). Normally this will then be used by the client to deny further use of the service.


Triggers are an additional capability provided by the RALs service. Triggers are actions that will be executed based on account counters reaching defined thresholds. This can be used for fraud detection, quality of service alerting, and many other advanced applications.

These triggers include:

  • A balance going above or below a defined threshold
  • Answer/Seize Ratio (ASR) going above or below a defined threshold (e.g. for a route)
  • Total call duration (TCD) going above or below a defined threshold

The CGRates Action Triggers documentation lists all of the trigger types. Each trigger has an associated Action which defines what should happen when the trigger threshold is reached. Actions which can be taken include:

  • Add or debit an account’s balance
  • Send an HTTP request to an external server
  • Log the action

Actions are defined within an Action Plan, and the foll list Action types and their parameters can be found in the CGRateS Actions documentation.


The RALs service also performs LCR support functions. This is a natural fit for a rating engine because the cheapest route can be determined in real time. Note that, whilst the RALs service can determine the cheapest route based on tariff tables, it cannot directly take routing decisions, as it is not in control of routing. Instead it passes a string parameter back to the routing engine (e.g. Kamailio, Freeswitch, etc.) which can then use that string in it’s routing plan to route the calls to the appropriate trunk.

LCR rules can be created not only on cost, but also other parameters including:

  • QoS thresholds (such as ASR)
  • QoS priority
  • Load distribution

The CGRateS LCR System documentation gives fuller details of the LCR rules and how they can be configured.






Leave a Reply

Your email address will not be published. Required fields are marked *