To implement the Ad hoc On-Demand Multipath Distance Vector (AOMDV) routing protocol in OMNeT++ has numerous steps. AOMDV is an extension of the AODV protocol that discovers various routes amongst the source and destination to optimize the reliability and load balancing in mobile ad hoc networks (MANETs). Here’s a detailed guide to help you implement AOMDV in OMNeT++ using the INET framework.
Step-by-Step Implementation:
Step 1: Set Up OMNeT++ and INET Framework
Step 2: Understand AOMDV Protocol
AOMDV extends AODV by maintaining various loop-free and link-disjoint paths. Key concepts include:
Step 3: Create the AOMDV Protocol Module
Define the Module in .ned File
Create a .ned file for the AOMDV protocol module.
simple AOMDV
{
parameters:
@display(“i=block/cogwheel”);
double helloInterval @unit(s) = default(1s);
double rreqTimeout @unit(s) = default(2s);
gates:
input fromNetworkLayer;
output toNetworkLayer;
input fromMacLayer;
output toMacLayer;
}
Implement the Module in C++
Create the corresponding .cc and .h files.
AOMDV.h
#ifndef __AOMDV_H_
#define __AOMDV_H_
#include <omnetpp.h>
#include “inet/networklayer/contract/IRoutingTable.h”
#include “inet/networklayer/common/L3AddressResolver.h”
#include “inet/networklayer/ipv4/IPv4Datagram.h”
#include <map>
#include <vector>
using namespace omnetpp;
using namespace inet;
class AOMDV : public cSimpleModule
{
private:
double helloInterval;
double rreqTimeout;
IRoutingTable *routingTable;
cMessage *helloMsg;
cMessage *rreqTimeoutMsg;
std::map<L3Address, std::vector<L3Address>> routeCache; // Cache for multiple routes
std::map<L3Address, int> rreqRetries; // Retries for RREQs
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, L3Address nextHop);
void processRREP(cMessage *msg);
void processRERR(cMessage *msg);
public:
AOMDV();
virtual ~AOMDV();
};
#endif
AOMDV.cc
#include “AOMDV.h”
Define_Module(AOMDV);
AOMDV::AOMDV()
{
helloMsg = nullptr;
rreqTimeoutMsg = nullptr;
}
AOMDV::~AOMDV()
{
cancelAndDelete(helloMsg);
cancelAndDelete(rreqTimeoutMsg);
}
void AOMDV::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 AOMDV::handleMessage(cMessage *msg)
{
if (msg == helloMsg)
{
sendHello();
scheduleAt(simTime() + helloInterval, helloMsg);
}
else if (msg == rreqTimeoutMsg)
{
// Handle RREQ timeout and retries
scheduleAt(simTime() + rreqTimeout, rreqTimeoutMsg);
}
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 (strcmp(msg->getName(), “Hello”) == 0)
{
processHello(msg);
}
else
{
// Handle other messages
}
}
void AOMDV::sendHello()
{
cMessage *hello = new cMessage(“Hello”);
send(hello, “toMacLayer”);
}
void AOMDV::processHello(cMessage *msg)
{
// Implement processing of Hello message
delete msg;
}
void AOMDV::sendRREQ(L3Address destAddr)
{
cMessage *rreq = new cMessage(“RREQ”);
rreq->addPar(“destAddr”) = destAddr.str().c_str();
send(rreq, “toMacLayer”);
}
void AOMDV::processRREQ(cMessage *msg)
{
// Implement processing of RREQ message
L3Address srcAddr = L3AddressResolver().resolve(msg->par(“srcAddr”).stringValue());
L3Address destAddr = L3AddressResolver().resolve(msg->par(“destAddr”).stringValue());
// Add route discovery logic for multiple paths
delete msg;
}
void AOMDV::sendRREP(L3Address destAddr, L3Address nextHop)
{
cMessage *rrep = new cMessage(“RREP”);
rrep->addPar(“destAddr”) = destAddr.str().c_str();
rrep->addPar(“nextHop”) = nextHop.str().c_str();
send(rrep, “toMacLayer”);
}
void AOMDV::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 update logic for multiple paths
delete msg;
}
void AOMDV::processRERR(cMessage *msg)
{
// Implement processing of RERR message
delete msg;
}
Step 4: Integrate with Simulation Model
Integrate the AOMDV module into a network simulation model.
Network Configuration .ned File
network AOMDVNetwork
{
submodules:
host1: StandardHost {
parameters:
@display(“p=100,100”);
}
host2: StandardHost {
parameters:
@display(“p=300,100”);
}
// Add more hosts as needed
connections:
host1.pppg++ <–> { @display(“m=100,100”); } <–> host2.pppg++;
}
omnetpp.ini Configuration
network = AOMDVNetwork
*.host*.pppg[*].queue.typename = “DropTailQueue”
*.host*.ipv4.routingTable = “inet.networklayer.routing.manet.Router”
*.host*.networkLayer.networkProtocol.typename = “IPv4NetworkLayer”
*.host*.transportLayer.tcp.typename = “Tcp”
*.host*.transportLayer.udp.typename = “Udp”
*.host*.application[*].typename = “UdpBasicApp”
*.host*.application[*].destAddresses = “host1” // Set destination as needed
*.host*.application[*].destPort = 2000
*.host*.application[*].startTime = uniform(0s, 10s)
*.host*.application[*].sendInterval = uniform(1s, 2s)
*.host*.application[*].packetLength = 512B
*.host*.app[0].typename = “AOMDV”
Step 5: Test and Debug
In conclusion, this demonstration has the useful insights on how to extend and implement the AOMDV, INET framework in the OMNeT++. If you need simulation and performance analysis on about AODV, we can offer them.