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

# Charging Data Function

Charging Data Function (CDF) is a key component in the 3GPP charging
architecture for mobile networks. It is responsible for collecting,
aggregating, and processing charging data records (CDRs) from various network elements. These CDRs contain information about the users' consumption of network resources.

CDF performs several important functions:

- Collecting CDRs from network elements such as Gateway GPRS Support Node (GGSN), Serving Gateway (SGW), or Packet Data Network Gateway (PGW)
- Transferring the processed CDRs to the Charging Gateway Function (CGF)

In the 3GPP charging architecture, CDF is often integrated into the network elements that generate CDRs. It works alongside other components like the CGF to support the overall charging and billing process in mobile networks.

CDF is part of the 3GPP offline charging architecture, where it connects to the CGF to send charging information. This architecture supports both offline and online charging scenarios, allowing for flexible and comprehensive billing solutions in telecommunications networks.

## Architecture

CDF is split into two applications: [CDF receiver](#receiver) and [CDF sender](#sender). The transport between receiver and sender is done with NATS.

See the CDF workflow diagram:

![CDF with NATS transport](https://docs.cennso.com/api/assets/components/cdf/4.0/assets/CDF3-NATS.svg)

1. On application startup, CDF configures the CDR stream and the work-queue consumer.
2. CDF Receiver receives Accounting Requests (ACRs) from Session Management Controller (SMC) and parses them into charging data content. The charging data is published to NATS.
3. CDF Receiver queues CDRs in a CDR stream. The stream is limited by the queue size in bytes or time.
4. The work-queue consumer, which is subscribed for all entries in the stream, consumes entities from the stream (CDRs).
5. CDF Sender sends CDRs through the Ga reference point to CGF.
6. CGF acknowledges the CDR delivery.
7. CDF Sender sends confirmations for the processed CDRs to the work-queue consumer.

### Receiver

CDF receiver processes accounting requests (ACRs) using the Rf interface. There are three types of ACRs:

- `start`
- `interim`
- `stop`

Only the `interim` and `stop` requests are saved. Nothing is saved if only `start` records arrive at the receiver. This behaviour assumes that the Session Management Controller (SMC) accumulates charging data until the reporting interval. The receiver generates CDRs in a format suitable for the sender and publishes each CDR to NATS.

### Sender

CDF sender periodically reads CDRs from NATS using pull consumers. It verifies the conditions that must be met to send a CDR through the Ga interface to CGF. If CDF sends GTP Echo Requests and does not get any response, it does not send the CDRs. The sender generates CDRs in a format suitable for the Ga interface and sends the CDRs in parallel. When a CDR gets a response from CGF, NATS gets an acknowledgement. If CGF doesn't acknowledge a CDR, NATS resends it.
