#include <Ieee80211RadioModel.h>
Inheritance diagram for Ieee80211RadioModel:
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 | packetOk (double snirMin, int lengthMPDU, double bitrate) |
virtual double | dB2fraction (double dB) |
Protected Attributes | |
double | snirThreshold |
|
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. 00035 { 00036 // The physical layer header is sent with 1Mbit/s and the rest with the frame's bitrate 00037 return airframe->length()/airframe->getBitrate() + PHY_HEADER_LENGTH/BITRATE_HEADER; 00038 }
|
|
00103 {
00104 return pow(10.0, (dB / 10));
00105 }
|
|
Allows parameters to be read from the module parameters of a module that contains this object. Implements IRadioModel. 00030 { 00031 snirThreshold = dB2fraction(radioModule->par("snirThreshold")); 00032 }
|
|
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. 00042 { 00043 // calculate snirMin 00044 double snirMin = receivedList.begin()->snr; 00045 for (SnrList::const_iterator iter = receivedList.begin(); iter != receivedList.end(); iter++) 00046 if (iter->snr < snirMin) 00047 snirMin = iter->snr; 00048 00049 cMessage *frame = airframe->encapsulatedMsg(); 00050 EV << "packet (" << frame->className() << ")" << frame->name() << " (" << frame->info() << ") snrMin=" << snirMin << endl; 00051 00052 if (snirMin <= snirThreshold) 00053 { 00054 // if snir is too low for the packet to be recognized 00055 EV << "COLLISION! Packet got lost\n"; 00056 return false; 00057 } 00058 else if (packetOk(snirMin, airframe->encapsulatedMsg()->length(), airframe->getBitrate())) 00059 { 00060 EV << "packet was received correctly, it is now handed to upper layer...\n"; 00061 return true; 00062 } 00063 else 00064 { 00065 EV << "Packet has BIT ERRORS! It is lost!\n"; 00066 return false; 00067 } 00068 }
|
|
00072 { 00073 double berHeader, berMPDU; 00074 00075 berHeader = 0.5 * exp(-snirMin * BANDWIDTH / BITRATE_HEADER); 00076 00077 // if PSK modulation 00078 if (bitrate == 1E+6 || bitrate == 2E+6) 00079 berMPDU = 0.5 * exp(-snirMin * BANDWIDTH / bitrate); 00080 // if CCK modulation (modeled with 16-QAM) 00081 else if (bitrate == 5.5E+6) 00082 berMPDU = 0.5 * (1 - 1 / sqrt(pow(2.0, 4))) * erfc(snirMin * BANDWIDTH / bitrate); 00083 else // CCK, modelled with 256-QAM 00084 berMPDU = 0.25 * (1 - 1 / sqrt(pow(2.0, 8))) * erfc(snirMin * BANDWIDTH / bitrate); 00085 00086 // probability of no bit error in the PLCP header 00087 double headerNoError = pow(1.0 - berHeader, HEADER_WITHOUT_PREAMBLE); 00088 00089 // probability of no bit error in the MPDU 00090 double MpduNoError = pow(1.0 - berMPDU, lengthMPDU); 00091 EV << "berHeader: " << berHeader << " berMPDU: " << berMPDU << endl; 00092 double rand = dblrand(); 00093 00094 if (rand > headerNoError) 00095 return false; // error in header 00096 else if (dblrand() > MpduNoError) 00097 return false; // error in MPDU 00098 else 00099 return true; // no error 00100 }
|
|
|