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`