How do I send messages from one RSU to another?
I'm using version 5.2 of Veins with the default example, I just added one more RSU (one very close to the other). I can send messages from vehicles to vehicles, from vehicles to RSU, and from RSU to vehicles using the sendDown()
or sendDelayedDown()
methods.
However, when I try to send a message from one RSU to another, it simply does not work, as the destination RSU does not receive the message.
如何将消息从一个RSU发送到另一个RSU?在默认示例中,我使用的是5.2版的静脉,我只是多添加了一个RSU(一个非常接近另一个)。我可以使用sendDown()或sendDelayedDown()方法将消息从车辆发送到车辆、从车辆发送到RSU、从RSU发送到车辆。然而,当我尝试将消息从一个RSU发送到另一个RSU时,它根本不起作用,因为目的地RSU没有接收到该消息。
What should I do in my project to make it work? Or what is the correct method for sending messages between RSUs?
我应该在我的项目中做些什么才能使它工作?或者,在RSU之间发送消息的正确方法是什么?
Thank you.
谢谢。
更多回答
I went through this too... You must be forgetting to use the populate() method: populate(wsm, ADDRESS);
我也经历过这个..。您一定忘了使用Popate()方法:Popate(wsm,Address);
Wow, what a mistake... It worked out! Post your answer so I can mark it as correct.
哇,真是个错误……它成功了!把你的答案张贴出来,这样我就可以把它标记为正确。
优秀答案推荐
You must be forgetting to use the populateWSM() method:
populateWSM(wsm, ADDRESS);
您一定忘了使用opolateWSM()方法:opolateWSM(wsm,Address);
In the initialize method you can put it like this:
在初始化方法中,您可以将其表示为:
void MyRSUClass::initialize(int stage) {
DemoBaseApplLayer::initialize(stage);
if (stage == 1) {
TraCIDemo11pMessage* wsm = new TraCIDemo11pMessage*();
populateWSM(wsm, OTHER_RSU_ADDRESS); // <------- here**
wsm->setSenderAddress(myId);
wsm->setDemoData("Message from RSU");
sendDown(wsm);
// OR, if you have problems with sendDown() method
// use send() ou sendDelayed() methods:
//// send(wsm, "lowerLayerOut");
//// sendDelayed(wsm, 2, "lowerLayerOut");
}
}
更多回答
我是一名优秀的程序员,十分优秀!