To implement the Industrial Internet of Things (IIoT) in OMNeT++ has encompasses to generating a recreation situation that contains different industrial devices, sensors, controllers, and communication networks. To support II0T specific functionalities can custom the INET framework and potentially cover. Connect with us for top-notch simulation and implementation of Industrial IoT using OMNeT++.In this step-by-step guide to help to get ongoing among a basic IIoT simulation in OMNeT++ by using the INET framework.
Step-by-Step Implementation:
Step 1: Install OMNeT++ and INET Framework
Step 2: Set Up Your Project
Step 3: Define IIoT Network Models Using NED
package iiot;
import inet.node.inet.StandardHost;
import inet.node.inet.Router;
import inet.node.wireless.AccessPoint;
import inet.node.wireless.SensorNode;
import inet.mobility.single.RandomWaypointMobility;
import inet.physicallayer.common.packetlevel.RadioMedium;
network IIoTNetwork
{
parameters:
int numSensors = default(10);
int numControllers = default(2);
submodules:
radioMedium: RadioMedium {
@display(“p=100,100”);
}
controller[numControllers]: StandardHost {
@display(“p=200,200+100*i”);
}
sensor[numSensors]: SensorNode {
@display(“p=400,100+50*i”);
mobility.typename = “RandomWaypointMobility”;
}
accessPoint: AccessPoint {
@display(“p=300,300”);
}
connections allowunconnected:
for i=0..numSensors-1 {
sensor[i].wlan[0] <–> radioMedium <–> accessPoint.wlan[0];
}
for i=0..numControllers-1 {
controller[i].ethg++ <–> accessPoint.ethg++;
}
}
Step 4: Implement IIoT Communication Logic
#include <omnetpp.h>
#include “inet/applications/base/ApplicationBase.h”
#include “inet/common/packet/Packet.h”
using namespace omnetpp;
using namespace inet;
class SensorNodeApp : public ApplicationBase
{
protected:
virtual void initialize(int stage) override;
virtual void handleMessageWhenUp(cMessage *msg) override;
void sendSensorData();
void handleSensorData(cPacket *pkt);
cMessage *sendEvent = nullptr;
};
Define_Module(SensorNodeApp);
void SensorNodeApp::initialize(int stage)
{
ApplicationBase::initialize(stage);
if (stage == INITSTAGE_LOCAL) {
sendEvent = new cMessage(“sendSensorData”);
scheduleAt(simTime() + par(“startTime”), sendEvent);
}
}
void SensorNodeApp::handleMessageWhenUp(cMessage *msg)
{
if (msg == sendEvent) {
sendSensorData();
scheduleAt(simTime() + par(“sendInterval”), sendEvent);
} else {
cPacket *pkt = check_and_cast<cPacket *>(msg);
handleSensorData(pkt);
}
}
void SensorNodeApp::sendSensorData()
{
// Create and send a sensor data packet to the access point or controller
EV << “Sending sensor data” << endl;
Packet *pkt = new Packet(“SensorData”);
pkt->setByteLength(par(“dataSize”));
send(pkt, “lowerLayerOut”);
}
void SensorNodeApp::handleSensorData(cPacket *pkt)
{
// Handle received sensor data packet
EV << “Received sensor data: ” << pkt->getName() << endl;
delete pkt;
}
#include <omnetpp.h>
#include “inet/applications/base/ApplicationBase.h”
#include “inet/common/packet/Packet.h”
using namespace omnetpp;
using namespace inet;
class ControllerApp : public ApplicationBase
{
protected:
virtual void initialize(int stage) override;
virtual void handleMessageWhenUp(cMessage *msg) override;
void handleSensorData(cPacket *pkt);
};
Define_Module(ControllerApp);
void ControllerApp::initialize(int stage)
{
ApplicationBase::initialize(stage);
}
void ControllerApp::handleMessageWhenUp(cMessage *msg)
{
if (msg->isSelfMessage()) {
delete msg;
} else {
cPacket *pkt = check_and_cast<cPacket *>(msg);
handleSensorData(pkt);
}
}
void ControllerApp::handleSensorData(cPacket *pkt)
{
// Handle received sensor data packet
EV << “Received sensor data: ” << pkt->getName() << endl;
delete pkt;
}
Step 5: Integrate IIoT Modules into Network Model
package iiot;
import inet.node.inet.StandardHost;
import inet.node.wireless.AccessPoint;
import inet.node.wireless.SensorNode;
import inet.physicallayer.contract.packetlevel.IRadioMedium;
import inet.physicallayer.common.packetlevel.RadioMedium;
import inet.mobility.single.RandomWaypointMobility;
network IIoTNetwork
{
parameters:
int numSensors = default(10);
int numControllers = default(2);
submodules:
radioMedium: RadioMedium {
@display(“p=100,100”);
}
controller[numControllers]: StandardHost {
@display(“p=200,200+100*i”);
@children:
wlan[0].radio.transmitter.typename = “ControllerApp”;
wlan[0].radio.receiver.typename = “ControllerApp”;
}
sensor[numSensors]: SensorNode {
@display(“p=400,100+50*i”);
mobility.typename = “RandomWaypointMobility”;
@children:
wlan[0].radio.transmitter.typename = “SensorNodeApp”;
wlan[0].radio.receiver.typename = “SensorNodeApp”;
}
accessPoint: AccessPoint {
@display(“p=300,300”);
}
connections allowunconnected:
for i=0..numSensors-1 {
sensor[i].wlan[0] <–> radioMedium <–> accessPoint.wlan[0];
}
for i=0..numControllers-1 {
controller[i].ethg++ <–> accessPoint.ethg++;
}
}
Step 6: Configure Simulation Parameters
[General]
network = IIoTNetwork
sim-time-limit = 100s
# Mobility
**.sensor[*].mobility.bounds = “0,0,1000,1000”
# Sensor application parameters
**.sensor[*].udpApp.startTime = uniform(0s, 10s)
**.sensor[*].udpApp.sendInterval = exponential(1s)
**.sensor[*].udpApp.dataSize = 256B
**.sensor[*].udpApp.localPort = 1000
**.sensor[*].udpApp.destPort = 2000
# Controller application parameters
**.controller[*].udpApp.localPort = 2000
Step 7: Build and Run the Simulation
Step 8: Analyze Results
In the above discussion, we are learn deeply about the Industrial IoT in IMNeT++ and then how we make enactment file which is implemented using OMNeT++ tool. We are willing to provide more information about the Industrial IoT in OMNeT++.