[nexus] add gRPC support and live demo (#12898)

This commit introduces gRPC support to the Nexus simulator, enabling
remote control and monitoring of simulations. This infrastructure allows
external tools and visualizers to interact with the simulated network
in real-time.

Key changes:
- Defined `simulation.proto` providing the `NexusService` definition for
  simulation control and event streaming.
- Implemented `GrpcServer` in `nexus_grpc.cpp` which functions as a
  Nexus simulation observer, pushing events to connected clients.
- Added RPCs for dynamic node creation, position updates, node state
  control, and network orchestration (forming and joining).
- Implemented a real-time event stream that includes node state changes,
  link updates, and packet captures (with basic protocol decoding).
- Introduced `nexus_native.cpp` as an entry point for a persistent
  simulation server that can be controlled via gRPC.
- Updated `Core` and `Observer` interfaces to support a list of
  concurrent observers instead of a single instance.
- Enhanced the CMake build system to optionally find and link against
  gRPC and Protobuf, including automatic source generation.
- Updated CI (GitHub Actions) to include build and test steps for the
  new gRPC functionality.
- Added comprehensive unit tests in `test_grpc.cpp` to verify all
  exposed gRPC service methods.
This commit is contained in:
Jonathan Hui
2026-04-16 20:05:19 -07:00
committed by GitHub
parent e536562296
commit 254043deec
16 changed files with 1956 additions and 42 deletions
+27
View File
@@ -106,3 +106,30 @@ jobs:
- name: Run TREL Tests
run: |
cd build/nexus && ctest -L trel --output-on-failure
nexus-grpc-tests:
name: nexus-grpc-tests
runs-on: ubuntu-24.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build libgrpc++-dev libprotobuf-dev protobuf-compiler-grpc
- name: Build Nexus
run: |
mkdir -p build/nexus
OT_NEXUS_GRPC=ON top_builddir=build/nexus ./tests/nexus/build.sh
- name: Run GRPC Tests
run: |
cd build/nexus && ./tests/nexus/nexus_grpc