> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/smc/3.14/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/smc/3.14/config/aaa/charging/overview.md).

# Charging Overview

## What is Charging?

Charging is the process of collecting, measuring, and reporting resource usage for billing purposes. In mobile networks, charging tracks data volume, session duration, and service usage to generate bills for subscribers.

SMC implements charging functions for both traditional (EPC) and 5G Core networks, collecting detailed usage information and sending it to charging systems.

## Online vs Offline Charging

Mobile networks use two charging models:

### Online Charging

Online charging (also called prepaid or real-time charging) verifies credit availability before allowing service usage. The network checks with a charging system in real-time to ensure the subscriber has sufficient credit.

**How it works:**

1. User requests service (for example, data session)
2. SMC requests quota from Online Charging System (OCS)
3. OCS checks subscriber balance and grants quota (for example, 100 MB or 1 hour)
4. SMC allows service up to the granted quota
5. When quota is consumed, SMC requests more quota or terminates service
6. OCS deducts charges from subscriber balance immediately

**Advantages:**
- Prevents overspending
- Real-time balance deduction
- Fraud prevention

**Disadvantages:**
- Requires constant OCS availability
- Higher latency (quota checks delay service establishment)
- More complex implementation

**Use cases:**
- Prepaid mobile services
- Pay-as-you-go data
- Budget-controlled accounts

**Protocol:** Diameter Ro over Gy reference point (3GPP TS 32.299)

### Offline Charging

Offline charging (also called postpaid or batch charging) collects usage information during service delivery and processes it later for billing. The network allows service first and charges afterwards.

**How it works:**

1. User requests service
2. SMC allows service immediately
3. SMC collects usage information (data volume, duration, location)
4. SMC sends charging records to Charging Gateway Function (CGF) or billing system
5. Billing system processes records later (hourly, daily, monthly)
6. Subscriber receives bill periodically

**Advantages:**
- Simple implementation
- Low latency (no quota checks)
- Works when charging system is temporarily unavailable

**Disadvantages:**
- Risk of overspending
- Delayed fraud detection
- Requires credit risk management

**Use cases:**
- Postpaid mobile services
- Enterprise accounts
- Flat-rate unlimited plans

**Protocols:**
- Diameter Rf (3GPP TS 32.299)
- RADIUS Accounting ([IETF RFC 2866][RFC2866])
- Diameter NASREQ ([IETF RFC 7155][RFC7155])

## Charging in SMC

SMC supports both online and offline charging simultaneously. PCC rules control which charging type applies to specific traffic.

```yaml
aaa:
  applicationDetection:
    rules:
      prepaid-data:
        type: classic
        precedence: 50
        onlineEnabled: true   # Online charging
        offlineEnabled: false
        ratingGroup: 3000
        # ... flow configuration
      
      postpaid-data:
        type: classic
        precedence: 100
        onlineEnabled: false
        offlineEnabled: true  # Offline charging
        ratingGroup: 4000
        # ... flow configuration
      
      hybrid-data:
        type: classic
        precedence: 200
        onlineEnabled: true   # Both online and offline
        offlineEnabled: true
        ratingGroup: 5000
        onlineRatingGroup: 5001   # Separate rating groups
        offlineRatingGroup: 5002
        # ... flow configuration
```

## Charging Triggers

SMC generates charging records based on configured triggers. Different triggers cause different actions:

### CDR Generation Triggers

These triggers cause SMC to close the current CDR and send a new one:

- `ms-time-zone-change` - User's time zone changes
- `rat-change` - Radio Access Technology changes (for example, 3G to 4G)
- `sgsn-sgw-change` - Serving gateway changes
- `sgsn-sgw-plmn-id-change` - Serving network PLMN changes

### Charging Container Update Triggers

These triggers update the charging containers within the current CDR without closing it:

- `cgi-sai-change` - Cell Global Identity or Service Area Identity changes
- `ecgi-change` - E-UTRAN Cell Global Identifier changes
- `qos-change` - QoS parameters change
- `rai-change` - Routing Area Identifier changes
- `tai-change` - Tracking Area Identifier changes
- `tariff-switch-change` - Charging tariff changes
- `user-location-info-change` - User location information changes

### Trigger Configuration by Role

Triggers vary depending on SMC's role:

**SMC as GGSN/PGW:**
- **Container updates:** cgi-sai-change, ecgi-change, qos-change, rai-change, tai-change, tariff-switch-change, user-location-info-change
- **CDR generation:** ms-time-zone-change, rat-change, sgsn-sgw-change, sgsn-sgw-plmn-id-change

**SMC as TDF (Traffic Detection Function):**
- **Container updates:** sgsn-sgw-plmn-id-change, tariff-switch-change
- **CDR generation:** ms-time-zone-change

Reference: 3GPP TS 32.251, sections 5.2.3.4, 5.2.3.9, 5.2.3.10

## Change Reporting Action (CRA)

For location-dependent triggers, SMC sends a Change Reporting Action (CRA) IE in GTPv2 Create Session Response messages. This instructs the SGSN/SGW to notify SMC when location changes occur.

The CRA IE depends on:
- Access network type (UTRAN, E-UTRAN)
- CRSI (Change Reporting Support Indication) flag
- ENBCRSI (eNodeB Change Reporting Support Indication) flag
- Configured triggers

**Example CRA values:**

| Access Type | CRSI | ENBCRSI | Triggers | CRA IE Value |
|---|:---:|:---:|---|---|
| EUTRAN | true | true | tai-change AND user-location-info-change | 8 - Start Reporting TAI, Macro eNodeB ID, Extended Macro eNodeB ID |
| EUTRAN | true | true | user-location-info-change | 7 - Start Reporting Macro eNodeB ID, Extended Macro eNodeB ID |
| EUTRAN | true | any | tai-change AND ecgi-change | 6 - Start Reporting TAI and ECGI |
| EUTRAN | true | any | tai-change | 3 - Start Reporting TAI |
| EUTRAN | true | any | ecgi-change | 4 - Start Reporting ECGI |
| UTRAN | true | any | user-location-info-change | 5 - Start Reporting CGI/SAI and RAI |
| UTRAN | true | any | cgi-sai-change AND rai-change | 5 - Start Reporting CGI/SAI and RAI |
| UTRAN | true | any | cgi-sai-change | 1 - Start Reporting CGI/SAI |
| UTRAN | true | any | rai-change | 2 - Start Reporting RAI |

## Rating Groups

Rating groups categorise traffic for different billing rates. Multiple rules can share the same rating group to aggregate usage.

```yaml
aaa:
  applicationDetection:
    rules:
      basic-web:
        ratingGroup: 1000  # Standard rate
      
      premium-video:
        ratingGroup: 2000  # Premium rate
      
      zero-rated:
        ratingGroup: 9999  # Free (no charging)
        onlineEnabled: false
        offlineEnabled: false
```

Rating groups are sent in charging messages and used by the charging system to apply the correct billing rates.

Reference: [RFC 4006][RFC4006], section 5.1.2

## Metering Methods

Metering methods define what is measured for charging:

| Value | Method | Measures | Use Case |
|---|---|---|---|
| 0 | DURATION | Session time | Voice calls, flat-rate data |
| 1 | VOLUME | Data bytes | Volume-based data plans |
| 2 | DURATION_VOLUME | Both time and bytes | Combined billing |
| 3 | EVENT | Discrete events | SMS, MMS, service activations |

Configure per rule:

```yaml
rules:
  voice-call:
    meteringMethod: 0  # DURATION
  
  mobile-data:
    meteringMethod: 1  # VOLUME
  
  premium-service:
    meteringMethod: 2  # DURATION_VOLUME
```

## Charging Interfaces

SMC supports multiple charging interfaces:

| Interface | Protocol | Type | Standard | Use |
|---|---|---|---|---|
| Rf | Diameter | Offline | 3GPP TS 32.299 | Postpaid charging |
| Ro (Gy) | Diameter | Online | 3GPP TS 32.299 | Prepaid charging |
| RADIUS | RADIUS | Offline | [IETF RFC 2866][RFC2866] | Postpaid charging (legacy) |
| NASREQ | Diameter | Offline | [IETF RFC 7155][RFC7155] | Fixed network access |

See interface-specific documentation:
- [Rf Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/charging/rf.md) - Offline charging via Diameter
- [Ro (Gy) Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/charging/ro.md) - Online charging via Diameter and OCS
- [RADIUS Charging](https://docs.cennso.com/components/smc/3.14/config/aaa/charging/radius.md) - Offline charging via RADIUS

## Charging Data Records (CDRs)

A CDR (Charging Data Record) contains detailed information about resource usage:

**Common CDR fields:**
- **Session identifiers** - IMSI, MSISDN, Session-Id
- **Time information** - Start time, stop time, duration
- **Location information** - Cell ID, Tracking Area, PLMN
- **Volume information** - Uplink bytes, downlink bytes, total bytes
- **QoS information** - QoS class, bandwidth
- **Rating information** - Rating group, service identifier
- **Network information** - APN/DNN, IP address, RAT type
- **Charging identifiers** - Charging ID, correlation IDs

CDR types in SMC:
- **PGW-CDR** - Generated by SMC in PGW role
- **TDF-CDR** - Generated by SMC in TDF role
- **GGSN-CDR** - Generated by SMC in GGSN role (legacy 3G)

Reference: 3GPP TS 32.251

## Configuration Overview

Charging configuration is split across multiple areas:

**AAA Transport:**
- [Diameter Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/diameter-concepts.md) - Diameter transport for Rf/Ro/NASREQ
- [RADIUS Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/authentication/radius.md) - RADIUS transport

**Policy Control:**
- [PCC Rules](https://docs.cennso.com/components/smc/3.14/config/aaa/policy/pcc-rules.md) - Define charging parameters per rule
- [Gx Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/policy/gx.md) - Policy control via Diameter
- [Npcf Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/policy/npcf.md) - Policy control via HTTP/2

**Charging Interfaces:**
- [Rf Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/charging/rf.md) - Offline charging configuration
- [Ro Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/charging/ro.md) - Online charging configuration
- [RADIUS Charging](https://docs.cennso.com/components/smc/3.14/config/aaa/charging/radius.md) - RADIUS charging configuration

## Next Steps

1. Configure AAA transports:
   - [Diameter Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/diameter-concepts.md) for Rf/Ro (Gy)
   - [RADIUS Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/authentication/radius.md) for RADIUS accounting

2. Define PCC rules with charging parameters:
   - [PCC Rules Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/policy/pcc-rules.md)

3. Enable charging interfaces:
   - [Rf Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/charging/rf.md) for offline charging
   - [Ro (Gy) Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/charging/ro.md) for online charging
   - [RADIUS Charging](https://docs.cennso.com/components/smc/3.14/config/aaa/charging/radius.md) for RADIUS accounting

4. Configure policy interfaces to activate rules:
   - [Gx Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/policy/gx.md) for Diameter Gx
   - [Npcf Configuration](https://docs.cennso.com/components/smc/3.14/config/aaa/policy/npcf.md) for Npcf

[RFC2866]: https://www.rfc-editor.org/rfc/rfc2866.html
[RFC4006]: https://www.rfc-editor.org/rfc/rfc4006.html
[RFC7155]: https://www.rfc-editor.org/rfc/rfc7155.html
