To implement the En route filtering in OMNeT++ has encompasses executing a mechanism where packets are checked and possibly strained as they traverse via the network. This method is frequently used to avoid malicious packets, enforce security policies, or decrease network congestion by filtering out needless traffic. Get tailored En Route Filtering solutions in OMNeT++ along with implementation and thesis ideas from the experts at omnet-manual.com. Given below is step-by-step guide to implementing en route filtering in OMNeT++ with examples:
Step-by-Step Implementations:
Step 1: Set Up the OMNeT++ Environment
Make sure that OMNeT++ and essential libraries, like INET, are installed and configured correctly. INET delivers models for networking protocols and devices, which can be expanded to contain en route straining functionality.
Step 2: Define the En Route Filter Module
Make a module that will perform as a filter, inspecting and possibly dropping packets based on certain norms like IP addresses, packet types, content, etc.
Example En Route Filter Module Definition
module EnRouteFilter
{
parameters:
string blockedIpAddresses[]; // List of blocked IP addresses
int blockedPorts[]; // List of blocked ports
@display(“i=block/filter”); // Icon for visualization
gates:
inout ethg; // Ethernet communication gate
submodules:
eth: <default(“EthernetInterface”)>; // Ethernet NIC for communication
connections:
ethg <–> eth.physIn;
}
Step 3: Implement the Filtering Logic
Execute the logic for filtering packets. This logic will check the packet’s contents like source IP, destination IP, port and select whether to forward or drop the packet.
Example Filtering Logic (Simplified)
class EnRouteFilter : public cSimpleModule
{
protected:
virtual void handleMessage(cMessage *msg) override;
private:
std::vector<std::string> blockedIpAddresses;
std::vector<int> blockedPorts;
bool isBlocked(cMessage *msg);
};
void EnRouteFilter::initialize()
{
// Initialize blocked IP addresses and ports from parameters
const char *ipList = par(“blockedIpAddresses”).stringValue();
cStringTokenizer tokenizer(ipList);
while (tokenizer.hasMoreTokens()) {
blockedIpAddresses.push_back(tokenizer.nextToken());
}
const char *portList = par(“blockedPorts”).stringValue();
cStringTokenizer tokenizerPorts(portList);
while (tokenizerPorts.hasMoreTokens()) {
blockedPorts.push_back(atoi(tokenizerPorts.nextToken()));
}
}
void EnRouteFilter::handleMessage(cMessage *msg)
{
if (isBlocked(msg))
{
EV << “Packet blocked: ” << msg->getName() << endl;
delete msg; // Drop the packet
}
else
{
EV << “Packet allowed: ” << msg->getName() << endl;
send(msg, “ethg$o”); // Forward the packet
}
}
bool EnRouteFilter::isBlocked(cMessage *msg)
{
const char *srcIp = msg->par(“srcIp”).stringValue();
int srcPort = msg->par(“srcPort”).intValue();
// Check if the source IP or port is blocked
if (std::find(blockedIpAddresses.begin(), blockedIpAddresses.end(), srcIp) != blockedIpAddresses.end())
{
return true;
}
if (std::find(blockedPorts.begin(), blockedPorts.end(), srcPort) != blockedPorts.end())
{
return true;
}
return false;
}
Step 4: Define the Network Scenario with En Route Filtering
Make a network situation where the en route filter is used to packets as they pass through the network. We can position the filter at routers, gateways, or other key network nodes.
Example Network Scenario Definition
network EnRouteFilteringNetwork
{
parameters:
int numHosts = default(3); // Number of hosts in the network
int numFilters = default(2); // Number of filters
submodules:
filters[numFilters]: EnRouteFilter {
@display(“p=300,300”);
}
hosts[numHosts]: StandardHost {
@display(“p=100,100”);
}
connections allowunconnected:
for i=0..numHosts-1 {
hosts[i].ethg <–> EthernetCable <–> filters[i % numFilters].ethg;
}
filters[0].ethg <–> EthernetCable <–> filters[1].ethg;
}
Step 5: Configure the Simulation Parameters
Configure the simulation parameters in the .ini file, containing the filtering criteria like blocked IPs and ports.
Example Configuration in the .ini File
[General]
network = EnRouteFilteringNetwork
sim-time-limit = 300s
# En Route Filter configuration
*.filters[0].blockedIpAddresses = “192.168.1.1”, “192.168.1.2”
*.filters[0].blockedPorts = 80, 443
*.filters[1].blockedIpAddresses = “10.0.0.1”
*.filters[1].blockedPorts = 25, 110
# Host configuration (just for simulation purposes)
*.hosts[*].eth.datarate = 100Mbps
Step 6: Implement Traffic Generation (Hosts)
Implement the logic for creating network traffic from the hosts to check the en route filtering.
Example Traffic Generation Logic (Simplified)
class TrafficGenerator : public cSimpleModule
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
private:
cMessage *sendTimer; // Timer to trigger sending data
std::string destIp;
int destPort;
};
void TrafficGenerator::initialize()
{
destIp = par(“destIp”).stringValue();
destPort = par(“destPort”).intValue();
sendTimer = new cMessage(“sendTimer”);
scheduleAt(simTime() + par(“sendInterval”), sendTimer);
}
void TrafficGenerator::handleMessage(cMessage *msg)
{
if (msg == sendTimer)
{
EV << “Sending packet to ” << destIp << ” on port ” << destPort << endl;
cMessage *packet = new cMessage(“DataPacket”);
packet->addPar(“srcIp”) = par(“srcIp”).stringValue();
packet->addPar(“srcPort”) = par(“srcPort”).intValue();
packet->addPar(“destIp”) = destIp.c_str();
packet->addPar(“destPort”) = destPort;
send(packet, “ethg$o”);
scheduleAt(simTime() + par(“sendInterval”), sendTimer);
}
else
{
delete msg;
}
}
Step 7: Run the Simulation
Compile and run the simulation. Monitor how the en route filters inspect and filter traffic depends on the configured norms.
Step 8: Analyse the Results
Use OMNeT++’s analysis tools to assess the act of the en route filtering setup. Examine metrics like:
Step 9: Extend the Simulation (Optional)
We can expand the simulation by:
We had explained step-by-step approaches that was used to make En Route Filtering that was implemented in OMNeT++. Inserting more details we will be delivered concerning En Route filtering in several tools.