Skip to first unread message

Boong Baang

unread,
Jun 19, 2020, 7:17:25 PM6/19/20
to ns-3-users
I created a function that I call every 100ms and record if the channel was CCA busy or not using the IsStateCcaBusy method. 

 
 void BsmApplication::ifCCAbusy(uint32_t nodeID)
 
{
   
Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice>(GetNode(nodeID)->GetDevice(0));
   
// more than 1 device can be at each node so take the 1st one

   
Ptr<WifiPhy> phy = device->GetPhy ();

   
Ptr <YansWifiPhy> wfc = phy->GetObject<YansWifiPhy> ();

   
// Ptr <WifiPhyStateHelper> statehelper = phy->GetState();

   
PointerValue ptr;
    wfc
->GetAttribute("State", ptr);
   
Ptr<WifiPhyStateHelper> wpsh = ptr.Get<WifiPhyStateHelper>();

    std
::cerr<<"CCA state for node "<<nodeID<<" is "<<wpsh->IsStateCcaBusy()()<<std::endl;

   
if (wpsh->IsStateCcaBusy() == true )
   
{
     
CBRTime[nodeID].push_back(1);
   
}
   
else
   
{
     
CBRTime[nodeID].push_back(0);
   
}

   
CBRreviewInstants[nodeID] = Simulator::Schedule (//recvSink->GetNode ()->GetId (), //BIPLAV
                                     
CBRcheckInterval, &BsmApplication::ifCCAbusy, this,
                                      nodeID
);
 
}

I start with a highly dense scenario of 200 mobile vehicles transmitting at 30 Hz, so I expected the CCA busy to be 1 quite frequently. But it is mostly 0 in my scenario of 300 seconds. Should I use some other methods to evaluate CBR, like the `IsStateIdle`

Boong Baang

unread,
Jun 20, 2020, 2:32:15 AM6/20/20
to ns-3-users
I used the callback:

 
void BsmApplication::LogMyState(const Time start, const Time duration, const WifiPhyState state)
 
{
 std
::cerr<<"start time = "<<start.GetMilliSeconds()<<" with duration "<<duration.GetMilliSeconds()<<" and state "<<state<<std::endl;
 
}

that is called by

 Config::ConnectWithoutContext ("/NodeList/30/DeviceList/0/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/State",MakeCallback (&BsmApplication::LogMyState, this));



and this is also never called. This callback should be called every time the state changes, so can someone please help in finding the mistake.
Reply all
Reply to author
Forward
0 new messages