This chapter describes the steps necessary to rate calls and export rated CDRs (call detail records) to external systems.
Service billing on Sipwise C5 is based on billing profiles, which may be assigned to customers and SIP peerings. The design focuses on a simple, yet flexible approach, to support arbitrary dial-plans without introducing administrative overhead for the system administrators. The billing profiles may define a base fee and free time or free money per billing interval. Unused free time or money automatically expires at the end of the billing interval.
Each profile may have call destinations (usually based on E.164 number prefix matching) with configurable fees attached. Call destination fees each support individual intervals and rates, with a different duration and/or rate for the first interval. (e.g.: charge the first minute when the call is opened, then every 30 seconds, or make it independent of the duration at all) It is also possible to specify different durations and/or rates for peak and off-peak hours. Peak time may be specified based on weekdays, with additional support for manually managed dates based on calendar days. The call destinations can finally be grouped for an overview on user’s invoices by specifying a zone in two detail levels. (E.g.: national landline, national mobile, foreign 1, foreign 2, etc.)
The first step when setting up billing data is to create a billing profile, which will be the container for all other billing related data. Go to Settings→Billing and click on Create Billing Profile.
The fields Reseller, Handle and Name are mandatory.
Each Billing Profile holds multiple Billing Fees.
To set up billing fees, click on the Fees button of the billing profile you want to configure. Billing fees may be uploaded using a configurable CSV file format, or entered directly via the web interface by clicking Create Fee Entry. To configure the CSV field order for the file upload, rearrange the entries in the www_admin→fees_csv→element_order array in /etc/ngcp-config/config.yml and execute the command ngcpcfg apply changed fees element order
. The following is an example of working CSV file to upload (pay attention to double quotes):
".","^1",out,"EU","ZONE EU",5.37,60,5.37,60,5.37,60,5.37,60,0,0,regex_longest_pattern "^01.+$","^02145.+$",out,"AT","ZONE Test",0.06250,1,0.06250,1,0.01755,1,0.01733,1,0,regex_longest_pattern,30,0.01,30,0.01
For input via the web interface, fill in the text fields accordingly.
A billing fee record essentially defines the rate per interval to charge the customer when calling a particular destination number. The properties below outline supported options in detail:
foreign zone 1
)
Match Mode: The mode for matching a fee’s source and destination patterns against a CDR’s source fields (the caller given by <source_cli>@<source_domain>
or <source_cli>
only) and destination fields (the callee given by <destination_user_in>@<destination_domain>
or <destination_user_in>
only). Each of the currently supported modes below provide different flexibility and speed:
exact_destination
.
REGEXP
table scans. The performance boundary is O(length(cdr src) * length(cdr dest) * log(#fees)), hence this will be the preferred mode for tens of thousands of fees in place or high throughput (LCR, rating peer-to-peer calls). In csv files, this match mode is specified by prefix
.
regex_longest_match
.
regex_longest_pattern
.
If fees with different match mode are in place and matching, the precedence is given by above order. When omitted in file uploads, the legacy default regex_longest_pattern
is used.
123
or regular expression ^123someone@sip\.sipwise\.com$
). The legacy default "."
regular expression (matching everything) will be set implicitly.
Destination: The destination pattern (string ie. 456somebody@sip.sipwise.com
, prefix ie. 456
or regular expression ^456somebody@sip\.sipwise\.com$
). This field must be set.
exact_destination
match mode and destination lnp:<lnp provider ID>
can be set up.
Outbound
for standard origination fees (applies to callers placing a call and getting billed for that) or Inbound
for termination fees (applies to callees if you want to charge them for receiving various calls, e.g. for 800-numbers). If in doubt, use Outbound. If you upload fees via CSV files, use out
or in
, respectively.
important | |
The {match mode, source, destination, direction} combination needs to be unique for a billing profile. The system will return an error if such a set is specified twice via web interface/ or /api, or skipped when processing the file upload. When uploading fees, the Purge Existing checkbox allows to drop all existing fees before creating the records. |
important | |
There are several internal services (vsc, conference, voicebox, fax2mail) which will need a specific destination entry with a domain-based destination. If you don’t want to charge the same (or nothing) for those services, add a fee for destination |
To be able to differentiate between on-peak and off-peak calls, the platform stores off-peak times for every billing profile based on weekdays and/or calendar days. To edit the settings for a billing profile, go to Settings→Billing and press the Off-Peaktimes button on the billing profile you want to configure.
To set off-peak times for a weekday, click on Edit next to the according weekday. You will be presented with two input fields which both receive a timestamp in the form of hh:mm:ss specifying a time of day for the start and end of the off-peak period. If any of the fields is left empty, the system will automatically insert 00:00:00
(start field) or 23:59:59 (end field). Click on Add to store the setting in the database. You may create more than one off-peak period per weekday. To delete a range, click Delete next to the entry. Click the close icon when done.
To specify off-peak ranges based on calendar dates, click on Create Special Off-Peak Date. Enter a date in the form of YYYY-MM-DD hh:mm:ss into the Start Date/Time input field and End Date/Time input field to define a range for the off-peak period.
The call rating engine component (ngcp-rate-o-mat) supports two different modes to consider configured off-peak/on-peak periods when calculating call costs:
Split-Peak-Parts mode: CDRs reflecting calls which cross an off-peak/on-peak period transition will be split into two CDR fragments. This way it is possible for each fragment to exactly mark it as either on-peak or off-peak, and the CDR’s frag_carrier_onpeak, frag_reseller_onpeak and frag_customer_onpeak fields can be populated accordingly.
CDRs that are entirely within either on-peak or off-peak periods are not split and show a value of 0 for their is_fragmented field. CDR fragments are marked by the is_fragmented field showing a value of 1. If the call is crossing n transitions, (n+1) fragments are created.
Apart from is_fragmented, *_onpeak and *_cost fields, each fragment is a copy of the original CDR, except for start_time and durations fields. The sum of durations of fragments is equal to the duration of the original CDR. Fragments are adjacent, so the start_time of a fragment is equal to the end time (start_time + duration) of the previous fragment.
The CDR fragmentation produced by Split-Peak-Parts mode can be useful when implementing:
The process of the regular mode does not create additional CDRs, which has advantages in other situations:
In a normal post-paid accounting scenario, each customer accumulates debt in their billing account, which at the end of the billing interval is then billed to the customer. A prepaid billing profile reverses this sequence: the customer first has to provide credit to their account balance, and the costs for all calls are then deducted from that account balance. Once the balance reaches zero, no further calls from this customer are accepted, with the exception of free calls. Additionally, if the balance drops to zero while any calls are currently active, Sipwise C5 will disconnect those calls as soon as that happens.
With prepaid billing enabled, all details of the billing profile and all details of the billing fees behave as they normally do, including interval free time. If any interval free time is given, the free time will be used before the account’s credit is.
important | |
For technical reasons, the system can make the distinction between on-peak and off-peak times only at call establishment time. In other words, if the currently active call fee at the moment when the call is established is an off-peak fee, then the same off-peak fee will remain active for the whole length of this call, even if the call actually transitions into an on-peak fee (and vice versa). |
important | |
For technical reasons, prepaid billing can’t charge local endpoint calls to Voicebox, VSC calls or calls to a Conference Room. |
The Sipwise C5 platform offers advanced billing features which are especially designed for pre-paid billing scenarios. For details please visit Billing Customizations section of the handbook.
The Sipwise C5 supports a fraud detection feature, which is designed to detect accounts causing unusually high customer costs, and then to perform one of several actions upon those accounts. This feature can be enabled and configured through two sets of billing profile options described in Section 8.1.1, “Creating Billing Profiles”, namely the monthly (fraud monthly limit, fraud monthly lock and fraud monthly notify) and daily limits (fraud daily limit, fraud daily lock and fraud daily notify). Either monthly/daily limits or both of them can be active at the same time.
Monthly fraud limit check runs once a day, shortly after midnight local time and daily fraud limit check runs every 30min. A background script (managed by cron daemon) automatically checks all accounts which are linked to a billing profile enabled for fraud detection, and selects those which have caused a higher cost than the fraud monthly limit configured in the billing profile, within the currently active billing interval (e.g. in the current month), or a higher cost than the fraud daily limit configured in the billing profile, within the calendar day. It then proceeds to perform at least one of the following actions on those accounts:
Fraud lock levels are various protection (and notification) settings that are applied to subscribers of a Customer, if fraud detection is enabled in the currently active billing profile and the Customer’s daily or monthly fraud limit has been exceeded.
The following lock levels are available:
none
: no account locking will happen
foreign calls
: only calls within the subscriber’s own domain, and emergency
calls, are allowed
all outgoing calls
: subscribers of the customer cannot place any calls, except
calls to free and emergency destinations
incoming and outgoing
: subscribers of the customer cannot place and receive
any calls, except calls to free and emergency destinations
global
: same restrictions as at incoming and outgoing
level, additionally
subscribers are not allowed to access the Customer Self Care (CSC) interface
ported
: only automatic call forwarding, due to number porting, is allowed
important | |
You can override fraud detection and locking settings of a billing profile on a per-account basis via REST API or the Admin interface. |
caution | |
Accounts that were automatically locked by the fraud detection feature will not be automatically unlocked when the next billing interval starts. This has to be done manually through the administration panel or through the provisioning interface. |
important | |
If fraud detection is configured to only send an email and not lock the affected accounts, it will continue to do so for over-limit accounts every day. The accounts must either be locked in order to stop the emails (only currently active accounts are considered when the script looks for over-limit accounts) or some other action to resolve the conflict must be taken, such as disabling fraud detection for those accounts. |
info | |
It is possible to fetch the list of fraud events and thus get fraud status
of Customers by using the REST API and referring to the resource: |
info | |
Apart from the daily fraud detection check service, Sipwise C5 also provides instant, "hard" locking for prepaid use cases, by means of billing profile packages. See Billing Profile Packages for reference. |
The standard way of doing the billing — i.e. having fixed billing intervals of a calendar month, starting on the 1st day of month — may not fit all billing profiles and intervals that Sipwise C5 platform operators would like to use.
The Sipwise C5 supports — starting from its mr4.2.1 version — alternate ways of defining billing profiles and intervals which are especially worthy for pre-paid scenarios. New functionality is covered by the following titles:
Subsequent sections will provide an introduction and configuration instructions to these advanced features of Sipwise C5.
The idea is to dynamically select billing profiles (including fees) depending on the IP network the caller‘s SIP client is using to connect. The caller‘s IP is populated in a call‘s CDR, and effectively processed by:
The billing profile for rating a call is identified by matching the source IP against network ranges linked to the customer contract‘s billing mappings records. This feature is sometimes also referred to as roaming.
A Billing Network is defined as a series of network blocks where each network block consists of a single IP address or an IP subnet. Blocks of a particular billing network can be defined by either IPv4, or IPv6 addresses but not mixed.
The new /api/billingnetworks/
REST API resource makes it possible to manage billing networks.
The example billing network that is shown in the figure above may be defined through
the API with this JSON structure:
{ "blocks" : [ { "ip" : "10.0.1.0", // subnet: 10.0.1.0 .. 10.0.1.255 "mask" : 24 }, { "ip" : "10.0.2.2" // single ip } ], "description" : "Some text", "name" : "Demo Billing Net 1", //unique per reseller "reseller_id" : 1 }
Input validation of the network blocks is automatically performed by Sipwise C5 during their definition in a way that it prevents specifying overlapping blocks by means of Interval Trees; billing networks themselves may overlap though.
Using the default settings related to billing when creating a new Reseller or Customer on the administrative web panel results in applying the standard billing profile mapping schedule: the same billing profile is always used.
The idea of billing profile mapping schedule is to extend the billing mappings logic to utilize it as a schedule for billing profiles (and associated fees) for the Customer or Reseller contract. So far, billing mapping records provided only a history showing which profile was in effect at a given time in the past, which is for example required for delayed rating of calls.
Now it is also possible to define in advance, when specific billing profiles should become active in the future, e.g. to plan campaigns or special offers.
Billing profile mappings represent a schedule of overlapping time intervals with Billing Profiles and Billing Networks, which are assigned to (customer) contracts when creating or editing them.
Mapping intervals can be of type:
half-open:
Applying the profile mapping schedule shown in the above figure will result in billing profiles being active as provided in the table below.
Table 13. Active Billing Profiles
Time | Web Panel shows | Rating | ||
Caller IP in Network 1 | Caller IP in Network 2 | Caller IP in other network | ||
May 30 | Profile 1 | Profile 1 | Profile 1 | Profile 1 |
June 1 | Profile 4 | Profile 3 | Profile 4 | Profile 1 |
June 2 | Profile 2 | Profile 2 | Profile 4 | Profile 1 |
June 5 | Profile 5 | Profile 3 | Profile 4 | Profile 5 |
A Customer’s default billing profile mapping can be changed to scheduled mappings
when editing its properties, at the parameter "Set billing profiles", selecting:
schedule (billing mapping intervals)
tip | |
Assigning a Billing Network to a billing profile mapping is optional. Without selecting the network, the Billing Profile will be applied to all calls. |
The profile mapping schedule assigned to a Customer is also listed among Customer’s properties. See Settings → Customers → Details → Billing Profile Schedule.
info | |
Profile mappings that started in the past, like the default one, are displayed with a strike-through font in order to indicate that those can not be modified. |
The currently active mapping is depicted by a checked box.
The /api/customers/
API resource was extended to provide three different modes of
defining profile mappings:
billing_profiles
field: explicitly declare profile mappings in form of (billing
profile, billing network, start time, stop time)
tuples
billing_profile_id
field (legacy API spec): a single profile mapping interval
is appended (billing profile, no network / any caller IP respectively, starting now)
profile_package_id
field: profile mappings starting now are appended by using
lists of (billing profile, billing network)
tuples from the given profile package
With regards to Resellers, the /api/contracts/
API resource was enhanced as well,
but supports method 1. and 2. only, and without billing networks.
Mapping Intervals
Intervals can be of open, half-open (left-open, right-open) or closed type. When specifying profile mappings discretely, allowed interval types are restricted, depending on create/update situation:
Table 14. Allowed Mapping Intervals
Interval Type | Start | Stop | POST (create) | PUT / PATCH (update) |
---|---|---|---|---|
| undefined | undefined |
|
|
| undefined | defined |
|
|
| > now() | undefined |
|
|
| > now() | > start |
|
|
Example Profile Mapping
An example JSON structure for definition of profile mapping schedules shown in Billing Profile Schedule List :
{ ..., "billing_profile_definition" : "profiles", // i.e. use 'billing_profiles' field "billing_profiles" : [ { "network_id" : "236", "profile_id" : "236", "start" : "2016-11-01 00:00:00", "stop" : "2016-12-31 00:00:00" }, // closed future interval, with network { "network_id" : null, "profile_id" : "237", "start" : "2017-01-01 00:00:00", "stop" : "2017-12-31 00:00:00" } ], // closed future interval, without network "contact_id" : 141, ... }
By introducing billing profile packages, general billing parameters can be defined for a customer contract:
Subscriber lock levels and profile sets to get applied upon:
Profile Packages are fundamental for pre-paid billing scenarios, since in such a billing scheme the traditional, fixed monthly periods prove to be insufficient to cover the business needs of Sipwise C5 platform operator. As an example: pre-paid subscribers typically have their "billing periods" between account balance top-ups.
A Profile Package consists of various elements that will be discussed in subsequent sections of Sipwise C5 handbook. In order to set the parameters of a profile package one must navigate to: Settings → Profile Packages → Create Profile Package, or alternatively, in order to update an existing profile package: select the package and press Edit button.
Basic Balance Intervals Setup
Interval start mode:
1st of month (1st): billing interval is 1 calendar month; this is the default for each Customer created on Sipwise C5 platform
upon customer creation (create): (the initial) billing interval starts when the Customer is created
upon topup (topup_interval): interval starts at first topup event and its
length is defined by interval duration
parameter of the profile package
intervals from topup to topup (topup): interval starts at any topup event
and its length is defined by interval duration
parameter of the profile package;
intervals can overlap in this case
Balance Carry Over
Carry Over: balance carry over behaviour upon interval transitions:
carry-over:
always keep balance
carry-over only if topped-up timely:
keep balance in case of a timely top-up
only; where timely means the topup happens within a pre-defined time span before
the end of the balance interval
discard:
discard balance at the end of each interval
Underrun Settings
Underrun lock level: this level of services will apply when an account balance underruns
don’t change:
no change in the available set of services
no lock:
all services are available
foreign:
only calls within subscriber’s own domain are allowed
outgoing:
all outgoing calls are prohibited
all calls:
all calls (incoming + outgoing) are prohibited
global:
all calls + access to Customer Self Care web interface are prohibited
ported:
only automatic call forwarding, due to number porting, is allowed
Basic Top-up Settings
Profile mappings
A lists of (billing profile, billing network) tuples for appending profile mappings:
Profile Package Configuration
Definition of basic profile package parameters
Definition of balance interval and carry-over behaviour
Definition of balance underrun parameters
Definition of top-up settings
Assigning a profile package to a customer
Interval start mode: top-up interval; carry-over: timely
Profile package setup:
Interval start mode: top-up to top-up; carry-over: always
The new /api/profilepackages/
REST API resource makes it possible to manage billing profile
package container entities, that aggregate settings of profile packages.
A sample JSON structure follows:
{ "reseller_id" : 1, "status" : "active", "name" : "demo profile package", "description" : "package for 10€ ...", "balance_interval_start_mode" : "1st", "balance_interval_value" : 1, "balance_interval_unit" : "month", "carry_over_mode" : "carry_over", "timely_duration_unit" : null, "timely_duration_value" : null, "initial_balance" : 0, "initial_profiles" : [...], // required default, e.g. same as „topup_profiles“ "notopup_discard_intervals" : null, "underrun_lock_threshold" : 0, "underrun_lock_level" : 4, "underrun_profile_threshold" : 5, "underrun_profiles" : [...], "service_charge" : 10, "topup_lock_level" : null, "topup_profiles" : [ { "network_id" : null, // any network "profile_id" : 29 }, { "network_id" : 2, // a specific billing network "profile_id" : 30 }, ], ... }
Vouchers are a typical mean of topping-up an account balance in pre-paid billing scenarios.
The definition of a voucher in the database may succeed via:
In order to manage vouchers the administrator has to navigate to: Settings → Vouchers → Create Billing Voucher or select an existing one and press Edit button.
Setting following properties of a voucher is optional:
Package: vouchers may be associated with profile packages; if done so, some changes will be applied to the Customer for whom the voucher is redeemed with the top-up event:
Vouchers can be created and managed using the /api/vouchers/
REST API resource.
This resource restricts invasive operations (POST, PUT, PATCH, DELETE) to authorized users.
{ "amount" : 1000, "customer_id" : null, //do not restrict to a specific customer "valid_until" : "2017-06-05 23:59:59", "package_id" : "571", //switch to profile package "reseller_id" : 1, "code" : "SILVER_1_1437974823" }
A customer’s administrator or subscriber can perform a top-up to increase the contract‘s cash balance. The Sipwise C5 platform supports two means of topping-up the balance:
The Sipwise C5 platform provides 2 interfaces to perform top-ups:
through the administrative web interface:
One has to select the Customer, then Details → Contract Balance and finally press Top-up Cash or Top-up Voucher.
When doing top-up with cash one needs to supply the amount of top-up in the currency of the customer contract. Optionally one can assign a Profile Package to the top-up event which will activate that profile package for the customer.
It is also possible to perform top-up through the REST API: POST /api/topupcash
{ "subscriber_id" : "73", "amount" : 100, "package_id" : null, }
Selecting Top-up Voucher option will provide a simple list of available vouchers from which the administrator can choose the voucher. If a Profile Package is assigned to the voucher, that package will be activated for the customer on the top-up event.
It is also possible to perform top-up through the REST API: POST /api/topupvouchers
{ "subscriber_id" : "73", "code" : "SILVER_1_1437974390“ "request_token" : "uuid_from_3rdparty_relay" // optional request identifier // for lookups in the top-up log }
The actual contract balance and logs of top-up or balance interval change events are a kind of financially important information and that’s why those are provided on the administrative web interface for each customer. One should navigate to: Settings → Customers → select the customer → Details.
The various information details available on the web interface are discussed in subsequent sections of the handbook.
This part of the overviews shows the actual financial state of the customer’s balance and the current profile package and balance interval.
Another functionality assigned to Contract Balance section is the manual top-up. Both top-up with cash and top-up with voucher can be performed from here.
This table shows the balance intervals that have been in use, including the current interval.
Content of the balance intervals table is:
Debit: the total spent amount of money in the actual interval
info | |
While "Cash" shows the remaining amount, "Debit" shows the spent amount. With a post-paid billing scenario only "Debit" field would be populated, with pre-paid both fields will display an amount. |
Each successful or failing top-up request has to be logged. The log records represent an audit trail and reflect any data changes in the course of the top-up request.
In case of an error during the top-up operation the error message and any parseable fields of failed top-up attempts is recorded.
Content of the top-up log table is:
cash
or voucher
ok
or failed
The top-up log table can also be queried using the readonly /api/topuplogs
REST API resource.
An example of the response:
{ "_embedded" : { "ngcp:topuplogs" : [{ "_links" : {...}, "amount" : null, "cash_balance_after" : null, "cash_balance_before" : null, "contract_balance_after_id" : null, "contract_balance_before_id" : null, "contract_id" : 2565, "id" : 373, "lock_level_after" : null, "lock_level_before" : null, "message" : ..., //error reason "outcome" : "failed", "package_after_id" : null, "package_before_id" : null, "profile_after_id" : null, "profile_before_id" : null, "request_token" : "1444956281_6", // = “panel“ for panel UI requests "subscriber_id" : 1804, "timestamp" : "2015-10-16 02:45:19", "type" : "voucher", // "cash" or "voucher" "username" : "administrator", "voucher_id" : null }] }, "_links" : { ... }, "total_count" : 1 }
After getting to know the concepts of customized billing solution on Sipwise C5 platform, it’s worth seeing some practical examples for the usage of those advanced features.
The starting point is the setup of Profile Packages for our fictive customers: A, B and C. There are 4 different packages defined, with corresponding vouchers:
Initial:
Silver:
Gold:
Extension:
Cash balance with post-paid billing profile
Customers with a post-paid billing profile may have a positive account cash balance value. This is the regular case when using a post-paid billing profile showing a free cash greater than 0.
tip | |
You can set the free cash (and the free time) in the billing profile. The account balance will be set and managed (i.e. refilled or carried over) automatically for subsequent balance intervals. |
In case the account has a positive cash balance, the cost of the call will be deducted from that balance and not considered as additional cost of that particular call for the customer.
important | |
The rating engine (ngcp-rate-o-mat) in Sipwise C5 will write 0 instead of the real cost of a call in the CDR, if the source customer’s (who initiated the call) account has a positive cash balance! The purpose of this is to reflect the usage of free cash in the CDR for the particular call. |
info | |
It might happen, for instance, that a customer’s billing profile is changed from pre-paid to post-paid, and the customer already had a positive cash balance on his account. In that case the same call rating mechanism is involved as for the free cash. |
Regular billing data export is done using CSV (comma separated values) files which may be downloaded from the platform using the cdrexport user which has been created during the installation.
There are two types of exports. One is CDR (Call Detail Records) used to charge for calls made by subscribers, and the other is EDR (Event Detail Records) used to charge for provisioning events like enabling certain features.
Billing records contain fields that hold data of various entities that play a role in the phone service offered by Sipwise C5. For a better understanding of billing data please refer to the glossary provided here:
In order to be able to easily identify billing files, the file names are constructed by the following fixed-length fields:
<prefix><separator><version><separator><timestamp><separator><sequence number><suffix>
The definition of the specific fields is as follows:
Table 15. CDR/EDR export file name format
File name element | Length | Description |
---|---|---|
| 7 | A fixed string. Always |
| 1 | A fixed character. Always |
| 3 | The format version, a three digit number. Currently |
| 14 | The file creation timestamp in the format |
| 10 | A unique 10-digit zero-padded sequence number for quick identification. |
| 4 | A fixed string. Always |
A valid example filename for a CDR billing file created at 2012-03-10 14:30:00 and being the 42nd file exported by the system, is:
sipwise_007_20130310143000_0000000042.cdr
Each billing file consists of three parts: one header line, zero to 5000 body lines and one trailer line.
The billing file header is one single line, which is constructed by the following fields:
<version>,<number of records>
The definition of the specific fields is as follows:
Table 16. CDR/EDR export file header line format
Body Element | Length | Type | Description |
---|---|---|---|
| 3 | zero-padded uint | The format version. Currently |
| 4 | zero-padded uint | The number of body lines contained in the file. |
A valid example for a Header is:
007,0738
The body of a CDR consists of a minimum of zero and a default maximum of 5000 lines.
The platform operator can configure the maximum number of lines kept in a file
by updating the cdrexport.max_rows_per_file
parameter in /etc/ngcp-config/config.yml
file. Each line holds one call detail record in CSV format and is constructed by
a configurable set of fields, all of them enclosed in single quotes.
The following table defines the default set of fields that are inserted into the
CDR file, for exports related to system scope. The list of fields is defined in
/etc/ngcp-config/config.yml
file, cdrexport.admin_export_fields
parameter.
Table 17. Default set of system CDR fields
Body Element | Length | Type | Description |
---|---|---|---|
| 1-10 | uint | Internal CDR ID. |
| 19 | timestamp | Timestamp of last modification, including date and time (with seconds precision). |
| 36 | string | Internal UUID of calling party subscriber. Value is |
| 0-255 | string | Internal ID of the contract of calling party provider (i.e. reseller or peer). |
| 0-255 | string | External, arbitrary ID of calling party subscriber. (A string value shown as "External ID" property of an Sipwise C5 subscriber.) |
| 1-11 | uint | Internal ID of calling party subscriber. Value is |
| 0-255 | string | External, arbitrary ID of calling party customer. (A string value shown as "External ID" property of an Sipwise C5 customer/peer.) |
| 1-11 | uint | Internal ID of calling party customer. |
| 0-255 | string | SIP username of calling party. |
| 0-255 | string | SIP domain of calling party. |
| 0-64 | string | CLI of calling party in E.164 format. |
| 1 | uint |
|
| 0-64 | string | IP Address of the calling party. |
| 36 | string | Internal UUID of called party subscriber. Value is |
| 0-255 | string | Internal ID of the contract of called party provider (i.e. reseller or peer). |
| 0-255 | string | External, arbitrary ID of called party subscriber. (A string value shown as "External ID" property of an Sipwise C5 subscriber.) |
| 1-11 | uint | Internal ID of called party subscriber. Value is |
| 0-255 | string | External, arbitrary ID of called party customer. (A string value shown as "External ID" property of an Sipwise C5 customer/peer.) |
| 1-11 | uint | Internal ID of called party customer. |
| 0-255 | string | Final SIP username of called party. |
| 0-255 | string | Final SIP domain of called party. |
| 0-255 | string | Incoming SIP username of called party, after applying inbound rewrite rules. |
| 0-255 | string | Incoming SIP domain of called party, after applying inbound rewrite rules. |
| 0-255 | string | The user-part of the SIP Request URI as received by NGCP. |
| 0-255 | string | Username used to authenticate towards peer. |
| 0-255 | string | Realm used to authenticate towards peer. |
| 3-4 | string | The type of the call - one of:
|
| 2-8 | string | The final call status - one of:
|
| 3 | string | The final SIP status code. |
| 23 | timestamp | Timestamp of call initiation (SIP INVITE received from calling party). Includes date, time with milliseconds (3 decimals). |
| 23 | timestamp | Timestamp of call establishment (final SIP response received from called party). Includes date, time with milliseconds (3 decimals). |
| 4-13 | fixed precision (3 decimals) | Length of call (calculated from |
| 23 | timestamp |
|
| 19 | timestamp |
|
| 19 | timestamp |
|
| 19 | timestamp |
|
| 100 | string | The name of the local subscriber’s active timezone, defined by the contact of the subscriber/contract/reseller. The caller’s timezone is used for outgoing calls. For calls from external susbcribers, the callee’s timezone is used. System timezone (defined in config.yml) is used for transit calls. |
| 23 | timestamp |
|
| 23 | timestamp |
|
| 23 | timestamp |
|
| 19 | timestamp |
|
| 19 | timestamp |
|
| 19 | timestamp |
|
| 0-255 | string | The SIP Call-ID. |
| 2-7 | string | The internal rating status of the CDR - one of:
Currently always |
| 0-19 | datetime | Time of rating, including date and time (with seconds precision). Empty if CDR is not rated. |
| 7-14 | fixed precision (6 decimals) | The originating carrier cost that the carrier (i.e. SIP peer) charges for the calls routed to his network, or empty if CDR is not rated. PLEASE NOTE: Only available in system exports, not for resellers. |
| 7-14 | fixed precision (6 decimals) | The originating customer cost, or empty if CDR is not rated. |
| 0-127 | string | Name of the originating carrier billing zone, or PLEASE NOTE: Only available in system exports, not for resellers. |
| 0-127 | string | Name of the originating customer billing zone, or empty if CDR is not rated. |
| 0-127 | string | Description of the originating carrier billing zone, or PLEASE NOTE: Only available in system exports, not for resellers. |
| 0-127 | string | Description of the originating customer billing zone, or empty if CDR is not rated. |
| 1-10 | uint | The number of free time seconds used on originating carrier side, or empty if CDR is not rated. PLEASE NOTE: Only available in system exports, not for resellers. |
| 1-10 | uint | The number of free time seconds used from the originating customer’s account balance, or empty if CDR is not rated. |
| 7-14 | fixed precision (6 decimals) | The terminating carrier cost, or empty if CDR is not rated. PLEASE NOTE: Only available in system exports, not for resellers. |
| 7-14 | fixed precision (6 decimals) | The terminating customer cost, or empty if CDR is not rated. |
| 0-127 | string | Name of the terminating carrier billing zone, or PLEASE NOTE: Only available in system exports, not for resellers. |
| 0-127 | string | Name of the terminating customer billing zone, or empty if CDR is not rated. |
| 0-127 | string | Description of the terminating carrier billing zone, or empty if CDR is not rated. PLEASE NOTE: Only available in system exports, not for resellers. |
| 0-127 | string | Description of the terminating customer billing zone, or empty if CDR is not rated. |
| 1-10 | uint | The number of free time seconds used on terminating carrier side, or empty if CDR is not rated. PLEASE NOTE: Only available in system exports, not for resellers. |
| 1-10 | uint | The number of free time seconds used from the terminating customer’s account balance, or empty if CDR is not rated. |
| 7-14 | fixed precision (6 decimals) | The originating reseller cost, or empty if CDR is not rated. PLEASE NOTE: Only available in system exports, not for resellers. |
| 0-127 | string | Name of the originating reseller billing zone, or empty if CDR is not rated. PLEASE NOTE: Only available in system exports, not for resellers. |
| 0-127 | string | Description of the originating reseller billing zone, or empty if CDR is not rated. PLEASE NOTE: Only available in system exports, not for resellers. |
| 1-10 | uint | The number of free time seconds used from the originating reseller’s account balance, or empty if CDR is not rated. PLEASE NOTE: Only available in system exports, not for resellers. |
| 7-14 | fixed precision (6 decimals) | The terminating reseller cost, or empty if CDR is not rated. PLEASE NOTE: Only available in system exports, not for resellers. |
| 0-127 | string | Name of the terminating reseller billing zone, or empty if CDR is not rated. PLEASE NOTE: Only available in system exports, not for resellers. |
| 0-127 | string | Description of the terminating reseller billing zone, or empty if CDR is not rated. PLEASE NOTE: Only available in system exports, not for resellers. |
| 1-10 | uint | The number of free time seconds used from the terminating reseller’s account balance, or empty if CDR is not rated. PLEASE NOTE: Only available in system exports, not for resellers. |
| 1 | string | Always |
A valid example of one body line of a rated CDR is (line breaks added for clarity):
'15','2013-03-26 22:09:11','a84508a8-d256-4c80-a84e-820099a827b0','1','','1','', '2','testuser1','192.168.51.133','4311001','0','192.168.51.1', '94d85b63-8f4b-43f0-b3b0-221c9e3373f2','1','','3','','4','testuser3', '192.168.51.133','testuser3','192.168.51.133','testuser3','','','call','ok','200', '2013-03-25 20:24:50.890','2013-03-25 20:24:51.460','10.880','44449842', 'ok','2013-03-25 20:25:27','0.00','24.00','onnet','testzone','platform internal', 'testzone','0','0','0.00','200.00','','foo','','foo','0','0', '0.00','','','0','0.00','','','0'
The format of the CDR export files generated for resellers (as opposed to the complete system-wide export) is identical except for a few missing fields.
info | |
Please check the description of fields in the table above, in order to see which fields are omitted for reseller related CDR exports. |
The list of fields for reseller CDR export is defined in
/etc/ngcp-config/config.yml
file, cdrexport.reseller_export_fields
parameter.
Supplementary Data
There are fields in CDR database that contain supplementary data related to subscribers. This data is not used by Sipwise C5 for CDR processing but rather provides the system administrator with a possibility to include supplementary information in CDRs.
info | |
This informational section is meant for problem solving / debugging purpose:
The supplementary data listed in following table is stored in |
Table 18. Supplementary data in CDR fields
Body Element | Length | Type | Description |
---|---|---|---|
| 0-255 | string | Supplementary data field 0 of calling party. |
| 0-255 | string | Supplementary data field 1 of calling party. |
| 0-255 | string | Supplementary data field 2 of calling party. |
| 0-255 | string | Supplementary data field 3 of calling party. |
| 0-255 | string | Supplementary data field 4 of calling party. |
| 0-255 | string | Supplementary data field 5 of calling party. |
| 0-255 | string | Supplementary data field 6 of calling party. |
| 0-255 | string | Supplementary data field 7 of calling party. |
| 0-255 | string | Supplementary data field 8 of calling party. |
| 0-255 | string | Supplementary data field 9 of calling party. |
| 0-255 | string | Supplementary data field 0 of called party. |
| 0-255 | string | Supplementary data field 1 of called party. |
| 0-255 | string | Supplementary data field 2 of called party. |
| 0-255 | string | Supplementary data field 3 of called party. |
| 0-255 | string | Supplementary data field 4 of called party. |
| 0-255 | string | Supplementary data field 5 of called party. |
| 0-255 | string | Supplementary data field 6 of called party. |
| 0-255 | string | Supplementary data field 7 of called party. |
| 0-255 | string | Supplementary data field 8 of called party. |
| 0-255 | string | Supplementary data field 9 of called party. |
Account balance details (prepaid calls)
There are fields in CDR database that show changes in cash or free time balance. In addition to that, a history of billing packages / profiles may also be present, since Sipwise C5 vouchers, that are used to top-up, may also be set up to cause a transition of profile packages. (Which in turn can result in changing the billing profile/applicable fees). Therefore the billing package and profile valid at the time of the CDR are recorded and exposed as fields for CDR export.
tip | |
Such fields may also be required to integrate Sipwise C5 with legacy billing systems. |
info | |
Please be aware that pre-paid billing functionality is only available in Sipwise C5 PRO and Sipwise C5 CARRIER products. |
The name of CDR data field consists of the elements listed below:
source|destination
: decides if the data refers to calling (source
) or called (destination
) party
carrier|reseller|customer
: the account owner, whose billing data is referred
data type:
cash_balance|free_time_balance _ before|after
: cash balance or free time balance, before or after the call
profile_package_id|contract_balance_id
: internal ID of the active pre-paid billing profile or the account balance
Examples:
important | |
For calls spanning multiple balance intervals, the latter one will be selected, that is the balance interval where the call ended. |
important | |
There are some limitations in rating pre-paid calls, please visit Pre-paid Billing section for details. |
On-net calls (made only between devices on your network) are sometimes treated differently from off-net calls (terminated to or received from a peer) in external billing systems.
To distinguish between on-net and off-net calls in such a billing systems, check the source_user_id and destination_user_id fields. For on-net calls, both fields will have a different from zero value (actually, a UUID).
The body of an EDR consists of a minimum of zero and a maximum of 5000 lines.
The platform operator can configure the maximum number of lines kept in a file
by updating the eventexport.max_rows_per_file
parameter in /etc/ngcp-config/config.yml
file. Each line holds one call detail record in CSV format and is constructed by
the fields as per the subsequent table.
The following table defines the default set of fields that are inserted into the
EDR file, for exports related to system scope. The list of fields is defined in
/etc/ngcp-config/config.yml
file, eventexport.admin_export_fields
parameter.
Table 19. Default set of system EDR fields
Body Element | Length | Type | Description |
---|---|---|---|
| 1-11 | uint | Internal EDR ID. |
| 0-255 | string | The type of the event - one of:
|
| 0-255 | string | The external ID of the customer. (A string value shown as "External ID" property of an Sipwise C5 customer.) |
| 0-127 | string | The company name of the customer’s contact. |
| 0-255 | string | The external ID of the subscriber. (A string value shown as "External ID" property of an Sipwise C5 subscriber.) PLEASE NOTE: This field is empty in case of |
| 0-64 | string | The pilot subscriber’s primary number (HPBX subscribers). PLEASE NOTE: This is not included in default set of EDR fields from Sipwise C5 version mr5.0 upwards. |
| 0-64 | string | The VoIP number of the subscriber with the highest ID (DID or primary number). |
| 0-255 | string | The old status of the event. Depending on the event_type:
|
| 0-255 | string | The new status of the event. Depending on the event_type:
|
| 23 | timestamp | Timestamp of event. Includes date, time with milliseconds (3 decimals). |
| 1-11 | uint | Internal ID of the reseller which the event belongs to. PLEASE NOTE: Only available in system exports, not for resellers. |
| 1 | string | A fixed character. Always |
A valid example of one body line of an EDR is (line breaks added for clarity):
"1","start_profile","sipwise_ext_customer_id_4","Sipwise GmbH", "sipwise_ext_subscriber_id_44","436667778","","1","2014-06-19 11:34:31","1"
The format of the EDR export files generated for resellers (as opposed to the complete system-wide export) is identical except for a few missing fields.
info | |
Please check the description of fields in the table above, in order to see which fields are omitted for reseller related EDR exports. |
The list of fields for reseller EDR export is defined in
/etc/ngcp-config/config.yml
file, eventexport.reseller_export_fields
parameter.
There are fields in EDR database that contain supplementary data related to subscribers, for example subscriber phone numbers are such data.
Table 20. Supplementary data in EDR fields
Body Element | Length | Type | Description |
---|---|---|---|
| 0-255 | string | The subscriber’s profile set name. |
| 0-255 | string | The profile set name of the subscriber’s pilot subscriber. |
| 0-255 | string | The profile name of the subscriber’s pilot subscriber. |
| 0-255 | string | The subscriber’s non-primary alias with lowest ID, before number updates during the operation. |
| 0-255 | string | The subscriber’s non-primary alias with lowest ID, after number updates during the operation. |
| 0-255 | string | The non-primary alias with lowest ID of the subscriber’s pilot subscriber, before number updates during the operation. |
| 0-255 | string | The non-primary alias with lowest ID of the subscriber’s pilot subscriber, after number updates during the operation. |
| 0-255 | string | The non-primary alias of a subscriber affected by an |
| 0-255 | string | The subscriber’s primary alias, before number updates during the operation. |
| 0-255 | string | The subscriber’s primary alias, after number updates during the operation. |
| 0-255 | string | The primary alias of the subscriber’s pilot subscriber, before number updates during the operation. |
| 0-255 | string | The primary alias of the subscriber’s pilot subscriber, after number updates during the operation. |
| 0-255 | string | Equals |
| 0-255 | string | Equals |
The billing file trailer is one single line, which is constructed by the following fields:
<md5 sum>
The <md5 sum>
is a 32 character hexadecimal MD5 hash of the Header
and Body.
To validate the billing file, one must remove the Trailer before computing
the MD5 sum of the file. The ngcp-cdr-md5
program included in the
ngcp-cdr-exporter
package can be used to validate the integrity of the
file.
Given a CDR-file named as sipwise_001_20071110123000_0000000004.cdr
, the
output of the integrity check for an intact CDR file would be:
$ ngcp-cdr-md5 sipwise_001_20071110123000_0000000004.cdr /tmp/ngcp-cdr-md5.sipwise_001_20071110123000_0000000004.cdr.oqkd4P2zXI: OK
If the file has been altered during transmission, the output of the integrity check would be:
$ ngcp-cdr-md5 sipwise_001_20071110123000_0000000004.cdr /tmp/ngcp-cdr-md5.sipwise_001_20071110123000_0000000004.cdr.hUtuhtKEn1: FAILED md5sum: WARNING: 1 of 1 computed checksum did NOT match
Billing files are created twice per hour at minutes 25
and 55
and are stored in the home directory of the cdrexport
user. If the amount of records within the transmission interval exceeds the threshold of 5000 records per file, multiple billing files are created. If no billing records are found for an interval, a billing file without body data is constructed for detection of lost billing files on the 3rd party side.
CDR and EDR files are fetched by a 3rd party billing system using SFTP or SCP with either public key or password authentication using the username cdrexport.
If public key authentication is chosen, the public key file has to be stored in the file ~/.ssh/authorized_keys2
below the home directory of the cdrexport
user. Otherwise, a password has to be set for the user.
The 3rd party billing system is responsible for deleting CDR files after fetching them.
info | |
The |