![]() |
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_CONVERGENCE_CHANNELSTATE_HPP 00030 #define WIFIMAC_CONVERGENCE_CHANNELSTATE_HPP 00031 00032 #include <WIFIMAC/lowerMAC/Manager.hpp> 00033 #include <WIFIMAC/convergence/IChannelState.hpp> 00034 #include <WIFIMAC/convergence/INetworkAllocationVector.hpp> 00035 #include <WIFIMAC/convergence/ITxStartEnd.hpp> 00036 #include <WIFIMAC/convergence/IRxStartEnd.hpp> 00037 #include <WIFIMAC/FrameType.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 wifimac { namespace lowerMAC { 00056 class Manager; 00057 }} 00058 00059 namespace wifimac { 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<wifimac::convergence::ITxStartEnd>, 00091 public wns::Observer<wifimac::convergence::IRxStartEnd>, 00092 public wns::events::CanTimeout, 00093 public wns::ldk::probe::Probe, 00094 public wns::events::PeriodicTimeout 00095 { 00096 00097 public: 00098 ChannelState(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config); 00099 virtual ~ChannelState(); 00100 00101 void 00102 setCarrierSensingService(wns::service::Service* cs); 00103 00104 void 00105 registerRSSObserver(wns::Observer<wns::service::phy::ofdma::CarrierSensing> *o) {rssObservers.push_back(o);} 00106 00107 private: 00109 void 00110 processIncoming(const wns::ldk::CompoundPtr& compound); 00111 void 00112 processOutgoing(const wns::ldk::CompoundPtr& compound); 00113 00114 virtual void 00115 onFUNCreated(); 00116 00118 virtual void 00119 onRSSChange(wns::Power newRSS); 00120 00122 void onTxStart(const wns::ldk::CompoundPtr& compound); 00123 void onTxEnd(const wns::ldk::CompoundPtr& compound); 00124 00126 void onRxStart(const wns::simulator::Time expRxDuration); 00127 void onRxEnd(); 00128 void onRxError(); 00129 00130 00131 virtual CS getCurrentChannelState() const; 00132 00134 void onTimeout(); 00135 00137 virtual void checkNewCS(); 00138 00140 void periodically(); 00141 00142 bool isRTS(const wns::ldk::CompoundPtr& compound) const; 00143 00145 void probeChannelBusy(); 00146 void probeChannelIdle(); 00147 00148 wns::pyconfig::View config; 00149 wns::logger::Logger logger; 00150 00152 std::vector<wns::Observer<wns::service::phy::ofdma::CarrierSensing>*> rssObservers; 00153 00164 struct ActiveIndicators { 00165 bool rawEnergyDetection; 00166 bool phyCarrierSense; 00167 bool nav; 00168 bool ownTx; 00169 bool ownRx; 00170 } activeIndicators; 00171 00180 struct Indicators { 00181 wns::Power rawEnergy; 00182 wns::Power phyCarrierSense; 00183 bool ownTx; 00184 bool ownRx; 00185 } indicators; 00186 00190 const wns::Power rawEnergyThreshold; 00191 00195 const wns::Power phyCarrierSenseThreshold; 00196 00197 struct Friends 00198 { 00199 wifimac::lowerMAC::Manager* manager; 00200 } friends; 00201 00205 CS lastCS; 00206 00207 wns::simulator::Time latestNAV; 00208 00209 bool waitForReply; 00210 00211 wifimac::FrameType lastCommandOut; 00212 00213 const std::string managerName; 00214 const std::string phyUserCommandName; 00215 const std::string rtsctsCommandName; 00216 const std::string txStartEndName; 00217 const std::string rxStartEndName; 00218 00222 const wns::simulator::Time sifsDuration; 00223 00227 wns::probe::bus::ContextCollectorPtr channelBusyFractionProbe; 00228 wns::simulator::Time channelBusyFractionMeasurementPeriod; 00229 wns::simulator::Time channelBusyTime; 00230 wns::simulator::Time channelBusySlotStart; 00231 wns::simulator::Time channelBusyLastChangeToBusy; 00232 00233 wns::service::phy::ofdma::Notification* myCS; 00234 }; 00235 00236 00237 } // convergence 00238 } // wifimac 00239 00240 #endif // WIFIMAC_CHANNELSTATE_HPP
1.5.5