Simulation Platform Manager
Example Project: Energy-Saving App
This installation manual uses the Energy-Saving App as a concrete example of how a simulator is registered and executed by the Simulation Platform Manager.
- Energy-Saving App (example simulator): https://github.com/ndtwin-lab/Energy-Saving-App
- Simulation Platform Manager: https://github.com/ndtwin-lab/Simulation-Platform-Manager
Installation Manual: Simulation Subsystem
Scope: Simulation Platform, Energy-Saving App Simulator, and NFS Configuration.
Deployment Note: In production, NDTwin-Kernel, Energy-Saving-App, and Simulation-Platform-Manager can run on different machines (e.g., Kernel on the NDTwin server, Simulation Platform Manager on a multi-core simulation server, and the App on any client host).
In this demo, we run all three components on the same machine for simplicity.
1. System Requirements
- Operating System: Linux Ubuntu 22.04.X ~ 24.04.X
- Language Standard: C++23
- Compiler: g++
2. Dependencies
The Simulation subsystem requires specific libraries for networking, logging, and cryptographic hashing.
2.1. Get the Source Code
Clone the example simulator and the Simulation Platform Manager:
# Clone the Simulation Platform Manager
git clone https://github.com/ndtwin-lab/Simulation-Platform-Manager.git
# Clone the example simulator (Energy-Saving App)
git clone https://github.com/ndtwin-lab/Energy-Saving-App.git
2.2 Install Packages
Execute the following commands:
# Core Utilities and JSON
sudo apt install nlohmann-json3-dev
sudo apt install libboost-all-dev
# Logging
sudo apt install libspdlog-dev
sudo apt install libfmt-dev
# Cryptography (Required for Flow Rule Hashing in Simulator)
sudo apt install libssl-dev
3. NFS Configuration
The Simulation Platform must share a file system with the NDTwin.
3.1 Server-Side Setup (On NDTwin Machine)
- Install NFS Server:
sudo apt update
sudo apt install -y nfs-kernel-server
sudo systemctl enable --now nfs-kernel-server
- Create Directory:
sudo mkdir -p /srv/nfs/sim
sudo chown nobody:nogroup /srv/nfs/sim
sudo chmod 777 /srv/nfs/sim
- Configure Exports:
Edit
/etc/exportsto include the Simulation Platform’s IP:
/srv/nfs/sim <Sim_Server_IP>(rw,sync,no_subtree_check,all_squash)
Note: If the Simulation Platform Manager and NDTwin Kernel run on the same machine, you can set
<Sim_Server_IP>tolocalhost(or127.0.0.1).
- Restart NFS:
sudo systemctl restart nfs-kernel-server
3.2 Client-Side Setup (On Simulation Platform Machine)
- Install Client:
sudo apt install nfs-common
- Create Mount Point:
sudo mkdir -p /mnt/nfs/app
Note: If you change this path, you must update the source code configuration to match.
4. Configure Energy-Saving-App and Simulation-Platform-Manager settings (before build)
4.1 Configure Energy-Saving-App settings
Before compiling, edit the example settings file and set your IP/port values:
- Open:
Energy-Saving-App/include/app/settings.hpp.example - Update fields such as:
app_ip,app_portndt_ip,ndt_portrequest_manager_ip,request_manager_portnfs_server_ip,nfs_mnt_dir, etc.
- Save it as
Energy-Saving-App/include/app/settings.hpp
If your Makefile supports auto-generation, you can also run
make allonce to createinclude/app/settings.hppfrom the example, then edit the generated file.
4.2 Configure Simulation-Platform-Manager settings
Before compiling, edit the example settings file:
- Open:
Simulation-Platform-Manager/include/settings/sim_server.hpp.example - Update fields such as:
request_manager_ip,request_manager_port,request_manager_targetsim_server_port,sim_server_targetnfs_server_ip,nfs_server_dir,nfs_mnt_dir
- Save it as
Simulation-Platform-Manager/include/settings/sim_server.hpp
If your Makefile supports auto-generation, you can run
make allonce to createinclude/settings/sim_server.hppfrom the example, then edit it.
Same-machine demo tip: If NDTwin-Kernel, Energy-Saving-App, and Simulation-Platform-Manager run on the same machine, you can set all
*_ipfields (e.g.,app_ip,ndt_ip,request_manager_ip,nfs_server_ip) tolocalhost(or127.0.0.1) and keep the ports as configured.
5. Compilation & Deployment
5.1 Build Flags
- Logging: Compile with
-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACEto ensure debug logs function correctly when the-l debugflag is used.
5.2 Simulator Registration and Build Energy-Saving App (Crucial Step)
The Simulation Platform does not compile the simulator logic directly into itself; it runs it as an external binary. You must “register” the Energy-Saving Simulator by placing the compiled binary in a specific directory.
- Compile the Energy-Saving Simulator code.
- Deploy the binary to the following path structure inside the Simulation Platform directory:
Path:
Simulation-Platform-Manager/registered/energy_saving_simulator/1.0/Filename:executableCommand Example:
# Assuming you are in the source root of Energy-Saving-App
cp ./energy_saving_simulator ../Simulation-Platform-Manager/registered/energy_saving_simulator/1.0/executable
Makefile option (recommended): The Energy-Saving App repository already automates simulator registration in its Makefile.
Run thesimtarget to build the simulator and copy it into the Simulation Platform Manager’s registered folder:# From the source root of Energy-Saving-App cd Energy-Saving-App make allThis will generate
./energy_saving_simulatorand copy it to:../Simulation-Platform-Manager/registered/energy_saving_simulator/1.0/executable.
5.3 Build Simulation Platform Manager
cd Simulation-Platform-Manager
make all
5.4 NDTwin Integration Check
For the Simulation Platform to receive tasks, the NDTwin must know its address.
- Action: Update
setting/AppConfigin the NDTwin-Kernel source code:
std::string SIM_SERVER_URL = "http://<YOUR_SIM_IP>:8003/submit";
Note: If the Simulation Platform Manager and NDTwin Kernel run on the same machine, you can set
<YOUR_SIM_IP>tolocalhost(or127.0.0.1).
- Recompile NDTwin-Kernel: After updating
setting/AppConfig, rebuild and restart the NDTwin-Kernel.
See the NDTwin-Kernel build steps in the Installation Manual.
6. Launch Guide
For step-by-step instructions on how to launch the NDTwin-Kernel, Simulation-Platform-Manager, and Energy-Saving-App, see:
- Demo: Demo
- User Manual: User Manual