Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

BasicDecider Class Reference

#include <BasicDecider.h>

Inheritance diagram for BasicDecider:

BasicModule INotifiable Decider80211 SnrDecider ErrAndCollDecider List of all members.

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


Public Member Functions

virtual void initialize (int)
 Initialization of the module and some variables.
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.

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


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.

00114 {
00115 
00116     bool correct = true;
00117     //check the entries in the snrList if a level greater than the
00118     //acceptable minimum occured:
00119     double min = 0.0000000000000001;    // just a senseless example
00120 
00121     for (SnrList::iterator iter = snrList.begin(); iter != snrList.end(); iter++)
00122     {
00123         coreEV << "snr=" << iter->snr << "...\n";
00124         if (iter->snr < min)
00125             correct = false;
00126     }
00127 
00128     if (correct)
00129     {
00130         coreEV << "frame " << frame->name() << " correct\n";
00131         sendUp(frame);
00132     }
00133     else
00134     {
00135         coreEV << "frame " << frame->name() << " corrupted -> delete\n";
00136         delete frame;
00137     }
00138 }

void BasicDecider::handleMessage cMessage *  msg  ) 
 

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
00067 {
00068     if (msg->arrivalGateId() == lowergateIn)
00069     {
00070         numRcvd++;
00071 
00072         //remove the control info from the AirFrame
00073         SnrControlInfo *cInfo = static_cast<SnrControlInfo *>(msg->removeControlInfo());
00074 
00075         // read in the snrList from the control info
00076         handleLowerMsg(check_and_cast<AirFrame *>(msg), cInfo->getSnrList());
00077 
00078         // delete the control info
00079         delete cInfo;
00080 
00081     }
00082     else if (msg->isSelfMessage())
00083     {
00084         handleSelfMsg(msg);
00085     }
00086 }

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

00093 {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.

00037 {
00038     BasicModule::initialize(stage);
00039 
00040     if (stage == 0)
00041     {
00042         uppergateOut = findGate("uppergateOut");
00043         lowergateIn = findGate("lowergateIn");
00044         numRcvd = 0;
00045         numSentUp = 0;
00046         WATCH(numRcvd);
00047         WATCH(numSentUp);
00048     }
00049 }

void BasicDecider::sendUp AirFrame frame  )  [protected]
 

Sends a message to the upper layer.

Decapsulate and send message to the upper layer.

to be called within handleLowerMsg.

00094 {
00095     numSentUp++;
00096     cMessage *macMsg = frame->decapsulate();
00097     send(macMsg, uppergateOut);
00098     coreEV << "sending up msg " << frame->name() << endl;
00099     delete frame;
00100 }


Member Data Documentation

int BasicDecider::lowergateIn [protected]
 

unsigned long BasicDecider::numRcvd [protected]
 

statistics

unsigned long BasicDecider::numSentUp [protected]
 

int BasicDecider::uppergateOut [protected]
 

gate id


The documentation for this class was generated from the following files:
Generated on Thu Oct 19 18:22:21 2006 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.0