Omnet++ Omnet++;/INET:如何从802.11 NIC获取RSSI?

Omnet++ Omnet++;/INET:如何从802.11 NIC获取RSSI?,omnet++,inet,Omnet++,Inet,我在一个节点模型中实现了一个无线路由协议,它使用IEEE801NIC类型的网络接口卡,并设置为在自组织模式下工作(IEEE801MGMTADHOC)。我想使用NIC的RSSI值作为路由协议中的指标之一 如何从NIC检索特定邻居节点(由其MAC地址标识)的RSSI值 编辑: void Ieee80211MgmtSTA::sendScanConfirm() { EV << "Scanning complete, found " << apList.size() <

我在一个节点模型中实现了一个无线路由协议,它使用IEEE801NIC类型的网络接口卡,并设置为在自组织模式下工作(IEEE801MGMTADHOC)。我想使用NIC的RSSI值作为路由协议中的指标之一
如何从NIC检索特定邻居节点(由其MAC地址标识)的RSSI值

编辑

void Ieee80211MgmtSTA::sendScanConfirm()
{
    EV << "Scanning complete, found " << apList.size() << " APs, sending confirmation to agent\n";

    // copy apList contents into a ScanConfirm primitive and send it back
    int n = apList.size();
    Ieee80211Prim_ScanConfirm *confirm = new Ieee80211Prim_ScanConfirm();
    confirm->setBssListArraySize(n);
    auto it = apList.begin();
    //XXX filter for req'd bssid and ssid
    for (int i = 0; i < n; i++, it++) {
        APInfo *ap = &(*it);
        Ieee80211Prim_BSSDescription& bss = confirm->getBssList(i);
        bss.setChannelNumber(ap->channel);
        bss.setBSSID(ap->address);
        bss.setSSID(ap->ssid.c_str());
        bss.setSupportedRates(ap->supportedRates);
        bss.setBeaconInterval(ap->beaconInterval);
        bss.setRxPower(ap->rxPower);
    }
    sendConfirm(confirm, PRC_SUCCESS);
}
在深入研究INET 3.6源代码后,我发现IEEE801NIC组件由以下模块(或层)组成(按自上而下的顺序):

  • 代理(仅在站点STA的基础架构模式下使用)
  • 管理(可以是IEEE80211GMTAP、IEEE80211GMTSTA、IEEE80211GMTADHOC类型)
  • 苹果
  • 无线电
我进一步分析了IEEE8011MGMTSTA的源代码,发现它实现了以下方法,记录接收信号强度(bss.setRxPower(ap->rxPower)):

void IEEE8011MGMTSTA::sendScanConfirm()
{

EV那么,你的工作完成了吗?
如我们所知,存在一种记录接收信号强度的实现方法
bss.setRxPower(ap->rxPower)

但是在同一个文件中,我们可以发现ap的变量在
storeAPInfo(const MACAddress&address,const ieee801beaconframebody&body)的函数中是初始的

见下文:

void Ieee80211MgmtSTA::storeAPInfo(const MACAddress& address, const Ieee80211BeaconFrameBody& body)
{
    APInfo *ap = lookupAP(address);
    if (ap) {
        EV << "AP address=" << address << ", SSID=" << body.getSSID() << " already in our AP list, refreshing the info\n";
    }
    else {
        EV << "Inserting AP address=" << address << ", SSID=" << body.getSSID() << " into our AP list\n";
        apList.push_back(APInfo());
        ap = &apList.back();
    }

    ap->channel = body.getChannelNumber();
    ap->address = address;
    ap->ssid = body.getSSID();
    ap->supportedRates = body.getSupportedRates();
    ap->beaconInterval = body.getBeaconInterval();
    //XXX where to get this from?
    //ap->rxPower = 。。。
}
bool FlatReceiverBase::computeIsReceptionPossible(const IListening *listening, const IReception *reception, IRadioSignal::SignalPart part) const
{
    if (!NarrowbandReceiverBase::computeIsReceptionPossible(listening, reception, part))
        return false;
    else {
        const FlatReceptionBase *flatReception = check_and_cast<const FlatReceptionBase *>(reception);
        W minReceptionPower = flatReception->computeMinPower(reception->getStartTime(part), reception->getEndTime(part));
        bool isReceptionPossible = minReceptionPower >= sensitivity;
        EV_DEBUG << "Computing whether reception is possible: minimum reception power = " << minReceptionPower << ", sensitivity = " << sensitivity << " -> reception is " << (isReceptionPossible ? "possible" : "impossible") << endl;
        return isReceptionPossible;
    }
}
void IEEE8011MGMTSTA::storeAPInfo(常量MACAddress&address,常量IEEE801BeaconFrameBody&body)
{
APInfo*ap=lookupAP(地址);
如果(ap){

在深入研究了源代码之后,我发现了一个有趣的函数

 bool computeIsReceptionPossible(const IListening *listening, const IReception *reception, IRadioSignal::SignalPart part) const
在文件FlatReceiverBase中,哪个路径可以是“#include”inet/physicalayer/base/packetlevel/FlatReceiverBase”。请参见以下内容:

void Ieee80211MgmtSTA::storeAPInfo(const MACAddress& address, const Ieee80211BeaconFrameBody& body)
{
    APInfo *ap = lookupAP(address);
    if (ap) {
        EV << "AP address=" << address << ", SSID=" << body.getSSID() << " already in our AP list, refreshing the info\n";
    }
    else {
        EV << "Inserting AP address=" << address << ", SSID=" << body.getSSID() << " into our AP list\n";
        apList.push_back(APInfo());
        ap = &apList.back();
    }

    ap->channel = body.getChannelNumber();
    ap->address = address;
    ap->ssid = body.getSSID();
    ap->supportedRates = body.getSupportedRates();
    ap->beaconInterval = body.getBeaconInterval();
    //XXX where to get this from?
    //ap->rxPower = 。。。
}
bool FlatReceiverBase::computeIsReceptionPossible(const IListening *listening, const IReception *reception, IRadioSignal::SignalPart part) const
{
    if (!NarrowbandReceiverBase::computeIsReceptionPossible(listening, reception, part))
        return false;
    else {
        const FlatReceptionBase *flatReception = check_and_cast<const FlatReceptionBase *>(reception);
        W minReceptionPower = flatReception->computeMinPower(reception->getStartTime(part), reception->getEndTime(part));
        bool isReceptionPossible = minReceptionPower >= sensitivity;
        EV_DEBUG << "Computing whether reception is possible: minimum reception power = " << minReceptionPower << ", sensitivity = " << sensitivity << " -> reception is " << (isReceptionPossible ? "possible" : "impossible") << endl;
        return isReceptionPossible;
    }
}
bool FlatReceiverBase::ComputeisReception可能(常量设置*侦听,常量设置*接收,IRadioSignal::SignalPart)常量
{
如果(!窄带ReceiverBase::ComputeisReception可能(侦听、接收、部分))
返回false;
否则{
const FlatReceptionBase*flatReception=检查和投射(接收);
W minReceptionPower=flatReception->computeMinPower(接收->获取开始时间(部分),接收->获取结束时间(部分));
bool IsReception可能=最小接收功率>=灵敏度;

EV_DEBUG特设管理模块的实现实际上相当有限。我正在考虑以下更改以启用RSSI的读取:1.将信标广播添加到Ieee80211MgmtAdhoc类中;2.添加用于保存相邻节点RSSI级别的表;3.修改ComputerCeptionindication()方法将RSSI读数添加到连接到MAC帧的接收指示结构中。>>其思想是从信标帧读取RSSI,并将其添加到相邻节点表中