Diameter Online Charging (Gy/Ro Interface)
Online Charging System (OCS) Interface
Table of Contents
- Overview
- 3GPP Charging Architecture
- Gy/Ro Interface Basics
- Credit Control Messages
- Online Charging Flows
- Bearer Charging Control
- Multiple Services Credit Control
- Configuration
- Message Flows
- Error Handling
- Integration with Gx
- Troubleshooting
Overview
The Gy interface (also called Ro interface in IMS contexts) connects PGW-C to the Online Charging System (OCS) for real-time credit control. This enables:
- Prepaid Charging - Real-time credit authorization and deduction
- Real-time Credit Control - Grant quota before service delivery
- Service-Based Charging - Different charging for voice, data, SMS, etc.
- Immediate Account Updates - Credit balance updates in real-time
- Service Denial - Block service when credit exhausted
Online vs. Offline Charging
| Aspect | Online Charging (Gy/Ro) | Offline Charging (Gz/Rf) |
|---|---|---|
| Timing | Real-time, before service | After service delivery |
| Use Case | Prepaid subscribers | Postpaid subscribers |
| Credit Check | Yes, before granting service | No, bill generated later |
| System | OCS (Online Charging System) | CGF/CDF (Charging Data Function) |
| Risk | No revenue loss | Risk of unpaid bills |
| Complexity | High (real-time requirements) | Lower (batch processing) |
| User Impact | Service denied if no credit | Service always available |
See also: Data CDR Format for offline charging records (postpaid billing)
See also: Session Management for complete PDN session lifecycle including charging integration
Gy in the Network Architecture
Key Functions
| Function | Description |
|---|---|
| Credit Authorization | Request quota from OCS before allowing traffic |
| Quota Management | Track granted units (bytes, time, events) |
| Credit Depletion Detection | Monitor remaining quota |
| Re-authorization | Request additional quota when threshold reached |
| Service Termination | Stop service when credit exhausted |
| Final Settlement | Report actual usage upon session end |
3GPP Charging Architecture
Charging Reference Points
Charging Trigger Function (CTF)
PGW-C acts as a CTF (Charging Trigger Function), responsible for:
- Detecting chargeable events - Session start, data usage, session end
- Requesting credit authorization - Before allowing service
- Tracking quota consumption - Monitor granted units
- Generating charging events - Trigger credit requests
- Enforcing credit control - Block traffic when quota exhausted
Online Charging Function (OCF)
The OCS implements the OCF (Online Charging Function):
- Account balance management - Track subscriber credit
- Rating - Determine price per unit (per MB, per second, etc.)
- Credit reservation - Reserve credit for granted quota
- Credit deduction - Deduct upon usage report
- Policy decisions - Grant or deny based on balance
Gy/Ro Interface Basics
3GPP Reference
- Specification: 3GPP TS 32.299 (Charging architecture)
- Protocol: 3GPP TS 32.251 (PS domain charging)
- Diameter Application ID: 4 (Gy/Ro - Credit Control Application)
- Base Protocol: RFC 4006 (Diameter Credit Control Application)
Session Concept
Each UE PDN connection requiring online charging has a Gy/Ro session identified by a Session-ID. This session:
- Created when bearer requires online charging (CCR-Initial)
- Updated when quota is consumed (CCR-Update)
- Terminated when session ends (CCR-Termination)
Session ID Format
Session-ID: <Origin-Host>;<high32>;<low32>[;<optional>]
Example: omni-pgw_c.epc.mnc999.mcc999.3gppnetwork.org;9876543210;12345;gy
Components:
- Origin-Host: PGW-C's Diameter identity
- high32: High 32 bits of unique identifier
- low32: Low 32 bits of unique identifier
- optional: Additional identifier (e.g., "gy" to distinguish from Gx)
Credit Control Messages
Message Types
CCR-Initial (Credit Control Request - Initial)
When: UE creates a PDN connection and bearer requires online charging
Purpose:
- Request initial credit authorization from OCS
- Reserve quota for service delivery
- Establish Gy/Ro session
Key AVPs Sent by PGW-C:
| AVP Name | AVP Code | Type | Description |
|---|---|---|---|
| Session-Id | 263 | UTF8String | Unique Gy session identifier |
| Auth-Application-Id | 258 | Unsigned32 | 4 (Credit Control) |
| Origin-Host | 264 | DiamIdent | PGW-C's Diameter identity |
| Origin-Realm | 296 | DiamIdent | PGW-C's Diameter realm |
| Destination-Realm | 283 | DiamIdent | OCS's realm |
| CC-Request-Type | 416 | Enumerated | 1 = INITIAL_REQUEST |
| CC-Request-Number | 415 | Unsigned32 | Sequence number (starts at 0) |
| Subscription-Id | 443 | Grouped | UE identifier (IMSI/MSISDN) |
| Service-Context-Id | 461 | UTF8String | Charging context identifier |
| Multiple-Services-Credit-Control | 456 | Grouped | Service-specific credit requests |
| Requested-Service-Unit | 437 | Grouped | Requested quota (bytes, time, etc.) |
| Used-Service-Unit | 446 | Grouped | Used quota (0 for initial) |
| Service-Identifier | 439 | Unsigned32 | Service type identifier |
| Rating-Group | 432 | Unsigned32 | Charging category identifier |
Example CCR-I Structure:
CCR (Command Code: 272, Request)
├── Session-Id: "pgw_c.example.com;123;456;gy"
├── Auth-Application-Id: 4
├── Origin-Host: "omni-pgw_c.epc.mnc999.mcc999.3gppnetwork.org"
├── Origin-Realm: "epc.mnc999.mcc999.3gppnetwork.org"
├── Destination-Realm: "epc.mnc999.mcc999.3gppnetwork.org"
├── CC-Request-Type: INITIAL_REQUEST (1)
├── CC-Request-Number: 0
├── Subscription-Id (Grouped)
│ ├── Subscription-Id-Type: END_USER_IMSI (1)
│ └── Subscription-Id-Data: "310260123456789"
├── Subscription-Id (Grouped)
│ ├── Subscription-Id-Type: END_USER_E164 (0)
│ └── Subscription-Id-Data: "15551234567"
├── Service-Context-Id: "32251@3gpp.org"
├── Multiple-Services-Credit-Control (Grouped)
│ ├── Service-Identifier: 1
│ ├── Rating-Group: 100
│ └── Requested-Service-Unit (Grouped)
│ └── CC-Total-Octets: 10000000 (request 10 MB)
└── Used-Service-Unit (Grouped)
└── CC-Total-Octets: 0 (no usage yet)
CCA-Initial (Credit Control Answer - Initial)
Sent by: OCS in response to CCR-I
Purpose:
- Grant or deny credit authorization
- Provide quota for service delivery
- Specify rating and charging parameters
Key AVPs Received by PGW-C:
| AVP Name | AVP Code | Description |
|---|---|---|
| Result-Code | 268 | Success (2001) or error code |
| Multiple-Services-Credit-Control | 456 | Service-specific credit grants |
| Granted-Service-Unit | 431 | Granted quota (bytes, time, etc.) |
| Validity-Time | 448 | Quota validity period (seconds) |
| Result-Code | 268 | Per-service result code |
| Final-Unit-Indication | 430 | Action when quota exhausted |
| Volume-Quota-Threshold | - | Threshold for re-authorization |
Success Response Example:
CCA (Command Code: 272, Answer)
├── Session-Id: "pgw_c.example.com;123;456;gy"
├── Result-Code: DIAMETER_SUCCESS (2001)
├── Origin-Host: "ocs.example.com"
├── Origin-Realm: "example.com"
├── Auth-Application-Id: 4
├── CC-Request-Type: INITIAL_REQUEST (1)
├── CC-Request-Number: 0
└── Multiple-Services-Credit-Control (Grouped)
├── Result-Code: DIAMETER_SUCCESS (2001)
├── Service-Identifier: 1
├── Rating-Group: 100
├── Granted-Service-Unit (Grouped)
│ └── CC-Total-Octets: 10000000 (granted 10 MB)
├── Validity-Time: 3600 (quota valid for 1 hour)
└── Volume-Quota-Threshold: 8000000 (re-auth at 8 MB used, 80%)
CCR-Update (Credit Control Request - Update)
When:
- Granted quota threshold reached (e.g., 80% consumed)
- Validity time expires
- Service change requires re-authorization
- Tariff time change
Purpose:
- Request additional quota
- Report usage of previously granted quota
- Update charging parameters
Key Differences from CCR-I:
CC-Request-Type: UPDATE_REQUEST (2)CC-Request-NumberincrementedUsed-Service-Unitcontains actual usageRequested-Service-Unitfor more quota
Example CCR-U Structure:
CCR (Command Code: 272, Request)
├── Session-Id: "pgw_c.example.com;123;456;gy"
├── Auth-Application-Id: 4
├── Origin-Host: "omni-pgw_c.epc.mnc999.mcc999.3gppnetwork.org"
├── Origin-Realm: "epc.mnc999.mcc999.3gppnetwork.org"
├── Destination-Realm: "epc.mnc999.mcc999.3gppnetwork.org"
├── CC-Request-Type: UPDATE_REQUEST (2)
├── CC-Request-Number: 1
└── Multiple-Services-Credit-Control (Grouped)
├── Service-Identifier: 1
├── Rating-Group: 100
├── Used-Service-Unit (Grouped)
│ └── CC-Total-Octets: 8000000 (8 MB used so far)
└── Requested-Service-Unit (Grouped)
└── CC-Total-Octets: 10000000 (request another 10 MB)
CCA-Update (Credit Control Answer - Update)
Sent by: OCS in response to CCR-U
Purpose:
- Grant additional quota (if credit available)
- Acknowledge usage
- Update charging parameters
Possible Outcomes:
1. More Quota Granted:
CCA (Update)
└── Multiple-Services-Credit-Control
├── Result-Code: DIAMETER_SUCCESS (2001)
├── Granted-Service-Unit
│ └── CC-Total-Octets: 10000000 (another 10 MB)
└── Validity-Time: 3600
2. Final Quota (Credit Exhausted):
CCA (Update)
└── Multiple-Services-Credit-Control
├── Result-Code: DIAMETER_SUCCESS (2001)
├── Granted-Service-Unit
│ └── CC-Total-Octets: 1000000 (only 1 MB left)
└── Final-Unit-Indication
└── Final-Unit-Action: TERMINATE (0)
3. No Credit Available:
CCA (Update)
├── Result-Code: DIAMETER_CREDIT_LIMIT_REACHED (4012)
└── Multiple-Services-Credit-Control
├── Result-Code: DIAMETER_CREDIT_LIMIT_REACHED (4012)
└── Final-Unit-Indication
└── Final-Unit-Action: TERMINATE (0)
CCR-Termination (Credit Control Request - Termination)
When:
- UE detaches
- PDN connection deleted
- Session terminated for any reason
Purpose:
- Final usage report
- Close Gy/Ro session
- Final settlement
Key Differences:
CC-Request-Type: TERMINATION_REQUEST (3)Used-Service-Unitcontains final usage- No
Requested-Service-Unit(no more quota needed) - Includes
Termination-Cause
Example CCR-T Structure:
CCR (Command Code: 272, Request)
├── Session-Id: "pgw_c.example.com;123;456;gy"
├── Auth-Application-Id: 4
├── Origin-Host: "omni-pgw_c.epc.mnc999.mcc999.3gppnetwork.org"
├── Origin-Realm: "epc.mnc999.mcc999.3gppnetwork.org"
├── Destination-Realm: "epc.mnc999.mcc999.3gppnetwork.org"
├── CC-Request-Type: TERMINATION_REQUEST (3)
├── CC-Request-Number: 5
├── Termination-Cause: DIAMETER_LOGOUT (1)
└── Multiple-Services-Credit-Control (Grouped)
├── Service-Identifier: 1
├── Rating-Group: 100
└── Used-Service-Unit (Grouped)
└── CC-Total-Octets: 18500000 (18.5 MB total usage)
CCA-Termination (Credit Control Answer - Termination)
Sent by: OCS in response to CCR-T
Purpose:
- Acknowledge session termination
- Complete accounting
- Release reserved credit
Example CCA-T:
CCA (Command Code: 272, Answer)
├── Session-Id: "pgw_c.example.com;123;456;gy"
├── Result-Code: DIAMETER_SUCCESS (2001)
├── Origin-Host: "ocs.example.com"
├── Origin-Realm: "example.com"
├── Auth-Application-Id: 4
├── CC-Request-Type: TERMINATION_REQUEST (3)
└── CC-Request-Number: 5
Online Charging Flows
Service Unit Types
The OCS can grant quota in different units:
| Unit Type | AVP | Description | Use Case |
|---|---|---|---|
| Time | CC-Time | Seconds | Voice calls, session duration |
| Volume | CC-Total-Octets | Bytes (total up+down) | Data services |
| Volume (separate) | CC-Input-Octets, CC-Output-Octets | Bytes (separate) | Asymmetric charging |
| Service-Specific | CC-Service-Specific-Units | Custom units | SMS, MMS, API calls |
| Events | - | Counted events | Pay-per-use services |
Quota Threshold Management
Problem: How does PGW-C know when to request more quota?
Solution: OCS provides a Volume-Quota-Threshold or Time-Quota-Threshold. PGW-C monitors usage via PFCP Session Reports from PGW-U (see PFCP Interface).
Example Flow:
1. OCS grants 10 MB quota with 80% threshold (8 MB)
2. PGW-C monitors usage via PGW-U usage reports (PFCP Session Reports)
3. When usage reaches 8 MB:
→ PGW-C sends CCR-Update
→ Continue allowing traffic (don't wait for response)
4. OCS responds with more quota
5. If quota exhausted before CCR-Update sent:
→ PGW-C must block traffic
Threshold Calculation:
Granted-Service-Unit: 10000000 bytes (10 MB)
Volume-Quota-Threshold: 8000000 bytes (8 MB)
When 8 MB consumed → Trigger CCR-Update
Remaining buffer: 2 MB (allows time for OCS response)
PGW-C Monitoring:
PGW-C monitors usage via PFCP Session Reports from PGW-U:
Final Unit Indication
What happens when credit is exhausted?
OCS includes Final-Unit-Indication AVP in CCA to specify action:
| Final-Unit-Action | Value | PGW-C Behavior |
|---|---|---|
| TERMINATE | 0 | Block all traffic, initiate session termination |
| REDIRECT | 1 | Redirect traffic to portal (e.g., top-up page) |
| RESTRICT_ACCESS | 2 | Allow access only to specific services (e.g., top-up server) |
Example: Final Unit with Redirect
CCA (Update)
└── Multiple-Services-Credit-Control
├── Result-Code: DIAMETER_SUCCESS (2001)
├── Granted-Service-Unit
│ └── CC-Total-Octets: 1000000 (final 1 MB)
└── Final-Unit-Indication
├── Final-Unit-Action: REDIRECT (1)
└── Redirect-Server (Grouped)
├── Redirect-Address-Type: URL (2)
└── Redirect-Server-Address: "http://topup.example.com"
PGW-C Actions:
- TERMINATE: Send CCR-T, delete bearer
- REDIRECT: Install PFCP rule to redirect HTTP to top-up URL
- RESTRICT_ACCESS: Install PFCP rules allowing only whitelisted IPs
Bearer Charging Control
What Controls if a Bearer is Charged?
3GPP Specification: TS 23.203, TS 29.212, TS 32.251
Bearer charging is controlled by PCC Rules provisioned by the PCRF via the Gx interface. See Diameter Gx Interface for complete PCC rule documentation.
Charging Decision Flow:
PCC Rule with Charging Information
PCRF Response (CCA-I on Gx):
CCA (Gx Interface)
└── Charging-Rule-Definition (Grouped)
├── Charging-Rule-Name: "prepaid_data_rule"
├── Rating-Group: 100
├── Online: 1 (enable online charging)
├── Offline: 0 (disable offline charging)
├── Metering-Method: VOLUME (1)
├── Precedence: 100
├── Flow-Information: [...]
└── QoS-Information: [...]
Key Charging AVPs in PCC Rules:
| AVP Name | AVP Code | Values | Description |
|---|---|---|---|
| Rating-Group | 432 | Unsigned32 | Charging category (maps to tariff in OCS) |
| Online | 1009 | 0=Disable, 1=Enable | Enable online charging (Gy) |
| Offline | 1008 | 0=Disable, 1=Enable | Enable offline charging (Gz) |
| Metering-Method | 1007 | 0=Duration, 1=Volume, 2=Both | What to meter |
| Reporting-Level | 1011 | 0=Service, 1=Rating Group | Granularity of usage reports |
Bearer Charging Decision Matrix
| Online | Offline | Rating-Group | Behavior |
|---|---|---|---|
| 1 | 0 | Present | Online charging only (prepaid) |
| 0 | 1 | Present | Offline charging only (postpaid) |
| 1 | 1 | Present | Both online and offline (convergent) |
| 0 | 0 | - | No charging (free service) |
Multiple Rating Groups
A single PDN connection can have multiple bearers with different rating groups:
Example Scenario:
Default Bearer (Internet)
├── Rating-Group: 100 (Standard Data)
└── Online: 1
Dedicated Bearer 1 (Video Streaming)
├── Rating-Group: 200 (Video Service)
└── Online: 1
Dedicated Bearer 2 (IMS Voice)
├── Rating-Group: 300 (Voice)
└── Online: 1
PGW-C Gy Behavior:
- Single CCR-I with multiple MSCC (Multiple-Services-Credit-Control) sections:
CCR-Initial
├── Session-Id: "..."
└── Multiple-Services-Credit-Control
├── [Rating-Group: 100] → Standard Data
├── [Rating-Group: 200] → Video Service
└── [Rating-Group: 300] → Voice
OCS Response:
CCA-Initial
└── Multiple-Services-Credit-Control
├── [Rating-Group: 100] → Granted: 10 MB
├── [Rating-Group: 200] → Granted: 5 MB (video more expensive)
└── [Rating-Group: 300] → Granted: 60 seconds
Per-Service Charging Enforcement
PGW-C tracks quota per Rating-Group:
# Pseudocode
state.charging_quotas = %{
100 => %{granted: 10_000_000, used: 0, threshold: 8_000_000},
200 => %{granted: 5_000_000, used: 0, threshold: 4_000_000},
300 => %{granted: 60_000, used: 0, threshold: 48_000} # milliseconds
}
Usage Monitoring per Bearer:
Multiple Services Credit Control
MSCC (Multiple-Services-Credit-Control) AVP
Purpose: Group charging information for a specific service/rating group
Structure:
Multiple-Services-Credit-Control (Grouped, AVP 456)
├── Service-Identifier (Unsigned32, AVP 439)
├── Rating-Group (Unsigned32, AVP 432)
├── Requested-Service-Unit (Grouped, AVP 437)
│ ├── CC-Time (Unsigned32, AVP 420)
│ ├── CC-Total-Octets (Unsigned64, AVP 421)
│ ├── CC-Input-Octets (Unsigned64, AVP 412)
│ └── CC-Output-Octets (Unsigned64, AVP 414)
├── Used-Service-Unit (Grouped, AVP 446)
│ └── [Same structure as Requested-Service-Unit]
├── Granted-Service-Unit (Grouped, AVP 431)
│ └── [Same structure as Requested-Service-Unit]
├── Validity-Time (Unsigned32, AVP 448)
├── Result-Code (Unsigned32, AVP 268)
└── Final-Unit-Indication (Grouped, AVP 430)
└── Final-Unit-Action (Enumerated, AVP 449)
Service-Identifier vs. Rating-Group
| Attribute | Service-Identifier | Rating-Group |
|---|---|---|
| Purpose | Identifies service type | Identifies charging category |
| Example | 1=Data, 2=Voice, 3=SMS | 100=Regular, 200=Premium |
| Granularity | Broad classification | Specific tariff |
| Required | Optional | Required for charging |
| Mapping | May map to multiple RGs | Single tariff in OCS |
Example:
Service-Identifier: 1 (Data Service)
├── Rating-Group: 100 (Standard Data - $0.01/MB)
└── Rating-Group: 200 (Premium Data - $0.05/MB)
Service-Identifier: 2 (Voice)
└── Rating-Group: 300 (Voice Calls - $0.10/min)
Configuration
Basic Gy Configuration
Edit config/runtime.exs:
config :pgw_c,
gy: %{
# Enable or disable online charging globally
enabled: true,
# OCS connection timeout (milliseconds)
timeout_ms: 5000,
# Default quota request (bytes) if not specified by PCRF
default_requested_quota: 10_000_000, # 10 MB
# Threshold percentage for re-authorization
# (0.8 = trigger CCR-Update at 80% quota consumed)
quota_threshold_percentage: 0.8,
# Action when OCS timeout occurs
# Options: :block, :allow
timeout_action: :block,
# Action when OCS returns no credit
# Options: :terminate, :redirect
no_credit_action: :terminate,
# Redirect URL for top-up (used if no_credit_action: :redirect)
topup_redirect_url: "http://topup.example.com"
},
diameter: %{
listen_ip: "0.0.0.0",
host: "omni-pgw_c.epc.mnc999.mcc999.3gppnetwork.org",
realm: "epc.mnc999.mcc999.3gppnetwork.org",
# OCS peer configuration
peer_list: [
# PCRF for policy control (Gx)
%{
host: "pcrf.epc.mnc999.mcc999.3gppnetwork.org",
realm: "epc.mnc999.mcc999.3gppnetwork.org",
ip: "10.0.0.30",
initiate_connection: true
},
# OCS for online charging (Gy)
%{
host: "ocs.epc.mnc999.mcc999.3gppnetwork.org",
realm: "epc.mnc999.mcc999.3gppnetwork.org",
ip: "10.0.0.40",
initiate_connection: true
}
]
}
Configuration Parameters Explained
enabled
true: Online charging active, CCR messages sent to OCSfalse: Online charging disabled, no Gy messages
timeout_ms
- Time to wait for CCA response from OCS
- Recommended: 3000-5000 ms
default_requested_quota
- Default quota to request if PCRF doesn't specify
- Typical values: 1-100 MB
quota_threshold_percentage
- Trigger CCR-Update when this % of quota consumed
- Recommended: 0.75-0.85 (75%-85%)
- Higher = fewer messages, but risk of quota exhaustion
- Lower = more messages, but safer
timeout_action
:block- Block traffic if OCS doesn't respond (safer, prevents revenue loss):allow- Allow traffic if OCS doesn't respond (better UX, revenue risk)
no_credit_action
:terminate- Delete bearer when credit exhausted:redirect- Redirect to top-up portal
Environment-Specific Configuration
Production (prepaid subscribers):
config :pgw_c,
gy: %{
enabled: true,
timeout_action: :block,
no_credit_action: :terminate,
quota_threshold_percentage: 0.8
}
Test/Development:
config :pgw_c,
gy: %{
enabled: false # Disable for testing
}
Hybrid (some prepaid, some postpaid):
config :pgw_c,
gy: %{
enabled: true, # Controlled per-subscriber by PCRF
timeout_action: :allow, # Don't block postpaid on OCS failure
no_credit_action: :terminate
}
Message Flows
Successful Session with Online Charging
Quota Re-authorization (CCR-Update)
Credit Exhaustion (Final Unit)
OCS Timeout Handling
Error Handling
Result Codes
Success Codes:
| Code | Name | Action |
|---|---|---|
| 2001 | DIAMETER_SUCCESS | Continue with granted quota |
Transient Failures (4xxx):
| Code | Name | PGW-C Action |
|---|---|---|
| 4010 | DIAMETER_TOO_BUSY | Retry with backoff |
| 4011 | DIAMETER_UNABLE_TO_COMPLY | Log error, may retry |
| 4012 | DIAMETER_CREDIT_LIMIT_REACHED | Terminate or redirect |
Permanent Failures (5xxx):
| Code | Name | PGW-C Action |
|---|---|---|
| 5003 | DIAMETER_AUTHORIZATION_REJECTED | Reject session |
| 5031 | DIAMETER_USER_UNKNOWN | Reject session (invalid subscriber) |
Per-Service Result Codes
Important: Result-Code can appear at two levels:
- Message level - Overall result
- MSCC level - Per-service result
Example:
CCA-Initial
├── Result-Code: DIAMETER_SUCCESS (2001) ← Message level: OK
└── Multiple-Services-Credit-Control
├── [Rating-Group: 100]
│ └── Result-Code: DIAMETER_SUCCESS (2001) ← RG 100: OK
└── [Rating-Group: 200]
└── Result-Code: DIAMETER_CREDIT_LIMIT_REACHED (4012) ← RG 200: No credit
PGW-C Behavior:
- Allow traffic for Rating-Group 100
- Block traffic for Rating-Group 200
Integration with Gx
The Gx interface (PCRF policy control) determines whether online charging is required and provides the Rating-Group that drives Gy charging. See Diameter Gx Interface for complete policy control documentation.
Gx and Gy Relationship
Integration Flow
1. Bearer Setup:
PGW-C receives Create Session Request
↓
Send CCR-I to PCRF (Gx)
↓
Receive CCA-I with PCC Rules
↓
Parse PCC Rules:
- Does rule have Rating-Group?
- Is Online = 1?
↓
If YES:
Send CCR-I to OCS (Gy) with Rating-Group
↓
Receive CCA-I with quota
↓
If quota granted: Proceed
If no credit: Reject bearer
If NO:
Proceed without online charging
2. Dynamic Policy Update (RAR from PCRF):
PCRF sends RAR (Re-Auth-Request) on Gx
↓
New PCC Rule added with Online=1, Rating-Group=200
↓
PGW-C sends CCR-U to OCS (Gy)
- Add MSCC for Rating-Group 200
↓
OCS grants quota for new service
↓
Install dedicated bearer with online charging
Troubleshooting
Common Issues
1. CCR-Initial to OCS Timeouts
Symptoms:
- Sessions fail with "OCS timeout"
- Log: "CCR-Initial (Gy) timeout"
Possible Causes:
- OCS not reachable
- Incorrect OCS IP in configuration
- Firewall blocking Diameter port (3868)
- OCS overloaded
Resolution:
# Test network connectivity
ping <ocs_ip>
# Test Diameter port (TCP 3868)
telnet <ocs_ip> 3868
# Check configuration
# Ensure OCS peer is configured in peer_list
2. Sessions Rejected by OCS
Symptoms:
- CCA-I with Result-Code != 2001
- Create Session Response fails
Common Result Codes:
| Result Code | Likely Cause | Resolution |
|---|---|---|
| 4012 | Credit limit reached | Subscriber needs to top-up |
| 5003 | Authorization rejected | Check subscriber permissions |
| 5031 | User unknown | Provision subscriber in OCS |
Debug Steps:
- Check OCS logs for rejection reason
- Verify subscriber balance in OCS
- Check IMSI/MSISDN in CCR-I matches subscriber record
3. Quota Exhaustion Not Detected
Symptoms:
- User continues using data after balance exhausted
- No CCR-Update sent
Possible Causes:
- URR (Usage Reporting Rule) not installed in PGW-U
- Threshold not configured correctly
- PFCP Session Reports not received
Debug Steps:
-
Verify URR in PFCP Session Establishment:
Create URR
├── URR-ID: 1
├── Measurement-Method: VOLUME
├── Volume-Threshold: 8000000 (8 MB)
└── Reporting-Triggers: VOLUME_THRESHOLD -
Check PGW-U logs for usage reports
-
Verify
quota_threshold_percentagein config
4. Incorrect Rating-Group
Symptoms:
- OCS rejects with "Unknown Rating-Group"
- Sessions fail
Cause:
- Rating-Group in CCR-I doesn't match OCS configuration
- PCRF provisioned invalid Rating-Group
Resolution:
- Verify Rating-Group in PCC Rule from PCRF
- Check OCS configuration for valid Rating-Groups
- Ensure mapping between PCC Rules and OCS tariffs
Monitoring
Key Metrics
# Gy message rates
rate(gy_inbound_messages_total{message_type="cca"}[5m])
rate(gy_outbound_messages_total{message_type="ccr"}[5m])
# Gy error rates
rate(gy_inbound_errors_total[5m])
# Quota exhaustion events
rate(gy_quota_exhausted_total[5m])
# OCS timeout rate
rate(gy_timeout_total[5m])
# Gy message handling duration
histogram_quantile(0.95, rate(gy_inbound_handling_duration_bucket[5m]))
Alerts
# Alert on high Gy error rate
- alert: GyErrorRateHigh
expr: rate(gy_inbound_errors_total[5m]) > 0.1
for: 5m
annotations:
summary: "High Gy error rate detected"
# Alert on OCS timeout
- alert: OcsTimeout
expr: rate(gy_timeout_total[5m]) > 0.05
for: 2m
annotations:
summary: "OCS timeouts occurring"
# Alert on credit exhaustion spike
- alert: CreditExhaustionSpike
expr: rate(gy_quota_exhausted_total[5m]) > 10
for: 5m
annotations:
summary: "High rate of credit exhaustion"
Web UI - Gy Credit Control Simulator
OmniPGW includes a built-in Gy/Ro simulator for testing online charging functionality without requiring an external OCS.
Access: http://<omnipgw-ip>:<web-port>/gy_simulator

Purpose: Test and simulate online charging scenarios for prepaid subscribers
Features:
1. Request Parameters
- IMSI - Subscriber identity (e.g., "310170123456789")
- MSISDN - Phone number (e.g., "14155551234")
- Requested Units - Amount of quota to request (in bytes)
- Service ID - Service type identifier
- Rating Group - Charging category
2. CCR-I Simulation
- Send CCR-Initial (Credit-Control-Request Initial)
- Simulates initial quota request during session establishment
- Tests OCS integration without live traffic
3. Use Cases
- Development Testing - Test Gy interface during development
- OCS Integration - Verify OCS connectivity and responses
- Quota Testing - Test different quota scenarios
- Troubleshooting - Debug charging issues
- Demo - Demonstrate online charging to stakeholders
How to Use:
1. Enter subscriber details (IMSI, MSISDN)
2. Set requested units (e.g., 1000000 for 1 MB)
3. Configure Service ID and Rating Group
4. Click "Send CCR-I"
5. View OCS response and granted quota
Benefits:
- No need for external OCS during testing
- Quick validation of charging logic
- Safe testing environment
- Useful for training and demos
Related Documentation
Charging and Policy
- Diameter Gx Interface - PCRF policy control, PCC rules that trigger online charging
- Data CDR Format - Offline charging records for postpaid billing
- Configuration Guide - Complete online charging configuration parameters
Session Management
- Session Management - PDN session lifecycle, bearer management
- PFCP Interface - Usage reporting from PGW-U via URRs
- S5/S8 Interface - GTP-C bearer setup and teardown
Operations
- Monitoring Guide - Gy metrics, quota tracking, OCS timeout alerts
- UE IP Allocation - IP pool configuration for charged sessions