3

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.

Julian Heinovski
  • 1,822
  • 3
  • 16
  • 27
user629034
  • 659
  • 2
  • 11
  • 30

1 Answers1

2

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).

Julian Heinovski
  • 1,822
  • 3
  • 16
  • 27
  • 2
    This is not 100% correct. As Veins internally duplicates messages, every car receives a message with a different id - although the message in reality is the same broadcast. Therefore, to make this work, you probably need to extend your message with a unique identifier and assign a value using `getUniqueNumber()` from the simulation environment. – floxyz Mar 13 '17 at 08:59