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

# CDFReceiver

CDF Receiver is responsible for receiving Charging Data Records (CDRs) from the Session Management Function (SMF) over the Diameter Rf interface. It handles incoming CDRs, validates them, and stores them in Cennso Data Mesh (CDM) for further processing by CDF Sender.

## Deployment options

You can deploy CDF Receiver in two ways:

- **Using the Cennso extension** - Deploy CDF Receiver to remote Core Clusters by creating a `CDFReceiver` Custom Resource (CR) in your Management Cluster. This method is recommended for most users as it provides better integration with Cennso and simplifies management of CDF components across multiple clusters.
- **Using Helm charts** - Deploy CDF Receiver using standard Helm commands to your current cluster context.

The sections below describe configuration parameters for CDF Receiver. Examples use Custom Resource syntax with camelCase field names (for example, `spec.config.rateLimit`, `nodeId`). If you're deploying using Helm charts, the same configuration options are available using snake_case with the `receiver.` prefix (for example, `receiver.rate_limit`, `receiver.node_id`).

> [!NOTE]
> **Helm chart users:** The first three sections (Kubernetes cluster secret reference, Scheduling and placement configuration, Target namespace setting) describe CR-specific deployment settings managed by Crossplane. For Helm deployments, you configure these directly in your `values.yaml` file. You can skip to [Hostname configuration](#hostname-configuration) for application-level configuration that applies to both deployment methods. Note that the [Resources configuration](#resources-configuration) section also uses CR syntax, but Helm has equivalent resource settings in `values.yaml`. For a complete list of Helm chart parameters, see the [Helm chart reference](https://docs.cennso.com/components/cdf/latest/technical-reference/chart-config.md).

## Kubernetes cluster secret reference

To deploy the CDF Receiver to a Core Cluster, you must specify the reference to the [Kubernetes secret](https://kubernetes.io/docs/concepts/configuration/secret/) so this cluster can be accessible. You can do this using the following configuration parameters:

```yaml
spec:
  connectionSecretRef:
    name: {CORE-CLUSTER-NAME}
    namespace: cennso-infra
```

The **spec.connectionSecretRef.name** should contain the name of the Core Cluster where the CDF Receiver should be installed. The **spec.connectionSecretRef.namespace** configuration parameter defines the Kubernetes namespace where the Kubernetes secret to access this Core Cluster is stored.

## Scheduling and placement configuration

`CDFReceiver` CR allows you to configure the CDF Receiver scheduling and placement settings according to your needs.

To control where the CDF Receiver Pods run and how they’re distributed across nodes, use the following configuration options:

- [**spec.nodeSelector**](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/) - runs pods on nodes with specific labels
- [**spec.tolerations**](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) - allows pods to run on tainted nodes

## Target namespace setting

One of the required fields in the `CDFReceiver` CR is the **spec.targetNamespace** parameter, which defines the Kubernetes namespace where CDF Receiver resources are created on the Core Cluster:

```yaml
spec:
  targetNamespace: cdf
```

## Hostname configuration

When SMF sends an Accounting Request (ACR), CDF Receiver must reply with an Accounting Answer (ACA). The **spec.config.hostname** parameter defines the Diameter `Origin-Host` identity that CDF Receiver uses in Accounting Answer (ACA) responses sent to SMF. It identifies the CDF instance that generated the response.

See the configuration example:

```yaml
spec:
  config:
    hostname: cdf.example.com  # Diameter Origin-Host identity
```

## Node ID configuration

You might run multiple CDF Receiver instances for high availability or load distribution. To distinguish between them, you must set the **spec.config.nodeId** parameter to a unique identifier for each CDF Receiver instance. This node ID is used in metrics and logs to identify which instance is processing specific charging data.

```yaml
spec:
  config:
    nodeId: receiver-1  # Unique identifier for this CDF Receiver instance
```

## Resources configuration

`CDFReceiver` CR allows you to configure the [resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) for the CDF Receiver. You can set CPU and memory requests and limits to ensure the CDF Receiver has adequate resources while preventing it from consuming too much on the node.

The **spec.resources.cdf.requests** parameter defines the minimum guaranteed resources, while **spec.resources.cdf.limits** defines the maximum resources the pod can use.

```yaml
spec:
  resources:
    cdf:
      requests:
        cpu: "1000m"       # 1 CPU core minimum
        memory: "2Gi"      # 2 GiB memory minimum
      limits:
        cpu: "2000m"       # Up to 2 CPU cores
        memory: "4Gi"      # Up to 4 GiB memory
```

## Maximum number of ACRs

You can use the **spec.config.rateLimit** parameter to configure the maximum number of ACRs received from SMF per second. The default value is `1000`.

When CDF Receiver gets more than the default value of simultaneously incoming ACRs, it answers with `TOO_BUSY` and does not write these ACRs to the disk. These ACRs are lost unless SMF resends them.

`TOO_BUSY` means that new Diameter messages arrived before the previous ones were processed. This happens to:

- Prevent CDF Receiver from becoming too slow to answer Diameter
- Avoid having too many pending ACRs consuming memory
- Protect CDF Receiver from being out-of-memory killed

```yaml
spec:
  config:
    rateLimit: 1000 # Maximum number of ACRs received per second, limit applied on the Diameter Rf interface
```

## Receive buffer size

The **spec.config.transportOptions.receiveBuffer** parameter allows you to configure the size (in bytes) of the socket receive buffer for Diameter Rf traffic coming from SMF. The default value equals the operating system settings.

If incoming ACRs arrive in bursts, a larger receive buffer temporarily stores messages that CDF Receiver cannot process immediately. This prevents message loss during traffic spikes. However, if the receive buffer is too small, ACRs may be dropped, leading to resends and reduced performance.

To calculate a suitable buffer size, you need to know the size of incoming ACRs. For example:

- Average packet size: `3000` bytes
- Incoming packet rate: `1000` per second
- Total incoming traffic: `1000 × 3000 = 3,000,000` bytes/s

With a buffer size of `131072` bytes, this would only cover about 43 milliseconds of traffic — so adjusting the buffer accordingly is important for stable performance.

Additionally, you can configure:

- **spec.config.transportOptions.transportType** - the Diameter Rf transport protocol (`tcp` or `sctp`). Use TCP when your network equipment (firewalls, load balancers) doesn't support SCTP or when SMF only supports TCP. SCTP is a protocol better suited for Diameter as it provides better reliability with multiple streams. Check your SMF configuration to see which protocol it uses — CDF Receiver must use the same protocol.
- **spec.config.transportOptions.port** - the Diameter Rf port number (default is `3868`). This must match the port where your SMF listens for Diameter Rf connections.

See the configuration example:

```yaml
spec:
  config:
    transportOptions:
      receiveBuffer: 262144  # 256 KiB buffer for incoming Diameter Rf traffic
      transportType: sctp    # Use SCTP transport protocol
      port: 3868             # Diameter Rf port
```

## Send buffer size

The **spec.config.transportOptions.sendBuffer** parameter allows you to configure the size (in bytes) of the socket send buffer for Diameter Rf traffic towards SMF. The default value equals the operating system settings.

If the send buffer is too small, outgoing Accounting Answers (ACAs) may be lost, which triggers the resending of the corresponding ACRs and overall performance degradation.

For example:

- ACAs per second: `1000`
- ACA size (including protocol overhead): `300` bytes
- Total outgoing traffic: `300,000` bytes/s

With a buffer size of `131072` bytes, this would cover about 437 milliseconds of traffic.

See the configuration example:

```yaml
spec:
  config:
    transportOptions:
      sendBuffer: 262144     # 256 KiB buffer for outgoing Diameter Rf traffic
      transportType: sctp    # Use SCTP transport protocol
      port: 3868             # Diameter Rf port
```

## CDM services configuration

CDF Receiver uses Cennso Data Mesh (CDM) to store CDRs. CDM provides several services that CDF Receiver connects to (see [Architecture](https://docs.cennso.com/components/cdf/latest/architecture.md) for more details). For each service, you can configure:

- **url** - the server URL to connect to the service
- **poolSize** - the number of connections to maintain in the connection pool for each service
- **credentialsSecretName** - the name of the Kubernetes secret containing CDM credentials for authentication

Additionally, for **workQueue** and **archive**, you can configure the **requestTimeout** parameter, which defines how long CDF Receiver waits for a response from CDM before timing out. The default value is `1000` milliseconds.

> [!NOTE]
> **Helm chart users:** In Helm values, CDM services are configured under `nats_services` instead of `cdmServices`. For example, `spec.config.cdmServices.workQueue` becomes `nats_services.work_queue`.

See the configuration example:

```yaml
spec:
  config:
    cdmServices:
      workQueue:                                # Stores incoming CDRs temporarily before processing by CDF Sender
        url: nats://nats.example.com:4222
        poolSize: 10                            # Number of connections to work queue
        requestTimeout: 5000                    # Wait up to 5 seconds for response
        credentialsSecretName: nats-creds-secret
      kvStore:                                  # Stores operational state information
        url: nats://nats.example.com:4222
        poolSize: 5                             # Number of connections to key-value store
        credentialsSecretName: nats-creds-secret
      archive:                                  # Stores CDRs long-term for auditing or backup
        url: nats://nats.example.com:4222
        poolSize: 5                             # Number of connections to archive
        requestTimeout: 3000                    # Wait up to 3 seconds for response
        credentialsSecretName: nats-creds-secret
      sessionStore:                             # Stores session information
        url: nats://nats.example.com:4222
        poolSize: 5                             # Number of connections to session store
        credentialsSecretName: nats-creds-secret
```

For more information about the available options for configuring CDM services, read the [`CDFReceiver` reference](https://docs.cennso.com/components/cdf/latest/technical-reference/crds/cdfreceiver.md) document. To learn how to configure CDM services for storing charging data, read the [Configure storage](https://docs.cennso.com/components/cdf/latest/operation-guides/storage.md) document. To learn how to configure archiving of CDRs, read the [Archive CDRs](https://docs.cennso.com/components/cdf/latest/operation-guides/archive.md) document.

## Logging

You can configure the logging level of CDF Receiver using the **spec.config.logging.level** parameter. The default logging level is `info`. You can set it to `debug` for more detailed logs during development or troubleshooting, but be aware that this may generate a large volume of logs in a production environment.

```yaml
spec:
  config:
    logging:
      level: info # Logging level (debug, info, warn, error)
```
