Use CGRateS as OCS for Open5GS LTE core

599 views
Skip to first unread message

S.Hossein Katebi

unread,
Oct 9, 2023, 7:19:58 AM10/9/23
to CGRateS
Hi everyone.
I'm trying to use CGRateS as the OCS to my Open5GS LTE core.

I successfully connected the CGRateS to Open5GS, and now they can talk over the Gy interface (Diameter). The pcap attached shows a sample message exchange between Open5GS (172.22.0.7) and CGRateS (172.22.0.50).

However, I'm facing problems charging users for their data usage (currently, I'm only concerned about being able to charge users for their data usage). I have attached my config file (ocs.json) which inside I have enabled DiameterAgent and defined some request processors. I have also attached my rating, actions, etc. csv files (csvs.zip).

The problem I am facing is that the CGRateS charges the user for the nanoseconds in sessions.debit_interval (which is set to 5 seconds in the ocs.json file) while it should charge the user for Input/Output-Octets (or the usage).

Can someone kindly help me configure my CGRateS to charge the users correctly?
ocs.json
ocs-smf.pcap
csvs.zip

Dan Christian Bogos

unread,
Oct 10, 2023, 4:32:02 AM10/10/23
to cgr...@googlegroups.com

Hi S. Hossein,


For most of the setups with Diameter we have met there was no automatic debits set (so debit_interval was set to 0 which is default) and the debit occurred via Diameter updates. Are you sure you need automatic debits?

Also as a tip, I would recommend you asking specific questions on this group since it will increase your chances of getting people's attention. One might false understand that you are waiting for someone else to do the heavy lifting for you.


Thanks,

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/95e608cb-4e0c-493e-ad4b-fe3f4aeaedcbn%40googlegroups.com.

S.Hossein Katebi

unread,
Oct 11, 2023, 8:57:11 AM10/11/23
to CGRateS
Yes, you are right. I will try this as soon as possible.

Thank you for your help and sorry for any inconvenience.
I didn't mean for anyone to do the heavy lifting for me.
I will be more specific next time.

By the way, do you know anyone who was able (or any tutorials on how to) connect CGRateS to Open5GS?

S.Hossein Katebi

unread,
Oct 15, 2023, 5:14:53 AM10/15/23
to CGRateS
Hi DanB.

I turned off the automatic debit as you suggested and that solved my problem (thank you for that).

But I've faced another problem now. I want the CGRateS to charge the users according to the ratings I have in my CSV files (more specifically Rates.CSV). But it does now seem to take that into account. It seems that CGRateS is only using the ratingsubject in user's balance (which is an empty string!) or the default one that I have provided in the config file (ocs.json) in case the one in the database is empty.

I apply the csv files through this commad (I store my csv files in /etc/cgrates-csv path):

#: cgr-loader -datadb_host=MONGODB_IP -datadb_port=27017 -datadb_type=*mongo -stordb_host=MONGODB_IP -stordb_port=27017 -stordb_type=*mongo -verbose -path=/etc/cgrates-csv

Can you guide me how to fix this and how should I apply the mentioned ratings?

Thanks,
Katebi

gezim....@itsyscom.com

unread,
Oct 24, 2023, 8:06:57 AM10/24/23
to CGRateS
Hi S. Hossein,

For rating CGRateS looks up first for ratingsubject in user balance, if not defined it will get the ratingprofiles of the subject and apply the rates.
Please check user balance and set ratingsubject to empty to charge based on your applied rates.

Thanks ,
Gezim

S.Hossein Katebi

unread,
Oct 24, 2023, 8:23:08 AM10/24/23
to CGRateS
Hi Gezim,

Thank you for your response.
I've checked my user balance and my ratingsubject is empty.
How can I confirm that CGRateS find my rating profiles?
Do I need to activate something for it to check the rating profile?
From what I am seeing, it finds that the ratingsubject in the user's balance is empty and then it will get the default ratingsubjects that I defined in the json config file.
Do I need to remove the default rating subjects from the json config file?

Thanks,
Katebi

Gezim Blliku

unread,
Oct 25, 2023, 7:45:25 AM10/25/23
to cgr...@googlegroups.com
Hi Katebi,

Could you please use ngrep to capture the requests on cgrates port
and send it to us so we can be able to understand better what's going
on .Be sure to change the conns between components into *localhost to
make visible the output.

Thanks,
Gezim
> To view this discussion on the web visit https://groups.google.com/d/msgid/cgrates/b62780c4-c792-45c7-b039-1349ce2a2151n%40googlegroups.com.

S.Hossein Katebi

unread,
Oct 26, 2023, 8:02:01 AM10/26/23
to CGRateS
Hi Gezim,

Thank you for your response.
I was able to capture the rpc_json port (2012) with the following command:

ngrep -d any port 2012 -O ngrep.pcap > ngrep.log 2>&1

The CGRateS config (ocs-config.json), captured pcap (ngrep.pcap), and ngrep output (ngrep.log) are attached.
However, I'm not sure that I'm doing everything right.
Because I was not able to parse the packets correctly in wireshark but the ngrep output (ngrep.log) file contain some information about the procedure calls.
Can you please take a look at these and see if I'm doing everything right?
And if so, where is the problem?

Yours sincerely,
Katebi
ngrep.log
ocs-config.json
ngrep.pcap

gezim....@itsyscom.com

unread,
Oct 31, 2023, 4:52:29 AM10/31/23
to CGRateS
Hi Katebi,

Could you please send us also the CDR generated for this example.

Thanks,
Gezim

S.Hossein Katebi

unread,
Oct 31, 2023, 8:01:05 AM10/31/23
to CGRateS
Hi Gezim,

I didn't activate the CDR function (the cdr is disabled in ocs-config.json) because it was throwing some errors back when we started the project.
Should I activate it now and send them to you?

Yours sincerely,
Katebi

Gezim Blliku

unread,
Oct 31, 2023, 10:01:20 AM10/31/23
to cgr...@googlegroups.com
Hi Katebi,

You need to enable writing of CDRs since we need to see what you
have debited and from where the rates are applied.
Please also send ngrep again along with CDRs .

Thanks,
Gezim
> To view this discussion on the web visit https://groups.google.com/d/msgid/cgrates/c8f89ee2-7848-497b-86bf-05ad26999513n%40googlegroups.com.

S.Hossein Katebi

unread,
Nov 2, 2023, 4:41:06 AM11/2/23
to CGRateS
Hi Gezim,

I will provide them as soon as possible.
I turned them on, and my database is still empty and no CDRs are generated and stored in DB.
Should I wait after the user is disconnected for the CGRateS to generate the CDRs before I stop CGRateS?

Yours sincerely,
Katebi

Gezim Blliku

unread,
Nov 2, 2023, 12:16:36 PM11/2/23
to cgr...@googlegroups.com
Hi Katebi,

I am not sure what you meant with your last question ,the  CDR will get generated after the user has hangup the call no need to stop CGrateS.

Best regards,
Gezim


S.Hossein Katebi

unread,
Nov 4, 2023, 6:12:31 AM11/4/23
to CGRateS

Hi Gezim,

I have captured the ngrep pcap (ngrep.pcap) and the logs (ngrep.log) as well as the CDRs (cdr.json) and session costs (session-costs.json) from my database.
I have attached them here.
Just so you know, I have a problem with my CTF (my open5gs core) that does not terminate the session unless the user tries to reconnect. So to generate the CDRs, I reconnected the user so that the CTF sends the termination request and the CDR gets generated. Because of this, you might see two initial connection requests. You can ignore the second one because it was not successful.

Thank you,
Katebi
ngrep.pcap
cdr.json
session-costs.json
ngrep.log

Gezim Blliku

unread,
Nov 7, 2023, 11:12:35 AM11/7/23
to cgr...@googlegroups.com
Hi  Katebi,

To apply your rates you can do it   by specifying  a  ratingsubject on the   user's balance e.g  https://github.com/cgrates/cgrates/blob/master/data/tariffplans/oldtutorial/Actions.csv#L4, with the  subject of a  ratingprofile e.g  https://github.com/cgrates/cgrates/blob/master/data/tariffplans/oldtutorial/RatingProfiles.csv#L4  containing the rates for data usage .Another method can be overwriting in the  "balance_rating_subject"  *data field https://github.com/cgrates/cgrates/blob/master/config/config_defaults.go#L337 to an empty subject  and   creating  a monetary balance for the user .

Best Regards,
Gezim


S.Hossein Katebi

unread,
Nov 11, 2023, 2:24:26 AM11/11/23
to CGRateS
Hi Gezim.

Thank you for the advice!
I will try this ASAP.

Best Regards,
Katebi

Awesome Dev

unread,
Nov 26, 2024, 10:22:29 AM11/26/24
to CGRateS
@S.Hossein Katebi Could you share the working cgrates.json file please?
Reply all
Reply to author
Forward
0 new messages