OMNET ++:如何获得无线信号功率? [英] OMNET++: How to obtain wireless signal power?

查看:146
本文介绍了OMNET ++:如何获得无线信号功率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用新发布的OMNET ++ INET 4.0框架,我想在无线主机(类型为AdhocHost)中获得接收到的信号强度值.我该怎么办?

I am using the newly released INET 4.0 framework for OMNET++ and I would like to obtain the received signal strength value in a wireless host (of type AdhocHost). How may I do that?

推荐答案

INET 4.0.0中,模块接收到的数据包包含多个 SignalTag.msg :

In INET 4.0.0 the packet received by a module contains several 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层的数据包处理中,例如:

This tag is present in packet processing by a wireless MAC layer, for example:

应用层收到的数据包也包含SignalPowerInd:

And packet received by application layer contains SignalPowerInd too:


可以使用标准API从任何层的接收到的无线电数据包中获取SignalPowerInd的值.例如,要在UdpBasicApp中获得它,应在UdpBasicApp.cc中添加:


One can obtain the value of SignalPowerInd from received radio packet in any layer using standard API. For example, to obtain it in UdpBasicApp one should add in 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 ++:如何获得无线信号功率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆