Skip to main content

โ† Back to Tutorials

OMNeT++ with INET

Difficulty: Advanced ยท Time: ~90 minutes

This tutorial extends the OMNeT++ Basic Integration using the INET framework for realistic wireless and wired network modeling.

Goal: Build advanced OMNeT++ simulations with NSB.

If you haven't already, read the OMNeT++ Basic Integration tutorial first โ€” it covers OMNeT++ installation and the Per-Node rationale this tutorial assumes.

Prerequisitesโ€‹

INET version 4.5 is required. The easiest way is via the IDE:

  1. Open the OMNeT++ IDE
  2. On first launch, you'll be prompted to install INET โ€” accept it
  3. If you skipped this prompt: Help โ†’ Install Simulation Models, select INET, and follow the prompts

For further information: INET Introduction.

INETAppFiles/ โ€” NSB API Integrationโ€‹

These files integrate NSB into INET's application layer. They belong under inet/src/inet/applications/udpapp/:

FileDescription
nsbBasicApp.cc / .h / .nedMessage source: Fetches messages from NSB Daemon and injects them into the simulation via UDP
nsbAppSink.cc / .h / .nedMessage receiver: Receives UDP packets from the simulation and notifies NSB Daemon of successful delivery

nsbBasicApp role: Acts as an NSBSimClient โ€” it calls fetch() to get payloads from NSB and sends them into the OMNeT++ simulation using INET's UDP stack.

nsbSinkApp role: Receives UDP packets that arrive at the destination, then calls post() to notify NSB that the payload has been delivered.

nsb_beta_simulations/simulations/ โ€” NED and INI Filesโ€‹

FileDescription
WirelessNetworkTwoHosts.nedTwo-host wireless network topology
WirelessNetworkTenHosts.nedTen-host wireless network topology
omnetpp.iniSimulation configuration referencing either NED topology

Steps to Runโ€‹

1. Open the OMNeT++ IDE:

cd omnetpp-6.1
source setenv
omnetpp

2. Import projects into your workspace:

  • File โ†’ Import โ†’ Existing project into workspace
  • Import both nsb_beta_simulations and inet4.5

3. Set project references:

  • Right-click nsb_beta_simulations โ†’ Properties โ†’ Project References
  • Check inet4.5 as a reference

4. Add NSB to INET's build:

  • Open inet4.5/src/makefrag
  • Add:
INCLUDE_PATH += $(shell pkg-config --cflags-only-I nsb)
LIBS += $(shell pkg-config --libs nsb)

5. Clean and build INET:

  • Right-click inet4.5 โ†’ Clean Local
  • Right-click inet4.5 โ†’ Build Project

6. Build and run the simulation:

  • Select omnetpp.ini from nsb_beta_simulations/simulations/
  • Project โ†’ Build Project
  • Run the 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 INET integration uses UDP as the application-layer transport within the simulation. The nsbBasicApp injects UDP packets; nsbSinkApp receives them.
  • INET's chunk system replaces the role that NSBMessage.msg plays in the pure OMNeT++ setup โ€” you don't need a custom .msg file here.
  • Null-byte payload handling is more robust under INET than pure OMNeT++, since INET's chunk system handles binary data differently. See Troubleshooting โ†’ Null byte in payload for the full limitation context.

Go Deeperโ€‹

You've now completed every tutorial. โ† Back to Tutorials to revisit any of them, or head to Contribute to get involved with NSB's development.