User Manual, Developers Guide and API Documentation

PhyUser.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_CONVERGENCE_PHYUSER_HPP
00030 #define WIFIMAC_CONVERGENCE_PHYUSER_HPP
00031 
00032 #include <WIFIMAC/convergence/PhyModeProvider.hpp>
00033 #include <WIFIMAC/lowerMAC/Manager.hpp>
00034 #include <WIFIMAC/convergence/ITxStartEnd.hpp>
00035 
00036 #include <WNS/service/phy/ofdma/Handler.hpp>
00037 #include <WNS/service/phy/ofdma/Notification.hpp>
00038 #include <WNS/service/phy/ofdma/DataTransmission.hpp>
00039 
00040 #include <WNS/service/dll/Address.hpp>
00041 
00042 #include <WNS/pyconfig/View.hpp>
00043 #include <WNS/logger/Logger.hpp>
00044 #include <WNS/events/CanTimeout.hpp>
00045 
00046 #include <WNS/ldk/fu/Plain.hpp>
00047 #include <WNS/ldk/Command.hpp>
00048 
00049 namespace wifimac { namespace lowerMAC {
00050         class Manager;
00051 }}
00052 
00053 namespace wifimac { namespace convergence {
00054 
00055     class CIRProviderCommand
00056     {
00057     public:
00058         virtual wns::Ratio getCIR(int stream = 0) const = 0;
00059         virtual wns::Power getRSS() const = 0;
00060         virtual ~CIRProviderCommand(){}
00061     };
00062 
00063     class PhyUserCommand :
00064         public wns::ldk::Command,
00065         public CIRProviderCommand
00066     {
00067     public:
00068         struct {
00069             wns::Power rxPower;
00070             wns::Power interference;
00071             std::vector<wns::Ratio> postSINRFactor;
00072         } local;
00073 
00074         struct {} peer;
00075         struct {} magic;
00076 
00077         wns::Ratio getCIR(int stream = 0) const
00078         {
00079             return wns::Ratio::from_dB( local.rxPower.get_dBm() - local.interference.get_dBm() + local.postSINRFactor[stream].get_dB() );
00080         }
00081 
00082         wns::Ratio getCIRwithoutMIMO() const
00083         {
00084             return wns::Ratio::from_dB( local.rxPower.get_dBm() - local.interference.get_dBm());
00085         }
00086 
00087         wns::Power getRSS() const
00088         {
00089             return (local.rxPower);
00090         }
00091     };
00092 
00103     class PhyUser:
00104         public wns::ldk::fu::Plain<PhyUser, PhyUserCommand>,
00105         public wns::service::phy::ofdma::Handler,
00106         public wns::events::CanTimeout,
00107         public TxStartEndNotification
00108     {
00109 
00110     public:
00111         PhyUser(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config);
00112         virtual ~PhyUser();
00113 
00115         virtual void onData(wns::osi::PDUPtr, wns::service::phy::power::PowerMeasurementPtr);
00116 
00118         virtual void setNotificationService(wns::service::Service* phy);
00119         virtual wns::service::phy::ofdma::Notification* getNotificationService() const;
00120         virtual void setDataTransmissionService(wns::service::Service* phy);
00121         virtual wns::service::phy::ofdma::DataTransmission* getDataTransmissionService() const;
00122 
00124         PhyModeProvider* getPhyModeProvider();
00125 
00127         void setFrequency(double frequency);
00128 
00129         wns::Ratio getExpectedPostSINRFactor(unsigned int nss, unsigned int numRx);
00130 
00131         bool isTransmitting() const
00132             {
00133                 return this->phyUserStatus == transmitting;
00134             }
00135 
00136     private:
00137 
00138         // CompoundHandlerInterface
00139         virtual void doSendData(const wns::ldk::CompoundPtr& sdu);
00140         virtual void doOnData(const wns::ldk::CompoundPtr& compound);
00141         virtual void onFUNCreated();
00142         virtual bool doIsAccepting(const wns::ldk::CompoundPtr& compound) const;
00143         virtual void doWakeup();
00144 
00145         // onTimeout realisation
00146         virtual void onTimeout();
00147 
00148         wns::pyconfig::View config;
00149         wns::logger::Logger logger;
00150 
00151         wns::service::phy::ofdma::Tune tune;
00152         wns::service::phy::ofdma::DataTransmission* dataTransmission;
00153         wns::service::phy::ofdma::Notification* notificationService;
00154         PhyModeProvider phyModes;
00155 
00156         const std::string managerName;
00157         const std::string txDurationProviderCommandName;
00158         const wns::simulator::Time txrxTurnaroundDelay;
00159         const bool bfEnabled;
00160 
00161         struct Friends
00162         {
00163             wifimac::lowerMAC::Manager* manager;
00164         } friends;
00165 
00166         enum PhyUserStatus
00167         {
00168             transmitting,
00169             receiving,
00170             txrxTurnaround
00171         } phyUserStatus;
00172 
00173         wns::ldk::CompoundPtr currentTxCompound;
00174         wns::simulator::Time lastTxRxTurnaround;
00175     };
00176 
00177 } // namespace convergence
00178 } // namespace wifimac
00179 
00180 #endif // NOT defined WIFIMAC_CONVERGENCE_PHYUSER_HPP
00181 
00182 

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