> 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/session-related.md).

# Session related operations

This section describes how to debug session-related aspects in UPG:

1. [Check sessions status](#check-sessions-status)
1. [Check flows status](#check-flows-info)

## Check Sessions Status

The number of sessions handled per UPG instance is exposed with metric `vpp_upf_total_sessions`.

To display detailed PFCP session information, run inside the UPG pod:

```bash
vppctl show upf session
```

> **Warning**
>
> Note that the output can be very large and may affect the UPG operation, or
cause it to stop. By default result is limited to 100 entries.

To print more than 100 entries in session output, use `show upf session limit N`
where `N` set to `0` means no limit.

For a description of known session SEID, filtering may be used:

```bash
vppctl show upf session up seid 0x898ca65801c51af2
```

And to display flows related to selected session:

```bash
vppctl show upf session up seid 0x898ca65801c51af2 flows
```

This filters by UP (User Plane) SEID (at the moment, the CP and UPG SEIDs are the same, but later that may change).

To get the SEID, `show upf flows` command can be used (it does not crash UPG even on high load).

In CP F-SEID for each session, the IP address of SMC is visible.

```
CP F-SEID: 0x5c1de72edcfff776 (6637715614276253558) @ 172.20.0.10
UP F-SEID: 0x5c1de72edcfff776 (6637715614276253558) @ 172.20.0.20
  PFCP Association: 0
  TEID assignment per choose ID
PDR: 1 @ 0x7f3b726a9f90
  Precedence: 100
  PDI:
    Fields: 00000001
    Source Interface: CP-function
    Network Instance: cp
    Local F-TEID: 465919227 (0x1bc55cfb)
            IPv4: 172.20.0.20
  Outer Header Removal: GTP-U/UDP/IPv4
  FAR Id: 1
  URR Ids: [] @ 0x0
  QER Ids: [] @ 0x0
FAR: 1
  Apply Action: 00000002 == [FORWARD]
  Forward:
    Network Instance: epc
    Destination Interface: 0
CP F-SEID: 0x898ca65801c51af2 (9911479776852646642) @ 172.20.0.10
UP F-SEID: 0x898ca65801c51af2 (9911479776852646642) @ 172.20.0.20
User ID: IMEI:0898802406000520,MSISDN:88228560500000
  PFCP Association: 0
  TEID assignment per choose ID
PDR: 1 @ 0x7f3b727a3420
  Precedence: 100
  PDI:
    Fields: 0000000c
    Source Interface: SGi-LAN
    Network Instance: sgi
    UE IP address (destination):
      IPv4 address: 198.19.190.23
    SDF Filter [1]:
      permit out ip from any to assigned
  Outer Header Removal: no
  FAR Id: 1
  URR Ids: [1] @ 0x7f3b71f8fdc0
  QER Ids: [] @ 0x0
PDR: 2 @ 0x7f3b727a34a0
  Precedence: 100
  PDI:
    Fields: 0000000d
    Source Interface: Access
    Network Instance: epc
    Local F-TEID: 486780446 (0x1d03ae1e)
            IPv4: 198.18.0.20
    UE IP address (source):
      IPv4 address: 198.19.190.23
    SDF Filter [1]:
      permit out ip from any to assigned
  Outer Header Removal: GTP-U/UDP/IPv4
  FAR Id: 2
  URR Ids: [1] @ 0x7f3b71f90670
  QER Ids: [] @ 0x0
FAR: 1
  Apply Action: 00000002 == [FORWARD]
  Forward:
    Network Instance: epc
    Destination Interface: 0
    Outer Header Creation: [GTP-U/UDP/IPv4],TEID:80770001,IP:198.18.0.31
FAR: 2
  Apply Action: 00000002 == [FORWARD]
  Forward:
    Network Instance: sgi
    Destination Interface: 2
URR: 1
  Measurement Method: 0003 == [TIME,VOLUME]
  Reporting Triggers: 0000 == []
  Status: 0 == []
  Start Time: 2022/07/12 10:24:54:232
  vTime of First Usage:       0.0000
  vTime of Last Usage:        0.0000
  Volume
    Up:    Measured:                    0, Theshold:                    0, Pkts:          0
           Consumed:                    0, Quota:                       0
    Down:  Measured:                    0, Theshold:                    0, Pkts:          0
           Consumed:                    0, Quota:                       0
    Total: Measured:                    0, Theshold:                    0, Pkts:          0
           Consumed:                    0, Quota:                       0
  Time
    Quota:                        0 secs @ 2022/07/12 10:24:55:567, in -16576214 secs, handle 0xffffffff
    Threshold:                    0 secs @ 2022/07/12 10:24:55:567, in -16576214 secs, handle 0xffffffff
```

A bit of explanation regarding the abbreviations used in the output:

- F-SEID stands for Fully Qualified SEID, SEID being the Session Identifier
- PDR stands for Packet Detection Rule
- PDI stands for Packet Detection Information
- FAR stands for Forwarding Action Rule
- URR stands for Usage Reporting Rule

Interpreting the session configuration based on the example above:

1. PDR is the rule against which the incoming packets are matched. It refers
  to the interface on which the packets arrive
    1. SGi-LAN/SGI for the WAN side of the UPG - PDR 1
    1. Access/EPC for the "mobile network" side of the UPG - PDR 2
1. Each PDR includes a forwarding rule (FAR), so that traffic on the inbound
  interface will be forwarded to the specified destination
    1. PDR 1 forwards the traffic according to FAR 1 - from SGi to EPC
    1. PDR 2 forwards the traffic according to FAR 2 - from EPC to SGi

Following output shows session info when `TDF` mode is enabled:

```
CP F-SEID: 0x50d1dcf24eabfd0f (5823678726426852623) @ 172.18.1.11
UP F-SEID: 0x50d1dcf24eabfd0f (5823678726426852623) @ 172.18.1.21
  PFCP Association: 0
  TEID assignment per choose ID
PDR: 1 @ 0x7fb20cb76280
  Precedence: 65000
  PDI:
    Fields: 00000008
    Source Interface: Access
    Network Instance: access
    SDF Filter [1]:
      permit out ip from any to any
  Outer Header Removal: no
  FAR Id: 1
  URR Ids: [1] @ 0x7fb20cb69fd0
  QER Ids: [] @ 0x0
PDR: 2 @ 0x7fb20cb76300
  Precedence: 100
  PDI:
    Fields: 00000001
    Source Interface: CP-function
    Network Instance: cp
    Local F-TEID: 1035543048 (0x3db92208)
            IPv4: 172.18.1.21
  Outer Header Removal: GTP-U/UDP/IPv4
  FAR Id: 2
  URR Ids: [] @ 0x0
  QER Ids: [] @ 0x0
FAR: 1
  Apply Action: 00000001 == [DROP]
FAR: 2
  Apply Action: 00000002 == [FORWARD]
  Forward:
    Network Instance: access
    Destination Interface: 0
URR: 1
  Measurement Method: 0004 == [EVENT]
  Reporting Triggers: 0010 == [START OF TRAFFIC]
  Status: 0 == []
  Start Time: 2022/07/22 11:30:04:359
  vTime of First Usage:       0.0000
  vTime of Last Usage:        0.0000
  Start Of Traffic UE IPs: 5, now:  172925.3069
    Timer:                   60 secs @ 2022/07/21 14:37:53:359, in -75139.66 secs, handle 0x00000c04
100.64.0.10 @  172916.9825 [      8.3245]
100.71.108.255 @  167130.6198 [   5794.6872]
100.66.13.252 @  168147.9239 [   4777.3830]
100.71.12.2 @  172679.3276 [    245.9794]
100.71.3.248 @  172830.4321 [     94.8749]
CP F-SEID: 0x7c5bf7d7b2494102 (8961028389364908290) @ 172.18.1.11
UP F-SEID: 0x7c5bf7d7b2494102 (8961028389364908290) @ 172.18.1.21
User ID: IMEI:0898802406000520,MSISDN:4534aab
  PFCP Association: 0
  TEID assignment per choose ID
PDR: 1 @ 0x7fb20d3c8800
  Precedence: 500
  PDI:
    Fields: 0000000c
    Source Interface: SGi-LAN
    Network Instance: de1
    UE IP address (destination):
      IPv4 address: 100.71.3.248
    SDF Filter [1]:
      permit out 6 from any 80 to assigned
  Outer Header Removal: no
  FAR Id: 1
  URR Ids: [1,2] @ 0x7fb20cb74a10
  QER Ids: [] @ 0x0
PDR: 2 @ 0x7fb20d3c8880
  Precedence: 500
  PDI:
    Fields: 0000000c
    Source Interface: Access
    Network Instance: access
    UE IP address (source):
      IPv4 address: 100.71.3.248
    SDF Filter [1]:
      permit out 6 from any 80 to assigned
  Outer Header Removal: no
  FAR Id: 2
  URR Ids: [1,2] @ 0x7fb20beaaae0
  QER Ids: [] @ 0x0
PDR: 3 @ 0x7fb20d3c8900
  Precedence: 100
  PDI:
    Fields: 0000000c
    Source Interface: SGi-LAN
    Network Instance: de1
    UE IP address (destination):
      IPv4 address: 100.71.3.248
    SDF Filter [1]:
      permit out ip from 198.19.0.0/24 to assigned
  Outer Header Removal: no
  FAR Id: 3
  URR Ids: [1,2,3] @ 0x7fb20beaaa80
  QER Ids: [] @ 0x0
PDR: 4 @ 0x7fb20d3c8980
  Precedence: 100
  PDI:
    Fields: 0000000c
    Source Interface: Access
    Network Instance: access
    UE IP address (source):
      IPv4 address: 100.71.3.248
    SDF Filter [1]:
      permit out ip from 198.19.0.0/24 to assigned
  Outer Header Removal: no
  FAR Id: 4
  URR Ids: [1,2,3] @ 0x7fb20beaab40
  QER Ids: [] @ 0x0
FAR: 1
  Apply Action: 00000002 == [FORWARD]
  Forward:
    Network Instance: access
    Destination Interface: 0
FAR: 2
  Apply Action: 00000002 == [FORWARD]
  Forward:
    Network Instance: de1
    Destination Interface: 2
    Redirect Information: HTTP to https://portal.tisp-ref.cennso
FAR: 3
  Apply Action: 00000002 == [FORWARD]
  Forward:
    Network Instance: access
    Destination Interface: 0
FAR: 4
  Apply Action: 00000002 == [FORWARD]
  Forward:
    Network Instance: de1
    Destination Interface: 2
URR: 1
  Measurement Method: 0003 == [TIME,VOLUME]
  Reporting Triggers: 0000 == []
  Status: 0 == []
  Start Time: 2022/07/22 11:28:38:198
  vTime of First Usage:       0.0000
  vTime of Last Usage:        0.0000
  Volume
    Up:    Measured:                    0, Theshold:                    0, Pkts:          0
           Consumed:                    0, Quota:                       0
    Down:  Measured:                    0, Theshold:                    0, Pkts:          0
           Consumed:                    0, Quota:                       0
    Total: Measured:                    0, Theshold:                    0, Pkts:          0
           Consumed:                    0, Quota:                       0
  Time
    Quota:                        0 secs @ 2022/07/22 11:30:13:029, in -16584894 secs, handle 0xffffffff
    Threshold:                    0 secs @ 2022/07/22 11:30:13:029, in -16584894 secs, handle 0xffffffff
URR: 2
  Measurement Method: 0003 == [TIME,VOLUME]
  Reporting Triggers: 0001 == [PERIODIC REPORTING]
  Status: 0 == []
  Start Time: 2022/07/22 11:28:38:198
  vTime of First Usage:       0.0000
  vTime of Last Usage:        0.0000
  Volume
    Up:    Measured:                    0, Theshold:                    0, Pkts:          0
           Consumed:                    0, Quota:                       0
    Down:  Measured:                    0, Theshold:                    0, Pkts:          0
           Consumed:                    0, Quota:                       0
    Total: Measured:                    0, Theshold:                    0, Pkts:          0
           Consumed:                    0, Quota:                       0
  Measurement Period:                 1800 secs @ 2022/07/22 11:58:38:198, in  1705.169 secs, handle 0x00000c05
  Time
    Quota:                        0 secs @ 2022/07/22 11:30:13:029, in -16584894 secs, handle 0xffffffff
    Threshold:                    0 secs @ 2022/07/22 11:30:13:029, in -16584894 secs, handle 0xffffffff
URR: 3
  Measurement Method: 0003 == [TIME,VOLUME]
  Reporting Triggers: 8300 == [VOLUME QUOTA,TIME QUOTA]
  Status: 0 == []
  Start Time: 2022/07/22 11:28:38:198
  vTime of First Usage:       0.0000
  vTime of Last Usage:        0.0000
  Volume
    Up:    Measured:                    0, Theshold:                    0, Pkts:          0
           Consumed:                    0, Quota:                       0
    Down:  Measured:                    0, Theshold:                    0, Pkts:          0
           Consumed:                    0, Quota:                       0
    Total: Measured:                    0, Theshold:                    0, Pkts:          0
           Consumed:                    0, Quota:               999999999
  Time
    Quota:                     5400 secs @ 2022/07/22 12:58:38:198, in  5305.169 secs, handle 0x00000c08
    Threshold:                    0 secs @ 2022/07/22 11:30:13:029, in -16584894 secs, handle 0xffffffff
```

## Check Flows Info

The number of sessions handled per UPG instance is exposed with metric `vpp_upf_flow_count`.

To see details of the flows initiated by the UEs, use command:

```bash
vppctl show upf flows
```

> **Warning**
>
> The output can be very large and in some cases, this may affect the UPG operation.
By default 100 entries is listed.

To print more than 100 entries in flows output, use `show upf flow limit N`,
where `N` set to `0` means no limit.

Example output of `show upf flows`:

```bash
proto 0x1, 198.19.130.12:0 <-> 198.19.0.100:0, seid 0x128f2dd3637c721e, UL pkt 1, DL pkt 1, Forward PDR 2, Reverse PDR 1, app None, lifetime 60, proxy 0, spliced 0 nat port 0
proto 0x1, 198.19.133.248:0 <-> 198.19.0.100:0, seid 0x7c14bd59516dd360, UL pkt 2, DL pkt 2, Forward PDR 2, Reverse PDR 1, app None, lifetime 60, proxy 0, spliced 0 nat port 0
proto 0x1, 198.19.173.212:0 <-> 198.19.0.100:0, seid 0xb6950251f0f385e6, UL pkt 1, DL pkt 1, Forward PDR 2, Reverse PDR 1, app None, lifetime 60, proxy 0, spliced 0 nat port 0
proto 0x1, 198.19.159.201:0 <-> 198.19.0.100:0, seid 0x7e639d8e212dd018, UL pkt 1, DL pkt 1, Forward PDR 2, Reverse PDR 1, app None, lifetime 60, proxy 0, spliced 0 nat port 0
proto 0x1, 198.19.189.96:0 <-> 198.19.0.100:0, seid 0xff799cc8c0273426, UL pkt 1, DL pkt 1, Forward PDR 2, Reverse PDR 1, app None, lifetime 60, proxy 0, spliced 0 nat port 0
proto 0x1, 198.19.148.20:0 <-> 198.19.0.100:0, seid 0x604dd5b38370fe22, UL pkt 1, DL pkt 1, Forward PDR 2, Reverse PDR 1, app None, lifetime 60, proxy 0, spliced 0 nat port 0
```
