INET Framework for OMNeT++/OMNEST
Decider80211 Class Reference

Decider for the 802.11 modules. More...

#include <Decider80211.h>

Inheritance diagram for Decider80211:
BasicDecider BasicModule INotifiable

List of all members.

Protected Member Functions

virtual void initialize (int)
 Initialization of the module and some variables.
virtual void handleLowerMsg (AirFrame *, SnrList &)
 In this function the decision whether a frame is received correctly or not is made.
double dB2fraction (double)
 converts a dB value into a normal fraction
virtual bool isPacketOK (double, int)
 computes if packet is ok or has errors

Protected Attributes

double bitrate
 should be set in the omnetpp.ini
double snirThreshold
 should be set in the omnetpp.ini; everthing below this threshold can't be read and is therefor considered as a collision

Detailed Description

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.

Author:
Marc Löbbers, David Raguin

Member Function Documentation

double Decider80211::dB2fraction ( double  dB) [protected]

converts a dB value into a normal fraction

Referenced by initialize().

{
    return pow(10.0, (dB / 10));
}
void Decider80211::handleLowerMsg ( AirFrame *  af,
SnrList receivedList 
) [protected, virtual]

In this function the decision whether a frame is received correctly or not is made.

Handle message from lower layer. The minimal snir is read in and it is computed wether the packet has collided or has bit errors or was received correctly. The corresponding kind is set and it is handed on to the upper layer.

Reimplemented from BasicDecider.

{

    double snirMin;

    //initialize snirMin:
    snirMin = receivedList.begin()->snr;

    for (SnrList::iterator iter = receivedList.begin(); iter != receivedList.end(); iter++)
    {
        if (iter->snr < snirMin)
            snirMin = iter->snr;
    }
    cMessage *fr = af->getEncapsulatedPacket();
    EV << "packet (" << fr->getClassName() << ")" << fr->getName() << " (" << fr->info() << ") snrMin=" << snirMin << endl;

    //if snir is big enough so that packet can be recognized at all
    if (snirMin > snirThreshold)
    {
        if (isPacketOK(snirMin, af->getEncapsulatedPacket()->getBitLength()))
        {
            EV << "packet was received correctly, it is now handed to upper layer...\n";
            sendUp(af);
        }
        else
        {
            EV << "Packet has BIT ERRORS! It is lost!\n";
            af->setName("ERROR");
            af->getEncapsulatedPacket()->setKind(BITERROR);
            sendUp(af);
        }
    }
    else
    {
        EV << "COLLISION! Packet got lost\n";
        af->setName("COLLISION");
        af->getEncapsulatedPacket()->setKind(COLLISION);
        sendUp(af);
    }
}
void Decider80211::initialize ( int  stage) [protected, virtual]

Initialization of the module and some variables.

First we have to initialize the module from which we derived ours, in this case BasicDecider.

This decider also needs the bitrate and some 802.11 parameters are initialized

Reimplemented from BasicDecider.

{
    BasicDecider::initialize(stage);

    if (stage == 0)
    {
        EV << "initializing stage 0\n";
        bitrate = par("bitrate");
        if (bitrate != 1E+6 && bitrate != 2E+6 && bitrate != 5.5E+6 && bitrate != 11E+6)
            error("Wrong bitrate!! Please chose 1E+6, 2E+6, 5.5E+6 or 11E+6 as bitrate!!");
        snirThreshold = dB2fraction(par("snirThreshold"));
    }
}
bool Decider80211::isPacketOK ( double  snirMin,
int  lengthMPDU 
) [protected, virtual]

computes if packet is ok or has errors

Referenced by handleLowerMsg().

{
    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 error in header
    if (rand > headerNoError)
        return (false);
    else
    {
        rand = dblrand();

        //if error in MPDU
        if (rand > MpduNoError)
            return (false);
        //if no error
        else
            return (true);
    }
}

Member Data Documentation

double Decider80211::bitrate [protected]

should be set in the omnetpp.ini

Referenced by initialize(), and isPacketOK().

double Decider80211::snirThreshold [protected]

should be set in the omnetpp.ini; everthing below this threshold can't be read and is therefor considered as a collision

Referenced by handleLowerMsg(), and initialize().


The documentation for this class was generated from the following files: