Reputation: 113
I have this code where a module which extends WirelessHost module is composed of a simple module called node : When I run the simulation, there's only mobility events, no communication events are displayed. I think this is due to not linking Drone gates module with gates that receive incoming traffic. How can I do this please?
SaaS.ned
import inet.node.inet.WirelessHost;
import inet.visualizer.integrated.IntegratedVisualizer;
import inet.networklayer.configurator.ipv4.Ipv4NetworkConfigurator;
import inet.physicallayer.unitdisk.UnitDiskRadioMedium;
simple Node
{
gates:
input in[];
output out[];
}
module Drone extends WirelessHost
{
gates:
input in[];
output out[];
submodules:
myNode: Node;
connections allowunconnected:
for i=0..sizeof(in)-1 {
in++ --> myNode.in++;
}
for i=0..sizeof(out)-1 {
out++ <-- myNode.out++;
}
}
network SaaS
{
parameters:
int numDrones;
submodules:
visualizer: IntegratedVisualizer {
@display("p=94.376,433.728");
}
configurator: Ipv4NetworkConfigurator {
parameters:
config = xml("<config><interface hosts='*' address='145.236.x.x' netmask='255.255.0.0'/></config>");
@display("p=94.376,56.224;is=s");
}
radioMedium: UnitDiskRadioMedium {
@display("p=94.376,178.71199");
}
drone[numDrones]: Drone {
@display("i=misc/node_vs");
}
}
Node.cc
#include <string.h>
#include <omnetpp.h>
using namespace omnetpp;
class Node : public cSimpleModule
{
protected:
// The following redefined virtual function holds the algorithm.
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
};
// The module class needs to be registered with OMNeT++
Define_Module(Node);
using namespace std;
void Node::initialize()
{
int n = gateSize("out");
cMessage *msg = new cMessage("tictocMessage");
for (int i = 0; i < n ; i++)
send(msg, "out", i);
}
void Node::handleMessage(cMessage *msg)
{
int n = gateSize("out");
for (int i = 0; i < n ; i++)
send(msg, "out", i);
}
Upvotes: 0
Views: 279
Reputation: 6681
This is not, how a WirelessHost
in INET is supposed to be configured.
You should implement an UDP application module and you must configure that application to be used in the WirelessHost
.
*.drone[0].numApps = 1
*.drone[0].app[0].typename = "MyUDPApp"
There is no need to extend the WirelessHost
as it already contains a module vector called app
which can be configured with the various application modules. You should check the various examples how applications are configured in them.
Upvotes: 1