Search code examples
c++simulationomnet++veinssumo

Checking for duplicates in VEINS


I am new to Veins and trying to implement a mechanism to detect if the WSM packet was received before. I am using the "psid" as the main variable to identify the packet - is it correct?

Will this type of code work? :

bool MyVeinsApp::msgReceivedBefore(int psid){
  /*
  This function will be used to determine if the message was received before
  and should be discarded or processed further
  */

  if(msg_log.find(psid) == msg_log.end()){
     return false
  }
  else {
     return true;
  }

}

Here msg.log is a C++ data structure storing WSMs based on psid.


Solution

  • The psid only is an identifier for the service you are using (see WaveShortMessage.msg) and therefore not unique among messages of the same service. To distinguish between messages you need a unique message identifier.

    A simple approach would be to use the id which every module in OMNeT++ gets:

    msg->getId()
    

    UPDATE: Please note that this id also is unique among all messages with the same content (see comment down below).