'car node can't receive wave short messages

I have a scenario that includes a single car node and a single RSU node. the car sends a beacon message every 1s. when the RSU receives a beacon message, it should reply back to the sender (the car) with a wave short message.

I create a WSM once the RSU receives a BSM, and I set the receiver's ID to the bsm sender ID (as I want the RSU to send the message only to a specific node). the problem is that the wsm in never received by the car (onWSM function is never called).

here is the code:

void RSUApp::onBSM(BasicSafetyMessage* bsm)
{
    /*this fn is called when rsu receives a beacon*/
    /*after receiving beacon, send the value of the current speed*/
    WaveShortMessage* msg= new WaveShortMessage("speed");
    msg->setSenderAddress(this->myId);
    msg->setWsmData(std::to_string(this->currentSpeed).c_str());
    int Id = bsm->getSenderAddress();
    populateWSM(msg,Id,0);
    sendDown(msg);
}

when I replace the receiver's ID by -1 (send broadcast message instead of sending to specific node), the car APP can handle the WSM without problems.

populateWSM(msg,-1,0);

I am using veins 4.7 and this is the ini file contents:

*.rsu[0].mobility.x = 500
*.rsu[0].mobility.y = 50
*.rsu[0].mobility.z = 3

*.rsu[*].applType = "iteration6.src.RSUApp"
*.rsu[*].appl.headerLength = 80 bit 
*.rsu[*].appl.sendBeacons = false
*.rsu[*].appl.dataOnSch = false

*.connectionManager.sendDirect = true
*.connectionManager.maxInterfDist = 2600m
*.connectionManager.drawMaxIntfDist = true

*.**.nic.mac1609_4.useServiceChannel = false
*.**.nic.mac1609_4.txPower = 20mW
*.**.nic.mac1609_4.bitrate = 6Mbps
*.**.nic.phy80211p.sensitivity = -89dBm 
*.**.nic.phy80211p.useThermalNoise = true
*.**.nic.phy80211p.thermalNoise = -110dBm  
*.**.nic.phy80211p.decider = xmldoc("config.xml")
*.**.nic.phy80211p.analogueModels = xmldoc("config.xml")
*.**.nic.phy80211p.usePropagationDelay = true

*.node[*].applType = "iteration6.src.carApp"
*.node[*].appl.headerLength = 80 bit
*.node[*].appl.sendBeacons = true
*.node[*].appl.dataOnSch = false
*.node[*].appl.beaconInterval = 1s

can anyone help me with that problem?



Solution 1:[1]

It seems like you are using the wrong id for the recipient. Instead of

int Id = bsm->getSenderModuleId();

you should rather use

int Id = bsm->getSenderAddress();

This should do the trick.

See the following sources for more details:

Solution 2:[2]

The newer version of veins returns MAC based myId while previous versions returned Module Identifier. This needs to be kept in mind while assigning addresses to nodes.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Julian Heinovski
Solution 2 Pasha M.