OMNET++:如何在INET 4.0中获取frame的源地址MAC?

OMNET++: How to obtain frame's source MAC Address in INET 4.0?

我正在使用 INET Framework 4.0 和 OMNET++。我已经自定义了我的 Ieee80211ScalarRadio 模块来读取信号功率和来源 MAC 从我的 AdhocHost.
中的各种 AP 接收到的信标地址 这是我的自定义 CIeee80211ScalarRadio.ned 文件:

import inet.physicallayer.ieee80211.packetlevel.Ieee80211ScalarRadio;

module CIeee80211ScalarRadio extends Ieee80211ScalarRadio
{
    @class(inet::physicallayer::CIeee80211ScalarRadio);
}

这里是相应的 CIeee80211ScalarRadio.cc 文件:

#include "inet/physicallayer/ieee80211/packetlevel/Ieee80211Radio.h"
#include "inet/physicallayer/common/packetlevel/SignalTag_m.h"
#include "inet/linklayer/common/MacAddressTag_m.h"


#include <omnetpp.h>
#include <string>

#include <cmath>
#include <iostream>

namespace inet{
namespace physicallayer{
class CIeee80211ScalarRadio : public Ieee80211Radio{
protected:
   virtual void sendUp(Packet *macFrame) override;
};

Define_Module(CIeee80211ScalarRadio);

void CIeee80211ScalarRadio::sendUp(Packet *macFrame)
{
    if (macFrame->findTag<SignalPowerInd>() != nullptr) {
           auto signalPowerInd = macFrame->getTag<SignalPowerInd>();
           auto rxPower = signalPowerInd->getPower().get();
           double pdBm = 10*log10(rxPower)+30;
           EV_INFO << "RX power = " << pdBm << " dBm" << endl;
    }
    if(macFrame->findTag<MacAddress>() != nullptr){
        auto macAddress = macFrame->getTag<MacAddress>();
        EV_INFO << "Mac Address = " << macAddress << endl;
    }

    Radio::sendUp(macFrame);
}
}//namespace physicallayer
}//namespace inet

如您所见,我正在覆盖 Ieee80211ScalarRadiosendUp() 方法以从 macFrame.
中获取我想要的值 我可以成功提取 RxPower,但是,当我对 MacAddress 做同样的事情时,我在 INET 自己的源代码中得到以下编译器错误:

../inet4/src/inet/common/packet/tag/TagSet.h:123:36: error: static_cast from 'std::__1::__vector_base<omnetpp::cObject *, std::__1::allocator<omnetpp::cObject *> >::value_type' (aka 'omnetpp::cObject *') to 'inet::MacAddress *', which are not related by inheritance, is not allowed

我怎样才能得到 MacAddress 值而不出现任何错误?

包含MAC地址的标签的正确名称是MacAddressInd,而不是MacAddress。它在您包含的 MacAddressTag_m.h 中声明。

编辑
附加说明:MacAddressInd 包含两个地址:源地址和目标地址。所以你应该明确你想要获得哪一个,例如:

auto macAddress = macFrame->getTag<MacAddressInd>()->getSrcAddress();