User Manual, Developers Guide and API Documentation

LinkQualityMeasurement.hpp

Go to the documentation of this file.
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_LINKQUALITYMEASUREMENT_HPP
00030 #define WIFIMAC_PATHSELECTION_LINKQUALITYMEASUREMENT_HPP
00031 
00032 #include <WIFIMAC/pathselection/Metric.hpp>
00033 #include <WIFIMAC/pathselection/PathSelectionInterface.hpp>
00034 #include <WIFIMAC/management/LinkNotificationInterface.hpp>
00035 
00036 #include <DLL/UpperConvergence.hpp>
00037 
00038 #include <WNS/ldk/Command.hpp>
00039 #include <WNS/ldk/fu/Plain.hpp>
00040 
00041 #include <WNS/simulator/Time.hpp>
00042 #include <WNS/events/PeriodicTimeout.hpp>
00043 #include <WNS/events/CanTimeout.hpp>
00044 #include <WNS/logger/Logger.hpp>
00045 #include <WNS/Observer.hpp>
00046 #include <WNS/distribution/Uniform.hpp>
00047 #include <WNS/SlidingWindow.hpp>
00048 
00049 namespace wifimac { namespace pathselection {
00050 
00051     class LinkQualityMeasurementCommand :
00052         public wns::ldk::Command
00053     {
00054     public:
00055         struct {
00056         } local;
00057 
00058         struct {
00059             wns::service::dll::UnicastAddress srcMACAddress;
00060             wns::service::dll::UnicastAddress dstMACAddress;
00061             wns::simulator::Time txTime;
00062             wns::simulator::Time lastFrameFlightTime;
00063         } peer;
00064 
00065         struct {
00066             bool isPiggybacked;
00067         } magic;
00068     };
00069     
00070     class LinkQualityMeasurement;
00071     
00075     class LinkQuality:
00076         public wns::events::CanTimeout, 
00077         public wns::events::PeriodicTimeout
00078     {
00079         public:
00088             LinkQuality(wns::service::dll::UnicastAddress _rx,
00089                     wns::simulator::Time _referenceFlightTime,
00090                     wns::simulator::Time _periodicity,
00091                     LinkQualityMeasurement* _parent);
00092             
00097             void receivedLinkQualityIndicator(const LinkQualityMeasurementCommand* lqm);
00098             
00105             wns::simulator::Time getLastRxFrameFlightTime() const;
00106             
00110             void hasSendPiggybackedLQM();
00111         private:
00118             void periodically();
00119             
00123             void onTimeout();
00124             
00128             const wns::service::dll::UnicastAddress rx;
00129             
00133             const wns::simulator::Time referenceFlightTime;
00134             
00138             wns::simulator::Time periodicity;
00139             
00143             LinkQualityMeasurement* parent;
00144             
00149             bool rxLastFrame;
00150             
00155             wns::simulator::Time lastRxFrameFlightTime;
00156             
00160             wns::SlidingWindow linkCostTx;
00161             
00165             Metric oldLinkCostTxAvg;
00166             
00170             wns::distribution::Uniform uniform;
00171     };
00172 
00182     class LinkQualityMeasurement :
00183         public wns::ldk::fu::Plain<LinkQualityMeasurement, LinkQualityMeasurementCommand>,
00184         public wns::Observer<wifimac::management::LinkNotificationInterface>
00185     {
00186     public:
00187         LinkQualityMeasurement(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config);
00188         virtual ~LinkQualityMeasurement();
00189         
00193         void sendLinkMeasurement(wns::service::dll::UnicastAddress rx, wns::simulator::Time last);
00194         
00198         void newLinkCost(wns::service::dll::UnicastAddress rx, Metric cost);
00199 
00200     private:
00204         virtual bool doIsAccepting(const wns::ldk::CompoundPtr& _compound) const;
00205         virtual void doSendData(const wns::ldk::CompoundPtr& _compound);
00206         virtual void doWakeup();
00207         virtual void doOnData(const wns::ldk::CompoundPtr& _compound);
00208 
00209         virtual void onFUNCreated();
00210 
00214         void calculateSizes(const wns::ldk::CommandPool* commandPool, Bit& commandPoolSize, Bit& dataSize) const;
00215 
00219         void onLinkIndication(const wns::service::dll::UnicastAddress myself,
00220                       const wns::service::dll::UnicastAddress peer);
00221         
00222         
00223         const wns::pyconfig::View config;
00224         const Bit frameSize;
00225         const wns::simulator::Time referenceFlightTime;
00226         const wns::simulator::Time period;
00227         wns::logger::Logger logger;
00228         const std::string ucName;
00229         
00230         const bool doPiggybacking;
00231         int piggybackingPeriod;
00232         int numPiggybacked;
00233         
00237         PathSelectionInterface* ps;
00238         
00242         typedef wns::container::Registry<wns::service::dll::UnicastAddress, LinkQuality*, wns::container::registry::DeleteOnErase> adr2qualityMap;
00243         adr2qualityMap linkQualities;
00244         
00245         wns::service::dll::UnicastAddress myMACAddress;
00246         struct Friends
00247         {
00248             dll::UpperConvergence* uc;
00249         } friends;
00250     };
00251 
00252 }}
00253 
00254 #endif
00255 

Generated on Thu May 24 03:32:11 2012 for openWNS by  doxygen 1.5.5