Multiple Rating Groups in CCR-I

459 views
Skip to first unread message

JSU

unread,
Nov 10, 2021, 8:40:21 AM11/10/21
to CGRateS
Hi,

I am trying to charge 4G customers from Huawei EPC using diameter. The problem I am facing is that my CCR-I has multiple rating groups populated with Requested Service Units.

I have the following questions:

1. How do I handle multiple rating groups in reply? I have tried defining it multiple times, but haven't been able to do so , it just picks up the last one. Screenshot 2021-11-10 at 4.46.43 PM.png

2. How do I calculate balance and deduct for each rating group usage separately?

Thanks,
Junaid

Junaid Uppal

unread,
Nov 11, 2021, 4:28:58 AM11/11/21
to CGRateS
Hi Dan, Team,

Below is my config, I am trying to respond back to the CCR-I with multiple appended rating groups ( like the successful reply in my earlier message ) - but the pcap only has the final rating group ( 5 ) in my CCR-A.

It seems that the setting append_cca doesnt work any more ? What can I use to append multiple rating groups in CCR-A.

{
"diameter_agent":
{
"request_processors":
[
{
"id": "data_init_noservice",
"dry_run": true,
"flags": ["*initiate", "*accounts","*continue","*log"],
"request_filter": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:(1*|2)", "*prefix:~*req.Service-Context-Id:6.3...@3gpp.org","*string:~req.Multiple-Services-Credit-Control.Rating-Group(^$)"],
"continue_on_success": false,
"request_fields":[
{"tag": "TOR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"},
{"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", "value": "~*req.Session-Id", "mandatory": true},
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Direction", "path": "*cgreq.Direction", "type": "*constant", "value": "*out"},
{"tag": "Tenant", "path": "*cgreq.Tenant", "type": "*constant", "value": "cgrates.org"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "data"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*composed", "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable", "value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", "value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant"}
],
"reply_fields": [
{"tag": "ResultCode", "path": "*rep.Result-Code", "type": "*constant", "value": "2001"},
]

},

{
"id": "data_init_internet",
"dry_run": false,
"request_filter": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:(1)","*prefix:~*req.Service-Context-Id:6.3...@3gpp.org","*string:~req.Multiple-Services-Credit-Control.Rating-Group(1)"],
"flags": ["*initiate", "*accounts","*continue","*log"],
"continue_on_success": true,
"append_cca": true,
"request_fields":[
{"tag": "TOR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"},
{"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed", "value": "~*req.Session-Id;^#1", "mandatory": true},
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Direction", "path": "*cgreq.Direction", "type": "*constant", "value": "*out"},
{"tag": "Tenant", "path": "*cgreq.Tenant", "type": "*constant", "value": "cgrates.org"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "internet"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*composed", "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*composed", "value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*composed", "value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "10240"}
],
"reply_fields": [
{"tag": "ResultCodeError", "field_filter": "CGRError(!^$)",
"path": "*rep.Multiple-Services-Credit-Control.Result-Code",
"type": "*constant","value": "4012"},
{"tag": "GrantedUnits", "field_filter": "CGRError(!^$)",
"path": "*rep.Multiple-Services-Credit-Control.Granted-Service-Unit.CC-Total-Octets",
"type": "*constant", "value": "0", "append": true},
{"tag": "GrantedUnits", "field_filter": "CGRError(^$)",
"path": "*rep.Multiple-Services-Credit-Control.Granted-Service-Unit.CC-Total-Octets",
"type": "*composed", "value": "10240", "append": true},
{"tag": "*rep.RatingGroup", "path": "*rep.Multiple-Services-Credit-Control.Rating-Group",
"type": "*constant", "value": "1"},
{"tag": "*rep.ValidityTime", "path": "*rep.Multiple-Services-Credit-Control.Validity-Time",
"type": "*constant", "value": "3300"},
{"tag": "*rep.ResultCode", "path": "*rep.Multiple-Services-Credit-Control.Result-Code",
"type": "*constant", "value": "2001"},
{"tag": "*rep.QuotaHoldingTime", "path": "*rep.Multiple-Services-Credit-Control.Quota-Holding-Time",
"type": "*constant", "value": "1880"},
{"tag": "*rep.QuotaConsumptionTime", "path": "*rep.Multiple-Services-Credit-Control.Quota-Consumption-Time",
"type": "*constant", "value": "0"},
{"tag": "*rep.VolumeQuotaThreshold", "path": "*rep.Multiple-Services-Credit-Control.Volume-Quota-Threshold",
"type": "*constant", "value": "200000"},
]
},
{
"id": "data_init_facebook",
"dry_run": false,
"request_filter": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:(1)","*prefix:~*req.Service-Context-Id:6.3...@3gpp.org","*string:~req.Multiple-Services-Credit-Control.Rating-Group(2)"],
"flags": ["*initiate", "*accounts","*continue","*log"],
"continue_on_success": true,
"append_cca": true,
"request_fields":[
{"tag": "TOR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"},
{"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed", "value": "~*req.Session-Id;^#2", "mandatory": true},
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Direction", "path": "*cgreq.Direction", "type": "*constant", "value": "*out"},
{"tag": "Tenant", "path": "*cgreq.Tenant", "type": "*constant", "value": "cgrates.org"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "internet"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*composed", "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*composed", "value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*composed", "value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "10240"}
],
"reply_fields": [
{"tag": "ResultCodeError", "field_filter": "CGRError(!^$)",
"path": "*rep.Multiple-Services-Credit-Control.Result-Code",
"type": "*constant","value": "4012"},
{"tag": "GrantedUnits", "field_filter": "CGRError(!^$)",
"path": "*rep.Multiple-Services-Credit-Control.Granted-Service-Unit.CC-Total-Octets",
"type": "*constant", "value": "0", "append": true},
{"tag": "GrantedUnits", "field_filter": "CGRError(^$)",
"path": "*rep.Multiple-Services-Credit-Control.Granted-Service-Unit.CC-Total-Octets",
"type": "*composed", "value": "10240", "append": true},
{"tag": "*rep.RatingGroup", "path": "*rep.Multiple-Services-Credit-Control.Rating-Group",
"type": "*constant", "value": "2"},
{"tag": "*rep.ValidityTime", "path": "*rep.Multiple-Services-Credit-Control.Validity-Time",
"type": "*constant", "value": "3300"},
{"tag": "*rep.ResultCode", "path": "*rep.Multiple-Services-Credit-Control.Result-Code",
"type": "*constant", "value": "2001"},
{"tag": "*rep.QuotaHoldingTime", "path": "*rep.Multiple-Services-Credit-Control.Quota-Holding-Time",
"type": "*constant", "value": "1880"},
{"tag": "*rep.QuotaConsumptionTime", "path": "*rep.Multiple-Services-Credit-Control.Quota-Consumption-Time",
"type": "*constant", "value": "0"},
{"tag": "*rep.VolumeQuotaThreshold", "path": "*rep.Multiple-Services-Credit-Control.Volume-Quota-Threshold",
"type": "*constant", "value": "200000"},
]
},
{
"id": "data_init_mobileapp",
"dry_run": false,
"request_filter": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:(1)","*prefix:~*req.Service-Context-Id:6.3...@3gpp.org","*string:~req.Multiple-Services-Credit-Control.Rating-Group(4)"],
"flags": ["*initiate", "*accounts","*continue","*log"],
"continue_on_success": true,
"append_cca": true,
"request_fields":[
{"tag": "TOR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"},
{"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed", "value": "~*req.Session-Id;^#4", "mandatory": true},
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Direction", "path": "*cgreq.Direction", "type": "*constant", "value": "*out"},
{"tag": "Tenant", "path": "*cgreq.Tenant", "type": "*constant", "value": "cgrates.org"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "internet"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*composed", "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*composed", "value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*composed", "value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "10240"}
],
"reply_fields": [
{"tag": "ResultCodeError", "field_filter": "CGRError(!^$)",
"path": "*rep.Multiple-Services-Credit-Control.Result-Code",
"type": "*constant","value": "4012"},
{"tag": "GrantedUnits", "field_filter": "CGRError(!^$)",
"path": "*rep.Multiple-Services-Credit-Control.Granted-Service-Unit.CC-Total-Octets",
"type": "*constant", "value": "0", "append": true},
{"tag": "GrantedUnits", "field_filter": "CGRError(^$)",
"path": "*rep.Multiple-Services-Credit-Control.Granted-Service-Unit.CC-Total-Octets",
"type": "*composed", "value": "10240", "append": true},
{"tag": "*rep.RatingGroup", "path": "*rep.Multiple-Services-Credit-Control.Rating-Group",
"type": "*constant", "value": "4"},
{"tag": "*rep.ValidityTime", "path": "*rep.Multiple-Services-Credit-Control.Validity-Time",
"type": "*constant", "value": "3300"},
{"tag": "*rep.ResultCode", "path": "*rep.Multiple-Services-Credit-Control.Result-Code",
"type": "*constant", "value": "2001"},
{"tag": "*rep.QuotaHoldingTime", "path": "*rep.Multiple-Services-Credit-Control.Quota-Holding-Time",
"type": "*constant", "value": "1880"},
{"tag": "*rep.QuotaConsumptionTime", "path": "*rep.Multiple-Services-Credit-Control.Quota-Consumption-Time",
"type": "*constant", "value": "0"},
{"tag": "*rep.VolumeQuotaThreshold", "path": "*rep.Multiple-Services-Credit-Control.Volume-Quota-Threshold",
"type": "*constant", "value": "200000"},
]
},
{
"id": "data_init_wttxportal",
"dry_run": false,
"request_filter": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:(1)","*prefix:~*req.Service-Context-Id:6.3...@3gpp.org","*string:~req.Multiple-Services-Credit-Control.Rating-Group(5)"],
"flags": ["*initiate", "*accounts","*continue","*log"],
"continue_on_success": true,
"append_cca": true,
"request_fields":[
{"tag": "TOR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"},
{"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed", "value": "~*req.Session-Id;^#5", "mandatory": true},
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Direction", "path": "*cgreq.Direction", "type": "*constant", "value": "*out"},
{"tag": "Tenant", "path": "*cgreq.Tenant", "type": "*constant", "value": "cgrates.org"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "internet"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*composed", "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*composed", "value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*composed", "value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "10240"}
],
"reply_fields": [
{"tag": "ResultCodeError", "field_filter": "CGRError(!^$)",
"path": "*rep.Multiple-Services-Credit-Control.Result-Code",
"type": "*constant","value": "4012"},
{"tag": "GrantedUnits", "field_filter": "CGRError(!^$)",
"path": "*rep.Multiple-Services-Credit-Control.Granted-Service-Unit.CC-Total-Octets",
"type": "*constant", "value": "0", "append": true},
{"tag": "GrantedUnits", "field_filter": "CGRError(^$)",
"path": "*rep.Multiple-Services-Credit-Control.Granted-Service-Unit.CC-Total-Octets",
"type": "*composed", "value": "10240", "append": true},
{"tag": "*rep.RatingGroup", "path": "*rep.Multiple-Services-Credit-Control.Rating-Group",
"type": "*constant", "value": "5"},
{"tag": "*rep.ValidityTime", "path": "*rep.Multiple-Services-Credit-Control.Validity-Time",
"type": "*constant", "value": "3300"},
{"tag": "*rep.ResultCode", "path": "*rep.Multiple-Services-Credit-Control.Result-Code",
"type": "*constant", "value": "2001"},
{"tag": "*rep.QuotaHoldingTime", "path": "*rep.Multiple-Services-Credit-Control.Quota-Holding-Time",
"type": "*constant", "value": "1880"},
{"tag": "*rep.QuotaConsumptionTime", "path": "*rep.Multiple-Services-Credit-Control.Quota-Consumption-Time",
"type": "*constant", "value": "0"},
{"tag": "*rep.VolumeQuotaThreshold", "path": "*rep.Multiple-Services-Credit-Control.Volume-Quota-Threshold",
"type": "*constant", "value": "200000"},
]
},
]
}
}

Thanks,
Junaid

Nickolas Daniel Filip

unread,
Nov 18, 2021, 7:26:34 AM11/18/21
to CGRateS
Hi Junaid,

First of all, the "append_cca" field is deprecated in the newer versions. Instead, have a look at this config file:
https://github.com/cgrates/cgrates/blob/342617156f4813e90364f14cdaa388c2ea9216f2/data/conf/samples/diamagent_mysql/dryrun.json#L180

Here you should observe the "reply_fields" section.
It should be enough to give you an example of how you might change your config. Keep in mind that, in order to append instead of overwrite values, you should specify the "type": "*group" field. Also, if you want to have a new path, the "new_branch": true field should do the job.
Thanks!
Nick

Waled Alezzy

unread,
Aug 1, 2023, 4:33:23 PM8/1/23
to CGRateS
Dears,

Could you please kindly inform if there any way to make the charging based on the rating_group (different rate for each RG)..
as from the above link we found UsedUnits1 for RG1 and UsedUnits2 for RG2 ----how to direct UsedUnits1 to be charge from FreeData1(account balance) and UsedUnits2 to be charge from FreeData2(account balance) ..

for example :
RG1 ---needs  to be charge from bundle FreeData1
RG2 ---needs to be charge from bundle FreeData2
.
.
. and so on..

As currently all of them are going to be charged from one Account balance!

Thank you in advance ,and appreciate your support.
Waled

Dan B

unread,
Aug 3, 2023, 9:34:37 AM8/3/23
to cgr...@googlegroups.com
Hi Waled,

Not sure if I follow you but if all you want is to extract data from different groups, you can see the example we got for extracting account from first group here:

If you would also like to simultaneously charge two sessions out of a single INIT/UPDATE coming from diameter side, you would need to capture both usages/accunts in different CGRateS session variables and use ChargerS to attach the right variables to the right CGRateS session. Each session will run independently and charge in this way from different bundles also.

Hope this helps.

DanB

--
You received this message because you are subscribed to the Google Groups "CGRateS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cgrates+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cgrates/4d86f239-5dc3-4d74-b2a5-f956e3a7973cn%40googlegroups.com.

Waled Alezzy

unread,
Sep 11, 2023, 9:00:56 AM9/11/23
to CGRateS
Hello Dan,
Thank you for your update ..
I have created a processor for each rating group (Init,Update and Terminate) and accordingly created two chargers (one for each rating group)..
But we observed that only one rating group is handled by the system and only one session was created ..

Please find the attached collected symptoms (ngrep,pcap trace and console logs)..


charger:
# Tenant,ID,FilterIDs,ActivationInterval,RunID,AttributeIDs,Weight

sabafon.com,CGR_DEFAULT,,,*default,*none,0
sabafon.com,RG1,RG1,,RG1_charge,*none,10
sabafon.com,RG2,RG2,,RG2_charge,*none,10


Filters:

sabafon.com,RG1,*string,~*req.Destination,1,2023-01-01T00:00:00Z
sabafon.com,RG2,*string,~*req.Destination,2,2023-01-01T00:00:00Z

So why there is no session for the second rating group ,i am sure its related to charger config..
I can send you the voice.json privately ..

Thank you in advance
Waled
Console_logs.txt
Trace.zip
ngrep.txt

Arber Katellari

unread,
Oct 23, 2023, 8:56:19 AM10/23/23
to CGRateS

Hello Waled,

Most likely there is something wrong in your config files. Can you send them to me privately then?

Thanks,
Arber

Arber Katellari

unread,
Oct 25, 2023, 4:53:09 AM10/25/23
to CGRateS
Hi Waled,

Based on your private email, it seems your issue is coming from your filters "*string:~*req.Multiple-Services-Credit-Control.Rating-Group:2". When you don't specify its index, index 0 is automatically taken. Since the Rating-Group with value 2 is on the 2nd index of Multiple-Services-Credit-Control.Rating-Group, the filter for it should be written like this:
`"*string:~*req.Multiple-Services-Credit-Control.Rating-Group[1]:2", ` .  Feel free to ask if you have further questions.

Kind regards,
Arber

Waled Alezzy

unread,
Oct 26, 2023, 12:44:56 PM10/26/23
to CGRateS
Thanks for the quick response Arber.
Yes, the filter was the issue, now the request processors are handling both Rating-Group's .. Thank you again..

I am still facing one issue ..that the CCA to the client contains only information for Rating group 2 (because its the last for each init/update/terminate), not for both rating-group (1,2)(observed from the wireshark trace attached ) even though I can observe on the console that we are replying for each request processor..

its could be related to (continue on success) or related to new_branch ..pleas help with this Kindly ..
Screenshot from 2023-10-26 22-23-54.png
NEW_LOGS.zip

Arber Katellari

unread,
Oct 27, 2023, 9:15:50 AM10/27/23
to CGRateS
Hello Waled,

This is happening because the request you are sending contains both rating groups 1 and 2 (from the same path), and the second rating group in your configs is of type *constant as well. This makes it overwrite the reply (Rating-Group:1) from the previous reply in config). To reply with both values appended, you have to change the type of all the fields with the same path that come after the first one to: *group. I.e.:
...
"request_processors": [
{
"id": "data_init_grp1",...
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group:1",...
"reply_fields": [
...
{"tag": "RatingGroup",  "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", "type": "*constant", "value": "1"}, // *constant again to overwrite any leftover value from previous requests if any
...
"id": "data_init_grp2",...
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group:2",...
  "reply_fields": [
...
{"tag": "RatingGroup",  "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", "type": "*group", "value": "2","new_branch": true},
...
"id": "data_update_grp1",...
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group:1",...
{"tag": "RatingGroup",  "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", "type": "*constant", "value": "1"},  // *constant again to overwrite any leftover value from previous requests if any
...
"id": "data_update_grp2",...
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group:2",...
{"tag": "RatingGroup",  "path": "*req.Multiple-Services-Credit-Control.Rating-Group", "type": "*group", "value": "2","new_branch": true},
...

This way if both filters are true, the reply has both Rating-Group:1 and Rating-Group:2 and they both have the same path. If one of the filters is true and the other is not, it will reply only with the Rating-Group which the filter was true for.
Samples that use this have already been sent previously in this thread: https://github.com/cgrates/cgrates/blob/c4e0d92a2ae40ccb3c3960a8e7a4f9dca80b30e6/data/conf/samples/diamagent_mysql/dryrun.json#L181-L187
Please ask if anything is still unclear!

Kind regards,
Arber
Reply all
Reply to author
Forward
0 new messages