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

# User equipment configuration 

You can configure a simulation for the connected user equipment (UE) using the **ue** configuration section that contains all parameters related to the UE generation and its behaviour. There are two sections under **ue**:

- **generators** - this section contains parameters and steps for every generated UE
- **create** - this section contains a list of Virtual Devices Groups that represent UEs with their attached behaviours

## Generators

These are the configurable parameters for the **generators** section:

| Parameter | Default | Description |
|:---|:---|:---|
| imsi_start | `0` | Start value for IMSI generation, see below |
| imsi_step | `1` | IMSI increment step |
| imei_start | `0` | Start value for IMEI generation, see below |
| imei_step | `1` | IMEI increment step |
| msisdn_start | `0` | Start value for MSISDN generation, see below |
| msisdn_step | `1` | MSISDN increment step |

A quoted start value sets the length of the generated value, leading zeros included. For example, `imsi_start: "00101123456789"` generates 14-digit IMSIs. An unquoted start value is padded with zeros to 15 digits for the IMSI, 16 for the IMEI, and 14 for the MSISDN.

## Behaviours

For each entity in the **create** section, there are two parameters:

- **count** - contains a number of UEs to generate
- **behaviours** - contains a list of attached session behaviours; the possible behaviours are: `connect`, `probe_session`, `download_http`, `ping_target`, `ipv6_router_solicitation`, `update_location`, `plmn_handover`, `update_bearer_context`, and `random`

### `connect` behaviour

The `connect` behaviour controls create and delete session requests. These are the settings that you can specify under the **parameters** section:

| Parameter | Default | Description |
|:---|:---|:---|
| request_ipv4 | `false` | Enables requesting of the IPv4 session |
| request_ipv6 | `false` | Enables requesting of the IPv6 session |
| apn | `""` | PGW access point name |
| disconnect_after | `0` | Time after a connection request before sending a disconnection request. Skip this field or use `0` to not send a disconnection request. |
| reconnect_after | `0` | Time after a disconnection request before requesting a connection again. Skip this field or use `0` to not send a re-connect request. |
| request_dns_ipv4 | `false` | Request DNS using protocol configuration options for IPv4 |
| request_dns_ipv6 | `false` | Request DNS using protocol configuration options for IPv6 |
| request_mtu | `false` | Request the IPv4 link MTU using protocol configuration options. The simulator logs the MTU that the PGW returns and sets it on the tunnel interface of the session, in place of **gtpu_tunnel.mtu**. Sessions on one interface share its MTU, so the last session to connect sets it. |
| pgw | `""` | Name of the PGW instance to send the sessions to. If skipped, each session goes to a randomly selected PGW. See [Packet Gateway configuration](https://docs.cennso.com/test-tools/sgw-sim/latest/configuration/pgw.md). Requires the `sgwsimulatorv2` binary. |

The **parameters** section also contains a set of the following **location** parameters:

| Parameter | Default | Description |
|:---|:---|:---|
| mcc | `""` | Mobile country code. If skipped, the global MCC is used. |
| mnc | `""` | Mobile network code. If skipped, the global MNC is used. |
| lac | `0` | Location Area Code |
| ci | `0` | Cell Identification |
| sac | `0` | Service Area Code |
| rac | `0` | Routing Area Code |
| tac | `0` | Tracking area code, part of Tracking Area Identity |
| eci | `0` | E-UTRAN Cell Identifier, part of E-UTRAN Cell Global Identifier |
| menbi | `0` | Macro eNodeB ID |
| emenbi | `0` | Extended Macro eNodeB ID |

See the example of the `connect` behaviour configuration:

```yaml
    - type: connect
      parameters:
        request_ipv4: true
        request_ipv6: true
        apn: test.apn.example
        disconnect_after: 1s~2s
        reconnect_after: 1s~2s
        request_dns_ipv4: true
        request_dns_ipv6: true
        location:
          mcc: "123"
          mnc: "45"
          lac: 123
          ci: 123
          sac: 123
          rac: 123
          tac: 123
          eci: 123
          menbi: 123
          emenbi: 123
```

### `probe_session` behaviour

The `probe_session` behaviour creates one permanent session and pins it to a named S5-U tunnel interface, so that interface gets exactly one UE IP address. External tools can then probe the data plane through that interface. The behaviour requires the `sgwsimulatorv2` binary. See [Set up probe mode](https://docs.cennso.com/test-tools/sgw-sim/latest/configuration/probe-mode.md) for the complete setup.

The behaviour holds the session for the whole simulator lifetime:

- If the create session request fails, the behaviour retries it every second.
- If the network deletes the session with a Delete Bearer Request, the behaviour re-establishes it.

Each interface accepts only one `probe_session` device. Configure one device per interface and set **count** to `1`. If two devices claim the same interface, the simulator stops with an error.

These are the settings that you can specify under the **parameters** section:

| Parameter | Default | Description |
|:---|:---|:---|
| interface | none | Name of the S5-U tunnel interface to pin the session to. This parameter is required. If no S5-U instance has this name, the simulator creates a new tunnel interface with this name on the S5-U address of the first instance. Creating an interface requires **gtpu_conn.type** set to `memif`. |
| imsi | `""` | Explicit IMSI for the device. If skipped, the generator assigns the IMSI. |
| apn | `""` | PGW access point name |
| request_ipv4 | `false` | Enables requesting of the IPv4 session |
| request_ipv6 | `false` | Enables requesting of the IPv6 session |
| request_dns_ipv4 | `false` | Request DNS using protocol configuration options for IPv4 |
| request_dns_ipv6 | `false` | Request DNS using protocol configuration options for IPv6 |
| request_mtu | `false` | Request the IPv4 link MTU using protocol configuration options. The simulator logs the MTU that the PGW returns and sets it on the tunnel interface of the session, in place of **gtpu_tunnel.mtu**. Sessions on one interface share its MTU, so the last session to connect sets it. |
| pgw | `""` | Name of the PGW instance to send the session to. If skipped, the session goes to a randomly selected PGW. See [Packet Gateway configuration](https://docs.cennso.com/test-tools/sgw-sim/latest/configuration/pgw.md). |

See the example of the `probe_session` behaviour configuration:

```yaml
    - type: probe_session
      parameters:
        interface: gtpu_sgw-de
        imsi: "1010123456000"
        apn: test.apn.example
        request_ipv4: true
```

### `download_http` behaviour

The `download_http` behaviour downloads a file after a session connection. These are the settings that you can specify under the **parameters** section:

| Parameter | Default | Description |
|:---|:---|:---|
| urls | `[]` | List of URLs to download. The device selects one URL randomly. |
| interval | `"0s"` | Interval between downloads |
| init_delay | `"0s"` | Delay before first download |
| timeout | `"0s"` | Time limit for a request. It includes the connection time, any redirections, and reading the response body. |
| use_ipv6 | `false` | Specifies if the IPv6 address should be used for download. By default, IPv4 is used. |
| threads | `1` | Number of parallel independent download routines per device |

See the example of the `download_http` behaviour configuration:

```yaml
    - type: download_http
      parameters:
        urls:
          - "http://example.com"
        interval: 1s~10s
        init_delay: 1s~10s
        timeout: 1m
        use_ipv6: false
        threads: 1
```

### `ping_target` behaviour

The `ping_target` behaviour tries to ping a given URL after a session connection is established. These are the settings that you can specify under the **parameters** section:

| Parameter | Default | Description |
|:---|:---|:---|
| targets | `[]` | List of IPs to ping. The device selects one URL randomly. |
| interval | `"0s"` | Interval between pings |
| init_delay | `"0s"` | Delay before the first ping |
| timeout | `"0s"` | Time limit to wait for the ICMP reply |
| threads | `1` | Number of parallel independent ping routines per device |

See the example of the `ping_target` behaviour configuration:

```yaml
    - type: ping_target
      parameters:
        targets:
          - 8.8.8.8
          - 1.1.1.1
        interval: 2s~10s
        init_delay: 1s~3s
        timeout: 10s
        threads: 2
```

### `ipv6_router_solicitation` behaviour

The `ipv6_router_solicitation` behaviour starts IPv6 Stateless Address Autoconfiguration (SLAAC) the way a real UE does. When the session tunnel comes up, the UE sends one Router Solicitation (RS) to the PGW and waits for a Router Advertisement (RA). The behaviour requires the `sgwsimulatorv2` binary and acts only on sessions with an IPv6 address.

The RS goes to `ff02::2` with hop limit `255`. Its source address ends with the interface identifier, the lower 64 bits of the IPv6 address in the PDN Address Allocation (PAA). The behaviour accepts the RA when one of its Prefix Information options carries the /64 prefix of the PAA address.

The behaviour ignores an RA that fails the validity checks of RFC 4861 §6.1.2, for example an RA with a hop limit other than `255` or a source address that is not link-local. An RA without the PAA prefix does not end the wait: the UE keeps waiting for a matching RA until the timeout.

Until the RA arrives, the UE holds back IPv6 traffic:

- `download_http` with `use_ipv6: true` starts only after the RA.
- `ping_target` skips IPv6 targets and keeps pinging IPv4 targets.

If no RA arrives within the timeout, the session sends no IPv6 traffic until it disconnects.

These are the settings that you can specify under the **parameters** section:

| Parameter | Default | Description |
|:---|:---|:---|
| timeout | `"5s"` | Time to wait for the RA after sending the RS |
| source | `link_local` | Source address of the RS. `link_local` uses `fe80::` and the PAA interface identifier, as a real UE does. `global` uses the address `::1` in the PAA /64 prefix. Use `global` as a control. If the RA arrives with `global` but not with `link_local`, the user plane drops RSs from link-local addresses. |

The behaviour reports these metrics:

| Metric | Description |
|:---|:---|
| **ipv6_ra_received_total** | Number of RAs that carry the PAA /64 prefix |
| **ipv6_ra_timeout_total** | Number of RSs without an RA within the timeout. Each timeout also logs a warning with the IMSI of the UE. |
| **ipv6_ra_prefix_mismatch_total** | Number of RAs without the PAA /64 prefix |

See the example of the `ipv6_router_solicitation` behaviour configuration:

```yaml
    - type: ipv6_router_solicitation
      parameters:
        timeout: 5s
        source: link_local
```

### `update_location` behaviour

The `update_location` behaviour changes TAC/ECI and sends modify bearer requests. These are the settings that you can specify under the **parameters** section:

| Parameter | Default | Description |
|:---|:---|:---|
| interval | `"0s"` | Interval between modify bearer requests |
| update_tac | `false` | Specifies if SGW Simulator should update TAC or not |
| update_eci | `false` | Specifies if SGW Simulator should update ECI or not |
| tac | `0xaaaa` | TAC to update |
| eci | `0xbbbb_bbb1` | ECI to update |

See the example of the `update_location` behaviour configuration:

```yaml
    - type: update_location
      parameters:
        interval: 3s~15s
        update_tac: true
        update_eci: true
```

### `plmn_handover` behaviour

This functionality allows the dynamic switch from the SGW preset MCC/MNC settings to the user-configured values at specified intervals. These are the settings that you can specify under the **parameters** section:

| Parameter | Default | Description |
|:---|:---|:---|
| interval | `"0s"` | Interval between modifying bearer requests |
| mcc | `""` | Specifies the user-configured MCC for handover |
| mnc | `""` | Specifies the user-configured MNC for handover |

See the example of the `plmn_handover` behaviour configuration:

```yaml
- type: plmn_handover
  parameters:
    interval: 1m
    mcc: "901"
    mnc: "02"
```

### `random` behaviour

The `random` behaviour allows composing multiple behaviours and executing one of them randomly at each interval, based on weighted chances. Nested behaviours are executed in RunOnce mode — they run a single action per trigger without starting their own repeating timers. These are the settings that you can specify under the **parameters** section:

| Parameter | Default | Description |
|:---|:---|:---|
| interval | `"0s"` | Interval between random behaviour triggers |
| behaviours | `[]` | List of weighted behaviours |

Each entry in the `behaviours` list has:

| Field | Description |
|:---|:---|
| chance | Relative weight for random selection. Higher values increase probability. |
| behaviour | A behaviour definition with `type` and `parameters` fields |

The nested behaviours must run in RunOnce mode, which is supported with `update_location`, `plmn_handover`, and `update_bearer_context` behaviours.

See the example of the `random` behaviour configuration:

```yaml
    - type: random
      parameters:
        interval: 1s
        behaviours:
          - chance: 1
            behaviour:
              type: plmn_handover
              parameters:
                mcc: "901"
                mnc: "02"
          - chance: 1
            behaviour:
              type: update_location
              parameters:
                update_tac: true
                update_eci: true
```

## Full UE example

See the full configuration example for UE:

```yaml
ue:
  create:
  - count: 1
    behaviours:
    - type: connect
      parameters:
        request_ipv4: true
        request_ipv6: true
        apn: test.apn.example
        disconnect_after: 1s~2s
        reconnect_after: 1s~2s
        request_dns_ipv4: true
        request_dns_ipv6: true
        location:
          mcc: "123"
          mnc: "45"
          lac: 123
          ci: 123
          sac: 123
          rac: 123
          tac: 123
          eci: 123
          menbi: 123
          emenbi: 123
    - type: download_http
      parameters:
        urls:
          - "http://example.com"
        interval: 1s~10s
        init_delay: 1s~10s
        timeout: 1m
        use_ipv6: false
        threads: 1
    - type: ping_target
      parameters:
        targets:
          - 8.8.8.8
          - 1.1.1.1
        interval: 2s~10s
        init_delay: 1s~3s
        timeout: 10s
        threads: 2
    - type: update_location
      parameters:
        interval: 3s~15s
        update_tac: true
        update_eci: true
    - type: random
      parameters:
        interval: 1s
        behaviours:
          - chance: 1
            behaviour:
              type: plmn_handover
              parameters:
                mcc: "901"
                mnc: "02"
          - chance: 1
            behaviour:
              type: update_location
              parameters:
                update_tac: true
                update_eci: true
  - count: 1
    behaviours:
    - type: connect
      parameters:
        apn: prod.apn.example
        request_ipv4: true
  generator:
    imsi_start: 1010123456000
    imsi_step: 1
    imei_start: 26279000000000
    imei_step: 1
    msisdn_start: 496448000000
    msisdn_step: 1
```
