To implement an Exterior Gateway Protocol (EGP) in OMNeT++ encompasses various stages. The Border Gateway Protocol (BGP) is the generally used EGP. Below is the detailed notes to help to implement BGP in OMNeT++ by using the INET framework.
Step-by-Step Implementations:
Step 1: Set Up OMNeT++ and INET Framework
Step 2: Understand BGP and EGP
BGP is a path-vector protocol used for inter-domain routing. BGP routers exchange routing information that includes IP prefixes and their associated attributes. Key concepts include:
Step 3: Create the BGP Protocol Module
Define the Module in .ned File
To build a .ned file for the BGP protocol module.
simple BGP
{
parameters:
double updateInterval @unit(s) = default(30s);
string asId; // Autonomous System ID
gates:
input fromNetworkLayer;
output toNetworkLayer;
input fromPeer;
output toPeer;
}
Implement the Module in C++
To make the corresponding .cc and .h files.
BGP.h
#ifndef __BGP_H_
#define __BGP_H_
#include <omnetpp.h>
#include “inet/networklayer/contract/IRoutingTable.h”
#include “inet/networklayer/common/L3AddressResolver.h”
#include “inet/networklayer/ipv4/IPv4Datagram.h”
#include <map>
using namespace omnetpp;
using namespace inet;
class BGP : public cSimpleModule
{
private:
double updateInterval;
std::string asId;
IRoutingTable *routingTable;
cMessage *updateMsg;
std::map<L3Address, std::string> routingTableMap; // Map to store IP prefixes and next hops
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
void sendRoutingUpdate();
void processRoutingUpdate(cMessage *msg);
void establishPeering();
void processPeeringRequest(cMessage *msg);
public:
BGP();
virtual ~BGP();
};
#endif
BGP.cc
#include “BGP.h”
Define_Module(BGP);
BGP::BGP()
{
updateMsg = nullptr;
}
BGP::~BGP()
{
cancelAndDelete(updateMsg);
}
void BGP::initialize()
{
updateInterval = par(“updateInterval”);
asId = par(“asId”).stringValue();
routingTable = getModuleFromPar<IRoutingTable>(par(“routingTableModule”), this);
updateMsg = new cMessage(“sendRoutingUpdate”);
scheduleAt(simTime() + updateInterval, updateMsg);
establishPeering();
}
void BGP::handleMessage(cMessage *msg)
{
if (msg == updateMsg)
{
sendRoutingUpdate();
scheduleAt(simTime() + updateInterval, updateMsg);
}
else if (strcmp(msg->getName(), “PeeringRequest”) == 0)
{
processPeeringRequest(msg);
}
else
{
processRoutingUpdate(msg);
}
}
void BGP::sendRoutingUpdate()
{
cMessage *update = new cMessage(“RoutingUpdate”);
// Add routing information to the message
for (const auto &entry : routingTableMap)
{
update->addPar(entry.first.str().c_str()) = entry.second.c_str();
}
send(update, “toPeer”);
}
void BGP::processRoutingUpdate(cMessage *msg)
{
// Process received routing update
for (int i = 0; i < msg->getParList().size(); ++i)
{
const char *key = msg->getParList().get(i).getName();
const char *value = msg->par(key).stringValue();
L3Address address(key);
routingTableMap[address] = value;
}
delete msg;
}
void BGP::establishPeering()
{
// Implement peering establishment logic
cMessage *peeringRequest = new cMessage(“PeeringRequest”);
send(peeringRequest, “toPeer”);
}
void BGP::processPeeringRequest(cMessage *msg)
{
// Implement processing of peering request
delete msg;
}
Step 4: Integrate with Simulation Model
Join in the BGP module into a network simulation model.
Network Configuration .ned File
network BGPNetwork
{
submodules:
router1: StandardHost {
parameters:
@display(“p=100,100”);
asId = “AS1”;
routingTableModule = “^.routingTable”;
}
router2: StandardHost {
parameters:
@display(“p=300,100”);
asId = “AS2”;
routingTableModule = “^.routingTable”;
}
// Add more routers as needed
connections:
router1.pppg++ <–> { @display(“m=100,100”); } <–> router2.pppg++;
router1.pppg++ <–> { @display(“m=100,100”); } <–> router2.pppg++;
}
omnetpp.ini Configuration
[General]
network = BGPNetwork
*.router*.pppg[*].queue.typename = “DropTailQueue”
*.router*.ipv4.routingTable = “inet.networklayer.routing.manet.Router”
*.router*.networkLayer.networkProtocol.typename = “IPv4NetworkLayer”
*.router*.transportLayer.tcp.typename = “Tcp”
*.router*.transportLayer.udp.typename = “Udp”
*.router*.application[*].typename = “UdpBasicApp”
*.router*.application[*].destAddresses = “router1” // Set destination as needed
*.router*.application[*].destPort = 2000
*.router*.application[*].startTime = uniform(0s, 10s)
*.router*.application[*].sendInterval = uniform(1s, 2s)
*.router*.application[*].packetLength = 512B
*.router*.app[0].typename = “BGP”
Step 5: Test and Debug
So, We have discussed about to create BGP protocol module, implementation of the module in C++, and some coding which is useful to implement the Exterior Gateway in OMNeT++.
We help with the setup and testing of the exterior gateway protocol using the OMNeT++ tool. Our focus is on everything related to the Border Gateway Protocol (BGP).