#include <Decider80211.h>
Inheritance diagram for Decider80211:

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.
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 | |
| bool | packetOk (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 | |
|
|
converts a dB value into a normal fraction
00137 {
00138 return pow(10.0, (dB / 10));
00139 }
|
|
||||||||||||
|
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. 00058 {
00059
00060 double snirMin;
00061
00062 //initialize snirMin:
00063 snirMin = receivedList.begin()->snr;
00064
00065 for (SnrList::iterator iter = receivedList.begin(); iter != receivedList.end(); iter++)
00066 {
00067 if (iter->snr < snirMin)
00068 snirMin = iter->snr;
00069 }
00070 EV << "packet from: " << ((Mac80211Pkt *) (af->encapsulatedMsg()))->
00071 getSrcAddr() << " snrMin: " << snirMin << endl;
00072
00073 //if snir is big enough so that packet can be recognized at all
00074 if (snirMin > snirThreshold)
00075 {
00076 if (packetOk(snirMin, af->encapsulatedMsg()->length()))
00077 {
00078 EV << "packet was received correctly, it is now handed to upper layer...\n";
00079 sendUp(af);
00080 }
00081 else
00082 {
00083 EV << "Packet has BIT ERRORS! It is lost!\n";
00084 af->setName("ERROR");
00085 af->encapsulatedMsg()->setKind(BITERROR);
00086 sendUp(af);
00087 }
00088 }
00089 else
00090 {
00091 EV << "COLLISION! Packet got lost\n";
00092 af->setName("COLLISION");
00093 af->encapsulatedMsg()->setKind(COLLISION);
00094 sendUp(af);
00095 }
00096 }
|
|
|
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. 00036 {
00037 BasicDecider::initialize(stage);
00038
00039 if (stage == 0)
00040 {
00041 EV << "initializing stage 0\n";
00042 bitrate = par("bitrate");
00043 if (bitrate != 1E+6 && bitrate != 2E+6 && bitrate != 5.5E+6 && bitrate != 11E+6)
00044 error("Wrong bitrate!! Please chose 1E+6, 2E+6, 5.5E+6 or 11E+6 as bitrate!!");
00045 snirThreshold = dB2fraction(par("snirThreshold"));
00046 }
00047 }
|
|
||||||||||||
|
computes if packet is ok or has errors
00100 {
00101 double berHeader, berMPDU;
00102
00103 berHeader = 0.5 * exp(-snirMin * BANDWIDTH / BITRATE_HEADER);
00104 //if PSK modulation
00105 if (bitrate == 1E+6 || bitrate == 2E+6)
00106 berMPDU = 0.5 * exp(-snirMin * BANDWIDTH / bitrate);
00107 //if CCK modulation (modeled with 16-QAM)
00108 else if (bitrate == 5.5E+6)
00109 berMPDU = 0.5 * (1 - 1 / sqrt(pow(2.0, 4))) * erfc(snirMin * BANDWIDTH / bitrate);
00110 else // CCK, modelled with 256-QAM
00111 berMPDU = 0.25 * (1 - 1 / sqrt(pow(2.0, 8))) * erfc(snirMin * BANDWIDTH / bitrate);
00112 //probability of no bit error in the PLCP header
00113 double headerNoError = pow(1.0 - berHeader, HEADER_WITHOUT_PREAMBLE);
00114
00115 //probability of no bit error in the MPDU
00116 double MpduNoError = pow(1.0 - berMPDU, lengthMPDU);
00117 EV << "berHeader: " << berHeader << " berMPDU: " << berMPDU << endl;
00118 double rand = dblrand();
00119
00120 //if error in header
00121 if (rand > headerNoError)
00122 return (false);
00123 else
00124 {
00125 rand = dblrand();
00126
00127 //if error in MPDU
00128 if (rand > MpduNoError)
00129 return (false);
00130 //if no error
00131 else
00132 return (true);
00133 }
00134 }
|
|
|
should be set in the omnetpp.ini
|
|
|
should be set in the omnetpp.ini; everthing below this threshold can't be read and is therefor considered as a collision
|
1.4.1