Dear Mr. Sommer and every experts of Veins
I want to get CBR from PHY layer of Veins. Currently, I can get an approximate CBR from Decider80211p::processNewSignal(AirFrame* msg). I use a calculation window to get "busyTime" every second as follows:
simtime_t Decider80211p::processNewSignal(AirFrame* msg) {
AirFrame11p *frame = check_and_cast<AirFrame11p *>(msg);
// get the receiving power of the Signal at start-time and center frequency
Signal& signal = frame->getSignal();
Argument start(DimensionSet::timeFreqDomain);
start.setTime(signal.getReceptionStart());
start.setArgValue(Dimension::frequency_static(), centerFrequency);
signalStates[frame] = EXPECT_END;
double recvPower = signal.getReceivingPower()->getValue(start);
if (recvPower < sensitivity) {
//annotate the frame, so that we won't try decoding it at its end
frame->setUnderSensitivity(true);
//check channel busy status. a superposition of low power frames might turn channel status to busy
if (cca(simTime(), NULL) == false) {
setChannelIdleStatus(false);
}
return signal.getReceptionEnd();
}
else {
setChannelIdleStatus(false);
if (phy11p->getRadioState() == Radio::TX) {
frame->setBitError(true);
frame->setWasTransmitting(true);
DBG_D11P << "AirFrame: " << frame->getId() << " (" << recvPower << ") received, while already sending. Setting BitErrors to true" << std::endl;
}
else {
if (!currentSignal.first) {
//NIC is not yet synced to any frame, so lock and try to decode this frame
currentSignal.first = frame;
DBG_D11P << "AirFrame: " << frame->getId() << " with (" << recvPower << " > " << sensitivity << ") -> Trying to receive AirFrame." << std::endl;
}
else {
//NIC is currently trying to decode another frame. this frame will be simply treated as interference
DBG_D11P << "AirFrame: " << frame->getId() << " with (" << recvPower << " > " << sensitivity << ") -> Already synced to another AirFrame. Treating AirFrame as interference." << std::endl;
}
//channel turned busy
//measure communication density
myBusyTime += signal.getDuration().dbl();
// Measure Channel Busy Ratio
myCBR += signal.getDuration().dbl();
}
return signal.getReceptionEnd();
}
}
The myCBR is accumulated in 1 second and reset to 0, and then be accumulated again, so on so forth. But, some myCBRs are more than 1 in dense network of my simulation, the maximum myCBR reaches 1.5 ! It's impossible because my calculation window is 1 second. So is there someone who can help me out please? We may use cca() directly? Any suggestion is welcome.
Thanks in advance.