![]() |
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 #ifndef WIFIMAC_PATHSELECTION_BEACONLINKQUALITYMEASUREMENT_HPP 00030 #define WIFIMAC_PATHSELECTION_BEACONLINKQUALITYMEASUREMENT_HPP 00031 00032 #include <WIFIMAC/lowerMAC/Manager.hpp> 00033 #include <WIFIMAC/pathselection/Metric.hpp> 00034 #include <WIFIMAC/pathselection/IPathSelection.hpp> 00035 #include <WIFIMAC/management/Beacon.hpp> 00036 #include <WIFIMAC/management/SINRInformationBase.hpp> 00037 00038 #include <WNS/ldk/Command.hpp> 00039 #include <WNS/ldk/fu/Plain.hpp> 00040 #include <WNS/ldk/probe/Probe.hpp> 00041 #include <WNS/probe/bus/ContextCollector.hpp> 00042 00043 #include <WNS/events/PeriodicTimeout.hpp> 00044 #include <WNS/events/CanTimeout.hpp> 00045 #include <WNS/logger/Logger.hpp> 00046 #include <WNS/Observer.hpp> 00047 #include <WNS/distribution/Uniform.hpp> 00048 #include <WNS/SlidingWindow.hpp> 00049 00050 namespace wifimac { namespace pathselection { 00051 00055 typedef wns::container::Registry<wns::service::dll::UnicastAddress, double> Address2SuccessRateMap; 00059 typedef wns::container::Registry<wns::service::dll::UnicastAddress, wns::Ratio> Address2RatioMap; 00060 00065 class BeaconLinkQualityMeasurementCommand : 00066 public wns::ldk::Command 00067 { 00068 public: 00069 struct { } local; 00070 00071 struct { 00075 wns::simulator::Time interval; 00076 00080 Address2SuccessRateMap rxBeaconSuccessRates; 00081 00085 Address2RatioMap rxBeaconSINRs; 00086 } peer; 00087 00088 struct { } magic; 00089 }; 00090 00091 class BeaconLinkQualityMeasurement; 00092 00096 class BroadcastLinkQuality: 00097 public wns::events::CanTimeout 00098 { 00099 public: 00101 BroadcastLinkQuality(const wns::pyconfig::View& config_, 00102 BeaconLinkQualityMeasurement* parent_, 00103 wns::service::dll::UnicastAddress peerAddress_, 00104 wns::service::dll::UnicastAddress myAddress_, 00105 wns::simulator::Time interval_); 00107 double 00108 getSuccessRate(); 00109 00111 wns::Ratio 00112 getAverageSINR(); 00113 00115 void 00116 newBeacon(wns::simulator::Time interval); 00117 00119 Metric 00120 newPeerMeasurement(double peerSuccessRate, wns::Ratio peerSINR); 00121 00125 void 00126 deadPeerMeasurement(); 00127 00129 bool 00130 isActive() const; 00131 00132 private: 00136 void 00137 onTimeout(); 00138 00144 double 00145 getBestRate(wns::Ratio sinr); 00146 00150 const wns::pyconfig::View config; 00151 00153 BeaconLinkQualityMeasurement* parent; 00154 00156 const wns::service::dll::UnicastAddress peerAddress; 00157 00159 wns::service::dll::UnicastAddress myAddress; 00160 00162 wns::simulator::Time curInterval; 00163 00165 wns::SlidingWindow successRate; 00166 00169 int missedBeaconsInRow; 00170 00173 bool linkCreated; 00174 00176 IPathSelection* ps; 00177 00179 wifimac::management::SINRInformationBase* sinrMIB; 00180 00182 const Bit meanFrameSize; 00184 const wns::simulator::Time maximumACKDuration; 00186 const wns::simulator::Time slotDuration; 00188 const wns::simulator::Time sifsDuration; 00190 const wns::simulator::Time preambleDuration; 00192 const double scalingFactor; 00194 const int maxMissedBeacons; 00195 }; 00196 00206 class BeaconLinkQualityMeasurement : 00207 public wns::ldk::fu::Plain<BeaconLinkQualityMeasurement, BeaconLinkQualityMeasurementCommand>, 00208 public wns::ldk::probe::Probe 00209 { 00210 public: 00212 BeaconLinkQualityMeasurement(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config); 00213 00215 virtual 00216 ~BeaconLinkQualityMeasurement(); 00217 00221 void newLinkCost(wns::service::dll::UnicastAddress rx, Metric cost); 00222 00226 wns::logger::Logger logger; 00227 00228 private: 00230 virtual bool doIsAccepting(const wns::ldk::CompoundPtr& _compound) const; 00231 00233 virtual void doSendData(const wns::ldk::CompoundPtr& _compound); 00234 00236 virtual void doWakeup(); 00237 00246 virtual void doOnData(const wns::ldk::CompoundPtr& _compound); 00247 00249 virtual void onFUNCreated(); 00250 00254 void calculateSizes(const wns::ldk::CommandPool* commandPool, Bit& commandPoolSize, Bit& dataSize) const; 00255 00257 const wns::pyconfig::View config; 00258 00260 wns::simulator::Time beaconInterval; 00261 00265 IPathSelection* ps; 00266 00268 typedef wns::container::Registry<wns::service::dll::UnicastAddress, BroadcastLinkQuality*> adr2qualityMap; 00269 00273 adr2qualityMap linkQualities; 00274 00276 wns::service::dll::UnicastAddress myMACAddress; 00277 00279 const std::string phyUserCommandName; 00280 00282 wns::probe::bus::ContextCollectorPtr receivedPower; 00283 00285 wns::probe::bus::ContextCollectorPtr peerMeasurement; 00286 00288 wns::probe::bus::ContextCollectorPtr linkCost; 00289 00290 struct Friends 00291 { 00292 wifimac::lowerMAC::Manager* manager; 00293 } friends; 00294 }; 00295 00296 }} 00297 00298 #endif 00299
1.5.5