To implement the Fog Computing security in OMNeT++ includes mimicking a distributed computing architecture where computations, storage, data and applications are placed somewhere among the cloud and the data source like IoT devices. It presents unique security challenges, like intrusion detection, secure communication, and data protection in a decentralized environment.
Do you have trouble putting fog computing security into practice in OMNeT++? Make sure you send us all the information of your project so we can provide you with the greatest research support.
Given below is a step-by-step approaches to implement Fog Computing security in OMNeT++.
Step-by-Step Implementations:
Before implementation, it’s vital to know the key components included in Fog Computing security:
Initially we define a network topology in OMNeT++ that contains edge devices, fog nodes, and cloud servers. Contain security components like secure communication channels, IDS, and firewalls.
network FogComputingNetwork
{
submodules:
edgeDevice1: EdgeDevice {
@display(“p=100,150”);
}
edgeDevice2: EdgeDevice {
@display(“p=100,250”);
}
fogNode1: FogNode {
@display(“p=300,150”);
}
fogNode2: FogNode {
@display(“p=300,250”);
}
cloudServer: CloudServer {
@display(“p=500,200”);
}
firewall: FirewallModule {
@display(“p=200,100”);
}
ids: IDSModule {
@display(“p=400,100”);
}
attacker: AttackerNode {
@display(“p=600,250”);
}
}
connections:
edgeDevice1.ethg++ <–> Eth100M <–> fogNode1.ethg++;
edgeDevice2.ethg++ <–> Eth100M <–> fogNode2.ethg++;
fogNode1.ethg++ <–> Eth100M <–> firewall.ethg++;
fogNode2.ethg++ <–> Eth100M <–> firewall.ethg++;
firewall.ethg++ <–> Eth100M <–> ids.ethg++;
ids.ethg++ <–> Eth100M <–> cloudServer.ethg++;
attacker.wlan++ <–> Adhoc80211Nic <–> fogNode1.wlan++;
}
The Edge Device is responsible for creating data and communicating with fog nodes for processing and storage. It wants to make certain that data is protectively transmitted to fog nodes.
Edge Device Implementation
#include <omnetpp.h>
#include “inet/common/INETDefs.h”
#include “inet/applications/udpapp/UDPBasicApp.h”
using namespace omnetpp;
using namespace inet;
class EdgeDevice : public cSimpleModule
{
protected:
virtual void initialize(int stage) override;
virtual void handleMessage(cMessage *msg) override;
void generateData();
};
Define_Module(EdgeDevice);
void EdgeDevice::initialize(int stage)
{
cSimpleModule::initialize(stage);
if (stage == inet::INITSTAGE_APPLICATION_LAYER) {
EV << “Edge Device Initialized” << endl;
scheduleAt(simTime() + uniform(1, 3), new cMessage(“generateData”));
}
}
void EdgeDevice::handleMessage(cMessage *msg)
{
if (strcmp(msg->getName(), “generateData”) == 0) {
generateData();
}
delete msg;
}
void EdgeDevice::generateData()
{
// Simulate generating and sending data to the fog node
Packet *packet = new Packet(“EdgeDataPacket”);
packet->insertAtBack(makeShared<Chunk>(std::vector<int>{10, 20, 30})); // Example data
send(packet, “ethgOut”);
// Schedule next data generation
scheduleAt(simTime() + uniform(1, 3), new cMessage(“generateData”));
}
Security calculates must make certain that data is processed securely and only by official entities. The fog node processes data from dge devices and provides storage, computation, and communication services.
Fog Node Implementation
#include <omnetpp.h>
#include “inet/common/INETDefs.h”
#include “inet/common/packet/Packet.h”
#include <openssl/evp.h>
using namespace omnetpp;
using namespace inet;
class FogNode : public cSimpleModule
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
void processData(Packet *packet);
std::string encryptData(const std::string &data);
};
Define_Module(FogNode);
void FogNode::initialize()
{
EV << “Fog Node Initialized” << endl;
}
void FogNode::handleMessage(cMessage *msg)
{
if (Packet *packet = dynamic_cast<Packet *>(msg)) {
processData(packet);
}
delete msg;
}
void FogNode::processData(Packet *packet)
{
const auto &payload = packet->peekData();
std::string data = payload->str();
// Encrypt the data before further processing
std::string encryptedData = encryptData(data);
EV << “Processing and encrypting data from edge device: ” << encryptedData << endl;
// Forward processed data to the cloud server
Packet *processedPacket = new Packet(“ProcessedDataPacket”);
processedPacket->insertAtBack(makeShared<Chunk>(encryptedData));
send(processedPacket, “ethgOut”);
}
std::string FogNode::encryptData(const std::string &data)
{
// Simplified encryption using OpenSSL
unsigned char key[16] = “fogkey12345678”;
unsigned char iv[16] = “initialvector12”;
EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
EVP_EncryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv);
unsigned char encrypted[1024];
int len;
EVP_EncryptUpdate(ctx, encrypted, &len, (unsigned char*)data.c_str(), data.length());
int ciphertext_len = len;
EVP_EncryptFinal_ex(ctx, encrypted + len, &len);
ciphertext_len += len;
EVP_CIPHER_CTX_free(ctx);
return std::string((char*)encrypted, ciphertext_len);
}
The Cloud Server acts as a centralized server that manages offloaded data and executes heavy processing tasks. It wants to make sure that data received from fog nodes is protectively stored and processed.
Cloud Server Implementation
#include <omnetpp.h>
#include “inet/common/INETDefs.h”
#include “inet/common/packet/Packet.h”
using namespace omnetpp;
using namespace inet;
class CloudServer : public cSimpleModule
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
void storeData(Packet *packet);
void processReceivedData(const std::string &data);
};
Define_Module(CloudServer);
void CloudServer::initialize()
{
EV << “Cloud Server Initialized” << endl;
}
void CloudServer::handleMessage(cMessage *msg)
{
if (Packet *packet = dynamic_cast<Packet *>(msg)) {
storeData(packet);
}
delete msg;
}
void CloudServer::storeData(Packet *packet)
{
const auto &payload = packet->peekData();
std::string encryptedData = payload->str();
// Decrypt and process the data
processReceivedData(encryptedData);
EV << “Storing and processing data in the cloud: ” << encryptedData << endl;
// Simulate data storage (e.g., write to cloud storage, database, etc.)
}
void CloudServer::processReceivedData(const std::string &data)
{
// Simulate data processing in the cloud
EV << “Processing data received from fog node: ” << data << endl;
// Implement further processing or analysis
}
The Firewall Module filters traffic to and from the fog nodes and cloud servers, make sure only legitimate traffic passes over and blocking any suspicious activity.
Firewall Module Implementation
#include <omnetpp.h>
#include “inet/common/INETDefs.h”
#include “inet/common/packet/Packet.h”
using namespace omnetpp;
using namespace inet;
class FirewallModule : public cSimpleModule
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
bool isAllowed(Packet *packet);
};
Define_Module(FirewallModule);
void FirewallModule::initialize()
{
EV << “Firewall Module Initialized” << endl;
}
void FirewallModule::handleMessage(cMessage *msg)
{
if (Packet *packet = dynamic_cast<Packet *>(msg)) {
if (isAllowed(packet)) {
send(packet, “ethgOut”);
} else {
EV << “Packet dropped by firewall.” << endl;
delete packet;
}
}
}
bool FirewallModule::isAllowed(Packet *packet)
{
// Implement filtering logic (e.g., block specific IPs or patterns)
const auto &payload = packet->peekData();
std::string data = payload->str();
return data.find(“malicious”) == std::string::npos; // Example rule
}
The IDS Module displays network traffic to discover any potential intrusions or attacks, like data breaches or DDoS attempts.
IDS Module Implementation
#include <omnetpp.h>
#include “inet/common/INETDefs.h”
#include “inet/common/packet/Packet.h”
using namespace omnetpp;
using namespace inet;
class IDSModule : public cSimpleModule
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
void detectIntrusion(Packet *packet);
};
Define_Module(IDSModule);
void IDSModule::initialize()
{
EV << “IDS Module Initialized” << endl;
}
void IDSModule::handleMessage(cMessage *msg)
{
if (Packet *packet = dynamic_cast<Packet *>(msg)) {
detectIntrusion(packet);
send(packet, “ethgOut”);
}
delete msg;
}
void IDSModule::detectIntrusion(Packet *packet)
{
const auto &payload = packet->peekData();
std::string data = payload->str();
// Implement simple intrusion detection logic
if (data.find(“attack”) != std::string::npos) {
EV << “Intrusion detected! Taking action…” << endl;
// Implement any action needed (e.g., alerting, blocking)
}
}
The Attacker Node mimics adversarial behaviour, like trying to breach fog node security, launch a DDoS attack, or inject malicious data.
Attacker Node Implementation
#include <omnetpp.h>
#include “inet/applications/tcpapp/TcpAppBase.h”
using namespace omnetpp;
using namespace inet;
class AttackerNode : public TcpAppBase
{
protected:
virtual void initialize(int stage) override;
virtual void handleMessageWhenUp(cMessage *msg) override;
void launchDataBreach();
void launchDDoSAttack();
};
Define_Module(AttackerNode);
void AttackerNode::initialize(int stage)
{
TcpAppBase::initialize(stage);
if (stage == inet::INITSTAGE_APPLICATION_LAYER) {
scheduleAt(simTime() + 2, new cMessage(“launchDataBreach”));
scheduleAt(simTime() + 5, new cMessage(“launchDDoSAttack”));
}
}
void AttackerNode::handleMessageWhenUp(cMessage *msg)
{
if (strcmp(msg->getName(), “launchDataBreach”) == 0) {
launchDataBreach();
delete msg;
} else if (strcmp(msg->getName(), “launchDDoSAttack”) == 0) {
launchDDoSAttack();
delete msg;
} else {
TcpAppBase::handleMessageWhenUp(msg);
}
}
void AttackerNode::launchDataBreach()
{
EV << “Launching data breach attempt…” << endl;
// Send a malicious packet to the fog node or cloud server
Packet *packet = new Packet(“DataBreachAttempt”);
packet->insertAtBack(makeShared<Chunk>(std::vector<int>{999, 999, 999})); // Example malicious data
sendToUDP(packet, localPort, Ipv4AddressResolver().resolve(“fogNode1”), 5000);
}
void AttackerNode::launchDDoSAttack()
{
EV << “Launching DDoS attack on fog node…” << endl;
for (int i = 0; i < 100; i++) {
Packet *packet = new Packet(“DDoSPacket”);
sendToUDP(packet, localPort, Ipv4AddressResolver().resolve(“fogNode1”), 5000);
}
}
Add the fog nodes, cloud servers, firewall, IDS, edge devices, and attacker node into the network to build a complete Fog Computing security simulation.
network FogComputingNetwork
{
submodules:
edgeDevice1: EdgeDevice {
@display(“p=100,150”);
}
edgeDevice2: EdgeDevice {
@display(“p=100,250”);
}
fogNode1: FogNode {
@display(“p=300,150”);
}
fogNode2: FogNode {
@display(“p=300,250”);
}
cloudServer: CloudServer {
@display(“p=500,200”);
}
firewall: FirewallModule {
@display(“p=200,100”);
}
ids: IDSModule {
@display(“p=400,100”);
}
attacker: AttackerNode {
@display(“p=600,250”);
}
}
connections:
edgeDevice1.ethg++ <–> Eth100M <–> fogNode1.ethg++;
edgeDevice2.ethg++ <–> Eth100M <–> fogNode2.ethg++;
fogNode1.ethg++ <–> Eth100M <–> firewall.ethg++;
fogNode2.ethg++ <–> Eth100M <–> firewall.ethg++;
firewall.ethg++ <–> Eth100M <–> ids.ethg++;
ids.ethg++ <–> Eth100M <–> cloudServer.ethg++;
attacker.wlan++ <–> Adhoc80211Nic <–> fogNode1.wlan++;
}
Compile and run the simulation in OMNeT++. In the fog environment, network would securely manage data processing and storage, during detecting and mitigating any adversarial activities according to the implemented functionality.
Verify the OMNeT++ simulation log to monitor how the network managed data, detected intrusions, and defended against attacks. Check that:
We can extend this setup by:
In this paper, we had presented details about how to implement Fog computing security in the tool OMNeT++. Additional informations will be given according to your needs.