> 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/tposs-aaa.md).

# TPOSS AAA architecture

When TPOSS is configured and deployed as an AAA server, it is composed of the following subsystems:

- Policy Control Server (PCS) - responsible for subscriber and service session handling, including policies and sessions lifecycle management.
- Charging Control Server (CCS) - responsible for online charging, quota management, and resource accounting.
- User Data Repository (UDR) - responsible for storing and managing subscriber profiles, service configuration, and related user data.

The PCS, CCS, and UDR are separate subsystems, but they run as a single application. Authorization, accounting, policy, and charging decisions are made in one process, so all subsystems work on the same state without a network call between them.

To expose their functionality and interact with external network elements, TPOSS provides standard `RADIUS` and `Diameter` interfaces. These interfaces handle incoming authentication, authorization, accounting, policy, and charging requests from external network elements.

In addition to `RADIUS` and `Diameter`, TPOSS provides experimental support for the 5G Service-Based Interfaces (SBIs). In this case, TPOSS may use HTTP/2 or CDMP-based APIs instead of Diameter to communicate with 5G network functions.

> [!IMPORTANT]
> Both `SBI` and `CDMP` interfaces are experimental. For more information, see the [SBI API](https://docs.cennso.com/components/tposs/latest/architecture/sbi.md) and [CDMP API](https://docs.cennso.com/components/tposs/latest/architecture/cdmp.md) documents.

TPOSS can communicate with external network elements directly or using intermediate `RADIUS`, `Diameter`, or `HTTP` proxies and agents. Regardless of the deployment topology, the high-level operational flow remains the same:

1. After a user attaches to the mobile network, TPOSS creates a [network session](https://docs.cennso.com/components/tposs/latest/glossary.md#network-session) and a [service session](https://docs.cennso.com/components/tposs/latest/glossary.md#service-session).
2. During the lifetime of these sessions, resource usage like data volume is continuously accounted for by the charging subsystems.
3. When the user detaches from the network, the corresponding network and service sessions are terminated, and final usage data is generated and stored for charging and reporting purposes.

A network session must always exist and be created before a service session. Network sessions are always created based on RADIUS requests, as described in the [RADIUS message flow](https://docs.cennso.com/components/tposs/latest/architecture/radius.md) document.

Service sessions can be created based on the following protocols:

- [Diameter](https://docs.cennso.com/components/tposs/latest/architecture/diameter.md)
- [SBI](https://docs.cennso.com/components/tposs/latest/architecture/sbi.md)
- [CDMP](https://docs.cennso.com/components/tposs/latest/architecture/cdmp.md)

In these documents, you can find a high-level, TPOSS-centric view of the concepts, architecture, and protocol-level message flows used in TPOSS AAA.

To handle incoming requests from the network elements, TPOSS AAA needs to have the following information:

- the data of a subscriber and the profile that authorizes it
- the sessions of an attached device and of its services
- the balance and the tariff to charge the traffic of a subscriber

In the sections below, you can find more information about each of them.

## Subscriber data

The UDR subsystem keeps the following information in the MySQL database:

- The subscriber that holds the IMSI and the tariff assigned to it.
- The service profile that holds the IP pools, the NAT IP pool, and the DNS servers of a subscriber.
- The charging account that holds the balances of a subscriber.

Subscribers, their tariffs, and their balances are provisioned over the TPOSS REST API, or over the JSON-RPC API that TPOSS API Gateway provides. For more information, see the [API overview](https://docs.cennso.com/components/tposs/latest/api-reference/api.md) and [Service profiles and IP pools](https://docs.cennso.com/components/tposs/latest/configuration/ip-pools-profiles.md) documents.

## Sessions

The PCS owns the sessions of a subscriber. A network session represents a device attached to the mobile network and holds the IP address assigned to it. A service session represents the services of that device and holds the policy and charging rules applied to them.

Requests for one subscriber can arrive at any TPOSS instance, and several of them can arrive at the same time. To keep the handling of one session in one place, the PCS takes a cluster-wide lock for the identifier of the session, such as the `IMSI` or the Diameter `Session-Id`.

A session can also end without a request from a network element. TPOSS terminates a network session that stops receiving RADIUS interim updates, and it removes the service sessions whose network session no longer exists. For more information, see the [Session management](https://docs.cennso.com/components/tposs/latest/configuration/session.md) document.

## Charging

The CCS grants quota to a service session from the balance of a subscriber and accounts the resources that the session consumes against it. The tariff of a subscriber decides how its traffic is rated. When the balance is exhausted, the charging option of the subscriber decides what happens next. The access can be restricted to a walled garden, or redirected to a captive portal.

When a service session is terminated, or when a balance runs out of volume or validity time, TPOSS creates a Charging Data Record (CDR). TPOSS writes CDRs to the MySQL database, to files that an external billing system fetches, or to both. For more information, see the [Charging configuration](https://docs.cennso.com/components/tposs/latest/configuration/charging.md) document.
