> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/tsr/1.2/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/tsr/1.2/tutorials/dest-mode.md).

# Set up Traffic Stream Reporter in the `dest` mode

Traffic Stream Reporter (TSR) that works in the `dest` mode collects the number of bytes sent and received from external IPs. It also stores information about virtual routing and forwarding (VRF) name, interface name, and observation domain name of the User Plane Gateway (UPG) component.

To set up TSR in the `dest` mode on a single cluster, configure the Sink, Collector, and Cleaner components by following this tutorial.

## Prerequisites

- [Kubernetes 1.18](https://kubernetes.io/docs/tasks/tools/) or newer
- [Helm client](https://helm.sh/docs/intro/install/) 3.9.2 or newer
- MySQL database

## Steps

1. Create a namespace for your TSR installation:

   ```bash
   kubectl create namespace tsr
   ```

2. Create a TSR Sink configuration file that saves information from the IPFIX packages into your deployed MySQL database. The information is stored in the `egress_$day` and `ingress_$day` tables. You can adjust the **ueNet** parameter to classify the IPFIX message in egress or ingress so that it can be stored in the corresponding database tables:

   ```yaml
   service:
     port: 4739
   mysql:
     host: tsr-db-mysql
     user: ipfix
     pass: ipfix
     db: ipfix
   
   ipfix:
     type: dest
     ueNet: 
       - 198.19.128.0/17
       - FC00::/7
   ```

3. Install TSR Sink on the cluster:

   ```bash
   helm install tsr-sink {REPOSITORY_NAME}/tsr-sink -f {FILENAME}.yaml --namespace tsr
   ```

4. Create a TSR Collector configuration file that contains the port on which Collector receives the IPFIX packets and forwards them to Sink available at the specified hostname:

   ```yaml
   ipfix:
     instances:
       - name: sink
         targets:
           - host: tsr-sink
             port: 4739
         listenPort: 4739
   ```

5. Install TSR Collector on the cluster:

   ```bash
   helm install tsr-collector {REPOSITORY_NAME}/tsr-collector -f {FILENAME}.yaml --namespace tsr
   ```

6. Create a TSR Cleaner configuration file for the ingress and egress tables. You can specify the exact time when the tables are cleaned. In the examples below, the tables are cleaned after 7 days at midnight. 

   ```yaml
   mysql:
     host: tsr-db-mysql
     user: ipfix
     db: ipfix
     pass: ipfix
   
   schedule: "0 0 * * *"
   retention: 7
   ttlSecondsAfterFinished: 120
   ```

7. Install TSR Cleaner ingress configuration on the cluster:

   ```bash
   helm install tsr-cleaner-ingress {REPOSITORY_NAME}/tsr-cleaner -f {FILENAME}.yaml --namespace tsr --set tablePrefix=ingress
   ```

8. Install TSR Cleaner egress configuration on the cluster:

   ```bash
   helm install tsr-cleaner-egress {REPOSITORY_NAME}/tsr-cleaner -f {FILENAME}.yaml --namespace tsr --set tablePrefix=egress
   ```
