OMNET++:如何获取无线信号功率?
OMNET++: How to obtain wireless signal power?
我正在为 OMNET++ 使用新发布的 INET 4.0 框架,我想获取无线主机(AdhocHost 类型)中的接收信号强度值。我该怎么做?
在INET
4.0.0中,一个模块收到的数据包包含几个tags. Between others there is SignalPowerInd
tag. According to SignalTag.msg:
This indication specifies the average analog signal power that was detected during receiving the packet.
It may be present on a packet from the phyiscal layer to the application.
此标记存在于无线 MAC 层的数据包处理中,例如:
应用层收到的数据包也包含SignalPowerInd
:
可以使用标准 API 从任何层中接收到的无线电数据包中获取 `SignalPowerInd` 的值。例如,要在 `UdpBasicApp` 中获取它,应该添加 `UdpBasicApp.cc`:
#include "inet/physicallayer/common/packetlevel/SignalTag_m.h"
// ...
void UdpBasicApp::socketDataArrived(UdpSocket *socket, Packet *packet) {
if (packet->findTag<SignalPowerInd>() != nullptr) {
auto signalPowerInd = packet->getTag<SignalPowerInd>();
auto rxPower = signalPowerInd->getPower().get();
EV_INFO << "RX power= " << rxPower << "W" << endl;
}
// process incoming packet
processPacket(packet);
}
我正在为 OMNET++ 使用新发布的 INET 4.0 框架,我想获取无线主机(AdhocHost 类型)中的接收信号强度值。我该怎么做?
在INET
4.0.0中,一个模块收到的数据包包含几个tags. Between others there is SignalPowerInd
tag. According to SignalTag.msg:
This indication specifies the average analog signal power that was detected during receiving the packet. It may be present on a packet from the phyiscal layer to the application.
此标记存在于无线 MAC 层的数据包处理中,例如:
应用层收到的数据包也包含SignalPowerInd
:
可以使用标准 API 从任何层中接收到的无线电数据包中获取 `SignalPowerInd` 的值。例如,要在 `UdpBasicApp` 中获取它,应该添加 `UdpBasicApp.cc`:
#include "inet/physicallayer/common/packetlevel/SignalTag_m.h"
// ...
void UdpBasicApp::socketDataArrived(UdpSocket *socket, Packet *packet) {
if (packet->findTag<SignalPowerInd>() != nullptr) {
auto signalPowerInd = packet->getTag<SignalPowerInd>();
auto rxPower = signalPowerInd->getPower().get();
EV_INFO << "RX power= " << rxPower << "W" << endl;
}
// process incoming packet
processPacket(packet);
}