|
INET Framework for OMNeT++/OMNEST
|
00001 /* -*- mode:c++ -*- ******************************************************** 00002 * file: SnrDecider.cc 00003 * 00004 * author: Marc Loebbers, Andreas Koepke 00005 * 00006 * copyright: (C) 2004 Telecommunication Networks Group (TKN) at 00007 * Technische Universitaet Berlin, Germany. 00008 * 00009 * This program is free software; you can redistribute it 00010 * and/or modify it under the terms of the GNU General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2 of the License, or (at your option) any later 00013 * version. 00014 * For further information see file COPYING 00015 * in the top level directory 00016 *************************************************************************** 00017 * part of: framework implementation developed by tkn 00018 **************************************************************************/ 00019 00020 #include "SnrDecider.h" 00021 #include "AirFrame_m.h" 00022 #include "FWMath.h" 00023 00024 00025 Define_Module(SnrDecider); 00026 00027 00028 void SnrDecider::initialize(int stage) 00029 { 00030 BasicDecider::initialize(stage); 00031 00032 if (stage == 0) 00033 { 00034 snrThresholdLevel = FWMath::dBm2mW(par("snrThresholdLevel")); 00035 } 00036 } 00037 00038 00043 bool SnrDecider::snrOverThreshold(SnrList& snrlist) const 00044 { 00045 //check the entries in the sduList if a level is lower than the 00046 //acceptable minimum: 00047 00048 //check 00049 for (SnrList::const_iterator iter = snrlist.begin(); iter != snrlist.end(); iter++) 00050 { 00051 if (iter->snr <= snrThresholdLevel) 00052 { 00053 EV << "Message got lost. MessageSnr: " << iter-> 00054 snr << " Threshold: " << snrThresholdLevel << endl; 00055 return false; 00056 } 00057 } 00058 return true; 00059 } 00060 00061 void SnrDecider::handleLowerMsg(AirFrame *af, SnrList& receivedList) 00062 { 00063 if (snrOverThreshold(receivedList)) 00064 { 00065 EV << "Message handed on to Mac\n"; 00066 sendUp(af); 00067 } 00068 else 00069 { 00070 delete af; 00071 } 00072 }