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

# Verification

To verify if UPG deployment works correctly, CLI commands and metrics are exposed. These commands should be executed in the UPG pod running in the Core Cluster.

UPG provides VPP CLI commands to check on running instance

Common steps to check if UPG works correctly:

- [Check VPP interfaces](#check-vpp-interfaces)
- [Check association](#check-upg-association) with Session Management Function (SMF)
- [Check VPP startup logs](#check-vpp-logs)
- [Check Network Instance (NWI) configuration](#check-nwi)
- [Check PFCP settings](#check-pfcp)
- [Check TDF settings](#check-tdf)
- [Check CG-NAT settings](#check-cg-nat)
- [Check ADF](#check-adf)
- [Check VPP errors](#check-vpp-errors)
- [Check memory](#check-memory)
- [Check VPP load](#check-vpp-load)
- [Check Sessions and flow states](https://docs.cennso.com/components/upg/latest/troubleshooting/session-related.md)

## Check VPP Interfaces
UPG after startup should create VPP interfaces, to check existing ones, exec into UPG pod and execute:

```bash
vppctl show interface
```

Output example:

```bash
              Name               Idx    State  MTU (L3/IP4/IP6/MPLS)     Counter          Count
grx                               1      up          9000/0/0/0     rx packets                   656
...
local0                            0     down          0/0/0/0
sgi                               2      up          9000/0/0/0     rx packets                   313
...
sxb                               3      up          9000/0/0/0     rx packets                  3127
...
upf-nwi-cp                        4      up           0/0/0/0
upf-nwi-epc                       5      up           0/0/0/0
upf-nwi-sgi                       6      up           0/0/0/0       drops                         53
...
```

To see what interfaces should be created for UPG instance, Kubernetes API can be checked:

```bash
kubectl get vppinterfaces.fpp-manager.cennso.com -n {UPG-NAMESPACE} -l fpp-manager.cennso.com/plumbing-instance={UPG-VPP-DEPLOYMENT} -owide
```

Output example:

```bash
NAME             IFNAME   READY
upg-prox01-grx   grx      true
upg-prox01-sgi   sgi      true
upg-prox01-sxb   sxb      true
```

All interfaces need to be in `READY=true` state. Otherwise, check events and status from the failing interface, use command:

```bash
kubectl describe vppinterfaces.fpp-manager.cennso.com -n {UPG-NAMESPACE} upg-prox01-sxb
```

You can also check the VPP Operator logs, to see if there are any errors reported.

## Check UPG Association
UPF expose `show upf association` command to is if UPG is connected to SMF CNF, exec to UPG pod and run:

```bash
vppctl show upf association
```

Output example:

```bash
Node: tdf.epc.mnc001.mcc001.3gppnetwork.org
  Recovery Time Stamp: 2022/07/11 16:14:52:000
  Sessions: 1
```

The output should be not empty.

The corresponding metric exposed by UPG is `vpp_upf_total_associations`.

New association or lost connectivity to SMF events are logged and can be checked in UPG pod logs, for example:

```
2022/10/26 08:07:18:967 info       upf            PFCP Association established: node pgw.epc.mnc001.mcc001.3gppnetwork.org, local IP 172.20.0.20, remote IP 172.20.0.10

```

If there is no SMF associated, please check [ping to SMF](https://docs.cennso.com/components/upg/latest/troubleshooting/connectivity.md#ping-to-smf), to verify if there is a network connection.
Also, SMF configuration should be checked, to see if UPG discovery is properly defined.

## Check VPP Logs

VPP logs can be checked to look for any errors. To check VPP logs, run this command inside the UPG pod:

```bash
vppctl show log
```

## Check NWI

To see, what Network Instances are configured, run `show upf nwi` in UPG pod:

```bash
vppctl sh upf nwi
```

Output example:

```bash
cp, ip4-table-id 0, ip6-table-id 0, ipfix-policy none, ipfix-collector-ip 0.0.0.0
access, ip4-table-id 100, ip6-table-id 100, ipfix-policy none, ipfix-collector-ip 0.0.0.0
de2, ip4-table-id 200, ip6-table-id 200, ipfix-policy NatEvent, ipfix-collector-ip 172.18.1.100
nl2, ip4-table-id 300, ip6-table-id 300, ipfix-policy NatEvent, ipfix-collector-ip 172.18.1.100
```

NWIs are also exposed as VPP interfaces, reported in `vpp_interface_bytes` metrics, Prometheus query:

```
sum by (name) (vpp_interface_bytes{name=~"upf-nwi.*", namespace="{UPG-NAMESPACE}"})
```

The source of NWI configuration is the `UPGConfig` Custom Resource object in the Core Cluster. To see what it includes, execute:

```bash
kubectl get upgconfigs.upg-manager.cennso.com -n {UPG-NAMESPACE}
```

Output example:

```bash
NAME             AGE
upg-fpp-prox01   2d3h
```

The NWI configuration is included in the object spec, for example:

```yaml
apiVersion: upg-manager.cennso.com/v1alpha1
kind: UPGConfig
metadata:
  labels:
    cennso.net/cnf: upg
    fpp-manager.cennso.com/plumbing-instance: upg-fpp-prox01
    fpp-manager.cennso.com/created-for: upg-operator
  name: upg-fpp-prox01
  namespace: upg-fpp
spec:
  nwis:
  - ipv4TableID: 0
    ipv6TableID: 0
    name: cp
  - ipv4TableID: 100
    ipv6TableID: 100
    name: access
  - ipfixCollectorAddress: 172.18.1.100
    ipfixPolicy: NatEvent
    ipv4TableID: 200
    ipv6TableID: 200
    name: de2
  - ipfixCollectorAddress: 172.18.1.100
    ipfixPolicy: NatEvent
    ipv4TableID: 300
    ipv6TableID: 300
    name: nl2
  pfcp:
    heartbeat:
      retries: 5
      timeout: 10
```

## Check PFCP

UPG exposes Packet Forwarding Control Protocol (PFCP) server running on port 8805. PFCP communication is initiated from SMF, using UDP datagrams.

The PFCP server status can be verified using this command in the UPG pod:

```bash
vppctl sh upf pfcp endpoint
```

Output example:

```bash
Endpoints: 1
  172.20.0.20 [@0]: 0
```

The non-empty output describes the PFCP server IP address exposed by UPG.

PFCP heartbeat settings from [UPGConfig spec](#check-nwi) can be verified on the UPG pod:

```bash
vppctl sh upf heartbeat
```

Output example:

```bash
Timeout: 10 Retries: 5
```

To verify PFCP communication, [check the PFCP connectivity section](https://docs.cennso.com/components/upg/latest/troubleshooting/connectivity.md#check-pfcp-traffic).

## Check TDF
Show TDF mode uplink tables when TDF mode is used:

```bash
vppctl show upf tdf ul tables
```

Output example:

```bash
UPF TDF UpLink VRF to fib-index mappings:
 ipv4
  100 -> 1001
 ipv6
```

## Check CG-NAT

Show CG-NAT pools configuration:

```bash
vppctl show upf nat pool
```

Output example:

```bash
id 0 name 'testing' addr 144.0.0.20-144.0.0.120 ports {size 512 in 10128-65423} blocks usage 1/10908 nwi id 2
```

List the NAT bindings in use for the pool. Make sure you run this command only when there are a few sessions on UPG; otherwise, it produces a lot of output.

```bash
vppctl show upf nat pool verbose name {NAT_POOL_NAME}
```

Output example:

```bash
id 0 name 'testing' addr 144.0.0.20-144.0.0.120 ports {size 512 in 10128-65423} blocks usage 1/10908 nwi id 2
List of bindings:
[t0] binding {id 0 pool id 0 external 144.0.0.20 (id 0) port block 10128-10639 (id 0) session id 0}
```

Verify the NAT flows existance. Commands output limited to 1000 entries.

```bash
vppctl show upf nat tcpudp flows
vppctl show upf nat icmp flows
```

Output example:
```bash
# for tcp/udp
[w 0][id 0] o2i {src 10.0.1.3:80 dst 144.0.0.20:10225} proto 6 el 'src' bind {id 0 sid 0) upf_flow 1
# for icmp
[w 0] id 0 {in 10.1.0.3 out 10.0.1.3 nat 144.0.0.20} icmp_id {og 22234 nat 10346} bind {id 0 sid 0} last time 4
```

Verify NAT-specific metrics. For more information, read [CG-NAT metrics documentation](https://docs.cennso.com/components/upg/latest/observability/metrics.md#cg-nat-metric-labels).

## Check ADF

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

The 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 runtime reconfiguration, an application versioning system was introduced.
It works by storing a set of rules in a version object that may be `uncommitted`, `active`, or `active + latest`.
When creating a new application version, you must provide all rules you want it to have. Rules from previous versions are not carried 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.

## Check VPP errors

UPG provides the following error metrics:

* `vpp_interface_errors` - multiple errors are reported, for example, if an interface is down or packet drops happen
  with memif or DPDK interface
* `vpp_interface_no_tx_slots` - shows issues with packet processing or system overload
* `vpp_arp_sent` - if many ARP requests are sent, it may indicate the wrong cluster configuration in terms of IP reachability
* `vpp_arp_hw_addr_not_match_l2_frame` - arp-reply arrived on the interface but it's not corresponding local HW address
* `vpp_node_vectors{name="drop"}` - shows that packets are dropped on specific VPP instance

## Check memory

To assess how much memory is left on the UPG pod, run main heap stats:

```bash
vppctl show memory main-heap
```

Output example:

```bash
Thread 0 vpp_main
  base 0x7f43b7299000, size 1g, locked, unmap-on-destroy, name 'main heap'
    page stats: page-size 4K, total 262144, mapped 235487, not-mapped 26657
      numa 0: 235487 pages, 919.87m bytes
    total: 1023.99M, used: 916.40M, free: 107.59M, trimmable: 107.14M
```

Heap stats are also exposed in these UPG metrics:

* `vpp_main_heap_total_bytes`
* `vpp_main_heap_used_bytes`
* `vpp_main_heap_free_bytes`

### API-trace commands

UPG can have API-trace enabled. In production deployments, the API-trace feature should be disabled. This paragraph explains how to check the API-trace status, how to release the used memory, and how to enable API-trace. Besides this config option, VPP Operator has VPP API logging in the central place. To see it, configure `trace` log level in VPP Operator.

To check how much memory API-trace uses, execute the following CLI commands in the UPG pod:

```bash
vppctl api trace status
```

Sample output:

```
RX trace: used 2066 of 262144 items, is enabled, has not wrapped
```

To free up the used memory, run:

```bash
vppctl api trace free
```

To enable API-trace in the runtime, use the following command:

```bash
vppctl api trace on
```

To enable API-trace using UPGDeployment object, set **spec.vpp.traceAPICalls** to `true` (by default `false`).

You can check if API-trace is enabled by looking at `/run/vpp/startup.conf`. If there is an `api-trace` section, API-trace is enabled by default. You can disable it through CLI after each UPG restart.

## Check VPP load

FPP 1.3.7 exposes new VPP metrics:

- `vpp_sys_vector_rate` - the average length of a packet vector, which translates to the number of packets processed by the VPP graph node per call
- `vpp_sys_loops_per_second` - the number of VPP worker loop cycles per second (reported as all `0` for UPG 2.4.X and earlier, which uses VPP 22.02)

These metrics help you diagnose if UPG is overloaded. Also, the rising vector rate value with a dropping number of loops per second is a symptom of VPP being overloaded.

> **NOTE:** `vpp_sys_loops_per_second` is unavailable in UPG 2.4.X and earlier because of VPP 22.02 usage, please use UPG 2.5.0 or newer.

To get the values on UPG 2.4.X and earlier, execute the `vppctl sh run` command into the pod. Sample output under the traffic:

```
Time 324.8, 10 sec internal node vector rate 23.79 loops/sec 49918.18
```

An overload results in the following statistics:

```
Time 327.4, 10 sec internal node vector rate 127.29 loops/sec 1853.62
```

The vector rate is low when there is low traffic. The value of loops/sec is high when VPP is performing well. After traffic increases, the vector rate goes up. The symptom of UPG being overloaded is a low number of loops per second when the vector rate is high.
