![]() |
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/RateAdaptation.hpp> 00030 00031 using namespace wifimac::lowerMAC; 00032 00033 STATIC_FACTORY_REGISTER_WITH_CREATOR( 00034 wifimac::lowerMAC::RateAdaptation, 00035 wns::ldk::FunctionalUnit, 00036 "wifimac.lowerMAC.RateAdaptation", 00037 wns::ldk::FUNConfigCreator); 00038 00039 RateAdaptation::RateAdaptation(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config_) : 00040 wns::ldk::fu::Plain<RateAdaptation, wns::ldk::EmptyCommand>(fun), 00041 wns::ldk::Processor<RateAdaptation>(), 00042 00043 phyUserName(config_.get<std::string>("phyUserName")), 00044 managerName(config_.get<std::string>("managerName")), 00045 arqName(config_.get<std::string>("arqName")), 00046 sinrMIBServiceName(config_.get<std::string>("sinrMIBServiceName")), 00047 perMIBServiceName(config_.get<std::string>("perMIBServiceName")), 00048 raForACKFrames(config_.get<bool>("myConfig.raForACKFrames")), 00049 00050 config(config_), 00051 logger(config_.get("logger")) 00052 { 00053 MESSAGE_SINGLE(NORMAL, this->logger, "created"); 00054 00055 friends.phyUser = NULL; 00056 friends.manager = NULL; 00057 00058 00059 } 00060 00061 00062 RateAdaptation::~RateAdaptation() 00063 { 00064 } 00065 00066 void RateAdaptation::onFUNCreated() 00067 { 00068 MESSAGE_SINGLE(NORMAL, this->logger, "onFUNCreated() started"); 00069 00070 friends.phyUser = getFUN()->findFriend<wifimac::convergence::PhyUser*>(phyUserName); 00071 friends.manager = getFUN()->findFriend<wifimac::lowerMAC::Manager*>(managerName); 00072 friends.arq = getFUN()->findFriend<wifimac::lowerMAC::ITransmissionCounter*>(arqName); 00073 00074 sinrMIB = getFUN()->getLayer<dll::ILayer2*>()->getManagementService<wifimac::management::SINRInformationBase>(sinrMIBServiceName); 00075 perMIB = getFUN()->getLayer<dll::ILayer2*>()->getManagementService<wifimac::management::PERInformationBase>(perMIBServiceName); 00076 } 00077 00078 void RateAdaptation::processIncoming(const wns::ldk::CompoundPtr& /*compound*/) 00079 { 00080 // we do exactly nothing with incoming compounds 00081 } 00082 00083 void RateAdaptation::processOutgoing(const wns::ldk::CompoundPtr& compound) 00084 { 00085 if((not raForACKFrames) and (friends.manager->getFrameType(compound->getCommandPool()) == ACK)) 00086 { 00087 MESSAGE_BEGIN(NORMAL, logger, m, "Send ACK frame to "); 00088 m << " rx: " << friends.manager->getReceiverAddress(compound->getCommandPool()); 00089 m << " with " << friends.manager->getPhyMode(compound->getCommandPool()); 00090 MESSAGE_END(); 00091 } 00092 else 00093 { 00094 00095 wns::service::dll::UnicastAddress receiver = friends.manager->getReceiverAddress(compound->getCommandPool()); 00096 size_t numTransmissions = friends.arq->getTransmissionCounter(compound); 00097 wifimac::convergence::PhyMode pm = this->getPhyMode(receiver, numTransmissions); 00098 rateAdaptation.find(receiver)->setCurrentPhyMode(pm); 00099 friends.manager->setPhyMode(compound->getCommandPool(), pm); 00100 00101 MESSAGE_BEGIN(NORMAL, logger, m, "Send data frame to "); 00102 m << " rx: " << friends.manager->getReceiverAddress(compound->getCommandPool()); 00103 m << " with " << friends.manager->getPhyMode(compound->getCommandPool()); 00104 MESSAGE_END(); 00105 } 00106 } 00107 00108 wifimac::convergence::PhyMode 00109 RateAdaptation::getPhyMode(wns::service::dll::UnicastAddress receiver, size_t numTransmissions) 00110 { 00111 wifimac::convergence::PhyMode pm; 00112 00113 if(not rateAdaptation.knows(receiver) ) 00114 { 00115 MESSAGE_BEGIN(NORMAL, logger, m, "No matching RA found for receiver "); 00116 m << receiver; 00117 m << ", create new of type " << config.get<std::string>("myConfig.raStrategy.__plugin__"); 00118 MESSAGE_END(); 00119 00120 rateAdaptation.insert(receiver, 00121 rateAdaptationStrategies::RateAdaptationStrategyFactory::creator 00122 (config.get<std::string>("myConfig.raStrategy.__plugin__"))->create(config.getView("myConfig.raStrategy"), 00123 receiver, 00124 perMIB, 00125 sinrMIB, 00126 friends.manager, 00127 friends.phyUser, 00128 &logger)); 00129 } 00130 00131 pm = rateAdaptation.find(receiver)->getPhyMode(numTransmissions); 00132 return(pm); 00133 } 00134 wifimac::convergence::PhyMode 00135 RateAdaptation::getPhyMode(const wns::ldk::CompoundPtr& compound) 00136 { 00137 wns::service::dll::UnicastAddress receiver = friends.manager->getReceiverAddress(compound->getCommandPool()); 00138 size_t numTransmissions = friends.arq->getTransmissionCounter(compound); 00139 return(this->getPhyMode(receiver, numTransmissions)); 00140 }
1.5.5