![]() |
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/draftn/FastLinkFeedback.hpp> 00030 00031 using namespace wifimac::draftn; 00032 00033 STATIC_FACTORY_REGISTER_WITH_CREATOR( 00034 wifimac::draftn::FastLinkFeedback, 00035 wns::ldk::FunctionalUnit, 00036 "wifimac.draftn.FastLinkFeedback", 00037 wns::ldk::FUNConfigCreator); 00038 00039 FastLinkFeedback::FastLinkFeedback(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config_) : 00040 wns::ldk::fu::Plain<FastLinkFeedback, FastLinkFeedbackCommand>(fun), 00041 wns::ldk::Processor<FastLinkFeedback>(), 00042 00043 phyUserCommandName(config_.get<std::string>("phyUserCommandName")), 00044 managerName(config_.get<std::string>("managerName")), 00045 sinrMIBServiceName(config_.get<std::string>("sinrMIBServiceName")), 00046 estimatedValidity(config_.get<wns::simulator::Time>("myConfig.estimatedValidity")), 00047 currentPeer(), 00048 00049 logger(config_.get("logger")) 00050 { 00051 MESSAGE_SINGLE(NORMAL, this->logger, "created"); 00052 00053 friends.manager = NULL; 00054 sinrMIB = NULL; 00055 } 00056 00057 00058 FastLinkFeedback::~FastLinkFeedback() 00059 { 00060 } 00061 00062 void FastLinkFeedback::onFUNCreated() 00063 { 00064 MESSAGE_SINGLE(NORMAL, this->logger, "onFUNCreated() started"); 00065 00066 friends.manager = getFUN()->findFriend<wifimac::lowerMAC::Manager*>(managerName); 00067 sinrMIB = getFUN()->getLayer<dll::Layer2*>()->getManagementService<wifimac::draftn::SINRwithMIMOInformationBase>(sinrMIBServiceName); 00068 } 00069 00070 void FastLinkFeedback::processIncoming(const wns::ldk::CompoundPtr& compound) 00071 { 00072 if(getFUN()->getProxy()->commandIsActivated(compound->getCommandPool(), this)) 00073 { 00074 if(getCommand(compound->getCommandPool())->peer.isRequest) 00075 { 00076 currentPeer = friends.manager->getTransmitterAddress(compound->getCommandPool()); 00077 wns::Ratio sinr = getFUN()->getCommandReader(phyUserCommandName)-> 00078 readCommand<wifimac::convergence::PhyUserCommand>(compound->getCommandPool())->getCIRwithoutMIMO(); 00079 sinrMIB->putMeasurement(currentPeer, sinr, estimatedValidity); 00080 00081 MESSAGE_SINGLE(NORMAL, this->logger, "Request from " << currentPeer << ", measured SINR " << sinr); 00082 } 00083 else 00084 { 00085 MESSAGE_SINGLE(NORMAL, this->logger, "Reply from " << friends.manager->getTransmitterAddress(compound->getCommandPool()) << ", with SINR " << getCommand(compound->getCommandPool())->peer.cqi); 00086 sinrMIB->putPeerSINR(friends.manager->getTransmitterAddress(compound->getCommandPool()), 00087 getCommand(compound->getCommandPool())->peer.cqi, 00088 estimatedValidity); 00089 for(std::vector< std::vector<wns::Ratio> >::iterator it = getCommand(compound->getCommandPool())->peer.mimoFactors.begin(); 00090 it != getCommand(compound->getCommandPool())->peer.mimoFactors.end(); 00091 ++it) 00092 { 00093 sinrMIB->putPeerFactor(friends.manager->getTransmitterAddress(compound->getCommandPool()), 00094 *it); 00095 #ifndef WNS_NO_LOGGING 00096 MESSAGE_BEGIN(NORMAL, logger, m, "Contains peer factors"); 00097 for(std::vector<wns::Ratio>::iterator itFactors = it->begin(); 00098 itFactors != it->end(); 00099 ++itFactors) 00100 { 00101 m << " " << *itFactors; 00102 } 00103 MESSAGE_END(); 00104 #endif 00105 } 00106 } 00107 } 00108 else 00109 { 00110 currentPeer = wns::service::dll::UnicastAddress(); 00111 } 00112 } 00113 00114 void FastLinkFeedback::processOutgoing(const wns::ldk::CompoundPtr& compound) 00115 { 00116 if(currentPeer == friends.manager->getReceiverAddress(compound->getCommandPool())) 00117 { 00118 if(sinrMIB->knowsMeasuredSINR(currentPeer)) 00119 { 00120 FastLinkFeedbackCommand* flfc = activateCommand(compound->getCommandPool()); 00121 flfc->peer.isRequest = false; 00122 flfc->peer.cqi = sinrMIB->getMeasuredSINR(currentPeer); 00123 00124 for(unsigned int numSS = 1; numSS <= friends.manager->getNumAntennas(); ++numSS) 00125 { 00126 if(sinrMIB->knowsMeasuredFactor(currentPeer, numSS)) 00127 { 00128 flfc->peer.mimoFactors.push_back(sinrMIB->getMeasuredFactor(currentPeer, numSS)); 00129 } 00130 } 00131 00132 #ifndef WNS_NO_LOGGING 00133 MESSAGE_BEGIN(NORMAL, this->logger, m, "Outgoing frame to requester " << currentPeer); 00134 m << ", piggyback measured SINR " << flfc->peer.cqi; 00135 m << ", pF:"; 00136 for(unsigned int numSS = 1; numSS <= friends.manager->getNumAntennas(); ++numSS) 00137 { 00138 m << "("; 00139 if(sinrMIB->knowsMeasuredFactor(currentPeer, numSS)) 00140 { 00141 std::vector<wns::Ratio> pF = sinrMIB->getMeasuredFactor(currentPeer, numSS); 00142 for(std::vector<wns::Ratio>::iterator it = pF.begin(); 00143 it != pF.end(); 00144 ++it) 00145 { 00146 m << " " << *it; 00147 } 00148 } 00149 m << ")"; 00150 } 00151 MESSAGE_END(); 00152 #endif 00153 } 00154 else 00155 { 00156 MESSAGE_SINGLE(NORMAL, this->logger, "Outgoing frame to requester " << currentPeer << ", but SINR is not known!"); 00157 } 00158 currentPeer = wns::service::dll::UnicastAddress(); 00159 return; 00160 } 00161 00162 if(friends.manager->getReplyTimeout(compound->getCommandPool()) > 0) 00163 { 00164 FastLinkFeedbackCommand* flfc = activateCommand(compound->getCommandPool()); 00165 flfc->peer.isRequest = true; 00166 MESSAGE_SINGLE(NORMAL, this->logger, "Outgoing frame to " << friends.manager->getReceiverAddress(compound->getCommandPool()) << ", use as request"); 00167 return; 00168 } 00169 } 00170
1.5.5