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

# Data Plane configuration

The current implementation of TPLoad Generator generates only UDP traffic. UDP payload contains the Generator metadata that is used to: 
- Discard non-TPLoad generated packets
- Check the correctness of the session and flow
- Check the NAT mapping
- Detect missed, duplicated, or reordered packets inside the flow

TPLoad Generator supports the following interfaces:

* `memif` - there is no interaction with the Linux kernel. Only the slave mode is supported.
* `tap` - used when you want the Generator to create a Linux interface connected directly to a router inside the Generator
* `macvtap` - similar to the `tap` interface but bridged with another Linux interface, which makes it look as if the Generator is attached to the existing interface. The `macvtap` interface must be created before starting the Generator using this command:

    ```bash
    ip link add link $INTERFACE_TO_ATTACH name $DESIRED_MACVTAP_INTERFACE_NAME type macvtap mode bridge
    ```

Both types of the traffic Generators have a set of common parameters:

| Parameter | Default | Description |
|:---|:---|:---|
| options.match_right_to_left | `false` | Defines how the pair of left and right Generators is selected. For `true`, Generators are paired by number, for example: the first Generator on the left is paired with the first on the right, the second on the left with the second on the right, and so on. For `false`, pairs are selected randomly. |
| options.use_per_gen_pools | `false` | Enables use of `ipv4_per_gen` instead of `ipv4` parameter in `device_generator` section |
| options.flow_mode | `"many-to-many"` | Specifies how the traffic port is allocated. The possible values are: `many-to-many`, `one-to-many`, and `many-to-one`. The default value is `many-to-many`. |
| nat_aware | `false` | If set to `true`, the traffic on the right side does not start until the traffic on the left side reaches the acknowledged NAT `ip:port`. |
| address | `""` | Address for the left and right side of Generator. With the `+` suffix, each Generator gets a different address incrementally, starting from the specified one. Without the `+` suffix, each Generator uses the same address. Usually used with the `+` suffix. |
| gateway | `""` | Gateway for the left and right side of Generator. It contains the gateway address for the Generators. If the value contains the `+` suffix, the range is used, which is useful for multi-UPG configurations without CGW. |

## Memif interface configuration

The following options are available for the `memif` interface:

| Parameter | Default | Description |
|:---|:---|:---|
| queue_count | `1` | Number of queues for the `memif` interface. Used for both **left** and **right** subsections. |
| ring_size | `2048` | Ring size of the `memif` interface. It directly affects the Generator's performance. The recommended value is `16384`, which is the maximum value possible on the VPP side. Must be a power of `2`. Used for both **left** and **right** subsections. |
| buffer_size | `2048` | Buffer size of the `memif` interface. Used for both **left** and **right** subsections. |

These are the environment variables for the Generator:

| Variable | Default | Description |
|:---|:---|:---|
| MEMIF_SOCKET_FILENAME | `/run/vpp/memif.sock` | File name of the `memif` socket |
| MEMIF_INTERFACE_ID | `""` | ID of the `memif` interface |

See the sample configuration for the `memif` interface:

```yaml
traffic_generators:
  options:
    match_right_to_left: true

  left:
    address: "10.250.0.2+"
    gateway: "10.250.0.1"
    queue_count: 4
    ring_size: 16384
    buffer_size: 2048

  right:
    nat_aware: true
    address: "10.251.0.2+"
    gateway: "10.251.0.1"
    queue_count: 4
    ring_size: 16384
    buffer_size: 2048
```

## Tap and macvtap interface configuration

The following options are available for the `tap` and `macvtap` interfaces:

| Parameter | Default | Description |
|:---|:---|:---|
| queue_count | `1` | Number of queues for the `macvtap` interface. Used for both **left** and **right** subsections. |
| tap_interface_name | `""` | Name of the interface created for `tap`. Since the interface is created dynamically, you can configure a Linux network in `init_script`. This is the name of the existing `macvtap` Linux interface for `macvtap`. Used for both **left** and **right** subsections. |
| scripts.init_script | `""` | Interface initialization script applied before the test. Scripts have `$address` and other fields of the Generator configuration in env. Used for both **left** and **right** subsections. |
| scripts.cleanup_script | `""` | Interface cleanup script applied after the test. Scripts have `$address` and other fields of the Generator configuration in env. Used for both **left** and **right** subsections. |

See the sample configuration for the `tap` and `macvtap` interfaces:

```yaml

traffic_generators:
  options:
    match_right_to_left: false

  left:
    address: "198.18.1.2+"
    gateway: "198.18.2.2"
    queue_count: 1
    tap_interface_name: macvtap-left
    scripts:
      init_script: |
        ip link set up ${tap_interface_name}
      cleanup_script: |

  right:
    nat_aware: true
    address: "198.18.2.2+"
    gateway: "198.18.1.2"
    queue_count: 1
    tap_interface_name: macvtap-right
    scripts:
      init_script: |
        ip link set up ${tap_interface_name}
      cleanup_script: |

```

## Traffic profiles

Traffic profiles define the payload of the generated traffic. Currently, you can only generate UDP traffic.

`size` describes the UDP payload size. To calculate it from the desired IP payload size, substract 8 bytes from the UDP header.
The size can't be less than 12 bytes because of the metadata inside the UDP payload.

You can configure traffic profiles using these parameters:

* **size_from_range** - packet has a random size chosen from `min` to `max`.
* **weighted_selection_of_sizes** - packet size is chosen from the defined distribution. For example, a packet with `size: X` is choosen with `chance: Y`.

See a sample configuration for traffic profiles:

```yaml
traffic_profiles:
  - name: default
    size_from_range: { min: 50, max: 1500 }

  - name: imix
    weighted_selection_of_sizes:
    - { chance: 58, size: 40 }
    - { chance: 33, size: 576 }
    - { chance: 9,  size: 1400 }
```

## Burst profiles

TPLoad supports the bursting capability to generate a sequential series of packets for each flow. This allows TPLoad to simulate user traffic in a better way. 

You can configure burst profiles using these parameters:

* `count_from_range` - packets sequence has a random length chosen from `min` to `max`.
* `weighted_selection_of_lengths` - packets sequence length is chosen from the defined distribution. For example, a packet with `length: X` is chosen with `chance: Y`.

See a sample configuration for burst profiles:

```yaml
burst_profiles:
  - name: minimal
    count_from_range: { min: 1, max: 3 }

  - name: user_common
    weighted_selection_of_lengths:
      - { chance: 10, length: 1  }
      - { chance: 2,  length: 3  }
      - { chance: 1,  length: 5  }
      - { chance: 2,  length: 7  }
      - { chance: 5,  length: 10 }

```
