【问题标题】:Accessing WiFiPhy from a recevied callback in NS3从 NS3 中收到的回调访问 WiFiPhy
【发布时间】:2018-04-21 09:22:58
【问题描述】:

我想通过签名访问 NetDevice 的接收回调中的 WiFiPhy。

typedef Callback< bool, Ptr<NetDevice>, Ptr<const Packet>, uint16_t, const Address & > ReceiveCallback;

在回调中,我将 NetDevice 转换为 WiFiDevice,就像 WiFiPhy 函数一样。

Ptr<WifiNetDevice> wifiNetDevice = DynamicCast<WifiNetDevice>(device);
Ptr<WifiPhy> wifiPhyDev = wifiNetDevice->GetPhy();

但是我在运行期间遇到了分段错误?实际上我在这里做错了什么?

谢谢

【问题讨论】:

    标签: c++ wifi simulator ns-3


    【解决方案1】:

    好的,我找到了.. 当您创建 NetDeviceContainer 时,该对象的类型为 NetDevice,它没有任何 WifiPhy。解决方案是将其动态投射到 WifiNetDevice 并发送帧。

    Ptr<WifiNetDevice> wifiNetDevice = DynamicCast<WifiNetDevice>(netDevice);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-14
      • 2019-09-05
      • 1970-01-01
      • 2014-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-08
      相关资源
      最近更新 更多