To implement the Industrial Internet of Things (IIoT) in OMNeT++ needs a network that helps industrial applications like predictive maintenance, process automation, and real-time monitoring by designing and simulating it. This network requires integration different kinds of nodes (sensors, actuators, controllers, gateways and so on) and communication protocols.
Below, we offered step-by-step guide to implementing IIoT in OMNeT++ using the INET framework:
Step-by-Step Implementation:
Make sure that you have OMNeT++ and the INET Framework installed.
Create a new NED file to state the network topology that has multiple IIoT components like sensors, actuators, controllers, gateways, and servers.
Example: IIoT Network Topology (IIoTNetwork.ned)
package iiotnetwork;
import inet.node.inet.StandardHost;
import inet.node.inet.WirelessHost;
import inet.node.inet.Router;
network IIoTNetwork
{
parameters:
@display(“bgb=800,400”);
submodules:
sensor1: WirelessHost {
@display(“p=100,300”);
}
sensor2: WirelessHost {
@display(“p=300,300”);
}
actuator1: WirelessHost {
@display(“p=500,300”);
}
controller: WirelessHost {
@display(“p=200,200”);
}
gateway: Router {
@display(“p=300,100”);
}
server: StandardHost {
@display(“p=400,100”);
}
connections allowunconnected:
sensor1.wlan[0] <–> AdhocChannel <–> controller.wlan[0];
sensor2.wlan[0] <–> AdhocChannel <–> controller.wlan[0];
actuator1.wlan[0] <–> AdhocChannel <–> controller.wlan[0];
controller.wlan[0] <–> AdhocChannel <–> gateway.wlan[0];
gateway.ethg++ <–> Eth10M <–> server.ethg++;
}
Configure the simulation parameters by creating an OMNeT++ initialization file.
Example: Configuration File (omnetpp.ini)
network = iiotnetwork.IIoTNetwork
sim-time-limit = 100s
# Visualization
*.visualizer.canvasVisualizer.displayBackground = true
*.visualizer.canvasVisualizer.displayGrid = true
# Sensor Configuration
*.sensor*.numApps = 1
*.sensor*.app[0].typename = “SensorApp”
*.sensor*.app[0].destAddresses = “controller”
*.sensor*.app[0].destPort = 5000
*.sensor*.app[0].messageLength = 512B
*.sensor*.app[0].sendInterval = 1s
# Actuator Configuration
*.actuator*.numApps = 1
*.actuator*.app[0].typename = “ActuatorApp”
*.actuator*.app[0].localPort = 5001
# Controller Configuration
*.controller.numApps = 1
*.controller.app[0].typename = “ControllerApp”
*.controller.app[0].localPort = 5000
# Gateway Configuration
*.gateway.numApps = 1
*.gateway.app[0].typename = “GatewayApp”
*.gateway.app[0].localPort = 5000
# Server Configuration
*.server.numApps = 1
*.server.app[0].typename = “ServerApp”
*.server.app[0].localPort = 6000
# UDP Configuration
*.sensor*.hasUdp = true
*.actuator*.hasUdp = true
*.controller.hasUdp = true
*.gateway.hasUdp = true
*.server.hasUdp = true
# Wireless Configuration
*.sensor*.wlan[0].typename = “AdhocHost”
*.actuator*.wlan[0].typename = “AdhocHost”
*.controller.wlan[0].typename = “AdhocHost”
# IP Address Configuration
*.sensor1.ipv4.config = xmldoc(“sensor1.xml”)
*.sensor2.ipv4.config = xmldoc(“sensor2.xml”)
*.actuator1.ipv4.config = xmldoc(“actuator1.xml”)
*.controller.ipv4.config = xmldoc(“controller.xml”)
*.gateway.ipv4.config = xmldoc(“gateway.xml”)
*.server.ipv4.config = xmldoc(“server.xml”)
Create XML files to state the IP address configuration for all node.
Example: IP Configuration File for sensor1 (sensor1.xml)
<config>
<interface>
<name>wlan0</name>
<address>192.168.1.1</address>
<netmask>255.255.255.0</netmask>
</interface>
</config>
Example: IP Configuration File for sensor2 (sensor2.xml)
<config>
<interface>
<name>wlan0</name>
<address>192.168.1.2</address>
<netmask>255.255.255.0</netmask>
</interface>
</config>
Example: IP Configuration File for actuator1 (actuator1.xml)
<config>
<interface>
<name>wlan0</name>
<address>192.168.1.3</address>
<netmask>255.255.255.0</netmask>
</interface>
</config>
Example: IP Configuration File for controller (controller.xml)
<config>
<interface>
<name>wlan0</name>
<address>192.168.1.4</address>
<netmask>255.255.255.0</netmask>
</interface>
</config>
Example: IP Configuration File for gateway (gateway.xml)
<config>
<interface>
<name>eth0</name>
<address>192.168.1.254</address>
<netmask>255.255.255.0</netmask>
</interface>
</config>
Example: IP Configuration File for server (server.xml)
<config>
<interface>
<name>eth0</name>
<address>192.168.2.1</address>
<netmask>255.255.255.0</netmask>
</interface>
</config>
Implement the logic for data collection, processing, and control by simulating IIoT applications.
Example: Sensor Application (Pseudo-Code)
#include <omnetpp.h>
using namespace omnetpp;
class SensorApp : public cSimpleModule
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
private:
void sendData();
};
Define_Module(SensorApp);
void SensorApp::initialize() {
// Initialization code
scheduleAt(simTime() + 1, new cMessage(“sendData”));
}
void SensorApp::handleMessage(cMessage *msg) {
if (strcmp(msg->getName(), “sendData”) == 0) {
sendData();
scheduleAt(simTime() + 1, msg);
} else {
// Handle other messages
}
}
void SensorApp::sendData() {
// Logic to send sensor data to the controller
cMessage *msg = new cMessage(“sensorData”);
send(msg, “out”);
}
Example: Actuator Application (Pseudo-Code)
#include <omnetpp.h>
using namespace omnetpp;
class ActuatorApp : public cSimpleModule
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
private:
void processCommand(cMessage *msg);
};
Define_Module(ActuatorApp);
void ActuatorApp::initialize() {
// Initialization code
}
void ActuatorApp::handleMessage(cMessage *msg) {
// Process commands from the controller
processCommand(msg);
}
void ActuatorApp::processCommand(cMessage *msg) {
// Logic to process and execute commands
delete msg; // Example: simply delete the message
}
Example: Controller Application (Pseudo-Code)
#include <omnetpp.h>
using namespace omnetpp;
class ControllerApp : public cSimpleModule
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
private:
void processAndForwardData(cMessage *msg);
};
Define_Module(ControllerApp);
void ControllerApp::initialize() {
// Initialization code
}
void ControllerApp::handleMessage(cMessage *msg) {
// Process data from sensors and forward commands to actuators
processAndForwardData(msg);
}
void ControllerApp::processAndForwardData(cMessage *msg) {
// Logic to process sensor data and send commands to actuators
cMessage *commandMsg = new cMessage(“command”);
send(commandMsg, “out”);
delete msg; // Example: delete the original message after processing
}
Example: Gateway Application (Pseudo-Code)
#include <omnetpp.h>
using namespace omnetpp;
class GatewayApp : public cSimpleModule
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
private:
void processAndForwardData(cMessage *msg);
};
Define_Module(GatewayApp);
void GatewayApp::initialize() {
// Initialization code
}
void GatewayApp::handleMessage(cMessage *msg) {
// Process and forward data to the server
processAndForwardData(msg);
}
void GatewayApp::processAndForwardData(cMessage *msg) {
// Logic to process and forward data
send(msg, “out”);
}
Example: Server Application (Pseudo-Code)
#include <omnetpp.h>
using namespace omnetpp;
class ServerApp : public cSimpleModule
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
private:
void processData(cMessage *msg);
};
Define_Module(ServerApp);
void ServerApp::initialize() {
// Initialization code
}
void ServerApp::handleMessage(cMessage *msg) {
// Process data from gateway
processData(msg);
}
void ServerApp::processData(cMessage *msg) {
// Logic to process data
delete msg; // Example: simply delete the message
}
We have covered the entire procedure using the step-by-step process on how to implement Industrial Internet of Things (IIoT) in OMNeT++ if you can’t understand then contact us for more simulation help.