To implement the Dynamic MANET On-demand (DYMO) routing protocol in OMNeT++ comprises more than a few stages. This is an on-demand moving protocol for mobile ad hoc networks (MANETs) that customs route request (RREQ) and route reply (RREP) posts to see and uphold routes.
The following is to implementing DYMO in OMNeT++ by using the INET framework.
Step-by-Step Implementations:
Step 1: Set Up OMNeT++ and INET Framework
Step 2: Understand DYMO Protocol
DYMO is an on-demand routing protocol, sense routes are recognised only when desirable. It is includes:
Step 3: Create the DYMO Protocol Module
Define the Module in .ned File
To make a .ned file for the DYMO protocol module.
simple DYMO
{
parameters:
@display(“i=block/cogwheel”);
double helloInterval @unit(s) = default(1s); // Interval for sending hello messages
double rreqTimeout @unit(s) = default(2s); // Timeout for RREQ retries
gates:
input fromNetworkLayer;
output toNetworkLayer;
input fromMacLayer;
output toMacLayer;
}
Implement the Module in C++
To make the corresponding .cc and .h files.
DYMO.h
#ifndef __DYMO_H_
#define __DYMO_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 DYMO : public cSimpleModule
{
private:
double helloInterval;
double rreqTimeout;
IRoutingTable *routingTable;
cMessage *helloMsg;
cMessage *rreqTimeoutMsg;
std::set<L3Address> rreqRetries; // Tracks RREQ retries
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
void sendHello();
void processHello(cMessage *msg);
void sendRREQ(L3Address destAddr);
void processRREQ(cMessage *msg);
void sendRREP(L3Address destAddr);
void processRREP(cMessage *msg);
void processRERR(cMessage *msg);
public:
DYMO();
virtual ~DYMO();
};
#endif
DYMO.cc
#include “DYMO.h”
Define_Module(DYMO);
DYMO::DYMO()
{
helloMsg = nullptr;
rreqTimeoutMsg = nullptr;
}
DYMO::~DYMO()
{
cancelAndDelete(helloMsg);
cancelAndDelete(rreqTimeoutMsg);
}
void DYMO::initialize()
{
helloInterval = par(“helloInterval”);
rreqTimeout = par(“rreqTimeout”);
routingTable = getModuleFromPar<IRoutingTable>(par(“routingTableModule”), this);
helloMsg = new cMessage(“sendHello”);
rreqTimeoutMsg = new cMessage(“rreqTimeout”);
scheduleAt(simTime() + helloInterval, helloMsg);
}
void DYMO::handleMessage(cMessage *msg)
{
if (msg == helloMsg)
{
sendHello();
scheduleAt(simTime() + helloInterval, helloMsg);
}
else if (msg == rreqTimeoutMsg)
{
// Handle RREQ timeout and retries
if (!rreqRetries.empty())
{
for (const auto& destAddr : rreqRetries)
{
sendRREQ(destAddr);
}
}
scheduleAt(simTime() + rreqTimeout, rreqTimeoutMsg);
}
else if (strcmp(msg->getName(), “Hello”) == 0)
{
processHello(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 (routingTable->findBestMatchingRoute(dest))
{
// 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 DYMO::sendHello()
{
cMessage *hello = new cMessage(“Hello”);
send(hello, “toMacLayer”);
}
void DYMO::processHello(cMessage *msg)
{
// Process received hello message
delete msg;
}
void DYMO::sendRREQ(L3Address destAddr)
{
cMessage *rreq = new cMessage(“RREQ”);
rreq->addPar(“destAddr”) = destAddr.str().c_str();
send(rreq, “toMacLayer”);
}
void DYMO::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 (routingTable->findBestMatchingRoute(destAddr))
{
sendRREP(destAddr);
}
else
{
// Forward the RREQ
send(msg, “toMacLayer”);
}
}
void DYMO::sendRREP(L3Address destAddr)
{
cMessage *rrep = new cMessage(“RREP”);
rrep->addPar(“destAddr”) = destAddr.str().c_str();
send(rrep, “toMacLayer”);
}
void DYMO::processRREP(cMessage *msg)
{
// Implement processing of RREP message
L3Address destAddr = L3AddressResolver().resolve(msg->par(“destAddr”).stringValue());
L3Address nextHop = L3AddressResolver().resolve(msg->par(“nextHop”).stringValue());
// Add route to the routing table
Ipv4Route *route = new Ipv4Route();
route->setDestination(destAddr.toIpv4());
route->setNextHop(nextHop.toIpv4());
route->setMetric(1); // Example metric
route->setInterface(routingTable->getInterfaceByAddress(nextHop));
routingTable->addRoute(route);
delete msg;
}
void DYMO::processRERR(cMessage *msg)
{
// Implement processing of RERR message
delete msg;
}
Step 4: Integrate with Simulation Model
To participate the DYMO module into a network simulation model.
Network Configuration .ned File
network DYMONetwork
{
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
[General]
network = DYMONetwork
*.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 = “DYMO”
Step 5: Test and Debug
Throughout the process, we understand how to build a module, and some coding to implement DYMO protocol in OMNeT++.
We’ve set up the DYMO Protocol in OMNeT++ and are excited to share how to get your project running smoothly. Our focus is on mobile ad hoc networks (MANETs), where we handle route request (RREQ) and route reply (RREP) messages, ensuring your projects have solid routing support.