汽车节点无法接收短消息

时间:2019-05-02 18:26:53

标签: omnet++ veins

我有一个方案,其中包括一个汽车节点和一个RSU节点。汽车每隔1s发送一次信标消息。当RSU收到信标消息时,它应以短消息答复发件人(汽车)。

一旦RSU收到BSM,我就创建一个WSM,并将接收者的ID设置为bsm发送者ID(因为我希望RSU仅将消息发送到特定节点)。问题是汽车永远不会接收到wsm(永远不会调用onWSM函数)。

代码如下:

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);
}

当我将接收者的ID替换为-1(发送广播消息而不是发送到特定节点)时,车载APP可以毫无问题地处理WSM。

populateWSM(msg,-1,0);

我正在使用静脉4.7,这是ini文件的内容:

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

有人可以帮助我解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

似乎您为接收者使用了错误的ID。代替

int Id = bsm->getSenderModuleId();

您宁愿使用

int Id = bsm->getSenderAddress();

这应该可以解决问题。

有关更多详细信息,请参见以下资源: