> 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/troubleshooting/verification.md).

# Verification

To verify if UPG deployment works correctly, CLI commands and metrics are exposed.

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 session-related guides](https://docs.cennso.com/components/upg/2.8/troubleshooting/session-related.md#check-sessions-info)
- [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 Sessions and flow states](https://docs.cennso.com/components/upg/2.8/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-NS} -l fpp-manager.cennso.com/plumbing-pod-name={UPG-POD-NAME}
```

Output example:

```bash
NAME                                                    IFNAME           READY
upg-fpp-prox01-857c94d587-wjj2t-memif-50-2r26d          memif1/101-grx   true
upg-fpp-prox01-857c94d587-wjj2t-memif-51-lsk85          memif1/102-sgi   true
upg-fpp-prox01-857c94d587-wjj2t-memif-56-s4jxk          memif1/100-sxb   true
upg-fpp-prox01-857c94d587-wjj2t-memif-client-50-nw44m   grx              true
upg-fpp-prox01-857c94d587-wjj2t-memif-client-51-7bxds   sgi              true
upg-fpp-prox01-857c94d587-wjj2t-memif-client-56-5b6mx   sxb              true
```

The first 3 VPPInterface objects are created inside the FPP switch pod, the other ones should be present on the UPG instance.

## 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/2.8/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-NS}"})
```

The source of NWI configuration is the `UPGConfig` Custom Resource object, to see what it includes, execute:

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

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
  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/2.8/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 configuration:

```bash
vppctl show nat44 interfaces
```

Output example:

```bash
NAT44 interfaces:
 at1 output-feature in out
 de1 output-feature in out
```

Check NAT binding can be helpful when there are very few sessions on UPG, when there is a high load this command will create
a lot of output:

```bash
vppctl show nat44 bindings
```

Output example:

```bash
  FRAMED: 100.71.3.248
  EXTERNAL: 198.19.8.1
  port start 10128 port end 10639
```

To view what is the current NAT flows, run:

```bash
vppctl show nat44 sessions
```

Example output:

```bash
NAT44 ED sessions:
-------- thread 0 vpp_main: 1 sessions --------
    i2o 100.66.206.185 proto UDP port 3000 fib 3
    o2i 198.19.8.1 proto UDP port 10128 fib 3
       external host 198.19.0.1:55555
       i2o flow: match: saddr 100.66.206.185 sport 3000 daddr 198.19.0.1 dport 55555 proto UDP fib_idx 3 rewrite: saddr 198.19.8.1 sport 10128 daddr 198.19.0.1 dport 55555 txfib 3
       o2i flow: match: saddr 198.19.0.1 sport 55555 daddr 198.19.8.1 dport 10128 proto UDP fib_idx 3 rewrite: daddr 100.66.206.185 dport 3000 txfib 3
       index 0
       last heard 4904.09
       total pkts 3, total bytes 171
       dynamic translation
```

Verify the NAT flow idle-timeout, run:

```bash
vppctl show nat timeouts
```

Output example:

```bash
udp timeout: 300sec
tcp-established timeout: 7440sec
tcp-transitory timeout: 240sec
icmp timeout: 60sec
```

## Check NAT settings

If UPG is deployed in TDF mode, NAT stats are exposed as metrics:

* `vpp_nat_pool_info` - reports NAT pool created per UPG instance, and which NWI it is connected to
* `vpp_nat_pool_capacity` - maximum number of NAT bindings to be allocated for UEs
* `vpp_nat_pool_utilization` - reports current NAT pool utilization, how many NAT bindings are assigned to UPF sessions
* `vpp_nat_flow_count` - shows how many NAT flows are used
* `vpp_max_nat_flows` - maximum number of NAT flows that can be handled per UPG instance
* `vpp_nat_max_flows_exceeded` - error counter, incremented each time when NAT flow cannot be created due to reached
  max NAT flows
* `vpp_nat_out_of_ports` - error counter, incremented each time when NAT flow cannot be created due to NAT binding
  running out of free port allocated to UPF session, check UPG logs to read more details about what session is affected

## 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 by default (version before UPG 2.5.0). 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 disable API-trace.

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 disable API-trace in the runtime, use the following command:

```bash
vppctl api trace off
```

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.
