Skip to main content

โ† Back to Tutorials

OMNeT++ Basic Integration

Difficulty: Advanced ยท Time: ~60 minutes

This tutorial covers step-by-step instructions for integrating NSB with a pure OMNeT++ setup (no INET).

Goal: Understand per-node simulator architecture.

Overviewโ€‹

OMNeT++ is a simulation framework that operates in a bottom-up, per-node model โ€” each simulated host is an individual module that independently handles its own traffic. Because of this, when using NSB with OMNeT++, you should configure NSB in Per-Node simulator mode (simulator_mode: 1).

In this integration:

  • Each simulated OMNeT++ node module has its own NSBSimClient instance, identified to match the corresponding NSBAppClient
  • When the OMNeT++ module receives a message, it calls post() to notify NSB; when it needs to inject traffic, it calls fetch()

This tutorial uses nsb_omnet_basic โ€” a complete example of NSB integration with pure OMNeT++ (no INET). For the more realistic wireless/wired setup, see OMNeT++ with INET.

Prerequisitesโ€‹

Highly recommended: OMNeT++ 6.1

Download from omnetpp.org/download.

For macOS Apple Silicon: download the aarch version and follow the OMNeT++ Installation Guide.

OMNeT++ Setupโ€‹

After downloading and extracting OMNeT++:

  1. Follow the install instructions for your platform.
  2. Create an OMNeT++ workspace: <your_workspace> inside your omnetpp-6.1/ folder.
  3. From a terminal inside omnetpp-6.1/, run:
source setenv
omnetpp

This sets up the environment and opens the OMNeT++ IDE.

nsb_omnet_basic Filesโ€‹

FileDescription
NSBMessage.msgCustom OMNeT++ message type carrying NSB payload information
NSBMessage_m.cc / .hAuto-generated C++ code from the .msg file
NSBHost.cc / .h / .nedHost module that fetches from NSB Daemon, routes to the correct simulated host, and notifies NSB of message delivery
NSBHostNetwork.nedNetwork definition: two hosts of NSBHost type for a simple ping test
NSBHostNetworkTenHosts.nedLarger network definition: 10 hosts in a fully-connected topology
omnetpp.iniConfiguration file for running NSBHostNetwork.ned
makefragBuild fragment that adds NSB include paths and libraries

Steps to Runโ€‹

1. Open the OMNeT++ IDE from your terminal:

cd omnetpp-6.1
source setenv
omnetpp

2. Import the project into your workspace:

  • File โ†’ Import โ†’ Existing project into workspace
  • Select the nsb_omnet_basic folder

3. Ensure the makefrag file contains the following (it should already be there):

INCLUDE_PATH += $(shell pkg-config --cflags-only-I nsb)
LIBS += $(shell pkg-config --libs nsb)

4. Build and run:

  • Select omnetpp.ini
  • Project โ†’ Build Project
  • Run the simulation โ€” this runs a 10-host fully-connected network simulation

Configuration for OMNeT++โ€‹

Since OMNeT++ is a per-node simulator, use Per-Node simulator mode in your config.yaml:

system:
daemon_address: 127.0.0.1
daemon_port: 65432
mode: 0 # PULL
simulator_mode: 1 # Per-Node โ€” each host has its own SimClient

database:
use_db: true
db_address: 127.0.0.1
db_port: 5050
db_num: 0

Startup Orderโ€‹

# 1. Start Redis
redis-server --port 5050

# 2. Start NSB Daemon
./build/nsb_daemon config.yaml

# 3. Start the OMNeT++ IDE and run the simulation
cd omnetpp-6.1 && source setenv && omnetpp
# (run simulation from IDE)

# 4. Run your application(s) with NSBAppClient
python3 my_application.py
Important

Start the NSB Daemon before opening the OMNeT++ IDE. When you're done, exit the OMNeT++ IDE before killing the NSB Daemon for a graceful shutdown.


Notesโ€‹

  • The NSBMessage.msg in nsb_omnet_basic defines the OMNeT++ message that carries NSB payload information. In INET setups, INET's chunk system would replace this.
  • In pure OMNeT++ (without INET), null characters (\00) within payloads may cause issues in string handling. This is a known limitation under active development. See Troubleshooting โ†’ Null byte in payload.

Go Deeperโ€‹

Next: OMNeT++ with INET โ†’