To implement the mesh protocols in OMNeT++ needs a module which has to simulate the characteristics of routing protocols specially build for wireless mesh network. The mesh protocols include AODV (Ad hoc On-Demand Distance Vector), HWMP (Hybrid Wireless Mesh Protocol), and others. We provided the step-by-step approach to implement the mesh protocols in OMNeT++:
Step-by-Step implementation:
Step 1: Set Up OMNeT++ and INET Framework
Step 2: Understand HWMP Protocol
HWMP syndicating both proactive and reactive elements:
Step 3: Create the HWMP Protocol Module
Define the Module in .ned File
Create a .ned file for the HWMP protocol module.
simple HWMP
{
parameters:
@display(“i=block/cogwheel”);
double proactiveInterval @unit(s) = default(5s); // Interval for proactive PREQ messages
gates:
input fromNetworkLayer;
output toNetworkLayer;
input fromMacLayer;
output toMacLayer;
}
Implement the Module in C++
Generate the corresponding .cc and .h files.
HWMP.h
#ifndef __HWMP_H_
#define __HWMP_H_
#include <omnetpp.h>
#include “inet/networklayer/contract/IRoutingTable.h”
#include “inet/common/INETDefs.h”
#include “inet/networklayer/common/L3AddressResolver.h”
#include <map>
#include <set>
using namespace omnetpp;
using namespace inet;
class HWMP : public cSimpleModule
{
private:
double proactiveInterval;
IRoutingTable *routingTable;
cMessage *proactiveMsg;
std::map<L3Address, L3Address> routeTable; // Maps destination to next hop
std::map<L3Address, int> metricTable; // Stores path metrics
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
void sendProactivePREQ();
void processProactivePREQ(cMessage *msg);
void sendRREQ(L3Address destAddr);
void processRREQ(cMessage *msg);
void sendRREP(L3Address destAddr);
void processRREP(cMessage *msg);
void processRERR(cMessage *msg);
public:
HWMP();
virtual ~HWMP();
};
#endif
HWMP.cc
#include “HWMP.h”
Define_Module(HWMP);
HWMP::HWMP()
{
proactiveMsg = nullptr;
}
HWMP::~HWMP()
{
cancelAndDelete(proactiveMsg);
}
void HWMP::initialize()
{
proactiveInterval = par(“proactiveInterval”);
routingTable = getModuleFromPar<IRoutingTable>(par(“routingTableModule”), this);
proactiveMsg = new cMessage(“sendProactivePREQ”);
scheduleAt(simTime() + proactiveInterval, proactiveMsg);
}
void HWMP::handleMessage(cMessage *msg)
{
if (msg == proactiveMsg)
{
sendProactivePREQ();
scheduleAt(simTime() + proactiveInterval, proactiveMsg);
}
else if (strcmp(msg->getName(), “ProactivePREQ”) == 0)
{
processProactivePREQ(msg);
}
else if (strcmp(msg->getName(), “RREQ”) == 0)
{
processRREQ(msg);
}
else if (strcmp(msg->getName(), “RREP”) == 0)
{
processRREP(msg);
}
else if (strcmp(msg->getName(), “RERR”) == 0)
{
processRERR(msg);
}
else if (dynamic_cast<cPacket *>(msg))
{
// Handle incoming data packets
L3Address dest = L3AddressResolver().resolve(msg->par(“destAddr”).stringValue());
if (routeTable.find(dest) != routeTable.end())
{
// Forward the packet to the next hop
send(msg, “toMacLayer”);
}
else
{
// Drop the packet if no route found
delete msg;
}
}
else
{
// Handle other messages
}
}
void HWMP::sendProactivePREQ()
{
cMessage *preq = new cMessage(“ProactivePREQ”);
send(preq, “toMacLayer”);
}
void HWMP::processProactivePREQ(cMessage *msg)
{
// Process received proactive PREQ message
delete msg;
}
void HWMP::sendRREQ(L3Address destAddr)
{
cMessage *rreq = new cMessage(“RREQ”);
rreq->addPar(“destAddr”) = destAddr.str().c_str();
send(rreq, “toMacLayer”);
}
void HWMP::processRREQ(cMessage *msg)
{
// Implement processing of RREQ message
L3Address srcAddr = L3AddressResolver().resolve(msg->par(“srcAddr”).stringValue());
L3Address destAddr = L3AddressResolver().resolve(msg->par(“destAddr”).stringValue());
if (routeTable.find(destAddr) != routeTable.end())
{
sendRREP(destAddr);
}
else
{
// Forward the RREQ
send(msg, “toMacLayer”);
}
}
void HWMP::sendRREP(L3Address destAddr)
{
cMessage *rrep = new cMessage(“RREP”);
rrep->addPar(“destAddr”) = destAddr.str().c_str();
send(rrep, “toMacLayer”);
}
void HWMP::processRREP(cMessage *msg)
{
// Implement processing of RREP message
L3Address destAddr = L3AddressResolver().resolve(msg->par(“destAddr”).stringValue());
L3Address nextHop = L3AddressResolver().resolve(msg->par(“nextHop”).stringValue());
int metric = msg->par(“metric”).intValue();
routeTable[destAddr] = nextHop;
metricTable[destAddr] = metric;
delete msg;
}
void HWMP::processRERR(cMessage *msg)
{
// Implement processing of RERR message
L3Address destAddr = L3AddressResolver().resolve(msg->par(“destAddr”).stringValue());
routeTable.erase(destAddr);
metricTable.erase(destAddr);
delete msg;
}
Step 4: Integrate with Simulation Model
Assimilate the HWMP module within the network simulation model.
Network Configuration .ned File
network HWMPNetwork
{
submodules:
node1: StandardHost {
parameters:
@display(“p=100,100”);
}
node2: StandardHost {
parameters:
@display(“p=300,100”);
}
// Add more nodes as needed
connections:
node1.pppg++ <–> { @display(“m=100,100”); } <–> node2.pppg++;
}
omnetpp.ini Configuration
network = HWMPNetwork
*.node*.pppg[*].queue.typename = “DropTailQueue”
*.node*.ipv4.routingTable = “inet.networklayer.routing.manet.Router”
*.node*.networkLayer.networkProtocol.typename = “IPv4NetworkLayer”
*.node*.transportLayer.tcp.typename = “Tcp”
*.node*.transportLayer.udp.typename = “Udp”
*.node*.application[*].typename = “UdpBasicApp”
*.node*.application[*].destAddresses = “node1” // Set destination as needed
*.node*.application[*].destPort = 2000
*.node*.application[*].startTime = uniform(0s, 10s)
*.node*.application[*].sendInterval = uniform(1s, 2s)
*.node*.application[*].packetLength = 512B
*.node*.app[0].typename = “HWMP”
Step 5: Test and Debug
Step 6: Extend to Other Mesh Protocols
To accomplish other mesh protocols like AODV, OLSR, etc., follow the provided steps:
This procedure will guide you through the process of implementing a basic mesh protocol, specifically HWMP, which is part of the IEEE 802.11s standard for mesh networking. For further references, we can help you by providing materials. For best simulation results be on touch with us we will help you more.