MiXiM
2.3
|
Decider implementation which decides a signals correctness by checking its SNR against a threshold. More...
#include <SNRThresholdDecider.h>
Public Member Functions | |
SNRThresholdDecider (DeciderToPhyInterface *phy, double sensitivity, int myIndex=-1, bool debug=false) | |
Initializes a new SNRThresholdDecider. | |
virtual bool | initFromMap (const ParameterMap ¶ms) |
Initialize the decider from XML map data. | |
virtual ChannelState | getChannelState () const |
A function that returns information about the channel state. | |
Protected Member Functions | |
virtual bool | checkIfAboveThreshold (Mapping *map, simtime_t_cref start, simtime_t_cref end) const |
Checks a mapping against a specific threshold (element-wise). | |
virtual DeciderResult * | createResult (const airframe_ptr_t frame) const |
Processes a received AirFrame. | |
virtual simtime_t | canAnswerCSR (const CSRInfo &requestInfo) const |
Returns point in time when the ChannelSenseRequest of the passed CSRInfo can be answered (e.g. because channel state changed or timeout is reached). | |
virtual void | answerCSR (CSRInfo &requestInfo) |
Answers the ChannelSenseRequest (CSR) from the passed CSRInfo. | |
bool | isIdleRSSI (double rssi) const |
Returns whether the passed rssi value indicates a idle channel. | |
Protected Attributes | |
double | snrThreshold |
Threshold value for checking a SNR-map (SNR-threshold). | |
double | busyThreshold |
The threshold rssi level above which the channel is considered busy. |
Decider implementation which decides a signals correctness by checking its SNR against a threshold.
SNRThresholdDecider decides the channel state (idle/busy) at hand of the current received total power level (independent from signal or noise). If its above the threshold defined by the "busyThreshold" parameter it considers the channel busy. The RSSI value returned by this Decider for a ChannelSenseRequest over time is always the RSSI value at the end of the sense.
SNRThresholdDecider implements only instantaneous channel sensing therefore it can only handle "UNTIL_IDLE" and "UNTIL_BUSY" ChannelSenseRequests but not "UNTIL_TIMEOUT".
Instantaneous channel sensing means SNRThresholdDecider is simplified in the way that the channel does not has to be below the threshold for a certain amount of time to be considered idle (how it would be in reality), but immediately after the RSSI drops below the threshold the channel is considered idle. This means "UNTIL_IDLE" and "UNTIL_BUSY" request are also answered at the first moment the channel drops below or raises above the threshold. SNRThresholdDecider does not support "UNTIL_TIMEOUT" requests because they are used to calculate the channel state over a time period (by averaging over it for example) which is not consistent with using instantaneous idle/busy changes.
SNRThresholdDecider::SNRThresholdDecider | ( | DeciderToPhyInterface * | phy, |
double | sensitivity, | ||
int | myIndex = -1 , |
||
bool | debug = false |
||
) | [inline] |
Initializes a new SNRThresholdDecider.
phy | - pointer to the deciders phy layer |
snrThreshold | - the threshold (as fraction) above which a signal is received correctly |
sensitivity | - the sensitivity (in mW) of the physical layer |
busyThreshold | - the rssi threshold (in mW) above which the channel is considered idle |
myIndex | - the index of the host of this deciders phy (for debugging output) |
debug | - should debug messages be displayed? |
: BaseDecider(phy, sensitivity, myIndex, debug) , snrThreshold(0) , busyThreshold(sensitivity) {}
void SNRThresholdDecider::answerCSR | ( | CSRInfo & | requestInfo | ) | [protected, virtual] |
Answers the ChannelSenseRequest (CSR) from the passed CSRInfo.
Calculates the rssi value and the channel idle state and sends the CSR together with the result back to the mac layer.
Reimplemented from BaseDecider.
References getChannelState(), Decider::phy, and DeciderToPhyInterface::sendControlMsgToMac().
{ // put the sensing-result to the request and // send it to the Mac-Layer as Control-message (via Interface) requestInfo.getRequest()->setResult( getChannelState() ); phy->sendControlMsgToMac(requestInfo.getRequest()); requestInfo.clear(); }
bool SNRThresholdDecider::checkIfAboveThreshold | ( | Mapping * | map, |
simtime_t_cref | start, | ||
simtime_t_cref | end | ||
) | const [protected, virtual] |
Checks a mapping against a specific threshold (element-wise).
References Mapping::createConstIterator(), BaseDecider::debug, ConstMappingIterator::getNextPosition(), ConstMappingIterator::getPosition(), Argument::getTime(), ConstMappingIterator::getValue(), ConstMappingIterator::hasNext(), ConstMappingIterator::iterateTo(), ConstMappingIterator::next(), and snrThreshold.
Referenced by createResult().
{ assert(map); if(debug){ deciderEV << "Checking if SNR is above Threshold of " << snrThreshold << endl; } // check every entry in the mapping against threshold value ConstMappingIterator* it = map->createConstIterator(Argument(start)); // check if values at start-time fulfill snrThreshold-criterion if(debug){ deciderEV << "SNR at time " << start << " is " << it->getValue() << endl; } if ( it->getValue() <= snrThreshold ){ delete it; return false; } while ( it->hasNext() && it->getNextPosition().getTime() < end) { it->next(); if(debug){ deciderEV << "SNR at time " << it->getPosition().getTime() << " is " << it->getValue() << endl; } // perform the check for smaller entry if ( it->getValue() <= snrThreshold) { delete it; return false; } } it->iterateTo(Argument(end)); if(debug){ deciderEV << "SNR at time " << end << " is " << it->getValue() << endl; } if ( it->getValue() <= snrThreshold ){ delete it; return false; } delete it; return true; }
DeciderResult * SNRThresholdDecider::createResult | ( | const airframe_ptr_t | frame | ) | const [protected, virtual] |
Processes a received AirFrame.
The SNR-mapping for the Signal is created and checked against the Deciders SNR-threshold. Depending on that the received AirFrame is either sent up to the MAC-Layer or dropped.
Reimplemented from BaseDecider.
References BaseDecider::calculateSnrMapping(), checkIfAboveThreshold(), Signal::getReceptionEnd(), Signal::getReceptionStart(), MappingUtils::post(), MappingUtils::pre(), and snrThreshold.
{ // first collect all necessary information Mapping* snrMap = calculateSnrMapping(frame); assert(snrMap); const Signal& signal = frame->getSignal(); // NOTE: Since this decider does not consider the amount of time when the signal's SNR is // below the threshold even the smallest (normally insignificant) drop causes this decider // to reject reception of the signal. // Since the default MiXiM-signal is still zero at its exact start and end, these points // are ignored in the interval passed to the following method. bool aboveThreshold = checkIfAboveThreshold(snrMap, MappingUtils::post(signal.getReceptionStart()), MappingUtils::pre(signal.getReceptionEnd())); delete snrMap; snrMap = NULL; // check if the snrMapping is above the Decider's specific threshold, // i.e. the Decider has received it correctly if (aboveThreshold) { deciderEV << "SNR is above threshold("<<snrThreshold<<") -> sending up." << endl; } else { deciderEV << "SNR is below threshold("<<snrThreshold<<") -> dropped." << endl; } return new DeciderResult(aboveThreshold && !frame->hasBitError()); }
ChannelState SNRThresholdDecider::getChannelState | ( | ) | const [virtual] |
A function that returns information about the channel state.
It is an alternative for the MACLayer in order to obtain information immediately (in contrast to sending a ChannelSenseRequest, i.e. sending a cMessage over the OMNeT-control-channel)
Reimplemented from BaseDecider.
References ChannelState::getRSSI(), and isIdleRSSI().
Referenced by answerCSR().
{ ChannelState csBase = BaseDecider::getChannelState(); return ChannelState(/*csBase.isIdle() &&*/ isIdleRSSI(csBase.getRSSI()), csBase.getRSSI()); }
bool SNRThresholdDecider::initFromMap | ( | const ParameterMap & | params | ) | [virtual] |
Initialize the decider from XML map data.
This method should be defined for generic decider initialization.
params | The parameter map which was filled by XML reader. |
Reimplemented from Decider.
References busyThreshold, and snrThreshold.
{ ParameterMap::const_iterator it = params.find("snrThreshold"); bool bInitSuccess = true; if (it != params.end()) { snrThreshold = ParameterMap::mapped_type(it->second).doubleValue(); } else if ((it = params.find("threshold")) != params.end()) { snrThreshold = ParameterMap::mapped_type(it->second).doubleValue(); } else { bInitSuccess = false; opp_warning("No threshold defined in config.xml for Decider80211!"); } if ((it = params.find("busyThreshold")) != params.end()) { busyThreshold = ParameterMap::mapped_type(it->second).doubleValue(); } else { deciderEV << "No busy threshold defined for SNRThresholdDecider. Using" << " phy layers sensitivity as busy threshold." << endl; } return BaseDecider::initFromMap(params) && bInitSuccess; }
bool SNRThresholdDecider::isIdleRSSI | ( | double | rssi | ) | const [inline, protected] |
Returns whether the passed rssi value indicates a idle channel.
rssi | the channels rssi value to evaluate |
Referenced by canAnswerCSR(), and getChannelState().
{ return rssi <= busyThreshold; }