> 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/use-cases/testing-pgw.md).

# Test a basic PGW

In this use case, the system under test (SUT) is the simple packet gateway (PGW), which consists of Session Management Controller (SMC), User Plane Gateway (UPG), and some possible connectivity components. In this case, TPLoad simulates SGW, acting as the S5/S8 interface. TPLoad Generator simulates User Plane traffic. 

The main features of the PGW test case are:

- User traffic is encapsulated in GTP-U. There is an easy, network-local communication between UPG and TPLoad Generator-left.
- SMC handles session creation. It provides UE IP address, UPG endpoints, etc.
- Right after TPLoad Core receives the `create_session_response`, it deploys the corresponding session to the TPLoad Generators and the traffic is properly forwarded by UPG.

To have the basic PGW ready for benchmark testing, make sure that:

- Possible Gy connectivity allows the IMSIs configured on TPLoad
- Proper routing between TPLoad Core and SMC is configured
- Proper routing between TPLoad Generator-left and the Access/S5/S8 side of UPG is configured
- Proper routing between TPLoad Generator-right and the SGi side of UPG is configured

![tpload and generators scheme](https://docs.cennso.com/api/assets/test-tools/tpload/latest/assets/test-pgw.svg "Test the basic PGW scenario")

For this use case, PGW has the following configuration:

| Component | Interface | Address |
|:---|:---|:---|
| SMC | S5/S8 | 198.18.0.16 |
| SMC | Sx | 172.20.0.16 |
| UPG | S5/S8 | 198.18.0.1 |
| UPG | Sx | 172.20.0.1 |
| UPG | SGi | 198.19.0.1 |

TPLoad has the following addresses:

| Component | Interface | Address | Gateway |
|:---|:---|:---|:---|
| TPLoad Core | S5/S8 | 198.18.0.128 | - |
| TPLoad Generator-left | S5/S8 | 198.18.0.129+ | 198.18.0.1 |
| TPLoad Generator-right | SGi | 198.19.0.129+ | 198.19.0.1 |

## TPLoad configuration steps

Follow these steps to configure TPLoad so that it performs testing for a basic PGW:

1. Configure the **core** and **servers** sections. In the **core** section, set the **session management** to `sgw`. Other parameters are not nessasary. In the **servers** section, configure a proper `sgw` instance. In the **pgw_address** parameter, specify the S5/S8 address of SMC. The UPG addresses are part of the `session_create_response` and TPLoad applies them automatically. The values of **apn**, **mcc**, and **mnc** must be aligned with the PGW setup.

    ```yaml
    core:
      session_management: sgw
      create_retry_limit: 5
      cleanup_retry_limit: 5
      default_rate_limits:
        create: 100
        delete: 100
        other: 100

      http_server_listen_address: 0.0.0.0:8900
      provision_duration: 3s

    servers:
      sgw:
        listen_address: 198.18.0.128
        pgw_address: 198.18.0.16
        ping_interval: 15s
        apn: "test.apn.net"
        mcc: "262"
        mnc: "79"
    ```

2. Set the values of the **device_generator** to the values allowed by PGW and the Gy interface:

    ```yaml
    device_generator:
      imsi:   { first: "001010100000000",  step: 1  }
      mei:    { first: "2222900000000",    step: 10 }
      msisdn: { first: "444440000000",     step: 1  }
      ipv4:   { first: "10.32.0.1",        last: "10.63.255.254",       pseudorandom: true }

    ```

3. For the PGW case, all of the testing funcitons are allowed. For the purpose of this use case, configure a simple `RampUp` testing function:

    ```yaml
    tests:
      - name: default
        function: RampUp
        flows_count: 20
        parameters:
          sessions_count: 5000
          hold_time: 30m
          send_bearer_requests: true
        load_left:
          speed: 100 kpps
          traffic_profile: imix
          burst_profile: user_common
        load_right:
          speed: 100 kpps
          traffic_profile: imix
          burst_profile: user_common
        rate_limits:
          create: 300
          delete: 300
    ```

4. Align network configuration with the overall network setup:

    ```yaml
    traffic_generators:
      options:
        match_right_to_left: false

      left:
        address: "198.18.0.129+"
        gateway: "198.18.0.1"
        queue_count: 1
        ring_size: 16384
        buffer_size: 2048

        tap_interface_name: macvtap-left
        tap_virtio: false

        scripts:
          init_script: |
            ip link set up ${tap_interface_name}
          cleanup_script: |
            ip link set down ${tap_interface_name}

      right:
        address: "198.19.0.129+"
        gateway: "198.19.0.1"
        incoming_network: "198.18.0.0/16"
        queue_count: 1
        ring_size: 16384
        buffer_size: 2048
        tap_interface_name: macvtap-right
        tap_virtio: false

        scripts:
          init_script: |
            ip link set up ${tap_interface_name}
          cleanup_script: |
            ip link set down ${tap_interface_name}

    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:
      - 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 }
    ```

5. After applying the configuration, the connectivity should work as expected.
