> 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/authentication/nasreq.md).

# Diameter NASREQ Authentication and Accounting

## Overview

Diameter NASREQ (Network Access Server Requirements) is specified in [IETF RFC 7155][RFC7155]. It provides AAA services using the Diameter protocol, similar to RADIUS but with the advantages of Diameter's connection-oriented transport and extensive capabilities.

NASREQ is **true AAA** - it handles authentication, authorisation, and accounting for network access. It is distinct from:
- **Policy control** (Gx, Npcf) - Traffic treatment decisions
- **Charging** (Rf, Ro) - Billing and revenue collection

References:
- [IETF RFC 7155][RFC7155] - Diameter Network Access Server Application
- [IETF RFC 6733][RFC6733] - Diameter Base Protocol
- [AAA Overview](https://docs.cennso.com/components/smc/3.15/config/aaa/overview.md) - Understanding AAA vs Policy vs Charging
- [Diameter Concepts](https://docs.cennso.com/components/smc/3.15/config/aaa/diameter-concepts.md) - Generic Diameter transport configuration

## NASREQ in Mobile Networks

NASREQ was originally designed for fixed network access (dial-up, DSL, cable) but can be used in mobile networks for AAA purposes. In 3GPP mobile networks, NASREQ is optional:

**3GPP uses:**
- **HSS/UDM** - Primary authentication and subscription data
- **Diameter Gx** - Policy control (separate concern from AAA)
- **Diameter Rf/Ro** - Charging (separate concern from AAA)

**NASREQ use cases in mobile:**
- Interoperability with fixed network AAA infrastructure
- Unified AAA for converged fixed-mobile networks
- Accounting integration with existing Diameter AAA servers
- Replacing RADIUS with Diameter for improved reliability

> [!NOTE]
> SMC supports NASREQ for AAA, but many deployments use RADIUS (simpler) or rely on 3GPP-native authentication (HSS/UDM) instead.

## Basic Configuration

Enable NASREQ and configure Diameter peers:

```yaml
aaa:
  nasreq:
    enabled: true
    standalone: false  # Use common Diameter settings from aaa.oss
  
  oss:
    destinations:
      - addr: "10.1.2.10"
        port: 3868
    destinationRealm: "aaa.example.com"
    originFqdn: "pgw.node1.example.com"
    originRealm: "node1.example.com"
```

See [Diameter Concepts](https://docs.cennso.com/components/smc/3.15/config/aaa/diameter-concepts.md) for detailed transport configuration.

## Authentication with AA-Request/AA-Answer

NASREQ uses AA-Request (AAR) and AA-Answer (AAA) messages for authentication and authorisation.

### AA-Request (AAR)

Sent when a user session is being established. Contains:

**Standard AVPs:**
- `Session-Id` - Unique session identifier
- `Auth-Application-Id` - Set to 1 (NASREQ)
- `Origin-Host` - SMC node FQDN
- `Origin-Realm` - SMC realm
- `Destination-Realm` - AAA server realm
- `Auth-Request-Type` - Request type (Authorize-Only, Authorize-Authenticate)
- `User-Name` - Subscriber identifier (typically IMSI)
- `NAS-Identifier` - Network Access Server identifier
- `NAS-IP-Address` - SMC IP address
- `NAS-Port-Type` - Access technology

**Mobile-specific AVPs:**
- `3GPP-IMSI` - International Mobile Subscriber Identity
- `3GPP-IMEI` - International Mobile Equipment Identity
- `3GPP-RAT-Type` - Radio Access Technology (2G/3G/4G/5G)
- `3GPP-User-Location-Information` - Cell/tracking area location
- `Called-Station-Id` - APN or DNN name
- `Framed-IP-Address` - Requested IPv4 address
- `Framed-IPv6-Prefix` - Requested IPv6 prefix

### AA-Answer (AAA)

Returned by the AAA server in response to AA-Request. Contains:

**Standard AVPs:**
- `Session-Id` - Same as in AAR
- `Auth-Application-Id` - Set to 1 (NASREQ)
- `Origin-Host` - AAA server FQDN
- `Origin-Realm` - AAA server realm
- `Result-Code` - Success or failure
  - `DIAMETER_SUCCESS` (2001) - Authentication successful
  - `DIAMETER_AUTHENTICATION_REJECTED` (4001) - Authentication failed
  - `DIAMETER_AUTHORIZATION_REJECTED` (5003) - Authorisation failed

**Authorisation AVPs (on success):**
- `Framed-IP-Address` - Assigned IPv4 address
- `Framed-IP-Netmask` - IPv4 netmask
- `Framed-IPv6-Prefix` - Assigned IPv6 prefix
- `Session-Timeout` - Maximum session duration
- `Idle-Timeout` - Idle timeout
- `Class` - Operator-specific session data
- `Filter-Id` - Policy filter identifier

### Authentication Flow

1. **User requests session** - UE sends Create Session Request (GTP) or Session Establishment Request (PFCP)
2. **SMC sends AA-Request** - Contains authentication information (IMSI, IMEI, location)
3. **AAA server validates** - Checks subscriber database, applies authorisation policies
4. **Server responds with AA-Answer**:
   - **Success** (Result-Code 2001) - Session is established with authorisation attributes
   - **Failure** (Result-Code 4001/5003) - Session is rejected
5. **SMC processes response** - Establishes or rejects session based on Result-Code

### Configuration

Authentication configuration is implicit when NASREQ is enabled. Unlike RADIUS, there is no separate `authenticate.enabled` flag - AA-Request/AA-Answer is always used for sessions requiring AAA.

## Accounting with ACR/ACA

NASREQ uses Accounting-Request (ACR) and Accounting-Answer (ACA) messages for accounting.

### Accounting Phases

#### Accounting-Start (ACR)

Sent when a user session is established. Contains:

**Standard AVPs:**
- `Session-Id` - Unique session identifier
- `Origin-Host` - SMC node FQDN
- `Origin-Realm` - SMC realm
- `Destination-Realm` - AAA server realm
- `Accounting-Record-Type` - Set to `START_RECORD` (2)
- `Accounting-Record-Number` - Sequence number (starts at 1)
- `Acct-Application-Id` - Set to 1 (NASREQ)
- `User-Name` - Subscriber identifier
- `NAS-Identifier` - Network Access Server identifier
- `NAS-IP-Address` - SMC IP address
- `NAS-Port-Type` - Access technology
- `Event-Timestamp` - Session start time

**Mobile-specific AVPs:**
- `3GPP-IMSI` - International Mobile Subscriber Identity
- `3GPP-IMEI` - International Mobile Equipment Identity
- `3GPP-RAT-Type` - Radio Access Technology
- `3GPP-User-Location-Information` - Cell/tracking area location
- `3GPP-SGSN-Address` - Serving gateway address
- `Called-Station-Id` - APN or DNN name
- `Framed-IP-Address` - User's IPv4 address
- `Framed-IPv6-Prefix` - User's IPv6 prefix

SMC always sends Accounting-Start when `aaa.nasreq.enabled: true`. There is no separate per-phase enable flag.

#### Accounting-Interim (ACR)

Sent periodically during an active session. Contains cumulative usage information:

**Additional AVPs beyond Start:**
- `Accounting-Record-Type` - Set to `INTERIM_RECORD` (3)
- `Accounting-Record-Number` - Incremented sequence number
- `Acct-Session-Time` - Session duration in seconds
- `Acct-Input-Octets` - Downlink data volume (32-bit)
- `Acct-Output-Octets` - Uplink data volume (32-bit)
- `Acct-Input-Gigawords` - Downlink data volume high-order bits
- `Acct-Output-Gigawords` - Uplink data volume high-order bits
- `Acct-Input-Packets` - Downlink packet count
- `Acct-Output-Packets` - Uplink packet count

Interim interval controlled by `aaa.acctInterimInterval`. Set to `null` to suppress interim records entirely:

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

#### Accounting-Stop (ACR)

Sent when a user session terminates. Contains final usage information:

**Additional AVPs beyond Interim:**
- `Accounting-Record-Type` - Set to `STOP_RECORD` (4)
- `Acct-Terminate-Cause` - Reason for termination
  - `USER_REQUEST` (1) - Normal user termination
  - `LOST_CARRIER` (2) - Connection lost
  - `IDLE_TIMEOUT` (4) - Session idle timeout
  - `SESSION_TIMEOUT` (5) - Maximum duration reached
  - `ADMIN_DISCONNECT` (6) - Administrative termination
  - `SERVICE_UNAVAILABLE` (8) - Service failure

SMC always sends Accounting-Stop when `aaa.nasreq.enabled: true`. There is no separate per-phase enable flag.

### Accounting Configuration

NASREQ sends all accounting phases (Start, Interim, Stop) automatically when enabled. Control the interim interval:

```yaml
aaa:
  acctInterimInterval: 1800  # Send interim every 30 minutes; null to disable interim

  nasreq:
    enabled: true
    standalone: false
```

## Diameter Transport Configuration

NASREQ uses the generic Diameter transport configuration. See [Diameter Concepts](https://docs.cennso.com/components/smc/3.15/config/aaa/diameter-concepts.md) for:
- TCP vs SCTP transport
- Socket options (`nodelay`, `recbuf`, `sndbuf`)
- Connection management and peer selection
- Rate limiting
- Resilience and failover

### Common Settings

Share Diameter transport with other interfaces:

```yaml
aaa:
  oss:
    destinations:
      - addr: "10.1.2.10"
        port: 3868
      - addr: "10.1.2.11"
        port: 3868
    destinationRealm: "aaa.example.com"
    originFqdn: "pgw.node1.example.com"
    originRealm: "node1.example.com"
  
  nasreq:
    enabled: true
    standalone: false  # Use aaa.oss settings
    transportType: "tcp"
    transportOpts:
      nodelay: true
      recbuf: 1024
      sndbuf: 1024
```

### Standalone Settings

Use dedicated Diameter peers for NASREQ:

```yaml
aaa:
  nasreq:
    enabled: true
    standalone: true
    destinations:
      - addr: "10.3.3.10"
        port: 3868
      - addr: "10.3.3.11"
        port: 3868
    destinationRealm: "nasreq.example.com"
    originFqdn: "pgw.node1.example.com"
    originRealm: "node1.example.com"
    transportType: "tcp"
    transportOpts:
      nodelay: true
```

## Example Configurations

### Authentication + AAA Accounting

Full NASREQ AAA with authentication and accounting (all phases are sent automatically):

```yaml
aaa:
  acctInterimInterval: 3600  # 1-hour interim updates

  nasreq:
    enabled: true
    standalone: false

  oss:
    destinations:
      - addr: "aaa1.example.com"
        port: 3868
      - addr: "aaa2.example.com"
        port: 3868
    destinationRealm: "aaa.example.com"
    originFqdn: "pgw1.node.example.com"
    originRealm: "node.example.com"

networking:
  oss:
    interface: "bond0"
    ipv4:
      addr: "10.1.2.3"
```

### No Interim Records

Accounting without periodic interim updates:

```yaml
aaa:
  acctInterimInterval: null  # Disable interim records; only Start and Stop are sent

  nasreq:
    enabled: true
    standalone: false

  oss:
    destinations:
      - addr: "10.1.2.10"
        port: 3868
    destinationRealm: "aaa.example.com"
    originFqdn: "pgw1.example.com"
    originRealm: "example.com"
```

### SCTP with High Throughput

NASREQ over SCTP with optimised socket buffers:

```yaml
aaa:
  acctInterimInterval: 3600

  nasreq:
    enabled: true
    standalone: true
    destinations:
      - addr: "10.5.6.10"
        port: 3868
      - addr: "10.5.6.11"
        port: 3868
      - addr: "10.5.6.12"
        port: 3868
    destinationRealm: "aaa.example.com"
    originFqdn: "pgw1.example.com"
    originRealm: "example.com"
    transportType: "sctp"
    transportOpts:
      reuseaddr: true
      recbuf: 4096
      sndbuf: 4096
      unordered: true

diameter:
  rateLimits:
    peers:
      - addr: "10.5.6.10"
        port: 3868
        rate: 2000
        outstanding_requests: 10000
      - addr: "10.5.6.11"
        port: 3868
        rate: 2000
        outstanding_requests: 10000
      - addr: "10.5.6.12"
        port: 3868
        rate: 2000
        outstanding_requests: 10000
```

## NASREQ vs RADIUS

Both NASREQ and RADIUS are "true AAA" protocols. Key differences:

| Feature | RADIUS | Diameter NASREQ |
|---|:---:|:---:|
| Transport | UDP | TCP or SCTP |
| Reliability | Best-effort (retransmit) | Connection-oriented |
| Message size | Limited (~4KB) | Unlimited |
| Roaming | Proxy chains | Peer routing |
| Attribute extensibility | Limited (255 types) | Extensive (4 billion AVPs) |
| 3GPP native | No | Yes (via Diameter) |
| Data volumes | 32-bit (4 GB limit) | 64-bit with Gigawords |
| Deployment complexity | Simple | Higher |
| Legacy support | Excellent | Limited |

**Choose RADIUS when:**
- Simple deployments
- Legacy AAA integration required
- UDP acceptable for reliability
- Lower operational complexity preferred

**Choose Diameter NASREQ when:**
- Modern 3GPP-aligned architecture
- TCP/SCTP reliability required
- Large data volumes (> 4 GB sessions)
- Complex roaming scenarios
- Unified Diameter infrastructure (with Gx, Rf, Ro)

See [RADIUS Authentication](https://docs.cennso.com/components/smc/3.15/config/aaa/authentication/radius.md) for RADIUS-based AAA configuration.

## AAA vs Charging

Like RADIUS, Diameter NASREQ is **true AAA**, distinct from charging:

### Diameter NASREQ for AAA (This Document)

**Purpose:** Identity verification and operational session tracking

**Application-Id:** 1 (NASREQ)

**Messages:** AA-Request/AA-Answer (authentication), ACR/ACA (accounting)

**Use cases:**
- Authenticate subscribers before allowing network access
- Track session establishment for security monitoring
- Audit network usage for operations (not billing)
- Integrate with existing Diameter AAA infrastructure

### Diameter Rf for Charging (See [Rf Configuration](https://docs.cennso.com/components/smc/3.15/config/aaa/charging/rf.md))

**Purpose:** Billing data collection (CDR generation)

**Application-Id:** 3 (Accounting)

**Messages:** ACR/ACA with 3GPP-specific AVPs and charging triggers

**Use cases:**
- Generate CDRs for offline billing
- Collect usage data per rating group
- Integrate with Offline Charging System (OFCS)
- Revenue assurance and billing reconciliation

### Diameter Ro for Charging (See [Ro Configuration](https://docs.cennso.com/components/smc/3.15/config/aaa/charging/ro.md))

**Purpose:** Real-time credit control and quota management

**Application-Id:** 4 (Credit Control)

**Messages:** CCR/CCA with quota management

**Use cases:**
- Enforce prepaid quotas
- Real-time credit control with OCS
- Quota management per rating group
- Hybrid online/offline charging

### Practical Distinction

**Authentication question:** "Is this user allowed to connect?"
- **NASREQ:** AA-Request/AA-Answer
- **Result:** Access-Accept or Access-Reject

**Accounting question:** "What happened during the session?" (operations)
- **NASREQ:** ACR with START/INTERIM/STOP
- **Result:** Session records for AAA server

**Charging question:** "How much should we bill?" (revenue)
- **Rf:** ACR with charging triggers and rating groups
- **Ro:** CCR with quota requests and grants
- **Result:** CDRs or real-time quota management for billing

## Troubleshooting

### No NASREQ Connections

**Symptom:** Metric `diameter_connections{svc="ergw_nasreq"}` shows 0.

**Possible causes:**
- NASREQ not enabled (`nasreq.enabled: false`)
- Network connectivity issues to Diameter peers
- Incorrect realm configuration
- Firewall blocking TCP/SCTP port 3868

**Solution:**

1. Verify NASREQ is enabled:
   ```yaml
   nasreq:
     enabled: true
   ```

2. Check Diameter connections:
   ```promql
   diameter_connections{svc="ergw_nasreq"}
   ```

3. Review connection configuration (see [Diameter Concepts](https://docs.cennso.com/components/smc/3.15/config/aaa/diameter-concepts.md))

4. Check SMC logs:
   ```bash
   kubectl logs {POD_NAME} | grep -i nasreq
   ```

### Authentication Failures

**Symptom:** Sessions rejected with authentication errors.

**Possible causes:**
- AAA server returning Result-Code 4001 (Authentication Rejected)
- AAA server returning Result-Code 5003 (Authorisation Rejected)
- AA-Request missing required AVPs
- Realm mismatch between SMC and AAA server

**Solution:**

1. Check AAA server logs for rejection reasons

2. Verify `destinationRealm` matches AAA server realm:
   ```yaml
   destinationRealm: "aaa.example.com"  # Must match server
   ```

3. Review SMC logs for Diameter errors:
   ```bash
   kubectl logs {POD_NAME} | grep -i "aa-request\|aa-answer"
   ```

4. Verify subscriber exists in AAA server database

### Accounting Messages Not Received

**Symptom:** AAA server not receiving ACR messages.

**Possible causes:**
- Accounting phases not enabled
- Diameter connection down
- Rate limiting active
- AAA server not processing NASREQ accounting

**Solution:**

1. Verify NASREQ is enabled:
   ```yaml
   nasreq:
     enabled: true
   ```

2. Check Diameter connections:
   ```promql
   diameter_connections{svc="ergw_nasreq"}
   ```

3. Review rate limits (see [Diameter Concepts](https://docs.cennso.com/components/smc/3.15/config/aaa/diameter-concepts.md))

4. Verify AAA server supports NASREQ accounting (Application-Id 1)

### InterimInterval Configuration

`aaa.acctInterimInterval` controls the interval in seconds for all accounting mechanisms, including NASREQ. Set to `null` to suppress interim records:

```yaml
aaa:
  acctInterimInterval: null  # Only Start and Stop records are sent

  nasreq:
    enabled: true
```

## Monitoring

### Diameter Connections

Monitor NASREQ Diameter connections:

```promql
diameter_connections{svc="ergw_nasreq"}
```

Expected value equals the number of configured peers.

### Outstanding Requests

Monitor pending requests per peer:

```promql
diameter_outstanding_requests{svc="ergw_nasreq"}
```

High values may indicate:
- AAA server slow to respond
- Rate limiting active
- Network latency

### Request Latency

Monitor AA-Request and ACR latency:

```promql
histogram_quantile(0.95, 
  rate(diameter_request_duration_seconds_bucket{svc="ergw_nasreq"}[5m]))
```

High latency may indicate:
- AAA server overloaded
- Network congestion
- Suboptimal socket configuration

## Related Documentation

- [AAA Overview](https://docs.cennso.com/components/smc/3.15/config/aaa/overview.md) - Understanding the three concerns
- [Diameter Concepts](https://docs.cennso.com/components/smc/3.15/config/aaa/diameter-concepts.md) - Generic Diameter transport configuration
- [RADIUS Authentication](https://docs.cennso.com/components/smc/3.15/config/aaa/authentication/radius.md) - RADIUS-based AAA
- [Rf Offline Charging](https://docs.cennso.com/components/smc/3.15/config/aaa/charging/rf.md) - Diameter offline charging
- [Ro Online Charging](https://docs.cennso.com/components/smc/3.15/config/aaa/charging/ro.md) - Diameter online charging
- [Gx Policy Control](https://docs.cennso.com/components/smc/3.15/config/aaa/policy/gx.md) - Diameter policy control

[RFC6733]: https://www.rfc-editor.org/rfc/rfc6733.html
[RFC7155]: https://www.rfc-editor.org/rfc/rfc7155.html
