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

# Application Detection Function

UPG can assign traffic going to certain endpoints to an application.
It is done by matching PDIs to the `Application ID`.
This is specified by SMC in Session Establishment/Modification PFCP Messages.

To use this function, UPG must know which IPs/URLs match which application.
This assignment is provided by specifying `UPGApplicationSet` objects described in [`docs/crs.md`](https://docs.cennso.com/components/upg/2.16/crs.md#upgapplication).

You can modify the objects at runtime, however this system has some limitations.

## Known limitations

- Existing flow reclassification. When modifying `UPGApplicationSet` objects, only new flows match the new rules.
   All flows that already existed are not reclassified unless an external event forces them to. An example of such event is any Session Modification request that SMC may send regularly, depending on the configuration.
- Proxy flag cannot be changed. Once `UPGApplicationSet` is created, its proxy flag must stay the same for the duration of its lifetime.
- Both flow sides must match the same application.

## Debug CLI

It is possible to interact with ADF function through CLI. It is restricted to debug purposes only as it interferes with UPG managers controlling the resources.

Possible commands are:

- `adf create application name <app_name> [proxy]`
- `adf delete application name <app_name>`
- `adf create version app <name>`
- `adf create rule app <name> [l7 regex <regex> | ipfilter <ipfilter>]`
- `adf version commit app <name>`
- `show adf apps`
- `show adf versions app <name>`
- `show adf version app <name> [ver <ver_id>, active, uncommited]`

To facilitate the runtime reconfiguration, a system of application versions was introduced.
It works by storing a set of rules in a version object that may be `uncommited`, `active`, or `active + latest`.
When creating a new application version, you must provide all rules you want it to have. Rules from previous versions do not carry over automatically.
Switching to a new version (`adf version commit`) is an atomic event.
All new flows and those that are reclassified use the latest version and all its rules from that point in time.

## Notes

- Application ID in the context of PFCP is a string. In context of ADF CLI, PFCP Application ID is called just the application name.
