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

# Set up TSR in the `default` mode

Traffic Stream Reporter (TSR) that works in the `default` mode stores information needed for data retention lawful interception.
It maps internal IP addresses to public IP addresses (NAT). It stores the IMSI, source and destination hosts and ports, the protocol, the NAT event and the session start and end time.

To set up TSR in the `default` 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 specifies the port on which Sink receives the IPFIX packets. The configuration file also contains a reference to your deployed MySQL database that stores data into the `natev_$day` table. The table name is set automatically based on the `default` setup type. 

   ```yaml
   service:
     port: 4739
   mysql:
     host: tsr-db-mysql
     user: ipfix
     pass: ipfix
     db: ipfix
   
   ipfix:
     type: default
   ```

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 * * *"
   tablePrefix: natev
   retention: 7
   ttlSecondsAfterFinished: 120
   ```

7. Install TSR Cleaner configuration on the cluster:

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