I'm currently working on a MANET project and wanted to create a customized wireless host to mimic a selfish node that would immediately drop a message it receives in the MANET. I have created a simple module called SelfishNode.NED, the code as follows:
simple SelfishNode {
parameters:
@display("i=block/buffer");
gates:
input radioIn[numRadios] @directIn;
inout pppg[] @labels(PPPFrame-conn);
inout ethg[] @labels(EtherFrame-conn);
}
2. Then, I created its C++ file with the code below:
#include "SelfishNode.h"
#include <string.h>
#include <omnetpp.h>
void SelfishNode::initialize()
{
}
void SelfishNode::handleMessage(cMessage *msg)
{
delete msg;
}
3. Next, I created a compound module called snode.NED that extends AODVRouter, the code as follows:
import inet.node.aodv.AODVRouter;
module snode extends AODVRouter
{
parameters:
@networkNode;
@display("i=device/wifilaptop");
@labels(wireless-node);
submodules:
bad: SelfishNode {
@display("p=273,350");
}
}
Next, I created a network module called ManetA.NED:
import inet.common.figures.DelegateSignalConfigurator;
import inet.networklayer.configurator.ipv4.IPv4NetworkConfigurator;
import inet.physicallayer.ieee80211.packetlevel.Ieee80211ScalarRadioMedium;
import inet.visualizer.integrated.IntegratedCanvasVisualizer;
import inet.environment.common.PhysicalEnvironment;
network ManetA
{
parameters:
int numHosts;
int numBadNodes;
submodules:
visualizer: IntegratedCanvasVisualizer {
@display("p=59,103");
}
configurator: IPv4NetworkConfigurator {
@display("p=59,164");
}
radioMedium: Ieee80211ScalarRadioMedium {
@display("p=60,50,i=misc/sun");
}
figureHelper: DelegateSignalConfigurator {
@display("p=61,236");
}
hostBad[numBadNodes]: snode {
@display("i=device/palm");
}
physicalEnvironment: PhysicalEnvironment {
@display("p=59,306");
}
}
Lastly, I configured the mobility type and the number of bad nodes in omnetpp.ini as follows:
*.numBadNodes = ${HOST=5}
*.hostBad.mobilityType = "inet.mobility.single.RandomWPMobility"
Is this correct? And also when I run the simulation, the nodes didn't move at all. I have studied for the whole day but couldn't resolve it.
Almost correct... if you operate in the INET namespace, you don't need to provide the full name of the mobility module when you set the mobilityType
**.hostBad.mobilityType = "RandomWPMobility"
Check the example configs in /inet/examples/mobility/omnetpp.ini
for further details.