Search code examples
omnet++veins

how to get Frame Id in BaseWaveApplLayer class veins


I am implementing ACK functionality to be sent by RSU and I am trying to get frameID in BaseWaveApplLayer class. It has cMessage object but I am unable to get correct freamID I tried to use messageId but it is different than the sent from nodes. Also tested the getEncapsulationId() but that is as well different. How can I get frameId sent by sender?

void BaseWaveApplLayer::handleLowerMsg(cMessage* msg) {
    WaveShortMessage* wsm = dynamic_cast<WaveShortMessage*>(msg);
    ASSERT(wsm);
    if (BasicSafetyMessage* bsm = dynamic_cast<BasicSafetyMessage*>(wsm)) {
        receivedBSMs++;
        onBSM(bsm);
    }
}

Solution

  • First of all you have to set the ID at the sender side, then you will be able to access the ID as at the receiver. To do so you will have to extend the message definition in the *.msg file to have a new field to store the ID for your application. That can be called myAppsId, for example.

    Note how this implementation extends the WaveShortMessage with new fields.

    You can use the same approach to extend WaveShortMessage and create a new message type for your application with the desired fields. Or you can directly modify the definition of the WaveShortMessage.

    Then basically use the set() and get() functions for the newly defined field on the sending and receiving side, respectively.

    Here is a useful solution for a different purpose, but the same applies to you.