User Manual, Developers Guide and API Documentation

ChannelState.hpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * WiMeMac                                                                    *
00003  * This file is part of openWNS (open Wireless Network Simulator)
00004  * _____________________________________________________________________________
00005  *
00006  * Copyright (C) 2004-2011
00007  * Chair of Communication Networks (ComNets)
00008  * Kopernikusstr. 5, 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 WIMEMAC_CONVERGENCE_CHANNELSTATE_HPP
00030 #define WIMEMAC_CONVERGENCE_CHANNELSTATE_HPP
00031 
00032 #include <WIMEMAC/convergence/IChannelState.hpp>
00033 #include <WIMEMAC/convergence/INetworkAllocationVector.hpp>
00034 #include <WIMEMAC/convergence/ITxStartEnd.hpp>
00035 #include <WIMEMAC/convergence/IRxStartEnd.hpp>
00036 #include <WIMEMAC/FrameType.hpp>
00037 #include <WIMEMAC/lowerMAC/Manager.hpp>
00038 
00039 #include <WNS/ldk/fu/Plain.hpp>
00040 #include <WNS/ldk/Processor.hpp>
00041 #include <WNS/ldk/Command.hpp>
00042 #include <WNS/logger/Logger.hpp>
00043 #include <WNS/events/CanTimeout.hpp>
00044 #include <WNS/service/phy/ofdma/Notification.hpp>
00045 #include <WNS/service/phy/ofdma/Handler.hpp>
00046 #include <WNS/Observer.hpp>
00047 #include <WNS/Functor.hpp>
00048 #include <WNS/ldk/crc/CRC.hpp>
00049 
00050 #include <WNS/events/PeriodicTimeout.hpp>
00051 #include <WNS/ldk/probe/Probe.hpp>
00052 #include <WNS/probe/bus/ContextCollector.hpp>
00053 #include <WNS/SlidingWindow.hpp>
00054 
00055 namespace wimemac { namespace lowerMAC {
00056     class Manager;
00057 }}
00058 
00059 namespace wimemac { namespace convergence {
00060 
00061     class ChannelStateCommand :
00062         public wns::ldk::EmptyCommand
00063     {
00064     };
00065 
00084     class ChannelState :
00085         public wns::ldk::fu::Plain<ChannelState, ChannelStateCommand>,
00086         public wns::ldk::Processor<ChannelState>,
00087         public ChannelStateNotification,
00088         public NAVNotification,
00089         public wns::service::phy::ofdma::RSSHandler,
00090         public wns::Observer<wimemac::convergence::ITxStartEnd>,
00091         public wns::Observer<wimemac::convergence::IRxStartEnd>,
00092         public wns::events::CanTimeout,
00093         public wns::ldk::probe::Probe,
00094         public wns::events::PeriodicTimeout,
00095         public RxStartEndNotification
00096     {
00097 
00098     public:
00099         ChannelState(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config);
00100         virtual ~ChannelState();
00101 
00102         void
00103         setCarrierSensingService(wns::service::Service* cs);
00104 
00105         void
00106         registerRSSObserver(wns::Observer<wns::service::phy::ofdma::CarrierSensing> *o) {rssObservers.push_back(o);}
00107 
00108     private:
00110         void
00111         processIncoming(const wns::ldk::CompoundPtr& compound);
00112         void
00113         processOutgoing(const wns::ldk::CompoundPtr& compound);
00114 
00115         virtual void
00116         onFUNCreated();
00117 
00119         virtual void
00120         onRSSChange(wns::Power newRSS);
00121 
00123         void onTxStart(const wns::ldk::CompoundPtr& compound);
00124         void onTxEnd(const wns::ldk::CompoundPtr& compound);
00125 
00127         void onRxStart(const wns::simulator::Time expRxDuration);
00128         void onRxEnd();
00129         void onRxError();
00130 
00131 
00132         virtual CS getCurrentChannelState() const;
00133 
00135         void onTimeout();
00136 
00138         virtual void checkNewCS();
00139 
00141         void periodically();
00142 
00143 //         bool isRTS(const wns::ldk::CompoundPtr& compound) const;
00144 
00146         void probeChannelBusy();
00147         void probeChannelIdle();
00148 
00149         wns::pyconfig::View config;
00150         wns::logger::Logger logger;
00151 
00153         std::vector<wns::Observer<wns::service::phy::ofdma::CarrierSensing>*> rssObservers;
00154 
00165         struct ActiveIndicators {
00166             bool rawEnergyDetection;
00167             bool phyCarrierSense;
00168             bool nav;
00169             bool ownTx;
00170             bool ownRx;
00171         } activeIndicators;
00172 
00181         struct Indicators {
00182             wns::Power rawEnergy;
00183             wns::Power phyCarrierSense;
00184             bool ownTx;
00185             bool ownRx;
00186         } indicators;
00187 
00191         const wns::Power rawEnergyThreshold;
00192 
00196         const wns::Power phyCarrierSenseThreshold;
00197 
00198         struct Friends
00199         {
00200             wimemac::lowerMAC::IManagerServices* manager;
00201         } friends;
00202 
00206         CS lastCS;
00207 
00208         wns::simulator::Time latestNAV;
00209 
00210         bool waitForReply;
00211 
00212         //wimemac::CompoundType lastCommandOut;
00213 
00214         const std::string managerName;
00215         const std::string phyUserCommandName;
00216         const std::string crcCommandName;
00217         //const std::string rtsctsCommandName;
00218         const std::string txStartEndName;
00219         const std::string rxStartEndName;
00220 
00224         const wns::simulator::Time sifsDuration;
00225 
00229         wns::probe::bus::ContextCollectorPtr channelBusyFractionProbe;
00230         wns::simulator::Time channelBusyFractionMeasurementPeriod;
00231         wns::simulator::Time channelBusyTime;
00232         wns::simulator::Time channelBusySlotStart;
00233         wns::simulator::Time channelBusyLastChangeToBusy;
00234 
00235         wns::service::phy::ofdma::Notification* myCS;
00236     };
00237 
00238 
00239 } // convergence
00240 } // wimemac
00241 
00242 #endif // WIMEMAC_CHANNELSTATE_HPP

Generated on Sun May 27 03:32:06 2012 for openWNS by  doxygen 1.5.5