To implement the VLAN Trunking Protocol (VTP) in OMNeT++ has needs to emulate the network where switches can share VLAN configuration information over trunk links, permitting the propagation of VLAN configurations all over a network. The VTP is commonly used in the circumstance where to handle the VLANs manually on each switch would be clumsy, as it systematizes the process of updating VLAN information through the network.
To execute the VTP in OMNeT++, we need to mimic the characteristics of VTP that concentrates on features such as VLAN creation, deletion, and propagation of VLAN configurations via VTP messages.
Step-by-Step Implementation:
Step 1: Set Up OMNeT++ and INET Framework
Step 2: Create a New OMNeT++ Project
Step 3: Define the Network Topology
Example:
network VTPNetwork
{
parameters:
int numSwitches = default(3); // Number of switches in the network
int numHosts = default(3); // Number of hosts in the network
submodules:
switch[numSwitches]: EtherSwitch {
@display(“i=block/switch”);
}
host[numHosts]: StandardHost {
@display(“i=block/host”);
}
connections allowunconnected:
switch[0].ethg++ <–> Eth10Gbps <–> switch[1].ethg++;
switch[1].ethg++ <–> Eth10Gbps <–> switch[2].ethg++;
switch[2].ethg++ <–> Eth10Gbps <–> switch[0].ethg++;
host[0].ethg++ <–> Eth10Gbps <–> switch[0].ethg++;
host[1].ethg++ <–> Eth10Gbps <–> switch[1].ethg++;
host[2].ethg++ <–> Eth10Gbps <–> switch[2].ethg++;
}
Step 4: Implement the VLAN Trunking Protocol (VTP)
We need to generate a module that manages VTP messages, including sending and receiving VLAN configuration updates.
Example (in NED):
simple VTP
{
parameters:
@display(“i=block/network2”);
gates:
inout lowerLayerIn[];
inout lowerLayerOut[];
}
Here’s a basic structure for implementing VTP in C++:
#include “inet/common/INETDefs.h”
#include “inet/networklayer/contract/IRoutingTable.h”
#include “inet/networklayer/ipv4/IPv4RoutingTable.h”
#include “inet/networklayer/ipv4/IPv4Route.h”
#include “inet/networklayer/common/L3Address.h”
#include “inet/common/packet/Packet.h”
#include “inet/networklayer/common/InterfaceTable.h”
#include “inet/linklayer/ethernet/switch/MACRelayUnitNP.h”
class VTP : public cSimpleModule
{
private:
std::map<int, std::string> vlanDatabase; // VLAN ID to VLAN name
int configurationRevision;
cMessage *vtpTimer;
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
void sendVTPUpdate();
void processVTPUpdate(Packet *packet);
void addVLAN(int vlanId, const std::string& vlanName);
void removeVLAN(int vlanId);
};
Define_Module(VTP);
void VTP::initialize() {
configurationRevision = 0;
// Schedule periodic VTP updates
vtpTimer = new cMessage(“VTP_Timer”);
scheduleAt(simTime() + 1, vtpTimer);
}
void VTP::handleMessage(cMessage *msg) {
if (msg == vtpTimer) {
sendVTPUpdate();
scheduleAt(simTime() + 1, vtpTimer); // Reschedule VTP update
} else {
Packet *packet = check_and_cast<Packet *>(msg);
processVTPUpdate(packet);
}
}
void VTP::sendVTPUpdate() {
Packet *vtpPacket = new Packet(“VTP_Update”);
// Add the VTP update data (e.g., VLAN database and revision number) to the packet
for (int i = 0; i < gateSize(“lowerLayerOut”); i++) {
send(vtpPacket->dup(), “lowerLayerOut”, i); // Send VTP update to all connected switches
}
delete vtpPacket;
}
void VTP::processVTPUpdate(Packet *packet) {
// Extract the VTP update data (e.g., VLAN database and revision number) from the packet
// Example: Update the local VLAN database if the received revision number is higher
int receivedRevision = /* Extract revision number from the packet */;
if (receivedRevision > configurationRevision) {
configurationRevision = receivedRevision;
// Update local VLAN database with the received data
}
delete packet;
}
void VTP::addVLAN(int vlanId, const std::string& vlanName) {
vlanDatabase[vlanId] = vlanName;
configurationRevision++;
}
void VTP::removeVLAN(int vlanId) {
vlanDatabase.erase(vlanId);
configurationRevision++;
}
Step 5: Configure the Simulation
Example:
network = VTPNetwork
sim-time-limit = 100s
**.scalar-recording = true
**.vector-recording = true
# VTP Configuration
**.switch*.hasVTP = true # Enable VTP on all switches
Step 6: Analyse the Results
Step 7: Optimize and Extend the Protocol
We had successfully implemented and executed the VLAN Trunking Protocol in OMNeT++ tool and that emulates the network then allowing the VLAN configuration over the network to analyse the outcome. Further specific details regarding the VLAN on your projects we will provided in further setup module with simulation results.