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

# SBI API

>**CAUTION:** This feature is experimental and can only be used with Session Management Controller (SMC) that supports 5G SBIs. The new behaviour is disabled by default to preserve backward compatibility with the previous versions of TPOSS.

TPOSS supports [service-based interfaces](https://www.3gpp.org/technologies/openapis-for-the-service-based-architecture) (SBI) APIs to establish service sessions and execute charging operations. The procedures are similar to Diameter `NASREQ`, `Gx`, and `Gy` requests but instead `Nnas`, `Npcf` and `Nchf` HTTP2 API calls are used.

The following APIs are supported by TPOSS:

- [TS 29.512](https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=3352) - to allocate PCC rules. For more information, see the [Npcf API](https://docs.cennso.com/components/tposs/6.15/api-reference/sbi/npcf.md) document.
- [TS 32.291](https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=3398) - to execute charging operations. For more information, see the [Nchf API](https://docs.cennso.com/components/tposs/6.15/api-reference/sbi/nchf.md) document.
- Internal Nnas API for authorization and NAT binding. For more information, see the [Nnas API](https://docs.cennso.com/components/tposs/6.15/api-reference/sbi/nnas.md) document.

To receive the incoming SBI requests from SMF/TDF, enable it using this configuration option:

```yaml
sbi:
  # Enables 5G SBIs in TPOSS
  enabled: false
  # Returns user data (like IMSI, Called-Station-Id, and Calling-Station-Id) from TPOSS on SBI Nnas requests
  userdata_on_nnas: false
  # Enables content validation of the incoming and outgoing SBI requests
  validation_enabled: false
```

>**NOTE:** If **sbi.enabled** is set to `true`, disable **scg.diameter.enabled** by setting it to `false`.

The general TPOSS architecture and the flows of requests are represented in the [General architecture](https://docs.cennso.com/components/tposs/6.15/architecture/architecture.md) document. When the **sbi.enabled** configuration option is set to `true`, the Diameter requests are not used anymore. Instead, all the operations, such as applying policy rules, NAT binding and charging operations, are executed based on SBI HTTP2 requests. All the flow, including the sessions creation, handling charging procedures, and sessions termination, is still the same. Only protocols and requests are changed.

The following sections represent diagrams for the actions described above. The diagrams represent very high-level architecture and are mostly TPOSS-centric. For more detailed RADIUS and Diameter interaction, see the TISP AAA documentation.

## Network session establishment

Packet gateway (PGW) creates a [network session](https://docs.cennso.com/components/tposs/6.15/glossary.md#types-of-sessions-within-tposs) through the RADIUS `Access-Request` for the newly-attached device. TPOSS authenticates the newly-attached device using data from the UDR storage and allocates `Framed-IP-Address` for the newly-created session. 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
TPOSS->>PGW:Authorization result

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
```

## Service session establishment

Traffic Detection Function (TDF) creates a [service session](https://docs.cennso.com/components/tposs/6.15/glossary.md#types-of-sessions-within-tposs) through the `HTTP Nnas Authorization` request. When the initial service session is created, TPOSS allocates PCC rules through the `HTTP Npcf Create` request and allocates quota through the `HTTP Nchf Create` request. As the last step, TPOSS handles the `HTTP NNas Accounting` request to apply NAT binding. The following diagram represents this flow:

```mermaid
sequenceDiagram

participant TDF
participant TPOSS
participant UDR
participant CCS
participant PCS
participant MySQL

Note over PGW,MySQL: Service session establishment

TDF->>TPOSS:HTTP NNas /nnas-authenticationauthorization request
TPOSS->>PCS:Service session creation
PCS->>MySQL:Service session creation
MySQL->>PCS:Service session created
PCS->>TPOSS:Service session created
TPOSS->>UDR:Fetch NAT-binding information
UDR->>MySQL:Fetch NAT-binding information
MySQL->>UDR:NAT-binding information
UDR->>TPOSS:NAT-binding information
TPOSS->>TDF:HTTP Nnas response. NAT-binding information

TDF->>TPOSS:HTTP Npcf /npcf-smpolicycontrol Create request
TPOSS->>PCS:Fetch charging rules for a session
PCS->>MySQL:Fetch charging rules for a session
MySQL->>PCS:Charging rules for a session
PCS->>TPOSS:Charging rules for a session
TPOSS->>TDF:HTTP Npcf response. Charging rules for a session

TDF->>TPOSS:HTTP Nchf /nchf-convergedcharging Create request
TPOSS->>CCS:Fetch charging information (quota, validity-time). Open CDRs.
CCS->>MySQL:Fetch charging information (quota, validity-time). Open CDRs.
MySQL->>CCS:Charging information (quota, validity-time). CDRs opened.
CCS->>TPOSS:Charging information (quota, validity-time). CDRs opened.
TPOSS->>TDF:HTTP Nchf response. Charging information (quota, validity-time)

TDF->>TPOSS:HTTP Nnas /nnas-accounting request
TPOSS->>PCS:Update service session with NAT IP and ports
PCS->>MySQL:Update service session with NAT IP and ports
MySQL->>PCS:Service session updated with NAT IP and ports
PCS->>TPOSS:Service session updated with NAT IP and ports
TPOSS->>TDF:HTTP Nnas /nnas-accounting response
```

## Charging procedures

After both network and service sessions are fully established for the newly-attached device, TPOSS awaits for charging reports through the `HTTP Nchf Update` request. The following diagram represents this flow:

```mermaid
sequenceDiagram

participant TDF
participant TPOSS
participant CCS
participant PCS
participant MySQL

Note over PGW,MySQL: Charging procedures

loop Validity time expired
  TDF->>TPOSS:HTTP Nchf /nchf-convergedcharging Update request
  TPOSS->>CCS:Update charging information (quota, validity-time, CDRs)
  CCS->>MySQL:Update charging information (quota, validity-time, CDRs)
  MySQL->>CCS:Updated charging information (quota, validity-time)
  CCS->>TPOSS:Updated charging information (quota, validity-time)
  TPOSS->>TDF:HTTP Nchf response. Charging information (quota, validity-time)
end
```

## Network and service sessions termination

When the device is detached, TPOSS receives the `RADIUS Accounting-Stop` request from PGW and notifies TDF through the `HTTP Nchf Abort Charging` request to trigger a termination of a service session. TPOSS waits for the `HTTP Npcf Delete` and `HTTP Nchf delete` requests from TDF to terminate the service session. The following diagram represents this flow:

```mermaid
sequenceDiagram

participant PGW
participant TDF
participant TPOSS
participant UDR
participant CCS
participant PCS
participant MySQL

Note over PGW,MySQL: Session termination

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

TPOSS->>TDF:HTTP Abort charging request
TDF->>TPOSS:HTTP Abort charging response
TDF->>TPOSS:HTTP /npcf-smpolicycontrol release request
TPOSS->>TDF:HTTP release response
TDF->>TPOSS:HTTP /nchf-convergedcharging release request

TPOSS->>PCS:Close CDRs
PCS->>MySQL:Close CDRs
MySQL->>PCS:CDRs closed
PCS->>TPOSS:CDRs closed

TPOSS->>PCS:Delete service session
PCS->>MySQL:Delete service session
MySQL->>PCS:Service session deleted
PCS->>TPOSS:Service session deleted

TPOSS->>TDF:HTTP release response
```
