![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2009 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 5, D-52074 Aachen, Germany 00008 * email: info@openwns.org 00009 * www: http://www.openwns.org 00010 * _____________________________________________________________________________ 00011 * 00012 * openWNS is free software; you can redistribute it and/or modify it under the 00013 * terms of the GNU Lesser General Public License version 2 as published by the 00014 * Free Software Foundation; 00015 * 00016 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00017 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00018 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00019 * details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 * 00024 ******************************************************************************/ 00025 00026 #ifndef WIMAC_SERVICES_ASSOCIATIONCONTROL_H 00027 #define WIMAC_SERVICES_ASSOCIATIONCONTROL_H 00028 00029 #include <WNS/ldk/ControlServiceInterface.hpp> 00030 #include <WNS/StaticFactory.hpp> 00031 #include <WNS/PowerRatio.hpp> 00032 #include <WNS/service/phy/power/PowerMeasurement.hpp> 00033 00034 #include <WIMAC/Component.hpp> 00035 #include <WIMAC/ConnectionIdentifier.hpp> 00036 #include <WIMAC/StationManager.hpp> 00037 #include <WIMAC/services/IChannelQualityObserver.hpp> 00038 00039 #include <boost/bind.hpp> 00040 00041 namespace wimac { namespace service { 00042 00043 class ConnectionManager; 00044 class AssociationControl : 00045 public wns::ldk::ControlService, 00046 public IChannelQualityObserver 00047 { 00048 public: 00049 AssociationControl( wns::ldk::ControlServiceRegistry* csr, 00050 wns::pyconfig::View& config ); 00051 00052 00053 void 00054 createRecursiveConnection( ConnectionIdentifier::CID basicCID, 00055 ConnectionIdentifier::CID primaryCID, 00056 ConnectionIdentifier::CID downlinkBETransportCID, 00057 ConnectionIdentifier::CID downlinkRtPSTransportCID, 00058 ConnectionIdentifier::CID downlinkNrtPSTransportCID, 00059 ConnectionIdentifier::CID downlinkUGSTransportCID, 00060 ConnectionIdentifier::CID uplinkBETransportCID, 00061 ConnectionIdentifier::CID uplinkRtPSTransportCID, 00062 ConnectionIdentifier::CID uplinkNrtPSTransportCID, 00063 ConnectionIdentifier::CID uplinkkUGSTransportCID, 00064 ConnectionIdentifier::StationID remote); 00065 void onCSRCreated(); 00066 00067 void associateTo( wimac::StationID destination); 00068 00069 void 00070 storeMeasurement(StationID source, 00071 const wns::service::phy::power::PowerMeasurementPtr&); 00072 00073 private: 00074 virtual void 00075 doOnCSRCreated() = 0; 00076 00077 virtual void 00078 doStoreMeasurement(StationID source, 00079 const wns::service::phy::power::PowerMeasurementPtr&) = 0; 00080 00081 struct { 00082 wimac::service::ConnectionManager* connectionManager; 00083 } friends_; 00084 00085 }; 00086 00087 namespace associationcontrol { 00088 00089 class IDecideBest 00090 { 00091 public: 00092 typedef wns::Creator<IDecideBest> Creator; 00093 typedef wns::StaticFactory<Creator> Factory; 00094 00095 virtual void 00096 put(StationID st, const wns::service::phy::power::PowerMeasurementPtr& p) = 0; 00097 00098 virtual StationID 00099 getBest()= 0; 00100 00101 virtual bool 00102 isInitialized() = 0; 00103 }; 00104 00105 template <typename T> 00106 class DecideBest : 00107 public IDecideBest 00108 { 00109 public: 00110 DecideBest() : 00111 samples_(0), 00112 initialized_(false){}; 00113 00114 void 00115 put(StationID st, const wns::service::phy::power::PowerMeasurementPtr& p) 00116 { 00117 samples_++; 00118 doPut(st, p); 00119 }; 00120 00121 StationID 00122 getBest(){return bestStation_;}; 00123 00124 virtual bool 00125 isInitialized(){return initialized_;}; 00126 00127 virtual 00128 ~DecideBest() 00129 {} 00130 private: 00131 virtual void 00132 doPut(StationID, const wns::service::phy::power::PowerMeasurementPtr&) = 0; 00133 00134 protected: 00135 StationID bestStation_; 00136 T bestValue_; 00137 unsigned int samples_; 00138 bool initialized_; 00139 }; 00140 00141 class BestPathloss : 00142 public DecideBest<wns::Ratio> 00143 { 00144 virtual void 00145 doPut(StationID st, const wns::service::phy::power::PowerMeasurementPtr& p) 00146 { 00147 if(!initialized_ || p->getPathLoss() < bestValue_) 00148 { 00149 initialized_ = true; 00150 bestValue_ = p->getPathLoss(); 00151 bestStation_ = st; 00152 } 00153 }; 00154 }; 00155 00156 class BestRxPower : 00157 public DecideBest<wns::Power> 00158 { 00159 virtual void 00160 doPut(StationID st, const wns::service::phy::power::PowerMeasurementPtr& p) 00161 { 00162 if(!initialized_ || p->getRxPower() > bestValue_) 00163 { 00164 initialized_ = true; 00165 bestValue_ = p->getRxPower(); 00166 bestStation_ = st; 00167 } 00168 }; 00169 }; 00170 00171 class BestSINR : 00172 public DecideBest<wns::Ratio> 00173 { 00174 virtual void 00175 doPut(StationID st, const wns::service::phy::power::PowerMeasurementPtr& p) 00176 { 00177 if(!initialized_ || p->getSINR() > bestValue_) 00178 { 00179 initialized_ = true; 00180 bestValue_ = p->getSINR(); 00181 bestStation_ = st; 00182 } 00183 }; 00184 }; 00185 00188 class Fixed : 00189 public AssociationControl 00190 { 00191 public: 00192 Fixed(wns::ldk::ControlServiceRegistry* csr, 00193 wns::pyconfig::View& config ); 00194 virtual 00195 ~Fixed(); 00196 00197 private: 00198 virtual void 00199 doOnCSRCreated(); 00200 00201 virtual void 00202 doStoreMeasurement(StationID source, 00203 const wns::service::phy::power::PowerMeasurementPtr&); 00204 00205 wimac::StationID associatedWithID_; 00206 00207 }; 00208 00211 class BestAtGivenTime : 00212 public AssociationControl 00213 { 00214 public: 00215 BestAtGivenTime(wns::ldk::ControlServiceRegistry* csr, 00216 wns::pyconfig::View& config ); 00217 virtual 00218 ~BestAtGivenTime(); 00219 00220 private: 00221 virtual void 00222 doOnCSRCreated(); 00223 00224 void 00225 doStoreMeasurement(StationID source, 00226 const wns::service::phy::power::PowerMeasurementPtr&); 00227 00228 void 00229 associateNow(); 00230 00231 wns::simulator::Time decisionTime_; 00232 IDecideBest* deciderStrategy_; 00233 }; 00234 } 00235 00236 } 00237 } 00238 00239 #endif 00240 00241
1.5.5