Reputation: 11
I am trying to simulate a WSN on Omnet and since I want it to be wireless, I chose the Inet Framework.
Now I need to personalize the Content of the Messages sent but I can't find a way to do so.
can anybody help me with that? I can't find anything in the unser Manual etc.
thank you!
Upvotes: 1
Views: 991
Reputation: 309
It depends on what is "the Message" and from which module you want to send it. If you are creating/testing application protocol then you might want to create new .msg file which describes the structure of your message.
INET's documentation has a section on working with packets https://inet.omnetpp.org/docs/developers-guide/ch-packets.html#representing-packets
The .msg
file can look something like this:
cplusplus {{
const B YOUR_APP_HEADER_LENGTH = B(6);
}}
class YourAppHeader extends FieldsChunk
{
chunkLength = YOUR_APP_HEADER_LENGTH;
int someField;
bool someBit;
};
then in your C++ code
Packet *packet = new Packet();
const auto& payload = makeShared<YourAppHeader>();
payload->setChunkLength(B(<someValue>));
payload->setSomeFiled(<intHere>);
packet->insertAtBack(payload);
//and then send it
Upvotes: 1