> 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-sender.md).

# CDFSender

CDF Sender is responsible for consuming Charging Data Records (CDRs) from CDF Receiver and forwarding them to the Charging Gateway Function (CGF) for further processing. It retrieves CDRs from Cennso Data Mesh (CDM), encodes them according to the configured format, and transmits them to CGF over GTP Prime interface.

## Deployment options

You can deploy CDF Sender in two ways:

- **Using the Cennso extension** - Deploy CDF Sender to remote Core Clusters by creating a `CDFSender` Custom Resource (CR) in your Management Cluster. Crossplane manages the deployment on your behalf.
- **Using Helm charts** - Deploy CDF Sender using standard Helm commands to your current cluster context.

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

> [!NOTE]
> **Helm chart users:** The first four sections (Kubernetes cluster secret reference, Scheduling and placement, Target namespace, Resources configuration) describe CR-specific deployment settings managed by Crossplane. For Helm deployments, you configure these directly in your `values.yaml` file. You can skip to [APN configuration](#apn-configuration) for application-level configuration that applies to both deployment methods. 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 Sender 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 Sender 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

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

To control where the CDF Sender 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 `CDFSender` CR is the **spec.targetNamespace** parameter, which defines the Kubernetes namespace where CDF Sender resources are created on the Core Cluster:

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

## Resources configuration

`CDFSender` CR allows you to configure the [resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) for the CDF Sender. You can set CPU and memory requests and limits to ensure the CDF Sender 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
```

## APN configuration

When configuring CDFSender, you must define APN-specific behavior for CDR processing using the **spec.config.apnSpecificConfig** parameter. Since different APNs often require different billing treatment — such as timezone conversions, usage adjustments, or rating group mappings — you can configure these settings per APN before CDRs are sent to the CGF.

Each APN configuration includes the following parameters:

- **name** (required) - the APN name to which this configuration applies
- **timezone** - timezone for timestamp conversions in CDRs for this APN (for example, convert UTC timestamps to `Europe/Stockholm`). If not set, timestamps remain in `UTC`.
- **interimInterval** - specifies how often (in seconds) to generate a CDR for sessions that are still active. For example, if set to `7200` (2 hours), CDF generates a CDR every 2 hours for ongoing sessions instead of waiting until the session ends.
- **adjustUsage** - if set to `true`, adjusts the reported data usage to match the actual session duration. This helps ensure billing accuracy when session start/stop times don't align perfectly with actual data transfer.
- **trafficVolumesFromServiceDataRatingGroups** - list of rating group IDs to include in the CDR. Rating groups categorize different types of traffic (for example, video streaming or web browsing). Only traffic from these groups will be counted.
- **ratingGroupMove** - remaps traffic from one rating group to another. For example, moving traffic from group `300` to group `400` can be useful when your billing system expects different categorization than what the network provides.

See the configuration example:

```yaml
spec:
  config:
    apnSpecificConfig:
      - name: iot.apn
        timezone: UTC
        interimInterval: 7200
        adjustUsage: false
        trafficVolumesFromServiceDataRatingGroups:
          - 10
          - 20
        ratingGroupMove:
          - from: 300
            to: 400
```

## CGF configuration

To send CDRs to proper CGF endpoints, you must configure the list of CGF addresses in the `CDFSender` CR. The **spec.config.cgfs** parameter defines the list of CGF endpoints to which CDF Sender sends CDRs. Each CGF receives an equal share of the load. Adding more CGFs increases overall throughput, as long as CDF Sender does not reach its performance limit.

See the configuration example:

```yaml
spec:
  config:
    cgfs:
      - ip: 192.0.2.10
        port: 2123
```

> [!NOTE]
> The **ip** parameter accepts either a hostname (for example, `cgf1.example.com`) or an IP address. When using an IPv6 address, enclose it in square brackets (for example, `[2001:DB8::1]`).

## Maximum number of CDRs

The **spec.config.rateLimit** parameter controls how quickly CDRs are consumed from the CDR queue and distributed across the available CGFs. Configure the CDF Sender rate limit according to the desired performance level.

```yaml
spec:
  config:
    rateLimit: 1000  # Maximum number of CDRs to consume per second (default: 1000)
```

## Number of processes for sending CDRs

The **spec.config.cdrLimitPerCgf** parameter defines the maximum number of processes that can send CDRs to a CGF simultaneously. This limit helps prevent overwhelming the CGF with too many concurrent requests, which can lead to timeouts and failed deliveries. The default value is `1000`, which means that up to `1000` CDRs can be in-flight (sent but not yet acknowledged) to each CGF at the same time.

If your system cannot support `1000` open sockets or has limited memory, you can reduce this value to better fit your resource constraints. A higher limit allows more outstanding requests, helping maintain throughput despite network latency.

## Response timeout and retries

When CDF Sender sends a CDR to CGF, it waits for a confirmation response. If the response doesn't arrive in time, CDF Sender tries sending the CDR again. You can configure how long to wait and how many times to retry using these parameters:

- **spec.config.responseTimeout** - specifies how long (in milliseconds) to wait for a response from CGF before timing out
- **spec.config.retries** - specifies how many times to retry sending a CDR if there's no response

If CGF still doesn't respond after the configured number of retries, CDF Sender marks that CGF as unavailable and stops sending CDRs to it until the CGF responds to a GTP Echo health check.

See the configuration example:

```yaml
spec:
  config:
    responseTimeout: 5000  # Wait 5 seconds for CGF response
    retries: 3             # Retry up to 3 times if no response
```

To avoid triggering a retransmission for still-in-flight responses from the CGF, set the timeout long enough for CGF to process the CDR and send a response back. A good starting point is to set the timeout at least twice as long as the network round-trip time between CDF Sender and CGF.

## Echo requests interval

CDF Sender periodically sends GTP Echo requests to CGF to check if it's still responding. You can use the **spec.config.echo** parameter to define the interval, in milliseconds, between these health check requests. According to the standard, this value cannot be shorter than `60` seconds. Setting a high value for echo increases the time CDF Sender takes to establish communication with a CGF.

If communication with a CGF is lost, CDF Sender continues to send Echo requests. While one or more CGFs are unresponsive, CDF Sender automatically reduces its throughput to match the capacity of the remaining active CGFs, and restores it once all CGFs respond to the echo request. When a response is received, CDF Sender considers the connection re-established.

## Pool size configuration

One way to scale CDF Sender performance is to increase the number of CDR queue connections using the **spec.config.cdmServices.poolSize** parameter. The default pool size is `8`.

More connections allow CDF Sender to retrieve CDRs from the CDR queue faster. However, this only helps if the CDR queue is the bottleneck. If CDRs are sent to CGF slowly due to network delays or CGF response times, adding more connections won't improve throughput. Keep in mind that each additional connection uses more CPU.

> [!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`.

```yaml
spec:
  config:
    cdmServices:
      workQueue:
        poolSize: 16  # Increase from default 8 to 16 connections
```

The table below shows the relation between CDF Sender pool size, CPU usage, and NATS ingress and egress throughput. The data was collected by running CDF Sender and CDF Receiver in a Kubernetes cluster.

| Pool size | CPU % | ingress CDR/s | egress CDR/s |
| --- | --- | --- | --- |
| 8 | 50 | 1500 | 935 |
| 16 | 117 | 1500 | 1500 |
| 16 | 98 | 3000 | 2425 |
| 24 | 216 | 3000 | 3000 |
| 24 | 164 | 4500 | 4250 |
| 32 | 260 | 4500 | 4500 |
| 32 | 226 | 6000 | 6000 |

After 6k ingress, the four load generators were restarted with 2000 rate per generator and not changed anymore.

| Pool size | CPU % | ingress CDR/s | egress CDR/s |
| --- | --- | --- | --- |
| 32 | 220 | 8000 | 6200 |
| 40 | 275 | 8000 | 7700 |
| 48 | 295 | 8000 | 9470 |

## Logging

You can configure the logging level of CDF Sender 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)
```
