e-mail address: omnetmanual@gmail.com

Phone number: +91 9444856435

Tel 7639361621

DEFENDER
  • Phd Omnet++ Projects
    • RESEARCH PROJECTS IN OMNET++
  • Network Simulator Research Papers
    • Omnet++ Thesis
    • Phd Omnet++ Projects
    • MS Omnet++ Projects
    • M.Tech Omnet++ Projects
    • Latest Omnet++ Projects
    • 2016 Omnet++ Projects
    • 2015 Omnet++ Projects
  • OMNET INSTALLATION
    • 4G LTE INSTALLATION
    • CASTALIA INSTALLATION
    • INET FRAMEWORK INSTALLATION
    • INETMANET INSTALLATION
    • JDK INSTALLATION
    • LTE INSTALLATION
    • MIXIM INSTALLATION
    • Os3 INSTALLATION
    • SUMO INSTALLATION
    • VEINS INSTALLATION
  • Latest Omnet++ Projects
    • AODV OMNET++ SOURCE CODE
    • VEINS OMNETPP
    • Network Attacks in OMNeT++
    • NETWORK SECURITY OMNET++ PROJECTS
    • Omnet++ Framework Tutorial
      • Network Simulator Research Papers
      • OMNET++ AD-HOC SIMULATION
      • OmneT++ Bandwidth
      • OMNET++ BLUETOOTH PROJECTS
      • OMNET++ CODE WSN
      • OMNET++ LTE MODULE
      • OMNET++ MESH NETWORK PROJECTS
      • OMNET++ MIXIM MANUAL
  • OMNeT++ Projects
    • OMNeT++ OS3 Manual
    • OMNET++ NETWORK PROJECTS
    • OMNET++ ROUTING EXAMPLES
    • OMNeT++ Routing Protocol Projects
    • OMNET++ SAMPLE PROJECT
    • OMNeT++ SDN PROJECTS
    • OMNET++ SMART GRID
    • OMNeT++ SUMO Tutorial
  • OMNET++ SIMULATION THESIS
    • OMNET++ TUTORIAL FOR WIRELESS SENSOR NETWORK
    • OMNET++ VANET PROJECTS
    • OMNET++ WIRELESS BODY AREA NETWORK PROJECTS
    • OMNET++ WIRELESS NETWORK SIMULATION
      • OMNeT++ Zigbee Module
    • QOS OMNET++
    • OPENFLOW OMNETPP
  • Contact

How to Implement cgsr protocol in OMNeT++

To implement the Clusterhead Gateway Switch Routing (CGSR) protocol in OMNeT++, we have to know the protocol’s procedure like setting up the OMNeT++ and INET framework environment, creating the necessary modules, integrating them into the INET framework, and testing. We offered the step-by-step implementation of CGSR protocol in OMNeT++:

Step-by-Step Implementation:

Step 1: Set Up OMNeT++ and INET Framework

  1. Install OMNeT++: Make sure to install the latest version of OMNeT++.
  2. Install INET Framework: Install the INET framework from the INET repository.

Step 2: Understand CGSR Protocol

CGSR is a hierarchical routing protocol for wireless ad hoc networks. To manage the routing within its cluster and gateway nodes to link different clusters, we have to use a clusterhead. The protocol involves the following steps:

  • Cluster Formation: Nodes are organized into clusters, each with a clusterhead.
  • Routing: Data packets are routed via clusterheads and gateway nodes.
  • Clusterhead Change: Handles the dynamic change of clusterheads.

Step 3: Create the CGSR Protocol Module

Define the Module in .ned File

Generate a .ned file for the CGSR protocol module.

simple CGSR

{

parameters:

@display(“i=block/cogwheel”);

double helloInterval @unit(s) = default(1s);

double clusterheadInterval @unit(s) = default(10s);

gates:

input fromNetworkLayer;

output toNetworkLayer;

input fromMacLayer;

output toMacLayer;

}

Implement the Module in C++

Build the corresponding .cc and .h files.

CGSR.h

#ifndef __CGSR_H_

#define __CGSR_H_

#include <omnetpp.h>

#include “inet/networklayer/contract/IRoutingTable.h”

#include “inet/common/geometry/common/Coord.h”

#include “inet/common/geometry/common/GeographicCoordinateSystem.h”

#include <map>

using namespace omnetpp;

using namespace inet;

class CGSR : public cSimpleModule

{

private:

double helloInterval;

double clusterheadInterval;

IRoutingTable *routingTable;

cMessage *helloMsg;

cMessage *clusterheadMsg;

std::map<L3Address, Coord> neighborTable;  // Stores the positions of neighbors

std::map<L3Address, L3Address> clusterTable;  // Maps nodes to their clusterheads

L3Address clusterhead;  // The clusterhead for this node

protected:

virtual void initialize() override;

virtual void handleMessage(cMessage *msg) override;

void sendHello();

void processHello(cMessage *msg);

void sendClusterheadAnnouncement();

void processClusterheadAnnouncement(cMessage *msg);

void handleDataPacket(cPacket *pkt);

void forwardToClusterhead(cPacket *pkt);

void forwardToGateway(cPacket *pkt);

double calculateDistance(const Coord& pos1, const Coord& pos2);

public:

CGSR();

virtual ~CGSR();

};

#endif

CGSR.cc

#include “CGSR.h”

#include “inet/networklayer/common/L3AddressResolver.h”

Define_Module(CGSR);

CGSR::CGSR()

{

helloMsg = nullptr;

clusterheadMsg = nullptr;

}

CGSR::~CGSR()

{

cancelAndDelete(helloMsg);

cancelAndDelete(clusterheadMsg);

}

void CGSR::initialize()

{

helloInterval = par(“helloInterval”);

clusterheadInterval = par(“clusterheadInterval”);

routingTable = getModuleFromPar<IRoutingTable>(par(“routingTableModule”), this);

helloMsg = new cMessage(“sendHello”);

clusterheadMsg = new cMessage(“sendClusterheadAnnouncement”);

scheduleAt(simTime() + helloInterval, helloMsg);

scheduleAt(simTime() + clusterheadInterval, clusterheadMsg);

}

void CGSR::handleMessage(cMessage *msg)

{

if (msg == helloMsg)

{

sendHello();

scheduleAt(simTime() + helloInterval, helloMsg);

}

else if (msg == clusterheadMsg)

{

sendClusterheadAnnouncement();

scheduleAt(simTime() + clusterheadInterval, clusterheadMsg);

}

else if (strcmp(msg->getName(), “Hello”) == 0)

{

processHello(msg);

}

else if (strcmp(msg->getName(), “ClusterheadAnnouncement”) == 0)

{

processClusterheadAnnouncement(msg);

}

else if (dynamic_cast<cPacket *>(msg))

{

handleDataPacket(check_and_cast<cPacket *>(msg));

}

else

{

// Handle other messages

}

}

void CGSR::sendHello()

{

cMessage *hello = new cMessage(“Hello”);

// Add position information to the hello message

Coord myPos = getParentModule()->getSubmodule(“mobility”)->par(“coord”);

hello->addPar(“x”) = myPos.x;

hello->addPar(“y”) = myPos.y;

send(hello, “toMacLayer”);

}

void CGSR::processHello(cMessage *msg)

{

// Process received hello message

L3Address sender = L3AddressResolver().resolve(msg->getSenderModule()->getFullPath().c_str());

Coord senderPos(msg->par(“x”).doubleValue(), msg->par(“y”).doubleValue());

neighborTable[sender] = senderPos;

delete msg;

}

void CGSR::sendClusterheadAnnouncement()

{

cMessage *announcement = new cMessage(“ClusterheadAnnouncement”);

// Add clusterhead information to the message

announcement->addPar(“clusterhead”) = clusterhead.str().c_str();

send(announcement, “toMacLayer”);

}

void CGSR::processClusterheadAnnouncement(cMessage *msg)

{

// Process received clusterhead announcement

L3Address sender = L3AddressResolver().resolve(msg->getSenderModule()->getFullPath().c_str());

L3Address announcedClusterhead = L3AddressResolver().resolve(msg->par(“clusterhead”).stringValue());

clusterTable[sender] = announcedClusterhead;

delete msg;

}

void CGSR::handleDataPacket(cPacket *pkt)

{

// Handle incoming data packets

// Decide whether to forward to clusterhead or gateway

L3Address dest = L3AddressResolver().resolve(pkt->getPar(“destAddr”).stringValue());

 

if (clusterTable.find(dest) != clusterTable.end() && clusterTable[dest] == clusterhead)

{

forwardToClusterhead(pkt);

}

else

{

forwardToGateway(pkt);

}

}

void CGSR::forwardToClusterhead(cPacket *pkt)

{

// Implement forwarding logic to clusterhead

send(pkt, “toMacLayer”);

}

void CGSR::forwardToGateway(cPacket *pkt)

{

// Implement forwarding logic to gateway

send(pkt, “toMacLayer”);

}

double CGSR::calculateDistance(const Coord &pos1, const Coord &pos2)

{

return pos1.distance(pos2);

}

Step 4: Integrate with Simulation Model

In network simulation model, we have to Integrate the CGSR module.

Network Configuration .ned File

network CGSRNetwork

{

submodules:

node1: StandardHost {

parameters:

@display(“p=100,100”);

}

node2: StandardHost {

parameters:

@display(“p=300,100”);

}

// Add more nodes as needed

connections:

node1.pppg++ <–> { @display(“m=100,100”); } <–> node2.pppg++;

}

omnetpp.ini Configuration

network = CGSRNetwork

*.node*.pppg[*].queue.typename = “DropTailQueue”

*.node*.ipv4.routingTable = “inet.networklayer.routing.manet.Router”

*.node*.networkLayer.networkProtocol.typename = “IPv4NetworkLayer”

*.node*.transportLayer.tcp.typename = “Tcp”

*.node*.transportLayer.udp.typename = “Udp”

*.node*.application[*].typename = “UdpBasicApp”

*.node*.application[*].destAddresses = “node1”  // Set destination as needed

*.node*.application[*].destPort = 2000

*.node*.application[*].startTime = uniform(0s, 10s)

*.node*.application[*].sendInterval = uniform(1s, 2s)

*.node*.application[*].packetLength = 512B

*.node*.app[0].typename = “CGSR”

Step 5: Test and Debug

  1. Run Simulations: Implement simulations to test the actions of the CGSR module under different network conditions.
  2. Analyze Results: Verify the correctness and performance of the execution.
  3. Debugging: Use OMNeT++’s debugging tools to troubleshoot any issues.

In this script, we provided the meticulous guide to help you implement CGSR in OMNeT++ using the INET framework. We will any additional information of CGSR or the INET, if you want it. Implementation and simulation of cgsr protocol in OMNeT++ tool are aided by us for all levels of scholars.

Related Topics

  • Network Intrusion Detection Projects
  • Computer Science Phd Topics
  • Iot Thesis Ideas
  • Cyber Security Thesis Topics
  • Network Security Research Topics

designed by OMNeT++ Projects .