INET Framework for OMNeT++/OMNEST
|
#include <Ieee80211RadioModel.h>
Public Member Functions | |
virtual void | initializeFrom (cModule *radioModule) |
virtual double | calculateDuration (AirFrame *airframe) |
virtual bool | isReceivedCorrectly (AirFrame *airframe, const SnrList &receivedList) |
Protected Member Functions | |
virtual bool | isPacketOK (double snirMin, int lengthMPDU, double bitrate) |
virtual double | dB2fraction (double dB) |
Protected Attributes | |
double | snirThreshold |
Radio model for IEEE 802.11. The implementation is largely based on the Mobility Framework's SnrEval80211 and Decider80211 modules. See the NED file for more info.
double Ieee80211RadioModel::calculateDuration | ( | AirFrame * | ) | [virtual] |
Should be defined to calculate the duration of the AirFrame. Usually the duration is just the frame length divided by the bitrate. However, in some cases, notably IEEE 802.11, the header has a different modulation (and thus a different bitrate) than the rest of the message.
Implements IRadioModel.
{ // The physical layer header is sent with 1Mbit/s and the rest with the frame's bitrate return airframe->getBitLength()/airframe->getBitrate() + PHY_HEADER_LENGTH/BITRATE_HEADER; }
double Ieee80211RadioModel::dB2fraction | ( | double | dB | ) | [protected, virtual] |
Referenced by initializeFrom().
{
return pow(10.0, (dB / 10));
}
void Ieee80211RadioModel::initializeFrom | ( | cModule * | radioModule | ) | [virtual] |
Allows parameters to be read from the module parameters of a module that contains this object.
Implements IRadioModel.
{ snirThreshold = dB2fraction(radioModule->par("snirThreshold")); }
bool Ieee80211RadioModel::isPacketOK | ( | double | snirMin, |
int | lengthMPDU, | ||
double | bitrate | ||
) | [protected, virtual] |
Referenced by isReceivedCorrectly().
{ double berHeader, berMPDU; berHeader = 0.5 * exp(-snirMin * BANDWIDTH / BITRATE_HEADER); // if PSK modulation if (bitrate == 1E+6 || bitrate == 2E+6) berMPDU = 0.5 * exp(-snirMin * BANDWIDTH / bitrate); // if CCK modulation (modeled with 16-QAM) else if (bitrate == 5.5E+6) berMPDU = 0.5 * (1 - 1 / sqrt(pow(2.0, 4))) * erfc(snirMin * BANDWIDTH / bitrate); else // CCK, modelled with 256-QAM berMPDU = 0.25 * (1 - 1 / sqrt(pow(2.0, 8))) * erfc(snirMin * BANDWIDTH / bitrate); // probability of no bit error in the PLCP header double headerNoError = pow(1.0 - berHeader, HEADER_WITHOUT_PREAMBLE); // probability of no bit error in the MPDU double MpduNoError = pow(1.0 - berMPDU, lengthMPDU); EV << "berHeader: " << berHeader << " berMPDU: " << berMPDU << endl; double rand = dblrand(); if (rand > headerNoError) return false; // error in header else if (dblrand() > MpduNoError) return false; // error in MPDU else return true; // no error }
bool Ieee80211RadioModel::isReceivedCorrectly | ( | AirFrame * | airframe, |
const SnrList & | receivedList | ||
) | [virtual] |
Should be defined to calculate whether the frame has been received correctly. Input is the signal-noise ratio over the duration of the frame. The calculation may take into account the modulation scheme, possible error correction code, etc.
Implements IRadioModel.
{ // calculate snirMin double snirMin = receivedList.begin()->snr; for (SnrList::const_iterator iter = receivedList.begin(); iter != receivedList.end(); iter++) if (iter->snr < snirMin) snirMin = iter->snr; cPacket *frame = airframe->getEncapsulatedPacket(); EV << "packet (" << frame->getClassName() << ")" << frame->getName() << " (" << frame->info() << ") snrMin=" << snirMin << endl; if (snirMin <= snirThreshold) { // if snir is too low for the packet to be recognized EV << "COLLISION! Packet got lost\n"; return false; } else if (isPacketOK(snirMin, airframe->getEncapsulatedPacket()->getBitLength(), airframe->getBitrate())) { EV << "packet was received correctly, it is now handed to upper layer...\n"; return true; } else { EV << "Packet has BIT ERRORS! It is lost!\n"; return false; } }
double Ieee80211RadioModel::snirThreshold [protected] |
Referenced by initializeFrom(), and isReceivedCorrectly().