Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring PyHSS with open5Gs #215

Open
alexeymx opened this issue Dec 16, 2024 · 11 comments
Open

Configuring PyHSS with open5Gs #215

alexeymx opened this issue Dec 16, 2024 · 11 comments

Comments

@alexeymx
Copy link

Hello everyone, i have several questions

I successfully installed Pyhss and could populace AcUs, Subscribers, apns,

how can i connect my open5gs setup to PyHSS to completely avoid using built-in hss and be able to run it as EPC / 4G ?

Thank you in advance, would be great to add some example here

@9600
Copy link

9600 commented Dec 16, 2024

In the Open5GS config:

  1. freeDiameter/mme.conf

The "connectPeer = " line, typically at the end of the file, would need to point to the PyHSS instance. The hostname should be the same as the OriginHost value set in PyHSS config.yaml and the IP obviously the address it is running on.

This is for the S6a interface from MME to HSS.

  1. freeDiameter/smf.conf

This should have the same "connectPeer =" line as above.

This is for the Gx interface from SMF to the PCRF provided by PyHSS.

Assuming you are running everything on the same host, you would probably also want to stop Open5GS HSS and PCRF from starting.

@alexeymx
Copy link
Author

In the Open5GS config:

  1. freeDiameter/mme.conf

The "connectPeer = " line, typically at the end of the file, would need to point to the PyHSS instance. The hostname should be the same as the OriginHost value set in PyHSS config.yaml and the IP obviously the address it is running on.

This is for the S6a interface from MME to HSS.

  1. freeDiameter/smf.conf

This should have the same "connectPeer =" line as above.

This is for the Gx interface from SMF to the PCRF provided by PyHSS.

Assuming you are running everything on the same host, you would probably also want to stop Open5GS HSS and PCRF from starting.

Hey! Thanks a lot for your reply, ok i understood that i'll stop open5gs hss and PCRF services.

is this setup enough to perform online charging ? i'm still a bit confused

There are 2 interfaces Gx and Gy, from what i understand connection SMF - PyHss implements Gx

But for credit control i need to implement Gy? how will i set this up

@9600
Copy link

9600 commented Dec 16, 2024

I don't know much about PCRF to be honest. My use case is for private networks and I just wanted to remove any reliance on Open5GS HSS/WebUI and MongoDB.

There are some PCRF notes in this repo, but I didn't see mention of Gy.

@ashokhs77
Copy link

Hello @9600 I am encountering the same issue now. I have followed your instructions above, but still the problem persists, attach fails.. with the following logs:

Under mme section, under freediameter, under connect, I gave the hss identity and the ip address. Did the same for freediameter connection under smf also. Hope its fine.

Updated the s1ap server address with the host address, updated the gummei and tai values appropriately.

Under sgwu, gtpu server address also I updated with host's ip address.

and disabled hss and pcrf and launched the EPC.

On the pyHSS config, I just updated the realm name with the same realm which was used by open5gs mme and the bind ip address and identity which was given for mme's freediameter.

Is this all I need to do or did I miss anything?

I launched the pyhss, added the APN, AUC, subscriber details and tried to attach a UE, initial authentication is passing and then attach is failing with diameter error 5030.

Attaching the epc console log for reference here.

02/27 19:13:30.225: [sgwc] INFO: [Added] Number of SGWC-Sessions is now 1 (../src/sgwc/context.c:924)
02/27 19:13:30.225: [sgwc] INFO: UE IMSI[404200100001915] APN[internet] (../src/sgwc/s11-handler.c:268)
02/27 19:13:30.225: [sgwu] INFO: UE F-SEID[UP:0xcbf CP:0xc87] (../src/sgwu/context.c:170)
02/27 19:13:30.225: [sgwu] INFO: [Added] Number of SGWU-Sessions is now 6 (../src/sgwu/context.c:175)
02/27 19:13:30.225: [smf] INFO: OLD Session Will Release [IMSI:404200100001915,APN:internet] (../src/smf/context.c:1407)
02/27 19:13:30.225: [smf] INFO: Removed Session: UE IMSI:[404200100001915] DNN:[internet:0] IPv4:[10.45.0.0] IPv6:[] (../src/smf/context.c:1693)
02/27 19:13:30.225: [smf] INFO: [Removed] Number of SMF-Sessions is now 0 (../src/smf/context.c:3198)
02/27 19:13:30.225: [smf] INFO: [Added] Number of SMF-Sessions is now 1 (../src/smf/context.c:3190)
02/27 19:13:30.225: [smf] INFO: UE IMSI[404200100001915] APN[internet] IPv4[10.45.0.0] IPv6[] (../src/smf/s5c-handler.c:303)
02/27 19:13:30.319: [smf] WARNING: ERROR DIAMETER Result Code(5030) (../src/smf/gx-path.c:888)
02/27 19:13:30.319: [smf] ERROR: Unexpected Diameter Result Code 5030/-1, defaulting to severe network failure (../src/smf/gsm-sm.c:57)
02/27 19:13:30.319: [sgwc] ERROR: No GTP TEID [Cause:125] (../src/sgwc/s5c-handler.c:143)
02/27 19:13:30.319: [sgwc] ERROR: No PDN Address Allocation [Cause:125] (../src/sgwc/s5c-handler.c:147)
02/27 19:13:30.320: [mme] ERROR: [404200100001915] No S11 TEID [Cause:103] (../src/mme/mme-s11-handler.c:285)
02/27 19:13:30.320: [mme] ERROR: [404200100001915] No S5C TEID [Cause:103] (../src/mme/mme-s11-handler.c:299)
02/27 19:13:30.320: [mme] ERROR: [404200100001915] No PDN Address Allocation [Cause:103] (../src/mme/mme-s11-handler.c:305)
02/27 19:13:30.320: [mme] ERROR: [404200100001915] Attach reject [Cause:103] (../src/mme/mme-s11-handler.c:318)
02/27 19:13:30.320: [mme] INFO: Removed Session: UE IMSI:[404200100001915] APN:[internet] (../src/mme/mme-gtp-path.c:416)
02/27 19:13:30.320: [mme] INFO: [Removed] Number of MME-Sessions is now 0 (../src/mme/mme-context.c:5055)
02/27 19:13:30.377: [mme] INFO: UE Context Release [Action:3] (../src/mme/s1ap-handler.c:1879)
02/27 19:13:30.377: [mme] INFO: ENB_UE_S1AP_ID[63] MME_UE_S1AP_ID[11] (../src/mme/s1ap-handler.c:1880)
02/27 19:13:30.377: [mme] INFO: IMSI[404200100001915] (../src/mme/s1ap-handler.c:1885)
02/27 19:13:30.377: [mme] INFO: [Removed] Number of eNB-UEs is now 0 (../src/mme/mme-context.c:5041)
02/27 19:13:30.377: [mme] INFO: [Removed] Number of MME-UEs is now 0 (../src/mme/mme-context.c:3695)

Please someone help me identify the issue and suggest the steps to overcome this.

Thanks & regards,
Ashok

@ashokhs77
Copy link

Hi @9600

Any update here? I did the 2 steps that you mentioned, but I have used srsenb.yaml on the open5gs to configure and launch the EPC. I did the 2 steps (for mme and smf that you mentioned in that only) and launched pyhss and configured apn, auc, subscriber, tfts and charging rule.

But when I try to attach the UE, the s6a/s6d interface between the mme and hss is success. But the Gx interface between SMF and PCRF is failing with DIAMETER_USER_UNKNOWN message for Credit Control Answers.

Not able to figure out how to solve this.

Please share any pointers.

Thanks & Regards,
Ashok

@ashokhs77
Copy link

Hi @9600 @nickvsnetworking

Found some differences between a working log (with the docker image based core+hss+ims) and the non-working log (with plain open5gs+pyhss)

In the working log, I see that the Credit Control Request is sending only the END_USER_IMSI (for the imsi) but for the non-working case, the Credit Control Request is coming with both END_USER_IMSI and END_USER_E164 (for msisdn).

But in the pyhss code, they are not parsing this filed (subscription-id type) while decoding the AVPs and while creating the response they iterate over the number of AVPs to copy the data directly to IMSI variable...so the 1st imsi is getting overwritten with msisdn value and subsequent usage of imsi variable is creating an issue.

So there are two issues...

  1. Why in non-working case, the CCR is coming with 2 messages (with both imsi and msisdn) how this is not the case in working log.
  2. When the pyhss gets both imsi and msisdn, its not handled properly

Attaching the screenshots of both the working and non-working case logs for your reference!

Image

Image

@ashokhs77
Copy link

ashokhs77 commented Mar 14, 2025

Hi @9600 @nickvsnetworking

In the working case above, both the hss in Open5GS and hss in pyhss are used. Open5GS for normal subscriber and pyhss for ims subscriber. And for open5gs hss, in the steps given under docker image usage, msisdn was not part of the subscriber config. Hence when msisdn is not present, the SMF will not send the msisdn in Gx CCR.

But now when I am using pyhss's hss itself for normal subscriber, I had entered msisdn and hence open5gs was sending msisdn also in CCR. But if I remove msisdn from the subscriber config, then it fails in the Authentication itself (in s6a/s6d interface). So only if I add msisdn again for the same subscriber then only Authentication will be success and it fails in CCA.

This is because briefly the HSS stops with the following error on console where I am running diameterService.py

[03/14/2025 15:01:09] [INFO] [Diameter] [writeOutboundData] [472a2135-c0a3-4126-8ac8-3871bc220df2] Connection closed for 127.0.0.1 on port 57712, closing writer.Traceback (most recent call last):
File "/etc/pyhss/services/diameterService.py", line 314, in writeOutboundData
diameterOutboundBinary = bytes.fromhex(outboundData.OutboundHex)
ValueError: non-hexadecimal number found in fromhex() arg at position 1192

and hence mme connection is lost and then connection gets reestablished. and the process repeats itself...

Any comments..? Has anyone faced similar issue ? Or am I the only one facing this issue?

Should I open a new issue for this ?

@ashokhs77
Copy link

Hi @nickvsnetworking

In the pyhss code for the Credit Control Answer, when the subscriber details are derived from AVPs, the imsi variable was getting overwritten with msisdn value because they were not checking for the Subscriber-ID Type to distinguish if it is IMSI or MSISDN, when both imsi and msisdn is sent over the Credit Control Request.

Added a code for the same and UE attached and traffic also worked :-)

Image

@alexeymx
Copy link
Author

alexeymx commented Mar 23, 2025

Hey ! Thanks guys so far i could make it work and playing with different eNbs. My goal is to create very basic billing and i'm familiar with python

i'd like to create certain flows -> captive portal ips, my webiste ip, paypal ips and add them in rating group as zero rate and the rest of traffic report to OSC and when user makes attach install proper limits with "reauth limits"

please give me a vector of implementation if you can :) i'm brand new to 3GPP protocols so my brain blows up ha ha

For example i see OCS webhook, so from what i understand i can push consumptions to my OCS but how can i reinstall for user updated remaining quotas?

@svinson1121
Copy link

@ashokhs77: Thank you for the Fix! I made a patch file for your code.
copy diameter.py.patch to /etc/pyhss/lib/ and from the lib dir run patch -p0 < diameter.py.patch

diameter.py.patch

@alexeymx
Copy link
Author

@ashokhs77: Thank you for the Fix! I made a patch file for your code.
copy diameter.py.patch to /etc/pyhss/lib/ and from the lib dir run patch -p0 < diameter.py.patch

diameter.py.patch

Thanks ! Very helpful . I made a fork in my case and managed to add conditions . Without your input I would probably spend weeks solving this trouble haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants