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

# [Experimental] CDMP message flow

> [!IMPORTANT]
> This feature is experimental and can only be used with Session Management Controller (SMC) that supports CDMP. The new behaviour is disabled by default to preserve backward compatibility with the previous versions of TPOSS. [SBI](https://docs.cennso.com/components/tposs/6.19/configuration/sbi.md) and [Diameter](https://docs.cennso.com/components/tposs/6.19/configuration/diameter.md) must be disabled if CDMP is enabled. You can disable them using the **sbi.enabled** and **scg.diameter.enabled** configuration options.

TPOSS supports CDMP APIs to establish service sessions, manage them, and execute charging operations. The procedures are similar to Diameter `NASREQ`, `Gx`, and `Gy` requests described in the [Diameter message flow](https://docs.cennso.com/components/tposs/6.19/architecture/diameter.md) document, but CDMP `Nnas`, `Npcf`, and `Nchf` API calls over Cennso Data Mesh (CDM) are used instead.

CDMP messages are similar to the messages based on [SBI](https://docs.cennso.com/components/tposs/6.19/architecture/sbi.md), but Cennso Data Mesh is used as a transport layer instead of HTTP2. TPOSS supports the following CDMP APIs:

- Npcf API ([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.19/api-reference/sbi/npcf.md) document.
- Nchf API ([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.19/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.19/api-reference/sbi/nnas.md) document.

TPOSS can create a [service session](https://docs.cennso.com/components/tposs/6.19/glossary.md#service-session) only after the related [network session](https://docs.cennso.com/components/tposs/6.19/glossary.md#network-session) exists for the given subscriber. For more information about the network session creation and management, read the [Network session flows](https://docs.cennso.com/components/tposs/6.19/architecture/architecture.md#network-session-flows) document.

After a network session is successfully established, SMF initiates a service session to apply policy rules and charging conditions for the services available for the user.

Service sessions can be created based on one of the following protocols:

- Diameter
- SBI
- CDMP

The general TPOSS architecture and request flows are presented in the [General architecture](https://docs.cennso.com/components/tposs/6.19/architecture/architecture.md) document. This document describes the request flow only based on the CDMP. For more information about other protocols, read the [Diameter](https://docs.cennso.com/components/tposs/6.19/architecture/diameter.md) and [SBI](https://docs.cennso.com/components/tposs/6.19/architecture/sbi.md) architecture documents.

For more information on how to configure the CDMP interface that TPOSS provides, read the [CDMP](https://docs.cennso.com/components/tposs/6.19/configuration/nats-services/cdmp.md) configuration guide.

## Creation of service sessions

The process of creating a service session is similar to the Diameter or SBI flows, but uses CDMP API calls instead. It consists of the following stages:

1. The initial session is created based on the CDMP `Nnas Authorization` request.
2. After the initial service session is created, TPOSS allocates PCC rules based on the CDMP `Npcf Create` message.
3. After PCC rules are set for the service session, the available quota is allocated based on the CDMP `Nchf Create` message.
4. TPOSS handles the CDMP `Nnas Accounting-Start` request to apply a NAT binding.

The following diagram describes this flow:

```mermaid
sequenceDiagram

participant SMF
participant CDM
participant TPOSS
participant UDR
participant CCS
participant PCS
participant MySQL

Note over SMF,MySQL: Creation of an initial session
SMF->>CDM:NNas Authorization request
CDM->>TPOSS:NNas Authorization 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->>CDM:Nnas Authorization response. NAT-binding information
CDM->>SMF:Nnas Authorization response. NAT-binding information

Note over SMF,MySQL: Allocation of policy rules
SMF->>CDM:Npcf Create request
CDM->>TPOSS:Npcf 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->>CDM:Npcf Create response. Charging rules for a session
CDM->>SMF:Npcf Create response. Charging rules for a session

Note over SMF,MySQL: Allocation of charging rules
SMF->>CDM:TPOSS:Nchf Create request
CDM->>TPOSS:Nchf 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->>CDM:Nchf Create response. Charging information (quota, validity-time)
CDM->>SMF:Nchf Create response. Charging information (quota, validity-time)

Note over SMF,MySQL: NAT-binding and full session establishment
SMF->>CDM:Nnas Accounting request
CDM->>TPOSS: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->>CDM:Nnas Accounting response
CDM->>SMF:Nnas Accounting response
```

## Charging procedures

After a service session is fully established, the user can start to consume services. The resources (like Internet traffic) that the user consumed must be periodically charged. Since both network and service sessions are established for the newly attached device, TPOSS waits for periodical charging reports sent through CDMP `Nchf Update` messages.

The following diagram describes this flow:

```mermaid
sequenceDiagram

participant SMF
participant CDM
participant TPOSS
participant CCS
participant PCS
participant MySQL

loop Validity time expired
  SMF->>CDM:Nchf Update request
  CDM->>TPOSS:Nchf 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->>CDM:Nchf Update response. Charging information (quota, validity-time)
  CDM->>SMF:Nchf Update response. Charging information (quota, validity-time)
end
```

In addition to the usual reporting of used resources from SMF to TPOSS, TPOSS may trigger a change of charging rules when certain events appear. Such events are:

- A valid balance provisioned for the active user which does not have one
- A balance was deleted for the active user

In this case, TPOSS may send outgoing CDMP requests towards SMF. The request type depends on the event which triggered the message and the current state of the user's session. If the user's balance was deleted, but there is another valid balance which can be used, TPOSS sends a CDMP `Nchf RAR` message to SMF to notify it that the current balance is not valid anymore, and the session switches to another quota. For all other events, TPOSS sends a CDMP `Npcf RAR` message to notify SMF about the change in the charging rules.

The following diagram describes this flow:

```mermaid
sequenceDiagram

participant TPOSS-API-GW
participant SMF
participant CDMP
participant TPOSS
participant UDR
participant CCS
participant PCS
participant MySQL

TPOSS-API-GW->>TPOSS:Delete balance
TPOSS->>CCS:Check another valid balance
CCS->>MySQL:Check another valid balance
alt Another valid balance exists
  MySQL->>CCS: Additional balance exist
  CCS->>TPOSS: Additional balance exist
  TPOSS->>CCS: Apply new balance
  CCS->>TPOSS: New balance applied

  TPOSS->>TPOSS-API-GW:Balance deleted

  TPOSS->>CDM:Nchf RAR request
  CDM->>SMF:Nchf RAR request
  SMF->>TPOSS:Nchf RAR response
else No more valid balances
  TPOSS->>TPOSS-API-GW:Balance deleted

  TPOSS->>PCS: Remove online rule
  PCS->>MySQL: Update session. Remove online rule
  MySQL->>PCS: Session updated. Online rule removed
  PCS->>TPOSS: Session updated. Online rule removed

  Note over SMF,MySQL: Remove online rule based on the balance deletion
  TPOSS->>CDM:Npcf RAR request.
  CDM->>SMF:Npcf RAR request.
end

Note over SMF,MySQL: Finish charging for the deleted balance
SMF->>CDM:Nchf Update request. Update charging information
CDM->>TPOSS:Nchf Update request. Update charging information
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->>CDM:Nchf Update response. Updated charging information (quota, validity-time)
CDM->>SMF:Nchf Update response. Updated charging information (quota, validity-time)
```

> [!NOTE]
> If the SMF response indicates any failure on these requests or there is no response at all, TPOSS terminates the service session.

## Service sessions termination

As soon as the device is detached, TPOSS receives a RADIUS `Accounting-Stop` request from a packet gateway as described in the [Network session flows](https://docs.cennso.com/components/tposs/6.19/architecture/architecture.md#network-session-flows) document. During a network session termination process, TPOSS notifies SMF using the CDMP `Nchf ASR` message to trigger a service session termination. After the CDMP message is sent, TPOSS waits to receive CDMP `Npcf release` and `Nchf release` requests from SMF to terminate the service session.

The following diagram describes this flow:

```mermaid
sequenceDiagram

participant PGW
participant SMF
participant CDM
participant TPOSS
participant UDR
participant CCS
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

TPOSS->>CDM:Nchf ASR request
CDM->>SMF:Nchf ASR request
SMF->>CDM:Nchf ASR response
SMF->>TPOSS:Nchf ASR response

SMF->>CDM:Npcf Release request
CDM->>TPOSS:Npcf Release request
TPOSS->>CDM:Npcf Release response
CDM->>SMF:Npcf Release response

SMF->>CDM:Nchf release request
CDM->>TPOSS:Nchf 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->>CDM:Nchf Release response
CDM->>SMF:Nchf Release response
```

> [!NOTE]
> If the SMF response for ASR messages indicates any failure or there is no response at all, TPOSS terminates the service session.
