Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ demo/images/ue_amr/nav_stack
.DS_Store

demo/open5gs_setup/db_data/*
demo_containerized/open5gs_setup/db_data/*
demo_containerized/open5gs_setup/db_data/*
302 changes: 300 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,27 @@ The table of content of this README file is:

- [UE World file declaration](#-ue-world-file-declaration)

5. [Modifying the source code](#modify-gnb-source-code)
5. [Network Monitor Plugin](#-network-monitor-plugin)

6. [Upcoming features](#upcoming-features)
- [Why monitor the network in a ROS 2 5G simulation](#-why-monitor-the-network-in-a-ros-2-5g-simulation)

- [Plugin behavior](#-plugin-behavior)

- [Usage](#-usage)

- [Configuration parameters](#-configuration-parameters)

6. [gNB Power and UE Power Control Plugins](#-gnb-power-and-ue-power-control-plugins)

- [What they do](#-what-they-do)

- [How they work](#-how-they-work)

- [Usage](#-usage-1)

- [Configuration parameters](#-configuration-parameters-1)

7. [Modifying the source code](#modify-gnb-source-code)


If something goes wrong in following this README file or you have any questions, you can write on our [slack chat](https://join.slack.com/t/robosimworkspace/shared_invite/zt-38i7sbsit-FpsT6d7PU241~nGz0fcUig).
Expand Down Expand Up @@ -761,6 +779,286 @@ To add the UE plugin to your SDF world file, include:

- Be sure to follow the same network and workspace structure as the demo for compatibility.

## 📊 Network Monitor Plugin

The **Network Monitor** is an Ignition Gazebo GUI plugin that provides real-time measurement of **latency** and **bandwidth** over the simulated 5G link between a User Equipment (UE) container and the Data Network (DN) container. It uses `ping` for latency and `iperf3` for bandwidth, executed via `docker exec` on the respective containers.

---

### 🤔 Why Monitor the Network in a ROS 2 5G Simulation

In any ROS 2 robotic application, the communication layer has a direct impact on system performance and safety. ROS 2 relies on DDS (Data Distribution Service) for all inter-node communication — including publishing sensor data, sending navigation goals, and exchanging control commands. When this communication happens over a **5G network** instead of a local Ethernet or Wi-Fi link, the characteristics of that network become a critical factor:

- **Latency affects control loops.** ROS 2 navigation stacks (e.g., Nav2) and teleoperation nodes depend on timely delivery of odometry, laser scans, and velocity commands. A latency spike over the 5G link can cause the robot to overshoot a waypoint, react late to an obstacle, or lose localization. Knowing the real-time round-trip time helps you understand whether your control loop frequency is achievable.

- **Bandwidth affects data-heavy topics.** Point clouds, camera images, and map updates are large messages. If the 5G uplink or downlink bandwidth is insufficient, DDS will drop messages or queue them, leading to stale data at the subscriber side. Monitoring bandwidth lets you verify that the 5G link can sustain the throughput your application requires.

- **5G behavior is not static.** Unlike a wired connection, a 5G link is subject to variability due to radio scheduling, handovers, and shared spectrum. Having a live monitor during simulation lets you correlate network conditions with robot behavior — for example, observing that navigation failures coincide with a bandwidth drop.

- **Validation before field deployment.** RoboSim5G is designed to let roboticists test their applications over a realistic 5G stack before deploying on physical hardware. The Network Monitor closes the loop: you can verify that the network performance meets the requirements of your ROS 2 application (e.g., < 50 ms RTT for teleoperation, > 10 Mbits/sec for video streaming) entirely within the simulation.

In short, if you are running ROS 2 topics over a 5G network, you should monitor that network — the Network Monitor plugin gives you that visibility directly inside Gazebo.

---

### ⚙️ Plugin Behavior

Once started, the plugin:

1. Launches an **iperf3 server** in daemon mode on the UE container.
2. Enters a continuous measurement loop that performs, in each cycle:
- **Downlink latency**: `ping` from the DN container to the UE IP (1 packet, 1 s timeout).
- **Uplink latency**: `ping` from the UE container to the DN IP (1 packet, 1 s timeout).
- **Downlink bandwidth**: `iperf3` from the DN client to the UE server (1 s test).
- **Uplink bandwidth**: `iperf3` in reverse mode (`-R` flag) (1 s test).
3. Updates the GUI with the latest results after each cycle.
4. When stopped, kills the iperf3 server on the UE container.

Each measurement cycle takes approximately **4 seconds**, keeping the overhead low enough to avoid slowing down the simulation.

---

### 🚀 Usage

The Network Monitor is a **GUI plugin** that can be added to your Gazebo Ignition world file or loaded at runtime from the Gazebo GUI plugin menu.

#### Adding to an SDF World File

Add the following block inside the `<gui>` section of your world file:

```xml
<gui>
<plugin name="phine_plugins::NetworkMonitor" filename="NetworkMonitor">
<ue_ip>10.0.0.1</ue_ip>
<dn_ip>192.168.70.135</dn_ip>
<ue_container_name>ue_turtlebot</ue_container_name>
<dn_container_name>oai-ext-dn</dn_container_name>
</plugin>
</gui>
```

All parameters are optional — they can also be set at runtime from the GUI text fields.

#### Environment Variable

The UE container name can also be set via the `UE_NAME_FOR_BUTTON` environment variable:

```bash
export UE_NAME_FOR_BUTTON=ue_turtlebot
```

If set, it overrides the default value (`ue_turtlebot`). A value provided in the SDF `<ue_container_name>` element takes precedence over the environment variable.

#### Runtime

Once the plugin is loaded in Gazebo:

1. Enter the **UE IP** (the 5G tunnel IP assigned to the UE, e.g., `10.0.0.1`) and the **DN IP** (the Data Network container IP, e.g., `192.168.70.135`).
2. Click **Start Test** to begin continuous monitoring.
3. The panel displays live uplink/downlink latency and bandwidth.
4. Click **Stop Test** to end the measurement loop.

---

### 🔧 Configuration Parameters

| **Parameter** | **Description** | **Default** |
| -------------------- | ------------------------------------------------------------------------------- | --------------- |
| `ue_ip` | 5G tunnel IP of the UE (e.g., `10.0.0.1`). Can be set from the GUI at runtime. | _(empty)_ |
| `dn_ip` | IP of the Data Network container (e.g., `192.168.70.135`). Can be set from GUI. | _(empty)_ |
| `ue_container_name` | Docker container name of the UE | `ue_turtlebot` |
| `dn_container_name` | Docker container name of the Data Network node | `oai-ext-dn` |

---

### ⚠️ Prerequisites

- **iperf3** must be installed inside both the UE and DN containers.
- **ping** must be available inside both containers.
- The Gazebo host must have **Docker access** (the plugin runs `docker exec` commands).
- The plugin shared library (`libNetworkMonitor.so`) must be in a path listed in `IGN_GAZEBO_GUI_PLUGIN_PATH`.

---

## 🔌 gNB Power and UE Power Control Plugins

The **gNB Power Plugin** and **UE Power Plugin** are Ignition Gazebo GUI plugins that provide **runtime control** over the 5G radio processes (gNB and UE softmodems) running inside Docker containers. These plugins allow you to **start, stop, and monitor** the OAI radio software directly from the Gazebo GUI without needing to manually execute Docker commands.

---

### 🎯 What They Do

Both plugins provide a graphical interface to:

- 🟢 **Start/Stop** the radio process (`nr-softmodem` for gNB, `nr-uesoftmodem` for UE) inside the container
- 🔄 **Toggle between OAI versions** (v24 and v26) which use different configuration file formats
- 📊 **Monitor process state** (running/stopped) with visual indicators
- 🔧 **Configure runtime parameters** like container names, IP addresses, and OAI version

This is particularly useful during simulation development and testing, where you may need to:
- Verify 5G connectivity by restarting the UE or gNB
- Test failure scenarios by stopping the radio link
- Switch between OAI versions without rebuilding containers
- Observe how your robot application handles connection loss

---

### ⚡ How They Work

#### gNB Power Plugin

1. **First Click** (Connect): Checks if the `nr-softmodem` process is running in the specified gNB container
2. **Subsequent Clicks** (Toggle): Starts or stops the gNB radio process using the appropriate command for the selected version:
- **v24**: Launches with `.conf` configuration file and `--sa` flag
- **v26**: Launches with `.yaml` configuration file (no `--sa` flag)

#### UE Power Plugin

Works similarly to the gNB plugin, but controls the `nr-uesoftmodem` process in the UE container:
- **v24**: Uses `.conf` file with frequency `3619200000` Hz
- **v26**: Uses `.yaml` file with frequency `3319680000` Hz
- Requires the **gNB IP address** to establish the RF simulator connection

---

### 🚀 Usage

Both plugins are **GUI plugins** that can be added to your Gazebo Ignition world file or loaded at runtime from the Gazebo GUI plugin menu.

#### Adding to an SDF World File

Add the following blocks inside the `<gui>` section of your world file:

##### gNB Power Plugin

```xml
<gui>
<plugin name="phine_plugins::gNBPowerPlugin" filename="gNBPowerPlugin">
<container_name>oai-gNB1</container_name>
<version>v24</version>
</plugin>
</gui>
```

##### UE Power Plugin

```xml
<gui>
<plugin name="phine_plugins::UePowerPlugin" filename="UePowerPlugin">
<container_name>ue_turtlebot</container_name>
<version>v24</version>
<gnb_ip>192.168.70.160</gnb_ip>
</plugin>
</gui>
```

All parameters are optional and can be configured at runtime from the GUI.

#### Environment Variable for UE Plugin

The UE container name can be set via the `UE_NAME_FOR_BUTTON` environment variable:

```bash
export UE_NAME_FOR_BUTTON=ue_turtlebot
```

If set, this overrides the default value. A value provided in the SDF `<container_name>` element takes precedence.

---

### 🖥️ GUI Interface

#### gNB Power Control Panel

When loaded, the plugin displays:
- **Container Name Field**: Name of the gNB Docker container (e.g., `oai-gNB1`)
- **Version Selector**: Dropdown to choose between "v24 (.conf)" and "v26 (.yaml)"
- **Power Button**:
- First click: **Connect** to the container and check process status
- Subsequent clicks: **Toggle** the gNB process on/off
- Color indicators: 🟢 Green (running) / 🔴 Red (stopped)
- **Status Display**: Shows current connection and process state

#### UE Power Control Panel

Similar to gNB, with an additional field:
- **Container Name Field**: Name of the UE Docker container (e.g., `ue_turtlebot`)
- **Version Selector**: Choose between v24 and v26
- **gNB IP Field**: IP address of the gNB for RF simulator connection (e.g., `192.168.70.160`)
- **Power Button**: Connect and toggle the UE process
- **Status Display**: Connection and process state

**Note**: Container name, version, and gNB IP can only be changed **before** the first connection. Once connected, these fields are locked to prevent accidental misconfiguration during active radio sessions.

---

### 🔧 Configuration Parameters

#### gNB Power Plugin Parameters

| **Parameter** | **Description** | **Default** |
| ---------------- | --------------------------------------------------------- | ------------- |
| `container_name` | Docker container name of the gNB | `oai-gNB1` |
| `version` | OAI version: `v24` (uses .conf) or `v26` (uses .yaml) | `v24` |

#### UE Power Plugin Parameters

| **Parameter** | **Description** | **Default** |
| ---------------- | --------------------------------------------------------- | ----------------- |
| `container_name` | Docker container name of the UE | `ue_turtlebot` |
| `version` | OAI version: `v24` (uses .conf) or `v26` (uses .yaml) | `v24` |
| `gnb_ip` | IP address of the gNB container for RF simulator | `192.168.70.160` |

---

### ✅ Tested Configurations

These plugins have been **tested and verified** with:
- **OAI 5G Core Network** (`oai_setup`)
- **demo** mode (Gazebo on host)
- **demo_containerized** mode (Gazebo in Docker)

Support for **free5GC** and **Open5GS** core networks is planned for future releases.

---

### 💡 Typical Workflow

1. **Launch your OAI 5G core network**:
```bash
cd path/demo/oai_setup
docker compose up -d
```

2. **Launch gNB and UE containers** (without starting the radio processes):
```bash
docker compose -f docker-compose-gNB.yml up -d
docker compose -f docker-compose-ue.yml up -d
```

3. **Start Gazebo** with your world file that includes the power plugins

4. **In Gazebo GUI**:
- Open the **gNB Power Control** panel
- Verify container name and version
- Click **Connect** to check status
- Click **Power Toggle** to start the gNB radio

5. **Then control the UE**:
- Open the **UE Power Control** panel
- Verify container name, version, and gNB IP
- Click **Connect** to check status
- Click **Power Toggle** to start the UE and establish the 5G connection

6. **Monitor AMF logs** to verify successful registration:
```bash
docker logs oai-amf
```

You should see the UE appear in the AMF's registered UEs table.

---

## Modify source code

The source code of the plugins is at `path/phine-plugins/src/phine_plugins/src`. You can modify it as you wish consulting [Coding Guidelines](CODE_OF_CONDUCT.md) and [Contributing](CONTRIBUTING.md) and in case you would like to share your work. Once you have modified the code, delete `path/phine-plugins/log`,`path/phine-plugins/install`,`path/phine-plugins/build` and run in `path/phine-plugins`(with `path` the path to main folder of the repo):
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions demo/images/ue_amr/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ RUN apt-get install -y libignition-transport8-dev
RUN apt-get install -y libignition-tools-dev
RUN apt-get install -y ros-humble-ros-ign-bridge
RUN apt-get install -y iptables
RUN apt-get install -y iperf3 iputils-ping

WORKDIR /app

Expand Down
Loading
Loading