I want to define 3 kinds of messages in omnet I know I have to use messagekind but I couldnt please help me I want help message, control message and jobs, which jobs should be processed thank you so much
Asked
Active
Viewed 243 times
2 Answers
0
Creating of messages is described in OMNeT++ Simulation Manual as well as in TicToc Tutorial.
In short:
You have to create a new
.msg
file, for exampleControlMessage.msg
, with your content, for example:message ControlMessage { int someAddress; // ... }
In your C++ code you have to add the following line:
#include "ControlMessage_m.h"
(during compilation ControlMessage_m.h
is automatically created from ControlMessage.msg
)

Jerzy D.
- 6,707
- 2
- 16
- 22
0
After creating the three message classes, in a class, say DemoLayer, you need 2 changes in .h file and 1 in .cc file.
In .h file, under the public specifier add
enum DemoMessageKinds {
SEND_DATA-MESSAGE,
SEND_CONTROL-MESSAGE,
SEND_JOB-MESSAGE
};
and under protected specifier add
void handleSelfMsg(cMessage* msg) override;
In .cc file, add
void DemoLayer::handleSelfMsg(cMessage* msg)
{
switch (msg->getKind())
{
case SEND_DATA-MESSAGE:
{
ControlMessage* cm = new ControlMessage();
....//
For an example, check this https://github.com/sommer/veins/tree/master/src/veins/modules/application/ieee80211p

Pasha M.
- 340
- 1
- 12
-
Hi. If you found my answer working, please mark it as answered. – Pasha M. Mar 06 '22 at 09:08
-
hi sure dear, but i want to define these types for all module, I mean in this way do I have a personal message just for a especial module? – Fatimah Faraji Mar 06 '22 at 10:12
-
Yes. You are right. handleSelfMessage () is used to handle messages within the module. Please use handleMessage( ) if you want all modules to get the generated message(s). – Pasha M. Mar 06 '22 at 13:02
-
I used the method name as handleMessage( ) referring to the tic-toc example. – Pasha M. Mar 06 '22 at 13:27
-
how ?i dont know how mark this – Fatimah Faraji Mar 07 '22 at 08:25
-
To mark an answer as accepted, click on the check mark beside the answer to toggle it from greyed out to filled in. You may change which answer is accepted, or simply un-accept the answer, at any time. – Pasha M. Mar 07 '22 at 08:26