# Advantech Routers

Advantech routers (ICR-4453) are the testbed's 5G NR/LTE UE nodes with Quad-core ARM CPU and 1 GB RAM. They should contain ep5G sim card to connect to the network and get an ip.

## Network Interfaces

They need two network interfaces to setup:

* `eth0` (Primary): 1G RJ45 facing the management network with an static ip in the range `10.10.5.x/16` .
* `eth2` (Tertiary): 10G SFP port connected to the tenants switches with an static ip `10.42.3.1/24`.

## 5G Connection

They must be equipped with an EP5G simcard. The router will get a unique IP address from EP5G when connects automatically. Optionally, an SDR network simcard can be inserted for SDR connectivity.

Refer to <https://eu.private5g.ericsson.net/network/sim-cards> to create a new sim card. You can set an IP in the ep5G web interface for example `172.16.0.8` for sim card `EXPECA-000`.

Insert the new sim into the Advantech router. Without any more requirments, the Advantech router should connect to the 5G network if it is up and get the ip.

## DNAT

In order to make these devices act as a middle hop to route the packets from `eth2` to `usb0` and vice versa, we use the default configurations of the router plus DNAT. The packets that start from the end-node and try to reach the server behind the 5G core, by default, because of the router's IP masquarade, find their way asking for the gateway. But, on the other hand, packets that arrive at the Advantech router, need to be forwarded to the end-node somehow. That is why we use DNAT on interface `usb0`. For instance, on a router that always get `172.16.0.8` assigned from 5G network, we configure DNAT to change the destination IP address of all packets arriving at `usb0` to `10.42.3.2` which is supposed to be the end-node.

Use `User Modules` section on the Advantech router's web interface to install NAT v4.

* Install NAT module: <https://icr.advantech.cz/products/software/user-modules#nat> Version 4 should be chosen, here is the [Direct link.](https://icr.advantech.cz/products/software/user-modules/download/395/nat.v4.tgz)
* Enable DNAT service and add a new rule: select interface `usb0`, set "To Destination" parameter to `10.42.3.2`, and leave the rest blank.

## Mobile Network Information Service

We run a simple HTTP server on the router that gives a JSON containing 5G connection information to any request.

SSH into the router which is connected to internet, then run the following commands to move the cross compiled binary to the device.

```
curl -LJO -k https://github.com/samiemostafavi/advmobileinfo/raw/main/ami
chmod +x ami
mv ami /usr/bin/
```

Add the following line to the scripts tab of the router web interface.

```
ami > /root/ami.log 2>&1 &
```

In order to test it, you can run the following command on the controller, if the management ip of the device is `10.10.5.1`:

```
curl http://10.10.5.1:50500
```

For more info check [here](https://github.com/samiemostafavi/advmobileinfo).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kth-expeca.gitbook.io/testbedconfig/prepare/advantech-routers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
