How to Simulate Industrial IoT Projects Using NS3

To simulate an Industrial Internet of Things (IIoT) projects within NS3 that encompasses making a network in which several devices (sensors, actuators, machines) are communicate in an industrial setting. This IIoT applications are intended to improve the industrial automation, process optimization, and real-time monitoring of machines. In an industrial IoT scenario, numerous communication technologies such as Wi-Fi, LTE, 5G, ZigBee, or LoRa can be used. We provide key features and stepwise approach are helps to simulate the IIoT projects using NS3:

Key Aspects of Industrial IoT (IIoT) Simulation:

  • Network Communication: Normally contains the wireless communication technologies such as Wi-Fi, LTE, 5G, ZigBee, or low-power wide-area networks (LPWANs) like LoRa.
  • Devices: Industrial sensors, machines, and controllers, which communicate with each other and with centralized systems.
  • Traffic Patterns: IIoT traffic frequently comprises a mix of regular telemetry data (sensor readings) and sporadic events (e.g., alarms).
  • Latency and Reliability: Critical in several IIoT applications that particularly in real-time control systems.

Steps to Simulate Industrial IoT Projects in NS3:

  1. Technologies for IIoT Simulation in NS3

We can be replicated an IIoT networks using numerous wireless communication technologies obtainable in NS3:

  • Wi-Fi (802.11 family, containing 802.11ax for high-throughput applications).
  • LTE or 5G for wide-area communication and low-latency requirements.
  • ZigBee (802.15.4) for low-power, low-data-rate communication among the sensors.
  • LoRa: Needs integration of third-party libraries or custom models.
  1. Basic IIoT Network Simulation Using Wi-Fi

Below is a step-by-step process to replicate an IIoT scenario in which numerous devices (sensors and controllers) communicate across a Wi-Fi network.

Example Code for Wi-Fi-Based IIoT Simulation:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/wifi-module.h”

#include “ns3/mobility-module.h”

#include “ns3/applications-module.h”

using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“IIoTSimulation”);

int main (int argc, char *argv[])

{

CommandLine cmd;

cmd.Parse (argc, argv);

// Create nodes for IIoT devices (sensors, machines)

NodeContainer sensorNodes;

sensorNodes.Create (5);  // 5 IIoT devices (sensors and controllers)

// Create one Access Point (AP)

NodeContainer apNode;

apNode.Create (1);  // Access Point

// Configure Wi-Fi using 802.11n for industrial IoT devices

WifiHelper wifi;

wifi.SetStandard (WIFI_PHY_STANDARD_80211n);

YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();

wifiPhy.SetChannel (wifiChannel.Create ());

WifiMacHelper wifiMac;

Ssid ssid = Ssid (“IIoT-WiFi”);

wifiMac.SetType (“ns3::StaWifiMac”, “Ssid”, SsidValue (ssid), “ActiveProbing”, BooleanValue (false));

// Install Wi-Fi on IIoT devices (sensors)

NetDeviceContainer sensorDevices;

sensorDevices = wifi.Install (wifiPhy, wifiMac, sensorNodes);

// Configure the Access Point (AP)

wifiMac.SetType (“ns3::ApWifiMac”, “Ssid”, SsidValue (ssid));

NetDeviceContainer apDevice = wifi.Install (wifiPhy, wifiMac, apNode);

// Set up mobility for IIoT devices (stationary for simplicity)

MobilityHelper mobility;

mobility.SetPositionAllocator (“ns3::GridPositionAllocator”,

“MinX”, DoubleValue (0.0),

“MinY”, DoubleValue (0.0),

“DeltaX”, DoubleValue (5.0),

“DeltaY”, DoubleValue (5.0),

“GridWidth”, UintegerValue (3),

“LayoutType”, StringValue (“RowFirst”));

mobility.SetMobilityModel (“ns3::ConstantPositionMobilityModel”);

mobility.Install (sensorNodes);

mobility.Install (apNode);

// Install the Internet stack

InternetStackHelper internet;

internet.Install (sensorNodes);

internet.Install (apNode);

// Assign IP addresses to IIoT devices and the AP

Ipv4AddressHelper ipv4;

ipv4.SetBase (“10.1.1.0”, “255.255.255.0”);

Ipv4InterfaceContainer sensorInterfaces = ipv4.Assign (sensorDevices);

Ipv4InterfaceContainer apInterface = ipv4.Assign (apDevice);

// Set up UDP echo server on the AP (simulating a centralized system)

UdpEchoServerHelper echoServer (9);

ApplicationContainer serverApp = echoServer.Install (apNode.Get (0));

serverApp.Start (Seconds (1.0));

serverApp.Stop (Seconds (10.0));

// Set up UDP echo clients on the IIoT devices (sending sensor data)

UdpEchoClientHelper echoClient (apInterface.GetAddress (0), 9);

echoClient.SetAttribute (“MaxPackets”, UintegerValue (100));

echoClient.SetAttribute (“Interval”, TimeValue (Seconds (1.0)));  // Send data every second

echoClient.SetAttribute (“PacketSize”, UintegerValue (1024));  // Simulate data packet size

ApplicationContainer clientApps = echoClient.Install (sensorNodes);

clientApps.Start (Seconds (2.0));

clientApps.Stop (Seconds (10.0));

// Enable PCAP tracing to capture packets

wifiPhy.EnablePcapAll (“iiot-wifi”);

// Run the simulation

Simulator::Run ();

Simulator::Destroy ();

return 0;

}

Explanation of Code:

  1. Node Setup: We can make a sensorNodes to signify the IIoT devices (like sensors and controllers) and one Access Point (AP).
  2. Wi-Fi Configuration: We use 802.11n, a general Wi-Fi standard in industrial applications for higher data rates and reliability.
  3. Mobility Model: The ConstantPositionMobilityModel keeps the nodes stationary, however we can be used dynamic mobility models if required.
  4. UDP Communication: We can configure a UDP echo server on the AP (simulating a central server) and UDP echo clients on the IIoT devices to replicate the data transmission from the sensors.
  5. PCAP Tracing: Packet capture is allowed for examine of traffic among the devices.
  1. IIoT Simulation Using LTE or 5G

To mimic wide-area IIoT applications, which use LTE or 5G, we can leverage the LTE/5G module in NS3. This configure permits the devices to communicate across cellular networks that is helpful for large-scale industrial setups or remote areas.

Example Code for LTE-Based IIoT Simulation:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/mobility-module.h”

#include “ns3/lte-module.h”

#include “ns3/applications-module.h”

using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“LTEIIoTSimulation”);

int main (int argc, char *argv[])

{

CommandLine cmd;

cmd.Parse (argc, argv);

// Create LTE Helper and EPC Helper (core network)

Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();

Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper> ();

lteHelper->SetEpcHelper (epcHelper);

// Create the PGW node (Packet Gateway) and a remote host

Ptr<Node> pgw = epcHelper->GetPgwNode ();

NodeContainer remoteHostContainer;

remoteHostContainer.Create (1);

Ptr<Node> remoteHost = remoteHostContainer.Get (0);

InternetStackHelper internet;

internet.Install (remoteHostContainer);

// Set up point-to-point connection between remote host and PGW

PointToPointHelper p2p;

p2p.SetDeviceAttribute (“DataRate”, StringValue (“100Gbps”));

p2p.SetChannelAttribute (“Delay”, StringValue (“1ms”));

NetDeviceContainer internetDevices = p2p.Install (pgw, remoteHost);

Ipv4AddressHelper ipv4h;

ipv4h.SetBase (“1.0.0.0”, “255.255.255.0”);

Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);

// Add a default route to the remote host via the PGW

Ptr<Ipv4StaticRouting> remoteHostStaticRouting = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting> (remoteHost->GetObject<Ipv4> ());

remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address (“7.0.0.0”), Ipv4Mask (“255.0.0.0”), 1);

// Create eNodeB (base station) and IIoT devices (UEs)

NodeContainer enbNode;

enbNode.Create (1);

NodeContainer iotNodes;

iotNodes.Create (5);  // 5 IIoT devices (UEs)

// Install mobility for eNodeB and UEs (stationary)

MobilityHelper mobility;

mobility.SetMobilityModel (“ns3::ConstantPositionMobilityModel”);

mobility.Install (enbNode);

mobility.Install (iotNodes);

// Install LTE devices on eNodeB and UEs

NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (enbNode);

NetDeviceContainer ueLteDevs = lteHelper->InstallUeDevice (iotNodes);

// Install Internet stack on UEs

internet.Install (iotNodes);

// Assign IP addresses to UEs

Ipv4InterfaceContainer ueIpIfaces = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueLteDevs));

// Attach UEs to the eNodeB

for (uint32_t i = 0; i < iotNodes.GetN (); ++i)

{

lteHelper->Attach (ueLteDevs.Get (i), enbLteDevs.Get (0));

}

// Set up a UDP echo server on the remote host

UdpEchoServerHelper echoServer (9);

ApplicationContainer serverApp = echoServer.Install (remoteHost);

serverApp.Start (Seconds (1.0));

serverApp.Stop (Seconds (10.0));

// Set up UDP echo clients on IIoT devices (UEs)

UdpEchoClientHelper echoClient (internetIpIfaces.GetAddress (1), 9);

echoClient.SetAttribute (“MaxPackets”, UintegerValue (100));

echoClient.SetAttribute (“Interval”, TimeValue (Seconds (1.0)));  // Send data every second

echoClient.SetAttribute (“PacketSize”, UintegerValue (1024));  // Simulate sensor data

ApplicationContainer clientApps = echoClient.Install (iotNodes);

clientApps.Start (Seconds (2.0));

clientApps.Stop (Seconds (10.0));

// Enable tracing for LTE network

lteHelper->EnablePcapAll (“lte-iiot”);

// Run the simulation

Simulator::Run ();

Simulator::Destroy ();

return 0;

}

Explanation:

  1. LTE Setup: The LteHelper and EPC Helper set up the LTE network, replicating an industrial IIoT environment in which devices (UEs) are communicate across LTE.
  2. eNodeB and UEs: The eNodeB (base station) serves the UEs (IIoT devices) that communicate with a central server (remote host) through the LTE network.
  3. UDP Communication: Same to the Wi-Fi example, UDP echo servers and clients are replicate data transmission from IIoT devices to a remote server.
  1. Additional IIoT Simulation Features
  2. ZigBee for Low-Power IoT Devices

If the IIoT scenario involves low-power devices then we can replicate ZigBee (IEEE 802.15.4) communication using the LR-WPAN module within NS3.

  1. Multi-hop Communication

In large industrial environments, IIoT devices may utilise multi-hop communication to attain the central server. We can replicate it using a routing protocol such as AODV or DSDV for multi-hop communication.

  1. Energy Models

IIoT devices are frequently battery-powered. To mimic an energy consumption, we can be combined an energy models within NS3 to track energy usage in the course of communication.

BasicEnergySourceHelper energySourceHelper;

energySourceHelper.Set (“BasicEnergySourceInitialEnergyJ”, DoubleValue (10000));  // 10,000 Joules of initial energy

EnergySourceContainer energySources = energySourceHelper.Install (iotNodes);

LrWpanRadioEnergyModelHelper radioEnergyHelper;

DeviceEnergyModelContainer energyModels = radioEnergyHelper.Install (iotLrWpanDevices, energySources);

  1. Data Aggregation

To replicate data aggregation (e.g., combining multiple sensor readings into one transmission), we can be inserted the custom logic at the application layer to manage the aggregation before transmission.

  1. Real-time Data Processing

For more difficult IIoT scenarios, we can replicate an edge or fog computing in which data is processed at local nodes or gateways before being sent to the central server.

  1. Performance Metrics for IIoT Networks

A few key performance parameters to estimate in IIoT networks contain:

  • Packet Delivery Ratio (PDR): The ratio of effectively delivered packets to the total transmitted packets.
  • Latency: The delay in sending data from IIoT devices to the central server.
  • Throughput: The total data well sent across the network.
  • Energy Consumption: For battery-powered devices, estimate the amount of energy consumed in the course of communication.
  1. Running the Simulation

To run the simulations, we use:

./waf –run scratch/iiot-wifi-simulation  # For Wi-Fi-based IIoT

./waf –run scratch/lte-iiot-simulation   # For LTE-based IIoT

In this procedure, we can completely understand how to simulate the Industrial IoT projects and using the NS3 simulation tool. These projects covers address several devices (sensors, actuators, machines) are communicate in an industrial setting. For further requirements, we will guide you through another projects.

If you’re looking to simulate Industrial IoT projects with NS3, check out phdprime.com. We’ve got all the tools and resources you need to get started. Just send us the details of your project, and we’ll make sure you get timely delivery and top-notch support. Plus, we can help you with a variety of communication technologies like Wi-Fi, LTE, 5G, ZigBee, and LoRa

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2