To implement the Fisheye State Routing (FSR) protocol in OMNeT++ encompasses fashioning units that simulate the actions of FSR. It is a hands-on routing protocol calculated for transportable ad hoc networks (MANETs) and by using a fisheye technique to diminish directing table size and control above. The following stages is to implement FSR in OMNeT++ by using the INET framework:
Step-by-Step Implementations:
Step 1: Set Up OMNeT++ and INET Framework
Step 2: Define the FSR Protocol
Produce the .ned and C++ files for the FSR protocol module.
Define the Module in .ned File
To generate a .ned file for the FSR protocol module.
simple FSR
{
parameters:
@display(“i=block/router”);
double updateInterval @unit(s) = default(1s); // Interval for updating routing tables
int maxHopCount = default(5); // Maximum hop count for fisheye scope
gates:
input fromNetworkLayer;
output toNetworkLayer;
input fromMacLayer;
output toMacLayer;
}
Step 3: Implement the FSR Protocol in C++
Make the corresponding .cc and .h files.
FSR.h
#ifndef __FSR_H_
#define __FSR_H_
#include <omnetpp.h>
#include “inet/common/INETDefs.h”
#include “inet/networklayer/contract/IRoutingTable.h”
#include “inet/networklayer/contract/IInterfaceTable.h”
#include “inet/networklayer/ipv4/Ipv4Header_m.h”
#include “inet/networklayer/ipv4/Ipv4Route.h”
#include “inet/networklayer/common/L3AddressResolver.h”
#include <map>
#include <vector>
using namespace omnetpp;
using namespace inet;
class FSR : public cSimpleModule
{
private:
double updateInterval;
int maxHopCount;
IRoutingTable *routingTable;
IInterfaceTable *interfaceTable;
cMessage *updateMsg;
std::map<L3Address, std::map<int, std::vector<L3Address>>> fisheyeTable; // Stores fisheye routing tables
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
void sendUpdate();
void processUpdate(cPacket *packet);
void handleUpperLayerPacket(cPacket *packet);
void handleLowerLayerPacket(cPacket *packet);
void forwardPacket(Ipv4Header *ipHeader, cPacket *packet);
void updateRoutingTable();
public:
FSR();
virtual ~FSR();
};
#endif
FSR.cc
#include “FSR.h”
Define_Module(FSR);
FSR::FSR()
{
updateMsg = nullptr;
}
FSR::~FSR()
{
cancelAndDelete(updateMsg);
}
void FSR::initialize()
{
updateInterval = par(“updateInterval”);
maxHopCount = par(“maxHopCount”);
routingTable = getModuleFromPar<IRoutingTable>(par(“routingTableModule”), this);
interfaceTable = getModuleFromPar<IInterfaceTable>(par(“interfaceTableModule”), this);
updateMsg = new cMessage(“sendUpdate”);
scheduleAt(simTime() + updateInterval, updateMsg);
}
void FSR::handleMessage(cMessage *msg)
{
if (msg == updateMsg)
{
sendUpdate();
scheduleAt(simTime() + updateInterval, updateMsg);
}
else if (msg->arrivedOn(“fromNetworkLayer”))
{
handleUpperLayerPacket(check_and_cast<cPacket *>(msg));
}
else if (msg->arrivedOn(“fromMacLayer”))
{
handleLowerLayerPacket(check_and_cast<cPacket *>(msg));
}
else
{
delete msg;
}
}
void FSR::sendUpdate()
{
cPacket *updatePacket = new cPacket(“RoutingUpdate”);
// Add routing information to the update packet
for (auto &entry : fisheyeTable)
{
for (int i = 0; i <= maxHopCount; ++i)
{
if (!entry.second[i].empty())
{
updatePacket->addPar(entry.first.str().c_str()) = i;
}
}
}
send(updatePacket, “toMacLayer”);
updateRoutingTable();
}
void FSR::processUpdate(cPacket *packet)
{
// Process received routing update packet
for (int i = 0; i < packet->getParList().size(); ++i)
{
const char *key = packet->getParList().get(i).getName();
int hopCount = packet->par(key).intValue();
L3Address addr(key);
if (hopCount <= maxHopCount)
{
fisheyeTable[addr][hopCount].push_back(addr);
}
}
delete packet;
updateRoutingTable();
}
void FSR::handleUpperLayerPacket(cPacket *packet)
{
Ipv4Header *ipHeader = new Ipv4Header();
ipHeader->setSrcAddress(interfaceTable->getInterface(0)->getIpv4Address());
ipHeader->setDestAddress(packet->par(“destAddr”).stringValue());
packet->insertAtFront(ipHeader);
forwardPacket(ipHeader, packet);
}
void FSR::handleLowerLayerPacket(cPacket *packet)
{
Ipv4Header *ipHeader = check_and_cast<Ipv4Header *>(packet->removeAtFront<Ipv4Header>());
if (ipHeader->getDestAddress() == interfaceTable->getInterface(0)->getIpv4Address())
{
send(packet, “toNetworkLayer”);
}
else
{
forwardPacket(ipHeader, packet);
}
}
void FSR::forwardPacket(Ipv4Header *ipHeader, cPacket *packet)
{
Ipv4Route *route = routingTable->findBestMatchingRoute(ipHeader->getDestAddress());
if (route)
{
send(packet, “toMacLayer”);
}
else
{
delete packet;
}
}
void FSR::updateRoutingTable()
{
// Update the routing table based on fisheyeTable
for (auto &entry : fisheyeTable)
{
for (int i = 0; i <= maxHopCount; ++i)
{
if (!entry.second[i].empty())
{
Ipv4Route *route = new Ipv4Route();
route->setDestination(entry.first.toIpv4());
route->setMetric(i);
routingTable->addRoute(route);
break;
}
}
}
}
Step 4: Integrate with Simulation Model
Add the FSR module into a network simulation model.
Network Configuration .ned File
To build a .ned file to define the network topology.
network FSRNetwork
{
parameters:
@display(“bgb=600,400”);
submodules:
node1: StandardHost {
parameters:
@display(“p=100,100”);
}
node2: StandardHost {
parameters:
@display(“p=300,100”);
}
node3: StandardHost {
parameters:
@display(“p=500,100”);
}
node4: StandardHost {
parameters:
@display(“p=100,300”);
}
node5: StandardHost {
parameters:
@display(“p=300,300”);
}
node6: StandardHost {
parameters:
@display(“p=500,300”);
}
connections:
node1.pppg++ <–> Eth10M <–> node2.pppg++;
node2.pppg++ <–> Eth10M <–> node3.pppg++;
node1.pppg++ <–> Eth10M <–> node4.pppg++;
node4.pppg++ <–> Eth10M <–> node5.pppg++;
node5.pppg++ <–> Eth10M <–> node6.pppg++;
node2.pppg++ <–> Eth10M <–> node5.pppg++;
// Add more connections as needed to form a mesh network
}
Step 5: Configure the Simulation
Organise the simulation parameters in the omnetpp.ini file.
[General]
network = FSRNetwork
**.pppg[*].queue.typename = “DropTailQueue”
**.ipv4.routingTable = “inet.networklayer.routing.manet.Router”
**.networkLayer.networkProtocol.typename = “Ipv4NetworkLayer”
**.transportLayer.tcp.typename = “Tcp”
**.transportLayer.udp.typename = “Udp”
**.application[*].typename = “UdpBasicApp”
**.application[*].destAddresses = “node1” // Set destination as needed
**.application[*].destPort = 2000
**.application[*].startTime = uniform(0s, 10s)
**.application[*].sendInterval = uniform(1s, 2s)
**.application[*].packetLength = 512B
**.app[0].typename = “FSR”
Step 6: Test and Debug
Throughout the scripts, we are reveal about how to implement FSR Protocol in OMNeT++. We offer more details about to implement the FSR Protocol in OMNeT++. We implement the fsr protocol in the OMNeT++ program for your projects, so feel free to message us for guidance. We can help you achieve the best simulation results. Our hands-on routing protocol, designed for mobile ad hoc networks (MANETs) using a fisheye technique, is also available for your projects. Get top-notch project performance results with our assistance.