Runtime data exchange between Python ML model and OMNeT++ network simulator

I’m working with an OMNeT++ network simulation (version 4.6) that uses the INET framework. My setup needs real-time communication with a Python-based machine learning agent while the simulation runs.

The workflow I need is:

  • OMNeT++ simulator collects network metrics (signal quality measurements and node positions)
  • This data gets sent to Python ML agent for processing
  • Python agent performs online learning and calculates optimization commands
  • These commands must be returned to OMNeT++ to adjust network parameters

What’s the best approach to establish this bidirectional communication between the running OMNeT++ process and Python script? I need both applications to exchange data continuously during simulation execution without stopping either process.

have u tried TCP sockets? I used them for my thesis project and they worked great. Just spawn a separate thread in OMNeT++ to handle socket comm while your main sim runs. On the Python side, use the socket library to connect and send JSON msgs back and forth. prob easier than ZeroMQ unless ya need those extra features.

I faced a similar challenge when integrating OMNeT++ simulations with Python ML models. A practical solution is to utilize a messaging library like ZeroMQ, which facilitates efficient bidirectional communication between the two processes. For my setup, I created a custom module in OMNeT++ with a PUSH socket to transmit real-time data, such as signal quality and node positions, to the Python agent, and a PULL socket to receive optimization commands. Ensuring both sides share compatible socket types is essential. Additionally, implementing a synchronization mechanism can help maintain the integrity of the data exchange, ensuring timely updates without disrupting the simulation flow.

Try named pipes or shared memory for inter-process communication. I built something similar using Python’s multiprocessing module with shared memory arrays to pass data between my OMNeT++ simulation and RL agent. Way lower latency than sockets. In OMNeT++, I made a communication module that dumps network metrics to memory segments at set intervals. The Python process watches these segments and writes back control decisions. You’ll need semaphores for proper sync to avoid race conditions. This setup worked great for my real-time vehicle networking sims where I needed millisecond response times. Define your data structures upfront and maybe use Protocol Buffers for serialization if things get complex.