I have to extend the UdpBasicApp module from INET4 in OMNeT++ 5.6.1 (Ubuntu 18.04.4) and execute two overridden methods (initialize and handleMessageWhenUp). It seems an easy task, and looked like it was all fine when I built the project (momentarily stored inside the "examples" folder in inet4) with no errors but, after starting the simulation the code isn't successfully overridden. The original code (the one from UdpBasicApp) is executed instead. In fact, after inspecting the code in the editor, the methods' name isn't bold (as should be) and the keywords aren't colored as they normally should be. My C++ skill is not high (nor my OMNeT one) hence I'm not sure what is really happening. The extended simple module is called "PriorityApp" (I added just an integer field more).
This is the .ned code (not sure if you need it)
package inet.examples.MyProject.src;
import inet.applications.udpapp.UdpBasicApp;
// The module extends UdpBasicApp adding a priority parameter
simple PriorityApp extends UdpBasicApp
{
parameters:
int priority = default(0); // priority 0 = higher priority
}
This is the .h code
#ifndef __INET4_PRIORITYAPP_H_
#define __INET4_PRIORITYAPP_H_
#include "inet/applications/udpapp/UdpBasicApp.h"
namespace inet {
class PriorityApp : public UdpBasicApp
{
protected:
int priority;
virtual void initialize(int stage) override;
virtual void handleMessageWhenUp(cMessage *msg) override;
};
} // namespace inet
#endif // ifndef __INET_PRIORITYAPP_H
This is the .cc code
#include "PriorityApp.h"
namespace inet {
Define_Module(PriorityApp);
void PriorityApp::initialize(int stage)
{
msg = new cMessage("priority");
EV << "Example Message" << endl;
}
void PriorityApp::handleMessageWhenUp(cMessage *msg)
{
}
} //namespace inet
This is the .ini file
[General]
[Config SwitchedNet1G]
description = "1Gbps Switched Network"
network = SwitchedNet
**.dataRate = 1Gbps # 1 Gbps channel datarate
# Priority stuff
**.host[0].app[0].priority = 1
# Dst Params
**.sink.app[*].typename = "UdpSink" # Destination host (it receives messages)
**.sink.app[*].localPort = 2500
# Src Params
**.host[0].app[0].packetName = "Host0-Data"
**.host[*].app[0].typename = "PriorityApp" # Source host (they send messages)
**.host[*].app[0].destPort = 2500
**.host[*].app[0].destAddresses = "sink"
**.host[0].app[0].sendInterval = 3s
**.host[*].app[0].startTime = uniform (0s, 3s)
# EthInterface Setup
**.eth[*].qEncap.typename = "Ieee8021qEncap" # 8021Q Encapsulation
**.etherSwitch.numEthInterfaces = 2 # Switch ethInterfaces total number (2)
**.numEthInterfaces = 1
# Global Params
**.messageLength = 100B
**.numHosts = 1
**.numApps = 1 # every host has 1 app (UdpBasicApp or UdpSink)