Omnet++ 模拟器日志模块中的显示问题
Display issue in the log module of Omnet++ simulator
我用的是 veins-4a2。首先,我执行了一个只有车辆的场景。现在我在示例中添加了 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());
}
我的问题是 "I am an RSU and I have received a data ! " 没有显示在日志模块中。
当 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: 1326
确保在 onData 函数中进行。
您可以为此使用 ASSERT 或退出函数。
使用 DBG、EV 或 cout 打印消息
DBG << "Test_DBG: I am an RSU and I have received a data!\n";
EV << "Test_EV: I am an RSU and I have received a data!\n";
std::cout << "Test_cout: I am an RSU and I have received a data!\n"
设置打印信息后,使用一个代码结束模拟
// terminate the simulation with error code 3
exit(3);
或使用断言
ASSERT2(0,"Test: I'm RSU");
如果模拟因错误而终止,您将确保执行了 onData,否则,不会在代码的任何部分调用 onData。
-抱歉,我没有声誉只能添加一条评论-祝您好运!
不知道你是否了解onData的工作原理
默认情况下,onData 仅在名称为 data 的包到达一个 car/node 或 RSU(通过 handleLowerMsg)时调用。
对于您在 RSU 中的情况,还需要:
cars/nodes需要appl.sendData和true
- Range of communication 与 cars/nodes 和 RSU。默认为1公里直径。
一个好的测试是用 randomTrips.py 创建一个小网格并将 RSU 设置在中心,所有节点都可以实现它。
-一个评论太重要了,所以我做了一个新的答案-祝你好运!
我用的是 veins-4a2。首先,我执行了一个只有车辆的场景。现在我在示例中添加了 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());
}
我的问题是 "I am an RSU and I have received a data ! " 没有显示在日志模块中。 当 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: 1326
确保在 onData 函数中进行。 您可以为此使用 ASSERT 或退出函数。
使用 DBG、EV 或 cout 打印消息
DBG << "Test_DBG: I am an RSU and I have received a data!\n";
EV << "Test_EV: I am an RSU and I have received a data!\n";
std::cout << "Test_cout: I am an RSU and I have received a data!\n"
设置打印信息后,使用一个代码结束模拟
// terminate the simulation with error code 3
exit(3);
或使用断言
ASSERT2(0,"Test: I'm RSU");
如果模拟因错误而终止,您将确保执行了 onData,否则,不会在代码的任何部分调用 onData。
-抱歉,我没有声誉只能添加一条评论-祝您好运!
不知道你是否了解onData的工作原理
默认情况下,onData 仅在名称为 data 的包到达一个 car/node 或 RSU(通过 handleLowerMsg)时调用。
对于您在 RSU 中的情况,还需要:
cars/nodes需要appl.sendData和true
- Range of communication 与 cars/nodes 和 RSU。默认为1公里直径。
一个好的测试是用 randomTrips.py 创建一个小网格并将 RSU 设置在中心,所有节点都可以实现它。
-一个评论太重要了,所以我做了一个新的答案-祝你好运!