To implement the IPv6 protocols in OMNeT++ is encompasses to producing a module that to handle the IPv6 packet forwarding, addressing, and routing functionalities. Complete provision for IPv6 provided by the INET framework. To need to employ or extend the own version of an IPv6 protocol is to help the step-by-step process.
Step-by-Step Implementations:
Step 1: Set Up OMNeT++ and INET Framework
Step 2: Define the IPv6 Protocol
To make an essential .ned and C++ files for the IPv6 protocol module.
Define the Module in .ned File
Create a .ned file for the IPv6 protocol module.
simple IPv6
{
parameters:
@display(“i=block/layer3”);
gates:
input fromNetworkLayer;
output toNetworkLayer;
input fromMacLayer;
output toMacLayer;
}
Step 3: Implement the IPv6 Protocol in C++
Make the corresponding .cc and .h files.
IPv6.h
#ifndef __IPV6_H_
#define __IPV6_H_
#include <omnetpp.h>
#include “inet/common/INETDefs.h”
#include “inet/networklayer/contract/IRoutingTable.h”
#include “inet/networklayer/contract/IInterfaceTable.h”
#include “inet/networklayer/ipv6/Ipv6Header_m.h”
#include “inet/networklayer/ipv6/Ipv6Route.h”
#include “inet/networklayer/common/L3AddressResolver.h”
#include <map>
using namespace omnetpp;
using namespace inet;
class IPv6 : public cSimpleModule
{
private:
IRoutingTable *routingTable;
IInterfaceTable *interfaceTable;
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
void handleUpperLayerPacket(cPacket *packet);
void handleLowerLayerPacket(cPacket *packet);
void forwardPacket(Ipv6Header *ipHeader, cPacket *packet);
public:
IPv6();
virtual ~IPv6();
};
#endif
IPv6.cc
#include “IPv6.h”
Define_Module(IPv6);
IPv6::IPv6()
{
}
IPv6::~IPv6()
{
}
void IPv6::initialize()
{
routingTable = getModuleFromPar<IRoutingTable>(par(“routingTableModule”), this);
interfaceTable = getModuleFromPar<IInterfaceTable>(par(“interfaceTableModule”), this);
}
void IPv6::handleMessage(cMessage *msg)
{
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 IPv6::handleUpperLayerPacket(cPacket *packet)
{
Ipv6Header *ipHeader = new Ipv6Header();
ipHeader->setSrcAddress(interfaceTable->getInterface(0)->getIpv6Address());
ipHeader->setDestAddress(packet->par(“destAddr”).stringValue());
packet->insertAtFront(ipHeader);
forwardPacket(ipHeader, packet);
}
void IPv6::handleLowerLayerPacket(cPacket *packet)
{
Ipv6Header *ipHeader = check_and_cast<Ipv6Header *>(packet->removeAtFront<Ipv6Header>());
if (ipHeader->getDestAddress() == interfaceTable->getInterface(0)->getIpv6Address())
{
send(packet, “toNetworkLayer”);
}
else
{
forwardPacket(ipHeader, packet);
}
}
void IPv6::forwardPacket(Ipv6Header *ipHeader, cPacket *packet)
{
Ipv6Route *route = routingTable->findBestMatchingRoute(ipHeader->getDestAddress());
if (route)
{
send(packet, “toMacLayer”);
}
else
{
delete packet;
}
}
Step 4: Integrate with Simulation Model
Integrate the IPv6 module into a network simulation model.
Network Configuration .ned File
Form a .ned file to explain the network topology.
network IPv6Network
{
parameters:
@display(“bgb=600,400”);
submodules:
host1: StandardHost {
parameters:
@display(“p=100,200”);
}
host2: StandardHost {
parameters:
@display(“p=300,200”);
}
router: Router {
parameters:
@display(“p=200,100”);
}
connections:
host1.pppg++ <–> Eth10M <–> router.pppg++;
host2.pppg++ <–> Eth10M <–> router.pppg++;
}
Step 5: Configure the Simulation
Configure the simulation parameters in the omnetpp.ini file.
[General]
network = IPv6Network
*.host*.pppg[*].queue.typename = “DropTailQueue”
*.host*.ipv6.routingTable = “inet.networklayer.routing.manet.Router”
*.host*.networkLayer.networkProtocol.typename = “Ipv6NetworkLayer”
*.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
*.router.app[0].typename = “IPv6”
Step 6: Test and Debug
Finally, now we are complete to learn about how to implement the IPv6 protocols is provided by INET framework in OMNeT++ tool. We provided further project topics guidance an implementation support for your reasech area, share with us all your details for best results.