![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /****************************************************************************** 00002 * WiFiMac * 00003 * This file is part of openWNS (open Wireless Network Simulator) 00004 * _____________________________________________________________________________ 00005 * 00006 * Copyright (C) 2004-2007 00007 * Chair of Communication Networks (ComNets) 00008 * Kopernikusstr. 16, D-52074 Aachen, Germany 00009 * phone: ++49-241-80-27910, 00010 * fax: ++49-241-80-22242 00011 * email: info@openwns.org 00012 * www: http://www.openwns.org 00013 * _____________________________________________________________________________ 00014 * 00015 * openWNS is free software; you can redistribute it and/or modify it under the 00016 * terms of the GNU Lesser General Public License version 2 as published by the 00017 * Free Software Foundation; 00018 * 00019 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00020 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00021 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00022 * details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public License 00025 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00026 * 00027 ******************************************************************************/ 00028 00029 #include <WIFIMAC/lowerMAC/rateAdaptationStrategies/PER.hpp> 00030 #include <WIFIMAC/management/VirtualCapabilityInformationBase.hpp> 00031 00032 #include <algorithm> 00033 00034 using namespace wifimac::lowerMAC::rateAdaptationStrategies; 00035 00036 STATIC_FACTORY_REGISTER_WITH_CREATOR(PER, IRateAdaptationStrategy, "PER", IRateAdaptationStrategyCreator); 00037 00038 PER::PER( 00039 const wns::pyconfig::View& _config, 00040 wns::service::dll::UnicastAddress _receiver, 00041 wifimac::management::PERInformationBase* _per, 00042 wifimac::management::SINRInformationBase* _sinr, 00043 wifimac::lowerMAC::Manager* _manager, 00044 wifimac::convergence::PhyUser* _phyUser, 00045 wns::logger::Logger* _logger): 00046 IRateAdaptationStrategy(_config, _receiver, _per, _sinr, _manager, _phyUser, _logger), 00047 myReceiver(_receiver), 00048 per(_per), 00049 perForGoingDown(_config.get<double>("perForGoingDown")), 00050 perForGoingUp(_config.get<double>("perForGoingUp")), 00051 logger(_logger) 00052 { 00053 friends.phyUser = _phyUser; 00054 curPhyMode = _config.getView("initialPhyMode"); 00055 } 00056 00057 wifimac::convergence::PhyMode 00058 PER::getPhyMode(size_t numTransmissions, const wns::Ratio /*lqm*/) const 00059 { 00060 return(this->getPhyMode(numTransmissions)); 00061 } 00062 00063 wifimac::convergence::PhyMode 00064 PER::getPhyMode(size_t numTransmissions) const 00065 { 00066 if(not per->knowsPER(myReceiver)) 00067 { 00068 assure(numTransmissions >= 1, "Must have at least one transmission"); 00069 00070 // if no information about the PER is available (due to a recent change), 00071 // we take the current phyMode 00072 return(curPhyMode); 00073 } 00074 00075 double curPER = per->getPER(myReceiver); 00076 wifimac::convergence::PhyMode pm = curPhyMode; 00077 00078 if(curPER > perForGoingDown) 00079 { 00080 // loose more than perForGoingDown of all frames -> go down 00081 friends.phyUser->getPhyModeProvider()->mcsDown(pm); 00082 } 00083 if(curPER < perForGoingUp) 00084 { 00085 // nearly all frames are successful -> go up 00086 friends.phyUser->getPhyModeProvider()->mcsUp(pm); 00087 } 00088 00089 return(pm); 00090 } 00091 00092 void 00093 PER::setCurrentPhyMode(wifimac::convergence::PhyMode pm) 00094 { 00095 if(curPhyMode != pm) 00096 { 00097 MESSAGE_SINGLE(NORMAL, *logger, "RA going from MCS "<< curPhyMode << " to " << pm); 00098 per->reset(myReceiver); 00099 curPhyMode = pm; 00100 } 00101 }
1.5.5