To implement the Optimized Link State Routing (OLSR) protocol in OMNeT++ has numerous steps which is setting up the environment, understanding the protocol, creating the OLSR module, integrating it with the INET framework, and testing it. In the below, we provided the step-by-step process on how to implement OLSR in OMNeT++:
Step-by-Step Implementation:
Step 1: Set Up OMNeT++ and INET Framework
Step 2: Understand OLSR Protocol
OLSR is a proactive routing protocol for mobile ad hoc networks (MANETs). Key topics to comprehend:
Step 3: Explore Existing Implementations
INET framework has multiple implementations of routing protocols. Studying these can provide insights into creating the OLSR implementation. The implementation will involve handling OLSR-specific messages and maintaining routing tables.
Step 4: Create OLSR Module
Define the Module in .ned File
Generate a .ned file for the OLSR module.
simple OLSR
{
parameters:
double helloInterval @unit(s) = default(2s);
double tcInterval @unit(s) = default(5s);
gates:
input in[];
output out[];
}
Implement the Module in C++
Create the corresponding .cc and .h files.
OLSR.h
#ifndef __OLSR_H_
#define __OLSR_H_
#include <omnetpp.h>
#include “inet/networklayer/contract/IRoutingTable.h”
#include “inet/networklayer/common/L3AddressResolver.h”
#include “inet/common/INETDefs.h”
#include “inet/networklayer/ipv4/IPv4Datagram.h”
using namespace omnetpp;
using namespace inet;
class OLSR : public cSimpleModule
{
private:
double helloInterval;
double tcInterval;
IRoutingTable *routingTable;
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
void sendHelloMessage();
void sendTcMessage();
void processHelloMessage(cMessage *msg);
void processTcMessage(cMessage *msg);
public:
OLSR();
virtual ~OLSR();
};
#endif
OLSR.cc
#include “OLSR.h”
Define_Module(OLSR);
OLSR::OLSR() {}
OLSR::~OLSR() {}
void OLSR::initialize()
{
helloInterval = par(“helloInterval”);
tcInterval = par(“tcInterval”);
routingTable = getModuleFromPar<IRoutingTable>(par(“routingTableModule”), this);
scheduleAt(simTime() + helloInterval, new cMessage(“sendHello”));
scheduleAt(simTime() + tcInterval, new cMessage(“sendTc”));
}
void OLSR::handleMessage(cMessage *msg)
{
if (strcmp(msg->getName(), “sendHello”) == 0)
{
sendHelloMessage();
scheduleAt(simTime() + helloInterval, msg);
}
else if (strcmp(msg->getName(), “sendTc”) == 0)
{
sendTcMessage();
scheduleAt(simTime() + tcInterval, msg);
}
else if (strcmp(msg->getName(), “Hello”) == 0)
{
processHelloMessage(msg);
}
else if (strcmp(msg->getName(), “TC”) == 0)
{
processTcMessage(msg);
}
else
{
// Handle other message types
}
}
void OLSR::sendHelloMessage()
{
cMessage *helloMsg = new cMessage(“Hello”);
send(helloMsg, “out”);
}
void OLSR::sendTcMessage()
{
cMessage *tcMsg = new cMessage(“TC”);
send(tcMsg, “out”);
}
void OLSR::processHelloMessage(cMessage *msg)
{
// Implement processing of Hello message
delete msg;
}
void OLSR::processTcMessage(cMessage *msg)
{
// Implement processing of TC message
delete msg;
}
Step 5: Integrate with Simulation Model
Assimilate the OLSR module into a network simulation model.
Network Configuration .ned File
network OLSRNetwork
{
submodules:
host1: StandardHost {
parameters:
@display(“p=100,100”);
routingTableModule = “^.routingTable”;
}
host2: StandardHost {
parameters:
@display(“p=300,100”);
routingTableModule = “^.routingTable”;
}
connections:
host1.pppg++ <–> { @display(“m=100,100”); } <–> host2.pppg++;
}
omnetpp.ini Configuration
network = OLSRNetwork
*.host1.ipv4Routing = “inet.networklayer.ipv4.IPv4Routing”
*.host2.ipv4Routing = “inet.networklayer.ipv4.IPv4Routing”
*.host1.ipRoutingTableModule = “host1.routingTable”
*.host2.ipRoutingTableModule = “host2.routingTable”
*.host1.olSr = “OLSR”
*.host2.olSr = “OLSR”
Step 6: Test and Debug
In conclusion, we offered a step-by-step process that helps you to understand how to set up the OLSR and how to work using the INET framework and how to implement them. If you have any doubts regarding this topic reach out to us, we will clarify them.
We offer full assistance with simulation outcomes for the implementation of the OLSR protocol in the OMNeT++ tool.