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

# UPG IP Flow Information Export (IPFIX)

UPG allows exporting per-flow information based on the IPFIX protocol described in RFC5470 (architecture), RFC7011 (protocol), and RFC8158 (NAT extension).

## Terminology

- Flow - set of packets sent from one endpoint to another (UE to outside or outside to UE), Packets share the same **src**, **dst**, **proto**, **src_port**, and **dst_port** fields. UPG works with biflows and IPFIX reports contain information for both directions of the bidirectional flow.
- Uplink direction - traffic direction from UE
- Downlink direction - traffic direction to UE

## Reporting

Three conditions can trigger IPFIX flow reporting:

1. Flow creation
1. Intermediate reports, if the reporting interval is configured
2. Flow termination

The source address of the IPFIX report always points to UE, even if UE is not the initiator of this flow. It is not always guaranteed to detect the initiator of the biflow but the `biflowDirection` field provides a good estimation, which can be used for statistic purposes.

The side of PFCP session directed towards UE is determined by "Source Interface" IE in PDRs or "Destination Interface" IE in FARs. One of them should have the value "Access" providing UE flow direction.

Multiple reports can be batched in a single UDP packet depending on the network load.

Because of the unreliability of UDP messaging and multiple unpredictable reliability requirements, you should always assume that a fraction of reports can be missing.

### Reporting on creation

The flow creation report is triggered by sending any packet which is not a part of the existing flow. The report is sent as soon as it determines all the required information for the corresponding flow, such as PDRs and FARs.

It is not guaranteed to send the creation report when the flow was destroyed before the determination of PDRs and FARs as this flow was finished.

### Reporting on flow termination

Flow termination happens when:

- Session is removed by a Control Plane event, such as session deletion request or association loss, or when a flow timeout occurs.
- Flow timeout happens when there is no traffic received for this flow for the duration of the flow timeout. The timeout is configurable per protocol.

There is no difference in IPFIX reporting, no matter if the report was triggered by a flow timeout or a session deletion.

### Reporting on intermediate report timer

The reporting interval of zero means that no intermediate reports are sent.

A configured reporting interval is the minimal time duration between the reporting intervals. The real value varies depending on the flow traffic presence.

## Available Information Elements

Information Elements provided in the report depend on the configured IPFIX policy and the flow IP version. The provided elements used in the report do not depend on the reporting trigger. IE reference information can be obtained in "IP Flow Information Export (IPFIX) Entities" IANA-IPFIX registry assignments.

### IPFIX policy `NatEvent`

| IPFIX IE Name | Proto | Description |
|---|---|---|
| sourceIPv4Address | IPv4 | UE address |
| sourceIPv6Address | IPv6 | UE address |
| destinationIPv4Address | IPv4 | Uplink endpoint address |
| destinationIPv6Address | 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. Details in the additional section below |
| 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 |
| biflowDirection | any | Direction in which the flow was created. Details in the additional section below |

### IPFIX policy `FlowUsage`

| IPFIX IE Name | Proto | Description |
|---|---|---|
| sourceIPv4Address | IPv4 | UE address |
| sourceIPv6Address | IPv6 | UE address |
| destinationIPv4Address | IPv4 | Uplink endpoint address |
| destinationIPv6Address | IPv6 | Uplink endpoint address |
| protocolIdentifier | any | Protocol number of the IP packet |
| 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 |
| VRFname | any | If forwarding policy is defined - name of forwarding policy, otherwise - egress VRF name |
| interfaceName | any | Interface name in the direction to uplink |
| observationDomainName | any | Configured observation domain name |
| observationPointId | any | Configured observation point id |
| biflowDirection | any | Direction in which the flow was created. Details in the additional section below |

### NAT event field

The **natEvent** field can have values `create(4)`, `delete(5)`, and `reserved(0)` in the case that there is no event to report.

In the case of UPG, this field is not NAT-specific and if NAT is not configured, it relates to the flow creation or removal.

The **natEvent** field populated with values in the corresponding conditions:

- `create(4)` - in the first IPFIX report for the flow
- `delete(5)` - in the last IPFIX report for the flow
- `reserved(0)` - in other cases

If the flow haven't finished the initalisation (no downlink packets in the case of connection faliure), it may be that the `delete(5)` event is sent as the first and the last report for the flow without the `create(4)` report.

### biflowDirection field

The **biflowDirection** field can have the following values:

- `initiator(1)` if the flow was created by traffic from the UE side
- `reverseInitiator(2)` if the flow was created by traffic in the direction to UE

This value should not be considered reliable, since it's not always possible to determine the correct direction of the flow.
