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

# Traffic Stream Reporter

Traffic Stream Reporter (TSR) is a project that receives and processes IPFIX information.

TSR consists of four components:

- TSR Collector - listens for IPFIX packets and forwards the packets to the next hop, for example another Collector or the Sink
- TSR Sink - receives IPFIX packets and stores the relevant information of the packets into a MySQL database
- TSR Engine - runs once or periodically and generates reports for traffic from and to external IP addresses (only for FlowUsageReport)
- TSR Cleaner - runs periodically and removes outdated data from the MySQL database

## IPFIX messages

TSR can handle two types of IPFIX messages:
- NatEvent
- FlowUsage

### NatEvent

When TSR is configured to handle NatEvent IPFIX messages, you can use the following information:

| IPFIX IE name | Protocol | Description |
|---|---|---|
| sourceIPv4Address | IPv4 | IPv4 UE address |
| sourceIPv6Address | IPv6 | IPv6 UE address |
| destinationIPv4Address | IPv4 | IPv4  uplink endpoint address |
| destinationIPv6Address | IPv6 | IPv6 uplink endpoint address |
| postNATSourceIPv4Address | IPv4 | External NAT allocated address of the flow if NAT is used |
| postNAPTSourceTransportPort | IPv4 | External NAT allocated port of the flow if NAT is used |
| natEvent | IPv4 | Change of the state of NAT allocation |
| protocolIdentifier | any | Protocol number of the IP packet |
| mobileIMSI | any | UE IMSI |
| initiatorOctets | any | Bytes seen in the uplink direction |
| responderOctets | any | Bytes seen in the downlink direction |
| initiatorPackets | any | Packets seen in the uplink direction |
| responderPackets | any | Packets seen in the downlink direction |
| flowStartMilliseconds | any | Time of the first seen packet of the flow |
| flowEndMilliseconds | any | Time of the last seen packet of the flow |
| sourceTransportPort | any | Uplink source port |
| destinationTransportPort | any | Uplink endpoint port |

TSR can handle messages with natEvent `create(4)` (start of NAT binding) and `delete(5)` (end of NAT binding).
As a result, the following data items are known:
- UE IP address and port
- IMSI
- Start/end of NAT binding
- Destination IP and port
- NAT IP and Port
- Protocol
- Number of bytes sent and received
- Number of packets sent and received
This information is stored in a database and used for analysing or debugging the traffic of devices.

### FlowUsage

There are two variants of FlowUsage IPFIX messages:

- Bidirectional
- Unidirectional

When TSR is configured to handle FlowUsage bidirectional IPFIX messages, you can use the following information:

| IPFIX IE name | Description |
|---|---|
| sourceIPv4Address | IPv4 UE address |
| sourceIPv6Address | IPv6 UE address |
| destinationIPv4Address | IPv4 uplink endpoint address |
| destinationIPv6Address | IPv6 uplink endpoint address |
| protocolIdentifier | Protocol number of the IP packet |
| initiatorOctets | Bytes seen in the uplink direction |
| responderOctets | Bytes seen in the downlink direction |
| initiatorPackets | Packets seen in the uplink direction |
| responderPackets | Packets seen in the downlink direction |
| flowStartMilliseconds | Time of the first seen packet of the flow |
| flowEndMilliseconds | Time of the last seen packet of the flow |
| VRFname | If forwarding policy is defined - name of the forwarding policy, otherwise - egress VRF name |
| interfaceName | Interface name in the direction to uplink |
| observationDomainName | Configured observation domain name |
| observationPointId | Configured observation point ID |

When TSR is configured to handle FlowUsage unidirectional IPFIX messages, you can use the following information:

| IPFIX IE name | Description |
|---|---|
| sourceIPv4Address | IPv4 UE address |
| sourceIPv6Address | IPv6 UE address |
| destinationIPv4Address | IPv4 uplink endpoint address |
| destinationIPv6Address | IPv6 uplink endpoint address |
| protocolIdentifier | Protocol number of the IP packet |
| octetDeltaCount | Bytes seen in the uplink direction |
| packetDeltaCount | Packets seen in the uplink direction |
| flowStartMilliseconds | Time of the first seen packet of the flow |
| flowEndMilliseconds | Time of the last seen packet of the flow |
| VRFname | If forwarding policy is defined - name of the forwarding policy, otherwise - egress VRF name |
| interfaceName | Interface name in the direction to uplink |
| observationDomainName | Configured observation domain name |
| biflowDirection | Direction in which the flow was created. Details in the additional section below |
