> 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/operation/aaa-and-charging.md).

# AAA and charging traffic

AAA and charging operations are related, but current standards do not enforce any particular order for one message in one interface relative to the messages in the other interfaces. The following sections describe the specific constraints of the standards, the design decisions taken in this product, and the conditions that peers in AAA and charging interfaces should expect from SMC.

## Relative ordering of AAA and charging operations during session termination

The 3GPP TS defining Gy, Rf, and SGi (NAS) interfaces do not impose any request ordering among these interfaces, apart from general common sense situations. For example, authentication blocks all other requests, OCS is asked for credit, and only then can the data session and offline charging be initiated. Specifically, the relative ordering of the interfaces after the data session has ended is not described. Peers of these different interfaces are responsible for coordinating among themselves if needed.

The full sequence for an ASR-triggered session termination from the SMC perspective is shown in the diagram below:

```mermaid
sequenceDiagram
    participant GTP-C
    participant PGW
    participant OCS
    participant CDF
    participant AAA
    OCS->>+PGW: ASR
    PGW->>GTP-C: Delete Bearer Request
    PGW-->>-OCS: ASA
    GTP-C-->>PGW: Delete Bearer Response
    PGW->>+AAA: ACR-Terminate
    AAA-->>-PGW: ACA-Terminate
    PGW->>+AAA: STR
    AAA-->>-PGW: STA
    PGW->>+OCS: CCR-Terminate
    OCS-->>-PGW: CCA-Terminate
    PGW->>+CDF: ACR-Terminate
    CDF-->>-PGW: ACA-Terminate
```

## Ordering of Diameter NASREQ (AAA) messages during session abort

During a NASREQ abort session scenario, SMC answers ASR from the NAS server with an ASA message. Since the session ended, SMC must also send an STR message to NAS. The [authorization state machine in RFC6733](https://datatracker.ietf.org/doc/html/rfc6733#section-8.1) includes the following relevant transition:

| State | Event | Action | NewState |
| --- | --- | --- | --- |
| Open | ASR received, client will comply with request to end the session | Send ASA with Result-Code = SUCCESS, Send STR. | Discon |

SMC first returns ASA before sending STR.

> [!NOTE]
> A NAS cannot consider a session terminated until **both** the STR message and the ASA response have been received.

The following figure reflects the ordering of these messages.

```mermaid
sequenceDiagram
  participant SMC
  participant NAS
  NAS ->> SMC: ASR
  SMC ->> NAS: ASA
  SMC ->> NAS: STR
  NAS ->> SMC: STA
```

## Ordering of Diameter Gy messages during session abort

During a Gy abort session scenario, SMC answers ASR from the OCS server with an ASA message. Since the session has ended, SMC must also send a CCR-Terminate (CCR-T) message to OCS. This is a deviation from RFC6733; usually, STR must be sent, but according to [3GPP TS 32.251 section 5.3.2.2.1](https://www.3gpp.org/DynaReport/32251.htm) a CCR-Terminate is sent instead.

SMC first returns ASA before sending CCR-T.

> [!NOTE]
> An OCS cannot consider a session terminated until **both** the CCR-T message and the ASA response have been received.

The following figure reflects the ordering of these messages.

```mermaid
sequenceDiagram
  participant SMC
  participant OCS
  OCS ->> SMC: ASR
  SMC ->> OCS: ASA
  SMC ->> OCS: CCR[T]
  OCS ->> SMC: CCA[T]
```
