从 NS3 中接收的回调访问 WiFiPhy

Accessing WiFiPhy from a recevied callback in NS3

本文关键字:回调 访问 WiFiPhy NS3      更新时间:2023-10-16

我想使用签名访问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();

但是我在运行过程中遇到分段错误?我到底在这里做错了什么?

谢谢

好的,

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

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