GenericRadioModel Class Reference

#include <GenericRadioModel.h>

Inheritance diagram for GenericRadioModel:

IRadioModel List of all members.

Detailed Description

Generic radio model. Frame duration is calculated from the bitrate and the packet length plus a physical header length. Bit error rate is calculated from the modulation scheme, signal bandwidth, bitrate and the frame length.


Public Member Functions

 GenericRadioModel ()
virtual ~GenericRadioModel ()
virtual void initializeFrom (cModule *radioModule)
virtual double calculateDuration (AirFrame *airframe)
virtual bool isReceivedCorrectly (AirFrame *airframe, const SnrList &receivedList)

Protected Member Functions

virtual bool packetOk (double snirMin, int length, double bitrate)
virtual double dB2fraction (double dB)

Protected Attributes

double snirThreshold
long headerLengthBits
double bandwidth
IModulationmodulation


Constructor & Destructor Documentation

GenericRadioModel::GenericRadioModel (  ) 

00029 {
00030     modulation = NULL;
00031 }

GenericRadioModel::~GenericRadioModel (  )  [virtual]

00034 {
00035     delete modulation;
00036 }


Member Function Documentation

double GenericRadioModel::calculateDuration ( AirFrame 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.

00059 {
00060     return (airframe->length()+headerLengthBits) / airframe->getBitrate();
00061 }

double GenericRadioModel::dB2fraction ( double  dB  )  [protected, virtual]

00107 {
00108     return pow(10.0, (dB / 10));
00109 }

void GenericRadioModel::initializeFrom ( cModule *  radioModule  )  [virtual]

Allows parameters to be read from the module parameters of a module that contains this object.

Implements IRadioModel.

00039 {
00040     snirThreshold = dB2fraction(radioModule->par("snirThreshold"));
00041     headerLengthBits = radioModule->par("headerLengthBits");
00042     bandwidth = radioModule->par("bandwidth");
00043 
00044     const char *modulationName = radioModule->par("modulation");
00045     if (strcmp(modulationName, "null")==0)
00046         modulation = new NullModulation();
00047     else if (strcmp(modulationName, "BPSK")==0)
00048         modulation = new BPSKModulation();
00049     else if (strcmp(modulationName, "16-QAM")==0)
00050         modulation = new QAM16Modulation();
00051     else if (strcmp(modulationName, "256-QAM")==0)
00052         modulation = new QAM256Modulation();
00053     else
00054         opp_error("unrecognized modulation '%s'", modulationName);
00055 }

bool GenericRadioModel::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.

00065 {
00066     // calculate snirMin
00067     double snirMin = receivedList.begin()->snr;
00068     for (SnrList::const_iterator iter = receivedList.begin(); iter != receivedList.end(); iter++)
00069         if (iter->snr < snirMin)
00070             snirMin = iter->snr;
00071 
00072     if (snirMin <= snirThreshold)
00073     {
00074         // if snir is too low for the packet to be recognized
00075         EV << "COLLISION! Packet got lost\n";
00076         return false;
00077     }
00078     else if (packetOk(snirMin, airframe->length()+headerLengthBits, airframe->getBitrate()))
00079     {
00080         EV << "packet was received correctly, it is now handed to upper layer...\n";
00081         return true;
00082     }
00083     else
00084     {
00085         EV << "Packet has BIT ERRORS! It is lost!\n";
00086         return false;
00087     }
00088 }

bool GenericRadioModel::packetOk ( double  snirMin,
int  length,
double  bitrate 
) [protected, virtual]

00092 {
00093     double ber = modulation->bitErrorRate(snirMin, bandwidth, bitrate);
00094 
00095     if (ber==0.0)
00096         return true;
00097 
00098     double probNoError = pow(1.0 - ber, length); // probability of no bit error
00099 
00100     if (dblrand() > probNoError)
00101         return false; // error in MPDU
00102     else
00103         return true; // no error
00104 }


Member Data Documentation

double GenericRadioModel::bandwidth [protected]

long GenericRadioModel::headerLengthBits [protected]

IModulation* GenericRadioModel::modulation [protected]

double GenericRadioModel::snirThreshold [protected]


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:20:19 2007 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.7