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

# [Experimental] HSS S6a message flow

> [!IMPORTANT]
> This feature is experimental. The new behavior is disabled by default to preserve backward compatibility with the previous versions of TPOSS. The HSS is a separate function that uses its own Diameter service. It excludes [SBI](https://docs.cennso.com/components/tposs/latest/configuration/sbi/sbi.md), [CDMP](https://docs.cennso.com/components/tposs/latest/configuration/cdmp/cdmp.md) and [Diameter](https://docs.cennso.com/components/tposs/latest/configuration/diameter.md). TPOSS serves one of the four per deployment and refuses to start with more than one enabled.

TPOSS can act as a 4G Home Subscriber Server (HSS) and Authentication Centre (AuC) over the Diameter S6a interface defined in [3GPP TS 29.272](https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1690). A [MME](https://docs.cennso.com/components/tposs/latest/glossary.md) uses the Diameter S6a protocol to authenticate a subscriber and to fetch the 4G mobile subscription data it needs to establish a default bearer.

The authentication procedures are executed based on the following incoming Diameter S6a messages:

- Authentication-Information (AIR)
- Update-Location (ULR)
- Purge-UE (PUR)

TPOSS also sends Cancel-Location (CLR) requests to an MME to inform it that a subscriber it was serving has moved elsewhere. For more information, see [Cancel-Location](#cancel-location).

This document describes the request flow only based on the TPOSS HSS Diameter S6a interface. For more details about the TPOSS HSS architecture and how to configure this mode, read the following documents:

- [General TPOSS architecture](https://docs.cennso.com/components/tposs/latest/architecture/architecture.md)
- [TPOSS HSS architecture](https://docs.cennso.com/components/tposs/latest/architecture/tposs-hss.md)
- [HSS settings](https://docs.cennso.com/components/tposs/latest/configuration/hss.md)

## Authentication and location update

When a device attaches to the mobile network, the MME authenticates the subscriber and fetches the subscription data it needs to establish a default bearer. It sends two S6a requests for the same attach:

1. The Authentication-Information-Request (AIR) asks TPOSS for the authentication vectors that the MME challenges the device with.
2. The Update-Location-Request (ULR) reports that this MME now serves the subscriber and asks for the subscription data.

The following diagram describes this flow:

```mermaid
sequenceDiagram

participant UE
participant MME
participant TPOSS as TPOSS (HSS)
participant AuC
participant MySQL

Note over UE,MySQL: Authentication
UE->>MME: Attach Request
MME->>TPOSS: Diameter S6a AIR
TPOSS->>AuC: Request authentication vectors
AuC->>MySQL: Read the subscriber key
MySQL->>AuC: Subscriber key
AuC->>TPOSS: Authentication vectors
TPOSS->>MME: Diameter S6a AIA
MME->>UE: Authentication Request
UE->>MME: Authentication Response

Note over UE,MySQL: Location update
MME->>TPOSS: Diameter S6a ULR
TPOSS->>MySQL: Fetch subscription and APN profiles
MySQL->>TPOSS: Subscription data
TPOSS->>MySQL: Record the serving MME
TPOSS->>MME: Diameter S6a ULA
MME->>UE: Attach Accept
```

## Purge-UE

When an MME deletes the mobility-management context for a detached subscriber, it sends a Purge-UE-Request (PUR):

```mermaid
sequenceDiagram

participant MME
participant TPOSS as TPOSS (HSS)
participant MySQL

MME->>TPOSS: Diameter S6a PUR
TPOSS->>MySQL: Look up the subscriber and the serving MME
MySQL->>TPOSS: Subscription and registration
TPOSS->>MySQL: Mark the registration purged
TPOSS->>MME: Diameter S6a PUA
```

A purge takes effect only when it comes from the MME the subscriber is registered with. TPOSS compares the `Origin-Host` of the request with the MME recorded by the last Update-Location and acts based on these values as described in the table below:

| The request comes from | TPOSS performs action | `PUA-Flags` in the response |
|---|---|---|
| The serving MME | Marks the registration purged | `0x1`, Freeze M-TMSI |
| Another MME | Nothing | `0` |
| Any MME, for a subscriber that has never attached | Nothing | `0` |

The `Freeze M-TMSI` flag tells the MME to hold that temporary identity back from immediate reuse, so the same identity is still available if the subscriber comes back.

The subscriber is kept in the database on a successful Purge-UE-Request. A purged subscriber has a serving MME on record but is known to be unreachable through it. The next successful Update-Location clears the `purged` mark, whether the subscriber returns to the same MME or attaches to a different one.

## Cancel-Location

When a subscriber attaches to a different MME, the MME that was serving it still can hold a mobility management context for that subscriber. To clean it up, TPOSS sends a Cancel-Location-Request (CLR):

```mermaid
sequenceDiagram

participant MME1 as Previous MME
participant TPOSS as TPOSS (HSS)
participant MySQL
participant MME2 as New MME

MME2->>TPOSS: Diameter S6a ULR
TPOSS->>MySQL: Look up the serving MME
MySQL->>TPOSS: Previous registration
TPOSS->>MySQL: Record the new serving MME
TPOSS->>MME1: Diameter S6a CLR
TPOSS->>MME2: Diameter S6a ULA
MME1->>TPOSS: Diameter S6a CLA
```

Whether a Cancel-Location is sent depends on which MME sent the Update-Location, and on what TPOSS already had on record for that subscriber:

| Entity that sent Update-Location | TPOSS action |
|---|---|
| A different MME | Sends a Cancel-Location to the previous MME |
| The MME already serving the subscriber | Nothing |
| Any MME, for a subscriber that has never attached | Nothing |
| A different MME, after the previous one purged the subscriber | Nothing |

> [!IMPORTANT]
> A Cancel-Location is not retried. A request that cannot be delivered leaves the previous MME holding its mobility-management context until that node's own timers expire.
