> For the complete documentation index, see [llms.txt](https://docs.cennso.com/test-tools/sgw-sim/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/test-tools/sgw-sim/latest/configuration/probe-mode.md).

# Set up probe mode

In probe mode, SGW Simulator holds a small number of permanent sessions, and each session is pinned to its own named tunnel interface. Each interface gets exactly one user equipment (UE) IP address. External tools, such as the Network Performance Probe (NPP), can then measure the data plane through each tunnel and export metrics keyed by the interface name. SGW Simulator itself runs no probes.

Probe mode requires the `sgwsimulatorv2` binary. To select it, set the **binary** parameter to `sgwsimulatorv2` in the Helm chart values.

## How it works

Probe mode combines three configuration elements:

- The **s5u_ip** address range in the **sgw.instances** section sets the number of S5-U instances. For example, `192.0.2.10~192.0.2.11` creates two instances.
- Each S5-U instance creates its own tunnel interface. The **gtpu_tunnel.interface_names** parameter assigns names to instances positionally: the first name goes to the instance with the first address in the range. The list may be shorter than the number of instances; unnamed instances get derived names and stay available for regular traffic. See [Serving Gateway configuration](https://docs.cennso.com/test-tools/sgw-sim/latest/configuration/sgw.md).
- One `probe_session` device pins a permanent session to each named interface. See the `probe_session` behaviour in [User equipment configuration](https://docs.cennso.com/test-tools/sgw-sim/latest/configuration/ue.md).

With **gtpu_conn.type** set to `memif`, a `probe_session` can also reference an interface that no S5-U instance defines.
The simulator then creates the interface on start and attaches it to the S5-U address of the first instance, so the probe needs no address of its own.

A configuration can mix `probe_session` devices with regular load devices when there are more S5-U instances than probes. Devices with other behaviours select their S5-U instance randomly among the instances not claimed by a `probe_session`, so each pinned interface keeps exactly one UE IP address. When every instance is claimed, regular devices fall back to random selection over all instances. This makes the address resolution ambiguous for external tools, so keep at least one unclaimed instance for load traffic.

The simulator validates the setup on start. It stops with an error in these cases:

- **gtpu_tunnel.interface_names** has more entries than there are S5-U instances.
- A `probe_session` references an unknown interface and **gtpu_conn.type** is not `memif`.
- Two `probe_session` devices claim the same interface.

## Requirements

Probe mode needs a real network device for each S5-U instance, so an external tool can bind to it:

- Set **gtpu_tunnel.type** to `tun`. The `kernel-module` type supports only a single S5-U instance and cannot be used in probe mode.
- Both supported **gtpu_conn.type** values work with the `tun` tunnel: `socket` and `memif`.

## Example

The following configuration runs two S5-U instances with named interfaces and one permanent probe session on each:

```yaml
# Requires the sgwsimulatorv2 binary (Helm chart value: binary: sgwsimulatorv2).
sgw:
  mcc: "001"
  mnc: "030"

  gtpu_conn:
    type: socket

  gtpu_tunnel:
    type: tun
    interface_names:
      - gtpu_sgw-de
      - gtpu_sgw-us
    mtu: 1350

  instances:
    # The s5u_ip range length sets the number of S5-U instances.
    - s5c_ip: 192.0.2.1
      s5u_ip: 192.0.2.10~192.0.2.11

pgw:
  instances:
    - s5c_ip: 192.0.2.55
      timeout: 10s

ue:
  # One probe_session device per interface, count 1 each.
  create:
    - count: 1
      behaviours:
        - type: probe_session
          parameters:
            interface: gtpu_sgw-de
            imsi: "1010123456000"
            apn: test.apn.example
            request_ipv4: true
    - count: 1
      behaviours:
        - type: probe_session
          parameters:
            interface: gtpu_sgw-us
            imsi: "1010123456001"
            apn: test.apn.example
            request_ipv4: true

  # The explicit imsi in probe_session overrides the generator.
  # The generator still assigns IMEI and MSISDN per device index.
  generator:
    imsi_start: 1010123456000
    imei_start: 26279000000000
    msisdn_start: 496448000000
```

## Probe with Network Performance Probe

The Network Performance Probe (NPP) operator schedules a probe pod on the same node as the SGW Simulator pod and enters its network namespace. The probe detects all tunnel interfaces with their UE IP addresses, binds to the address of each interface, and exports Prometheus metrics. Name each NPP probe configuration after the interface it probes, so the metrics are keyed by the interface name.
