Decider for the 802.11 modules. More...
#include <Decider80211.h>
Inherits BaseDecider.
Inherited by Decider80211Battery.
Public Types | |
enum | Decider80211ControlKinds { NOTHING = 22100, BITERROR, COLLISION, LAST_DECIDER_80211_CONTROL_KIND } |
Control message kinds used by this Decider. More... | |
Public Member Functions | |
Decider80211 (DeciderToPhyInterface *phy, double threshold, double sensitivity, int channel, int myIndex=-1, bool debug=false) | |
Initializes the Decider with a pointer to its PhyLayer and specific values for threshold and sensitivity. | |
Protected Member Functions | |
virtual DeciderResult * | checkIfSignalOk (AirFrame *frame) |
Checks if the passed completed AirFrame was received correctly. | |
virtual simtime_t | processNewSignal (AirFrame *frame) |
Processes a new Signal. Returns the time it wants to handle the signal again. | |
virtual simtime_t | processSignalEnd (AirFrame *frame) |
Processes a received AirFrame. | |
bool | packetOk (double snirMin, int lengthMPDU, double bitrate) |
computes if packet is ok or has errors | |
virtual double | calcChannelSenseRSSI (simtime_t start, simtime_t end) |
Calculates the RSSI value for the passed interval. | |
Protected Attributes | |
double | snrThreshold |
threshold value for checking a SNR-map (SNR-threshold) | |
double | centerFrequency |
The center frequency on which the decider listens for signals. |
Decider for the 802.11 modules.
Depending on the minimum of the snr included in the PhySDU this module computes a bit error probability. The header (1 Mbit/s) is always modulated with DBQPSK. The PDU is normally modulated either with DBPSK (1 and 2 Mbit/s) or CCK (5.5 and 11 Mbit/s). CCK is not easy to model, therefore it is modeled as DQPSK with a 16-QAM for 5.5 Mbit/s and a 256-QAM for 11 Mbit/s.
Definition at line 29 of file Decider80211.h.
Control message kinds used by this Decider.
BITERROR |
The decider has recognized a bit error in the packet. |
COLLISION |
Packet lost due to collision. |
LAST_DECIDER_80211_CONTROL_KIND |
Sub-classing deciders should begin their own kinds at this value. |
Definition at line 32 of file Decider80211.h.
{ NOTHING = 22100, BITERROR, COLLISION, LAST_DECIDER_80211_CONTROL_KIND };
double Decider80211::calcChannelSenseRSSI | ( | simtime_t | start, | |
simtime_t | end | |||
) | [protected, virtual] |
Calculates the RSSI value for the passed interval.
This method is called by BaseDecider when it answers a ChannelSenseRequest or calculates the current channel state.
Returns the maximum RSSI value inside the passed time interval and the channel the Decider currently listens to.
Reimplemented from BaseDecider.
Definition at line 62 of file Decider80211.cc.
References BaseDecider::calculateRSSIMapping(), centerFrequency, MappingUtils::findMax(), Dimension::frequency_static(), Argument::setArgValue(), Argument::setTime(), and DimensionSet::timeFreqDomain.
{ Mapping* rssiMap = calculateRSSIMapping(start, end); Argument min(DimensionSet::timeFreqDomain); min.setTime(start); min.setArgValue(Dimension::frequency_static(), centerFrequency - 11e6); Argument max(DimensionSet::timeFreqDomain); max.setTime(end); max.setArgValue(Dimension::frequency_static(), centerFrequency + 11e6); double rssi = MappingUtils::findMax(*rssiMap, min, max); delete rssiMap; return rssi; }
DeciderResult * Decider80211::checkIfSignalOk | ( | AirFrame * | frame | ) | [protected, virtual] |
Checks if the passed completed AirFrame was received correctly.
Returns the result as a DeciderResult
Reimplemented in Decider80211MultiChannel.
Definition at line 80 of file Decider80211.cc.
References BaseDecider::calculateSnrMapping(), centerFrequency, Mapping::createConstIterator(), MappingUtils::findMin(), Dimension::frequency_static(), Signal::getBitrate(), Signal::getSignalLength(), Signal::getSignalStart(), ConstMappingIterator::getValue(), ConstMappingIterator::next(), packetOk(), Argument::setArgValue(), Argument::setTime(), snrThreshold, and DimensionSet::timeFreqDomain.
Referenced by processSignalEnd().
{ // check if the snrMapping is above the Decider's specific threshold, // i.e. the Decider has received it correctly // first collect all necessary information Mapping* snrMap = calculateSnrMapping(frame); assert(snrMap); Signal& s = frame->getSignal(); simtime_t start = s.getSignalStart(); simtime_t end = start + s.getSignalLength(); start = start + RED_PHY_HEADER_DURATION; //its ok if the phy header is received only //partly - TODO: maybe solve this nicer Argument min(DimensionSet::timeFreqDomain); min.setTime(start); min.setArgValue(Dimension::frequency_static(), centerFrequency - 11e6); Argument max(DimensionSet::timeFreqDomain); max.setTime(end); max.setArgValue(Dimension::frequency_static(), centerFrequency + 11e6); double snirMin = MappingUtils::findMin(*snrMap, min, max); deciderEV << " snrMin: " << snirMin << endl; ConstMappingIterator* bitrateIt = s.getBitrate()->createConstIterator(); bitrateIt->next(); //iterate to payload bitrate indicator double payloadBitrate = bitrateIt->getValue(); delete bitrateIt; DeciderResult80211* result = 0; if (snirMin > snrThreshold) { if(packetOk(snirMin, frame->getBitLength() - (int)PHY_HEADER_LENGTH, payloadBitrate)) { result = new DeciderResult80211(true, payloadBitrate, snirMin); } else { deciderEV << "Packet has BIT ERRORS! It is lost!\n"; result = new DeciderResult80211(false, payloadBitrate, snirMin); } } else { deciderEV << "Packet has ERRORS! It is lost!\n"; result = new DeciderResult80211(false, payloadBitrate, snirMin); } delete snrMap; snrMap = 0; return result; }
simtime_t Decider80211::processNewSignal | ( | AirFrame * | frame | ) | [protected, virtual] |
Processes a new Signal. Returns the time it wants to handle the signal again.
Default implementation checks if the signals receiving power is above the sensitivity of the radio and we are not already trying to receive another AirFrame. If thats the case it waits for the end of the signal.
Reimplemented from BaseDecider.
Reimplemented in Decider80211MultiChannel.
Definition at line 26 of file Decider80211.cc.
References centerFrequency, BaseDecider::currentSignal, Dimension::frequency_static(), Signal::getReceivingPower(), Signal::getSignalLength(), Signal::getSignalStart(), Decider::notAgain, BaseDecider::sensitivity, Argument::setArgValue(), BaseDecider::setChannelIdleStatus(), Argument::setTime(), and DimensionSet::timeFreqDomain.
{ if(currentSignal.first != 0) { deciderEV << "Already receiving another AirFrame!" << endl; return notAgain; } // get the receiving power of the Signal at start-time and center frequency Signal& signal = frame->getSignal(); Argument start(DimensionSet::timeFreqDomain); start.setTime(signal.getSignalStart()); start.setArgValue(Dimension::frequency_static(), centerFrequency); double recvPower = signal.getReceivingPower()->getValue(start); // check whether signal is strong enough to receive if ( recvPower < sensitivity ) { deciderEV << "Signal is to weak (" << recvPower << " < " << sensitivity << ") -> do not receive." << endl; // Signal too weak, we can't receive it, tell PhyLayer that we don't want it again return notAgain; } // Signal is strong enough, receive this Signal and schedule it deciderEV << "Signal is strong enough (" << recvPower << " > " << sensitivity << ") -> Trying to receive AirFrame." << endl; currentSignal.first = frame; currentSignal.second = EXPECT_END; //channel turned busy setChannelIdleStatus(false); return ( signal.getSignalStart() + signal.getSignalLength() ); }
simtime_t Decider80211::processSignalEnd | ( | AirFrame * | frame | ) | [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.
Definition at line 172 of file Decider80211.cc.
References BITERROR, checkIfSignalOk(), BaseDecider::currentSignal, DeciderResult::isSignalCorrect(), Decider::notAgain, Decider::phy, DeciderToPhyInterface::sendControlMsg(), DeciderToPhyInterface::sendUp(), and BaseDecider::setChannelIdleStatus().
{ // here the Signal is finally processed DeciderResult* result = checkIfSignalOk(frame); if (result->isSignalCorrect()) { deciderEV << "packet was received correctly, it is now handed to upper layer...\n"; // go on with processing this AirFrame, send it to the Mac-Layer phy->sendUp(frame, result); } else { deciderEV << "packet was not received correctly, sending it as control message to upper layer\n"; Mac80211Pkt* mac = static_cast<Mac80211Pkt*>(frame->decapsulate()); mac->setName("ERROR"); mac->setKind(BITERROR); phy->sendControlMsg(mac); delete result; } // we have processed this AirFrame and we prepare to receive the next one currentSignal.first = 0; //channel is idle now setChannelIdleStatus(true); return notAgain; }