> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/tposs/latest/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/tposs/latest/architecture/radius.md).

# RADIUS message flow

TPOSS creates and manages [network sessions](https://docs.cennso.com/components/tposs/latest/glossary.md#network-session) over RADIUS. A packet gateway sends the RADIUS requests that attach a device to the mobile network, keep its session alive, and detach it again.

A network session must exist before a [service session](https://docs.cennso.com/components/tposs/latest/glossary.md#service-session) can be created for the same subscriber. For more information about service sessions, read the [Diameter](https://docs.cennso.com/components/tposs/latest/architecture/diameter.md), [SBI](https://docs.cennso.com/components/tposs/latest/architecture/sbi.md), and [CDMP](https://docs.cennso.com/components/tposs/latest/architecture/cdmp.md) documents.

For more information about TPOSS AAA architecture and how to configure the RADIUS interface, read:

- [General TPOSS architecture](https://docs.cennso.com/components/tposs/latest/architecture/architecture.md)
- [TPOSS AAA](https://docs.cennso.com/components/tposs/latest/architecture/tposs-aaa.md) document
- [RADIUS settings](https://docs.cennso.com/components/tposs/latest/configuration/radius.md)

## Network session flows

When a user attaches to the mobile network, the packet gateway (PGW) initiates the creation of a [network session](https://docs.cennso.com/components/tposs/latest/glossary.md#network-session) in TPOSS. This is done by sending a RADIUS `Access-Request` message for the newly attached device.

Upon receiving the request, TPOSS processes it as follows:

1. TPOSS identifies the subscriber and authenticates the device using subscriber credentials and configuration stored in the User Data Repository (UDR).
2. Based on the subscriber profile, access parameters, and applicable policies, TPOSS authorizes (or not) the network access request.
3. As part of the authorization process, TPOSS allocates network resources for the session, including assignment of a [Framed-IP-Address](https://datatracker.ietf.org/doc/html/rfc2058#section-5.8), which uniquely identifies the device within the data network.

The following diagram represents this flow:

```mermaid
sequenceDiagram

participant PGW
participant TPOSS
participant UDR
participant PCS
participant MySQL

PGW->>TPOSS:RADIUS Access-Request
TPOSS->>UDR:Subscriber authorization. Network session creation
UDR->>MySQL:Authorization procedures. Network session creation
MySQL->>UDR:Authorization result. Network session created
UDR->>TPOSS:Authorization result. Network session created

alt Successful Authorization
  TPOSS->>PGW:RADIUS Access-Accept.

  PGW->>TPOSS:RADIUS Accounting-Request Start
  TPOSS->>PCS:Accounting per session
  PCS->>MySQL:Update network session
  MySQL->>PCS:Network session updated
  PCS->>TPOSS:Network session updated
  TPOSS->>PGW: RADIUS Accounting Start response
else
break The user is not authorized
  TPOSS->>PGW:RADIUS Access-Reject
end
end
```

If a network session is created successfully, TPOSS returns the RADIUS [`Access-Accept`](https://datatracker.ietf.org/doc/html/rfc2865#section-4.2) response. If TPOSS failed to create a network session, it returns the RADIUS [`Access-Reject`](https://datatracker.ietf.org/doc/html/rfc2865#section-4.3) response.

Every RADIUS `Access-Reject` response contains at least one RADIUS [`Reply-Message`](https://datatracker.ietf.org/doc/html/rfc2865#section-5.18) AVP. Each `Reply-Message` describes a reason why a request was rejected. For more information about the reasons why the subscriber's authentication was rejected, read the [RADIUS error codes](https://docs.cennso.com/components/tposs/latest/troubleshooting/radius-error-codes.md) document. In addition, TPOSS provides the **radiusServTotalAccessRejects** metric that contains the label `reason` to determine the reason for rejection. For more information, read the [RADIUS server metrics](https://docs.cennso.com/components/tposs/latest/observability/radius.md#radius-server-metrics) document.

To maintain an active network session, the packet gateway must send periodic RADIUS interim requests to TPOSS. Otherwise, a network session can be terminated as [idle](https://docs.cennso.com/components/tposs/latest/configuration/session.md#idle-session-management):

```mermaid
sequenceDiagram

participant PGW
participant TPOSS
participant PCS
participant MySQL

PGW->>TPOSS:RADIUS Accounting-Request Update
TPOSS->>PCS:Accounting per session
PCS->>MySQL:Update network session
MySQL->>PCS:Network session updated
PCS->>TPOSS:Network session updated
TPOSS->>PGW: RADIUS Accounting Stop response
```

After the user detaches from the mobile network, TPOSS must terminate the network session. To terminate a network session, the packet gateway sends a RADIUS `Accounting-Stop` request, after which TPOSS notifies SMF/TDF if there is an associated service session and deletes the network session from the database:

```mermaid
sequenceDiagram

participant PGW
participant TPOSS
participant PCS
participant MySQL

PGW->>TPOSS:RADIUS Accounting-Request Stop
TPOSS->>PCS:Accounting per session
PCS->>MySQL:Delete network session
MySQL->>PCS:Network session deleted
PCS->>TPOSS:Network session deleted
TPOSS->>PGW: RADIUS Accounting Stop response
```
