Search code examples
simulationomnet++veins

Changing length of WAVE message(VEINS/OMNET++)


How to change the length of the WAVE message. Method setWsmLength doesn't work. From the answer in here I gather that it is not possible, as the functionality is not implemented in WAVE. But the answer provided is very vague. It asks to create a .msg file, which is clear. But the rest is not very clear. Can somebody clarify or explain it?

P.S: I couldn't comment in that thread, so had to ask new question.


Solution

  • WaveShortMessage is an OMNeT++ packet, so one can always use addByteLength() to increase its existing size or setByteLength() to set a new size of it, description in OMNeT++ manual. Defining a new message is not necessary.
    An example:

    WaveShortMessage* wsm = prepareWSM("data", dataLengthBits, channel, dataPriority, -1,2);
    wsm->setWsmData(blockedRoadId.c_str());
    int byteLen = blockedRoadId.length(); // assuming that one char = one byte
    wsm->addByteLength(byteLen);