Accessing PHY layer state of wifi80211p devices

86 views
Skip to first unread message

Alejandro Jimenez

unread,
Jul 3, 2015, 1:03:10 PM7/3/15
to ns-3-...@googlegroups.com
This is a follow up of the post:


I am trying to access the IsStateBusy() of the YansWifiPhy class of nodes in a vehicular scenario. The important extracts of my code for this issue are:

int main (int argc, char *argv[])
{
 
......

 
NetDeviceContainer devices = wifi80211p.Install (wifiPhy, wifi80211pMac, cars);
 
......
 
Simulator::Schedule (Tm, &CalculateCL, devices, Tm);
}

void CalculateCL (NetDeviceContainer devices, Time pktInterval)
{
 
Ptr<NetDevice> dev = devices.Get(0);
 
Ptr<WifiNetDevice> wifiDev = DynamicCast<WifiNetDevice> (dev);
 
Ptr<WifiPhy> phy = dev->GetPhy ();
 
Ptr <YansWifiPhy> phyobj =phy->GetObject<YansWifiPhy> ();
}

The problem comes at the line:

Ptr<WifiNetDevice> wifiDev = DynamicCast<WifiNetDevice> (dev);

I am getting the following error that has to do with the DynamicCast to WifiNetDevice":

In file included from ./ns3/attribute.h:25:0,
                 from ./ns3/vector.h:23,
                 from ../scratch/80211p_simple_v3.cc:32:
./ns3/ptr.h: In instantiation of ‘ns3::Ptr<T> ns3::DynamicCast(const ns3::Ptr<T2>&) [with T1 = ns3::WifiNetDevice; T2 = ns3::NetDevice]’:
../scratch/80211p_simple_v3.cc:109:63:   required from here
./ns3/ptr.h:667:55: error: cannot dynamic_cast ‘ns3::PeekPointer<ns3::NetDevice>((* & p))’ (of type ‘class ns3::NetDevice*’) to type ‘class ns3::WifiNetDevice*’ (target is not pointer or reference to complete type)
   return Ptr<T1> (dynamic_cast<T1 *> (PeekPointer (p)));
                                                       ^
I will appreciate any comments. Thanks.

Tommaso Pecorella

unread,
Jul 3, 2015, 1:29:34 PM7/3/15
to ns-3-...@googlegroups.com
It should work. Have you included the right headers ?

T.

Alejandro Jimenez

unread,
Jul 6, 2015, 5:20:43 AM7/6/15
to ns-3-...@googlegroups.com
No I have not. I was missing this one.

#include "ns3/wifi-module.h"

Thanks.
Reply all
Reply to author
Forward
0 new messages