> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/smc/3.15/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.15/config/aaa/charging/radius.md).

# RADIUS Charging Configuration

## Overview

RADIUS Accounting provides offline charging for mobile networks using the RADIUS protocol specified in [IETF RFC 2866][RFC2866]. SMC sends Accounting-Request messages to a RADIUS server, which processes them for billing and monitoring.

RADIUS charging is simpler than Diameter but less feature-rich. It is commonly used in legacy deployments or for interoperability with existing RADIUS infrastructure.

References:
- [IETF RFC 2866][RFC2866] - RADIUS Accounting
- [IETF RFC 2865][RFC2865] - RADIUS Authentication
- [RADIUS Configuration](https://docs.cennso.com/components/smc/3.15/config/aaa/authentication/radius.md) - RADIUS transport and server configuration
- [Charging Overview](https://docs.cennso.com/components/smc/3.15/config/aaa/charging/overview.md) - Charging concepts

## Basic Configuration

Enable RADIUS charging by enabling specific accounting phases:

```yaml
aaa:
  radius:
    enabled: true
    start:
      enabled: true   # Send Accounting-Start
    interim:
      enabled: true   # Send Accounting-Interim
    stop:
      enabled: true   # Send Accounting-Stop
    server:
      addr: "192.168.1.100"
      type: "ipv4"
      password: "sharedsecret"
      acct:
        port: 1813     # Standard RADIUS accounting port
```

See [RADIUS Configuration](https://docs.cennso.com/components/smc/3.15/config/aaa/authentication/radius.md) for detailed server and transport configuration.

## Accounting Phases

### Accounting-Start

Sent when a user session is established. Contains initial session information:
- User identity (IMSI as User-Name)
- Session start time (Event-Timestamp)
- Network context (NAS-Identifier, NAS-IP-Address)
- Access technology (NAS-Port-Type)
- IP address (Framed-IP-Address, Framed-IPv6-Prefix)

Enable with:

```yaml
radius:
  start:
    enabled: true
```

Automatically sent when a GTP Create Session or PFCP Session Establishment completes successfully.

### Accounting-Interim

Sent periodically during an active session. Contains cumulative usage information:
- Session duration (Acct-Session-Time)
- Data volume (Acct-Input-Octets, Acct-Output-Octets)
- Packet counts (Acct-Input-Packets, Acct-Output-Packets)
- Current session state

Interim interval controlled by `aaa.acctInterimInterval`:

```yaml
aaa:
  acctInterimInterval: 3600  # Send interim every 3600 seconds (1 hour)
  radius:
    interim:
      enabled: true
```

> [!CAUTION]
> If RADIUS interim or stop accounting are enabled, `acctInterimInterval` cannot be `null`.

### Accounting-Stop

Sent when a user session terminates. Contains final usage information:
- Final session duration
- Final data volume
- Termination cause (Acct-Terminate-Cause)
- Final packet counts

Enable with:

```yaml
radius:
  stop:
    enabled: true
```

Automatically sent when a GTP Delete Session or PFCP Session Deletion completes.

## Interim Interval Configuration

The interim interval applies to all accounting mechanisms (RADIUS, Rf, NASREQ):

```yaml
aaa:
  acctInterimInterval: 1800  # 30 minutes
```

Common values:
- `300` - 5 minutes (frequent updates, higher load)
- `1800` - 30 minutes (balanced)
- `3600` - 1 hour (infrequent updates, lower load)
- `null` - No interim records (RADIUS must have only Start/Stop enabled)

## RADIUS vs Diameter Accounting

| Feature | RADIUS | Diameter (Rf) |
|---|:---:|:---:|
| Protocol | UDP | TCP or SCTP |
| Reliability | Best-effort | Connection-oriented |
| Message size | Limited (~4KB) | Unlimited |
| Roaming | Proxy chains | Direct routing |
| Extensibility | Limited | Extensive AVPs |
| 3GPP support | Basic | Full |

**When to use RADIUS:**
- Legacy infrastructure requires it
- Simple deployments
- Interoperability with existing RADIUS servers

**When to use Diameter:**
- Modern 3GPP deployments
- Complex roaming scenarios
- Rich CDR content required

## PCC Rule Integration

RADIUS accounting is triggered by offline charging enablement in PCC rules:

```yaml
aaa:
  applicationDetection:
    rules:
      radius-charged:
        type: classic
        precedence: 100
        meteringMethod: 1
        offlineEnabled: true  # Triggers RADIUS accounting
        onlineEnabled: false
        ratingGroup: 2000
        additionalSDF:
          - "permit out ip from any to assigned"
```

> [!NOTE]
> RADIUS accounting and Diameter Rf can be enabled simultaneously. Both will generate records for sessions with `offlineEnabled: true`.

## Attribute Filtering

Filter specific RADIUS attributes from accounting messages:

```yaml
aaa:
  radius:
    enabled: true
    start:
      enabled: true
    stop:
      enabled: true
    avp_filters:
      - "Calling-Station-Id"
      - "Called-Station-Id"
      - "User-Password"
    server:
      addr: "192.168.1.100"
      type: "ipv4"
      password: "sharedsecret"
      acct:
        port: 1813
```

Filtered attributes are excluded from all RADIUS messages (Start, Interim, Stop).

**Common attributes to filter:**
- `User-Password` - Never send passwords in accounting
- `Calling-Station-Id` - Source number (privacy)
- `Called-Station-Id` - Destination number (privacy)
- `Class` - Operator-specific data
- `State` - Session state information

## Example Configurations

### RADIUS Accounting Only (No Authentication)

```yaml
aaa:
  acctInterimInterval: 3600
  
  radius:
    enabled: true
    authenticate:
      enabled: false  # No authentication
    start:
      enabled: true
    interim:
      enabled: true
    stop:
      enabled: true
    server:
      addr: "accounting.example.com"
      type: "fqdn"
      password: "AcctSecret"
      acct:
        port: 1813
  
  applicationDetection:
    rules:
      postpaid-data:
        type: classic
        precedence: 500
        meteringMethod: 1
        offlineEnabled: true
        ratingGroup: 1000
        additionalSDF:
          - "permit out ip from any to assigned"
```

### Start and Stop Only (No Interim)

```yaml
aaa:
  acctInterimInterval: null  # No interim records
  
  radius:
    enabled: true
    authenticate:
      enabled: false
    start:
      enabled: true
    interim:
      enabled: false  # No interim
    stop:
      enabled: true
    server:
      addr: "192.168.1.100"
      type: "ipv4"
      password: "SimpleSecret"
      acct:
        port: 1813
  
  applicationDetection:
    rules:
      simple-accounting:
        type: classic
        precedence: 1000
        meteringMethod: 1
        offlineEnabled: true
        ratingGroup: 5000
        additionalSDF:
          - "permit out ip from any to assigned"
```

### Separate Authentication and Accounting Servers

```yaml
aaa:
  acctInterimInterval: 1800
  
  radius:
    enabled: true
    authenticate:
      enabled: true
    start:
      enabled: true
    interim:
      enabled: true
    stop:
      enabled: true
    server:
      acct:
        standalone: true
        addr: "10.1.2.200"
        port: 1813
        type: "ipv4"
        password: "AcctSecret123"
      auth:
        addr: "10.1.2.100"
        port: 1812
        type: "ipv4"
        password: "AuthSecret456"
  
  applicationDetection:
    rules:
      radius-service:
        type: classic
        precedence: 300
        meteringMethod: 1
        offlineEnabled: true
        ratingGroup: 3000
        additionalSDF:
          - "permit out ip from any to assigned"
```

### With Attribute Filtering

```yaml
aaa:
  acctInterimInterval: 3600
  
  radius:
    enabled: true
    start:
      enabled: true
    interim:
      enabled: true
    stop:
      enabled: true
    avp_filters:
      - "Calling-Station-Id"
      - "Called-Station-Id"
      - "User-Password"
      - "Class"
    server:
      addr: "radius.example.com"
      type: "fqdn"
      password: "FilteredSecret"
      acct:
        port: 1813
  
  applicationDetection:
    rules:
      privacy-protected:
        type: classic
        precedence: 100
        meteringMethod: 1
        offlineEnabled: true
        ratingGroup: 7000
        additionalSDF:
          - "permit out ip from any to assigned"
```

### Concurrent RADIUS and Diameter Accounting

```yaml
aaa:
  acctInterimInterval: 3600
  
  # RADIUS accounting
  radius:
    enabled: true
    start:
      enabled: true
    interim:
      enabled: true
    stop:
      enabled: true
    server:
      addr: "radius.example.com"
      type: "fqdn"
      password: "RadiusSecret"
      acct:
        port: 1813
  
  # Diameter Rf accounting
  rf:
    enabled: true
    standalone: false
  
  applicationDetection:
    rules:
      dual-accounting:
        type: classic
        precedence: 200
        meteringMethod: 1
        offlineEnabled: true  # Triggers both RADIUS and Rf
        ratingGroup: 4000
        additionalSDF:
          - "permit out ip from any to assigned"
```

> [!TIP]
> Use concurrent RADIUS and Diameter accounting during migration from RADIUS to Diameter. Verify both systems produce consistent results before disabling RADIUS.

## Troubleshooting

### No Accounting Messages Received

**Symptom:** RADIUS server receives no accounting messages.

**Possible causes:**
- Accounting phases not enabled
- `aaa.radius.enabled` is `false`
- No rules have `offlineEnabled: true`
- RADIUS server address incorrect

**Solution:**

1. Verify RADIUS is enabled:
   ```yaml
   radius:
     enabled: true
   ```

2. Verify accounting phases are enabled:
   ```yaml
   start:
     enabled: true
   stop:
     enabled: true
   ```

3. Verify at least one rule has offline charging:
   ```yaml
   rules:
     {RULE_NAME}:
       offlineEnabled: true
   ```

4. Check SMC logs for RADIUS errors

5. Verify server address and shared secret

### Interim Accounting Not Working

**Symptom:** Start and Stop messages received, but no Interim messages.

**Possible causes:**
- `interim.enabled` is `false`
- `acctInterimInterval` is `null`
- Sessions shorter than interim interval

**Solution:**

1. Enable interim accounting:
   ```yaml
   interim:
     enabled: true
   ```

2. Set interim interval:
   ```yaml
   acctInterimInterval: 1800
   ```

3. Verify sessions last longer than interval

4. Test with short interval:
   ```yaml
   acctInterimInterval: 300  # 5 minutes for testing
   ```

### Shared Secret Errors

**Symptom:** RADIUS server rejects messages with "Bad Authenticator" errors.

**Cause:** Shared secret mismatch between SMC and RADIUS server.

**Solution:**

1. Verify shared secret in SMC matches server:
   ```yaml
   server:
     password: "correct_shared_secret"
   ```

2. Check for trailing spaces or special characters

3. Verify server configuration

4. Test with simple secret first (for example, "test123")

> [!IMPORTANT]
> Shared secrets are case-sensitive and must match exactly on both sides.

### UDP Packet Loss

**Symptom:** Some accounting messages not received by RADIUS server.

**Cause:** UDP is unreliable; packets can be lost in transit.

**Solution:**

1. Check network quality between SMC and RADIUS server

2. Monitor packet loss:
   ```bash
   ping -c 100 {RADIUS_SERVER}
   ```

3. Consider using Diameter Rf instead:
   ```yaml
   rf:
     enabled: true
   ```

4. Verify RADIUS server has adequate capacity

### Cannot Disable Interim

**Symptom:** Error when setting `acctInterimInterval: null`.

**Cause:** RADIUS interim or stop accounting is enabled.

**Solution:**

Either keep interim enabled:

```yaml
acctInterimInterval: 3600
radius:
  interim:
    enabled: true
```

Or disable RADIUS interim accounting:

```yaml
acctInterimInterval: null
radius:
  interim:
    enabled: false
  stop:
    enabled: true
```

### Missing Attributes in Accounting Messages

**Symptom:** Expected attributes not present in accounting messages.

**Possible causes:**
- Attributes filtered in `avp_filters`
- Session context missing information
- RADIUS message size limit exceeded

**Solution:**

1. Check `avp_filters` configuration:
   ```yaml
   avp_filters: []  # Remove all filters temporarily
   ```

2. Verify session has required information (for example, IP address, location)

3. Check RADIUS server logs for truncated messages

4. Consider using Diameter Rf for larger messages

### Accounting Records Without Authentication

**Symptom:** Need accounting without authentication, but unsure how to configure.

**Solution:**

Disable authentication explicitly:

```yaml
radius:
  enabled: true
  authenticate:
    enabled: false  # No authentication
  start:
    enabled: true
  interim:
    enabled: true
  stop:
    enabled: true
  server:
    addr: "{RADIUS_SERVER}"
    type: "ipv4"
    password: "{SECRET}"
    acct:
      port: 1813
```

This sends only accounting messages, no Access-Request messages.

## NASREQ Diameter Accounting

NASREQ is an alternative to RADIUS accounting using Diameter. By default, NASREQ interim accounting is enabled with a 1800-second interval.

To disable NASREQ interim accounting:

```yaml
aaa:
  acctInterimInterval: null
```

> [!NOTE]
> This setting affects all accounting mechanisms (RADIUS, Rf, NASREQ). When `null`, NASREQ interim is disabled, but RADIUS Stop and interim must also be disabled.

For NASREQ configuration, see [Diameter Configuration](https://docs.cennso.com/components/smc/3.15/config/aaa/diameter-concepts.md).

[RFC2865]: https://www.rfc-editor.org/rfc/rfc2865.html
[RFC2866]: https://www.rfc-editor.org/rfc/rfc2866.html
