INET Framework for OMNeT++/OMNEST
BasicDecider Class Reference

Module to decide whether a frame is received correctly or is lost due to bit errors, interference... More...

#include <BasicDecider.h>

Inheritance diagram for BasicDecider:
BasicModule INotifiable Decider80211 SnrDecider ErrAndCollDecider

List of all members.

Public Member Functions

virtual void initialize (int)
 Initialization of the module and some variables.
virtual void handleMessage (cMessage *)
 Called every time a message arrives.

Protected Member Functions

Handle Messages

Functions to redefine by the programmer

virtual void handleSelfMsg (cMessage *msg)
 Handle self messages such as timer...
virtual void handleLowerMsg (AirFrame *, SnrList &)
 In this function the decision whether a frame is received correctly or not is made.
Convenience Functions

Functions for convenience - NOT to be modified

These are functions taking care of message encapsulation and message sending. Normally you should not need to alter these but should use them to handle message encasulation and sending. They will wirte all necessary information into packet headers and add or strip the appropriate headers for each layer.

virtual void sendUp (AirFrame *)
 Sends a message to the upper layer.

Protected Attributes

int uppergateOut
 gate id
int lowergateIn
unsigned long numRcvd
 statistics
unsigned long numSentUp

Detailed Description

Module to decide whether a frame is received correctly or is lost due to bit errors, interference...

The decider module only handles messages from lower layers. All messages from upper layers are directly passed to the snrEval layer and cannot be processed in the decider module

This is the basic decider module which does not really decide anything. It only provides the basic functionality which all decider modules should have, namely message de- & encapsulation (For further information about the functionality of the physical layer modules and the formats used for communication in between them have a look at "The Design of a Mobility Framework in OMNeT++" paper)

Every own decider module class should be derived from this class and only the handle*Msg functions may be redefined for your own needs. The other functions should usually NOT be changed.

All decider modules should assume bits as a unit for the length fields.

Author:
Marc Löbbers, Daniel Willkomm

Member Function Documentation

void BasicDecider::handleLowerMsg ( AirFrame *  frame,
SnrList snrList 
) [protected, virtual]

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

Redefine this function if you want to process messages from the channel before they are forwarded to upper layers

In this function it has to be decided whether this message got lost or not. This can be done with a simple SNR threshold or with transformations of SNR into bit error probabilities...

If you want to forward the message to upper layers please use sendUp which will decapsulate the MAC frame before sending

Reimplemented in Decider80211, ErrAndCollDecider, and SnrDecider.

Referenced by handleMessage().

{

    bool correct = true;
    //check the entries in the snrList if a level greater than the
    //acceptable minimum occured:
    double min = 0.0000000000000001;    // just a senseless example

    for (SnrList::iterator iter = snrList.begin(); iter != snrList.end(); iter++)
    {
        coreEV << "snr=" << iter->snr << "...\n";
        if (iter->snr < min)
            correct = false;
    }

    if (correct)
    {
        coreEV << "frame " << frame->getName() << " correct\n";
        sendUp(frame);
    }
    else
    {
        coreEV << "frame " << frame->getName() << " corrupted -> delete\n";
        delete frame;
    }
}
void BasicDecider::handleMessage ( cMessage *  msg) [virtual]

Called every time a message arrives.

The basic handle message function.

Depending on the gate a message arrives handleMessage just calls different handle*Msg functions to further process the message.

The decider module only handles messages from lower layers. All messages from upper layers are directly passed to the snrEval layer and cannot be processed in the decider module

You should not make any changes in this function but implement all your functionality into the handle*Msg functions called from here.

See also:
handleLowerMsg, handleSelfMsg
{
    if (msg->getArrivalGateId() == lowergateIn)
    {
        numRcvd++;

        //remove the control info from the AirFrame
        SnrControlInfo *cInfo = static_cast<SnrControlInfo *>(msg->removeControlInfo());

        // read in the snrList from the control info
        handleLowerMsg(check_and_cast<AirFrame *>(msg), cInfo->getSnrList());

        // delete the control info
        delete cInfo;

    }
    else if (msg->isSelfMessage())
    {
        handleSelfMsg(msg);
    }
}
virtual void BasicDecider::handleSelfMsg ( cMessage *  msg) [inline, protected, virtual]

Handle self messages such as timer...

Define this function if you want to timer or other kinds of self messages

Referenced by handleMessage().

{delete msg;};
void BasicDecider::initialize ( int  stage) [virtual]

Initialization of the module and some variables.

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

Then we have to intialize the gates and - if necessary - some own variables.

Reimplemented from BasicModule.

Reimplemented in Decider80211, and SnrDecider.

{
    BasicModule::initialize(stage);

    if (stage == 0)
    {
        uppergateOut = findGate("uppergateOut");
        lowergateIn = findGate("lowergateIn");
        numRcvd = 0;
        numSentUp = 0;
        WATCH(numRcvd);
        WATCH(numSentUp);
    }
}
void BasicDecider::sendUp ( AirFrame *  frame) [protected, virtual]

Sends a message to the upper layer.

Decapsulate and send message to the upper layer.

to be called within handleLowerMsg.

Referenced by SnrDecider::handleLowerMsg(), ErrAndCollDecider::handleLowerMsg(), Decider80211::handleLowerMsg(), and handleLowerMsg().

{
    numSentUp++;
    cPacket *macMsg = frame->decapsulate();
    send(macMsg, uppergateOut);
    coreEV << "sending up msg " << frame->getName() << endl;
    delete frame;
}

Member Data Documentation

int BasicDecider::lowergateIn [protected]

Referenced by handleMessage(), and initialize().

unsigned long BasicDecider::numRcvd [protected]

statistics

Referenced by handleMessage(), and initialize().

unsigned long BasicDecider::numSentUp [protected]

Referenced by initialize(), and sendUp().

int BasicDecider::uppergateOut [protected]

gate id

Referenced by initialize(), and sendUp().


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