To implement a routing interface protocol in OMNeT++ has encompasses to generate a module that manage the communication among various routing protocols and the network layer. It acts as an interface that needs to permits the routing protocols to communicate with the network stack, manage the route updates, and forward packets consequently. For comparison analysis of your projects ,share with us all your project details we will guide you more.
The given below is the procedure to execute the basic routing interface protocol in OMNeT++ using the INET framework.
Step-by-Step Implementation:
Step 1: Set Up OMNeT++ and INET Framework
Step 2: Define the Routing Interface Protocol
Define the Module in .ned File
Create a .ned file for the routing interface protocol module.
simple RoutingInterface
{
parameters:
@display(“i=block/router”);
gates:
input fromRoutingProtocol;
output toRoutingProtocol;
input fromNetworkLayer;
output toNetworkLayer;
input fromMacLayer;
output toMacLayer;
}
Implement the Module in C++
Generate the corresponding .cc and .h files.
RoutingInterface.h
#ifndef __ROUTINGINTERFACE_H_
#define __ROUTINGINTERFACE_H_
#include <omnetpp.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/common/INETDefs.h”
#include <map>
using namespace omnetpp;
using namespace inet;
class RoutingInterface : public cSimpleModule
{
private:
IRoutingTable *routingTable;
IInterfaceTable *interfaceTable;
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
void handleRoutingUpdate(cMessage *msg);
void handleUpperLayerPacket(cPacket *packet);
void handleLowerLayerPacket(cPacket *packet);
void forwardPacket(Ipv4Header *ipHeader, cPacket *packet);
public:
RoutingInterface();
virtual ~RoutingInterface();
};
#endif
RoutingInterface.cc
#include “RoutingInterface.h”
Define_Module(RoutingInterface);
RoutingInterface::RoutingInterface()
{
}
RoutingInterface::~RoutingInterface()
{
}
void RoutingInterface::initialize()
{
routingTable = getModuleFromPar<IRoutingTable>(par(“routingTableModule”), this);
interfaceTable = getModuleFromPar<IInterfaceTable>(par(“interfaceTableModule”), this);
}
void RoutingInterface::handleMessage(cMessage *msg)
{
if (msg->arrivedOn(“fromRoutingProtocol”))
{
handleRoutingUpdate(msg);
}
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 RoutingInterface::handleRoutingUpdate(cMessage *msg)
{
// Process routing update message
for (int i = 0; i < msg->getParList().size(); ++i)
{
const char *key = msg->getParList().get(i).getName();
L3Address addr(key);
int metric = msg->par(key).intValue();
Ipv4Route *route = new Ipv4Route();
route->setDestination(addr.toIpv4());
route->setMetric(metric);
routingTable->addRoute(route);
}
delete msg;
}
void RoutingInterface::handleUpperLayerPacket(cPacket *packet)
{
Ipv4Header *ipHeader = new Ipv4Header();
ipHeader->setSrcAddress(interfaceTable->getInterface(0)->getIpv4Address());
ipHeader->setDestAddress(packet->getPar(“destAddr”).stringValue());
packet->insertAtFront(ipHeader);
forwardPacket(ipHeader, packet);
}
void RoutingInterface::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 RoutingInterface::forwardPacket(Ipv4Header *ipHeader, cPacket *packet)
{
Ipv4Route *route = routingTable->findBestMatchingRoute(ipHeader->getDestAddress());
if (route)
{
send(packet, “toMacLayer”);
}
else
{
delete packet;
}
}
Step 3: Integrate with Simulation Model
Incorporate RoutingInterface module inside a network simulation model.
Network Configuration .ned File
Create a .ned file to define the network topology.
network RoutingInterfaceNetwork
{
parameters:
@display(“bgb=600,400”);
submodules:
host1: StandardHost {
parameters:
@display(“p=100,200”);
}
host2: StandardHost {
parameters:
@display(“p=300,200”);
}
router: StandardHost {
parameters:
@display(“p=200,100”);
}
routingInterface: RoutingInterface {
parameters:
@display(“p=200,50”);
}
connections:
host1.ethg++ <–> Eth10M <–> router.ethg++;
host2.ethg++ <–> Eth10M <–> router.ethg++;
router.ethg++ <–> Eth10M <–> routingInterface.fromMacLayer++;
}
Step 4: Configure the Simulation
Configure the simulation parameters in the omnetpp.ini file.
network = RoutingInterfaceNetwork
*.host*.eth[*].mac.typename = “EthernetMac”
*.host*.ipv4.arp.typename = “GlobalArp”
*.host*.ipv4.routingTable.netmaskRoutes = “true”
*.router.eth[*].mac.typename = “EthernetMac”
*.router.eth[*].mac.promiscuous = true
*.host1.ipv4.config = “host1.config”
*.host2.ipv4.config = “host2.config”
*.host1.ipv4.routingTable.netmaskRoutes = “true”
*.host2.ipv4.routingTable.netmaskRoutes = “true”
*.router.app[0].typename = “RoutingInterface”
Step 5: Test and Debug
Here, we successfully implemented and executed the routing interface protocol in OMNeT++ that handles the communication between the several protocols. We will give further information on how the routing interface protocol is executed in alternate simulations.