我用静脉-4a2。 首先,我已经执行了一个只有车辆的scnario。 现在我在我的例子中添加了RSU。 我需要每个RSU接收数据,在Omnet ++的模块日志中显示一条消息。 就像我在接收数据时对节点所做的那样,我在TraCIDemp11p的onData()函数中添加了粗线,如下所示:
void TraCIDemoRSU11p::onData(WaveShortMessage* wsm) { findHost()->getDisplayString().updateWith("r=16,green"); annotations->scheduleErase(1, annotations->drawLine(wsm->getSenderPos(), mobi->getCurrentPosition(), "blue")); **EV << " I am an RSU and I have received a data ! \n";** //if (!sentMessage) sendMessage(wsm->getWsmData()); }我的问题是“我是一个RSU,我收到了一个数据!”没有显示在日志模块中。 当RSU收到数据时,这是omnet ++的日志模块中显示的内容:
** Event #4802 t=9.004337832007 RSUExampleScenario.node[4].nic.phy80211p (PhyLayer80211p, id=161), on `data' (Mac80211Pkt, id=669) node[4]::PhyLayer80211p: AirFrame encapsulated, length: 1326I use veins-4a2. First, I have executed a scnario with only vehicles. Now I have added RSU in my example. I need that every RSU receives data, displays a message in the module log of Omnet++. Like I did for nodes when they receives data, I have add the bold line in onData() function of the TraCIDemp11p like this:
void TraCIDemoRSU11p::onData(WaveShortMessage* wsm) { findHost()->getDisplayString().updateWith("r=16,green"); annotations->scheduleErase(1, annotations->drawLine(wsm->getSenderPos(), mobi->getCurrentPosition(), "blue")); **EV << " I am an RSU and I have received a data ! \n";** //if (!sentMessage) sendMessage(wsm->getWsmData()); }My problem is that "I am an RSU and I have received a data ! " isn't displayed in the log module. When an RSU receives a data, this is what is displayed in the log module of omnet++:
** Event #4802 t=9.004337832007 RSUExampleScenario.node[4].nic.phy80211p (PhyLayer80211p, id=161), on `data' (Mac80211Pkt, id=669) node[4]::PhyLayer80211p: AirFrame encapsulated, length: 1326最满意答案
我不知道您是否了解onData的工作原理。
在默认静脉中,仅在具有名称数据的一个包到达一个汽车/节点或RSU(通过handleLowerMsg)时调用onData。
在您的RSU情况下,需要:
汽车/节点需要appl.sendData为true
调用带有名称数据的发送包
与汽车/节点和RSU 的通信范围 。 默认值为1千米直径。一个好的测试是使用randomTrips.py创建一个小网格,并将RSU设置在中心,所有节点都可以在其中实现。
- 一个评论的大,所以我做了一个新的答案 - 祝你好运!
I don't know if you are aware of how onData works.
In the default veins, the onData is only called where one package with name data arrived in one car/node or RSU (through the handleLowerMsg).
In your case in a RSU, so are needed:
The cars/nodes need the appl.sendData with true
Calls for send packages with name data
Range of communication with the cars/nodes and the RSU. The default is 1 km of diameter.A good test is create a small grid with the randomTrips.py and set the RSU in center, where all nodes can achieve it.
-Big for one comment, so I make a new answer - Good luck!
更多推荐
发布评论