> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/smc/3.14/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/smc/3.14/use-cases/gtpproxy.md).

# GTP Proxy 

GTP (GPRS Tunneling Protocol) Proxy is an important network element that facilitates the secure and efficient handling of GTP traffic within mobile networks. Session Management Controller (SMC) configured as GTP Proxy serves the following purposes:

- GTP traffic control: GTP Proxy manages and controls GTP traffic between different nodes in the mobile network, such as between the Serving Gateway (SGW) and the Packet Gateway (PGW).
- Modification of selected GTP information elements: GTP Proxy lets you modify specific GTP information elements such as IMSI, IMEI, MSISDN, RAT, and RAI.
- Load balancing: GTP Proxy helps in load balancing by distributing GTP traffic across multiple network paths to optimise resource usage and enhance network performance.

In more technical terms, GTP Proxy transmits GTP messages towards other GTP peers (for example, another SMC instance) while maintaining data tunnels on the User Plane Gateway (UPG) consistent with the GTP message flow. This use case does not involve AAA interfaces. See the diagram that shows the architecture of SMC acting as GTP Proxy:

![GTP Proxy use case](https://docs.cennso.com/api/assets/components/smc/3.14/assets/gtpproxy.svg)

The key features of SMC configured as GTP Proxy include:

- GTPv1 and GTPv2 connectivity that ensures compatibility with SGSN and SGW for managing data tunnels.
- PFCP (Packet Forwarding Control Protocol) for connectivity with the User Plane Function (UPF).
- HTTP OAM API that allows operations and management tasks such as checking node status, draining GTP contexts, and managing GTP sessions.
- Limited Npcf Connectivity that facilitates per-IMSI (International Mobile Subscriber Identity) forwarding policies.

## Configuration

This section presents the minimal configuration that allows you to forward traffic from the GTP interface on the `access` side (represented by SGW) to the GTP interfaces on the `core` side (represented by PGWs).

> [!TIP]
> You can find the full list of configurable parameters in the SMC [chart configuration](https://docs.cennso.com/components/smc/3.14/installation/chart-configuration.generated.md) document.

### Configure networking

> [!NOTE]
> The terms **grx-access** and **grx-core** in network interface and endpoint names are just examples. They have no special meaning and any sensible identifier can be used. Endpoint names don't need to match or relate to interface names.

SMC acting as GTP Proxy allows you to configure multiple network interfaces to forward GTP traffic. First, configure the dedicated network interfaces to handle traffic on the `access` and `core` sides. The **networking.interfaces** property specifies the settings of a given network interface, such as interface name, IPv4 or IPv6 address, mask, and routes with which this interface is configured. The physical network interfaces are created based on the [Network Attachment Definition](https://docs.cennso.com/components/smc/3.14/config/networking.md#access-network).

Interfaces for GTP or Sx traffic should have individual VRF settings. This means the underlying Linux network interface is encapsulated in a Linux [VRF-Lite](https://docs.kernel.org/networking/vrf.html) instance, preventing traffic on the underlying interfaces from accidentally or intentionally reaching other VRFs or the pod network.

In the example below, the **grx-access** section contains connection details for the GRX `access` side. The **grx-core** section contains connection details for the GRX `core` side.

```yaml
networking:
  interfaces:
    grx-access:
      vrf: grx-access
      endpoints:
        grx-access:
          ipv4:
            addr: "192.168.4.68/28"
            routes:
            - to: 192.168.4.65
    grx-core:
      vrf: grx-core
      endpoints:
        grx-core:
          ipv4:
            addr: "192.168.5.69/28"
  services:
    grx-access:
      endpoint: grx-access.grx-access
      networkInstance: access
      type: grx
      direction: access
    grx-core:
      endpoint: grx-core.grx-core
      networkInstance: core
      type: grx
      direction: core
```

The **services** section is used to bind specific services to the endpoints. Multiple services can use the same endpoint.
The **services.{SERVICE_NAME}** section creates a new named binding between a service and an endpoint. It contains the following configuration options for the newly created service:
- **services.{SERVICE_NAME}.endpoint** - references the endpoint to which the service is attached. The value of this property has the format of `{INTERFACE_NAME}.{ENDPOINT_NAME}`. `{INTERFACE_NAME}` must refer to the network interface defined in the **networking.interfaces.{INTERFACE_NAME}**. `{ENDPOINT_NAME}` refers to the endpoint referenced by the given interface. 
- **services.{SERVICE_NAME}.networkInstance** - must be set and match the **networkInstance** configured for UPG for interfaces of the `sx` or `grx` type.
- **services.{SERVICE_NAME}.type** - defines the type of a service. The possible values are `grx`, `sx`, `rf`, `ro`, and `gx`. 
- **services.{SERVICE_NAME}.direction** - a section needed for GTP services to define which direction they are serving.

You can also use the same endpoint IP in both directions:

```yaml
networking:
  interfaces:
    grx-1-if:
      vrf: grx
      endpoints:
        grx-1:
          ipv4:
            addr: "192.168.4.68/28"
            routes:
            - to: 192.168.4.65
  services:
    grx-access:
      endpoint: grx-1-if.grx-1
      networkInstance: access
      type: grx
      direction: access
    grx-core:
      endpoint: grx-1-if.grx-1
      networkInstance: core
      type: grx
      direction: core
```

### Configure GTP forwarding

You can control GTP forwarding using the **routingContexts** configuration. Each context specifies a list of services for forwarding requests. The services are defined in **service.{SERVICE_NAME}** parameters described in the [Configure networking](#configure-networking) section. A context and service are selected at the start of a session and used throughout that session. Setting the **routingContexts** is mandatory.

```yaml
gtpProxy:
  routingContexts:
    default: [grx-core]
```

### Specify a DNS server for GGSN/PGW node selection

To forward new sessions, SMC acting as GTP Proxy must select the GGSN/PGW nodes. The node selection is usually done using a DNS server that translates node names into IP addresses. To do so, specify a DNS server:

```yaml
gtpProxy:
  dns:
    server: 127.0.0.1
    port: 53
```

### Specify APN, IMSI, and MSISDN mapping

The default proxy can map APNs, IMSIs, and MSISDNs. See the example of the APN mapping:

```yaml
gtpProxy:
  mapping:
    apn:
      - from: example.net
        to: proxy.example.net
```

See the example of the IMSI and MSISDN mapping:

```yaml
gtpProxy:
  mapping:
    imsi:
      - from: "111111111111111"
        to:
          imsi: "222222222222222"
          msisdn: "491111111111"
```
