![]() |
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_LOWERMAC_RTSCTS_HPP 00030 #define WIFIMAC_LOWERMAC_RTSCTS_HPP 00031 00032 #include <WIFIMAC/convergence/PhyUser.hpp> 00033 #include <WIFIMAC/lowerMAC/Manager.hpp> 00034 #include <WIFIMAC/lowerMAC/ITransmissionCounter.hpp> 00035 00036 #include <WIFIMAC/convergence/INetworkAllocationVector.hpp> 00037 #include <WIFIMAC/convergence/IRxStartEnd.hpp> 00038 #include <WIFIMAC/convergence/ITxStartEnd.hpp> 00039 #include <WIFIMAC/management/ProtocolCalculator.hpp> 00040 00041 #include <WNS/ldk/probe/Probe.hpp> 00042 #include <WNS/probe/bus/ContextCollector.hpp> 00043 00044 #include <WNS/simulator/Time.hpp> 00045 #include <WNS/events/CanTimeout.hpp> 00046 00047 #include <WNS/Observer.hpp> 00048 00049 namespace wifimac { namespace lowerMAC { 00050 00051 class RTSProviderCommand 00052 { 00053 public: 00054 virtual bool isRTS() const = 0; 00055 virtual ~RTSProviderCommand() {}; 00056 }; 00057 00058 class RTSCTSCommand: 00059 public wns::ldk::Command, 00060 public RTSProviderCommand 00061 { 00062 public: 00063 struct {} local; 00064 struct { 00065 bool isRTS; 00066 } peer; 00067 struct {} magic; 00068 00069 bool isRTS() const 00070 { 00071 return(this->peer.isRTS); 00072 } 00073 }; 00074 00075 00096 class RTSCTS: 00097 public wns::ldk::fu::Plain<RTSCTS, RTSCTSCommand>, 00098 public wns::events::CanTimeout, 00099 public wns::Observer<wifimac::convergence::INetworkAllocationVector>, 00100 public wns::Observer<wifimac::convergence::IRxStartEnd>, 00101 public wns::Observer<wifimac::convergence::ITxStartEnd>, 00102 public wns::ldk::probe::Probe 00103 { 00104 public: 00105 00106 RTSCTS(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config); 00107 00108 virtual 00109 ~RTSCTS(); 00110 00111 // observer RxStartEnd 00112 void 00113 onRxStart(wns::simulator::Time expRxTime); 00114 void 00115 onRxEnd(); 00116 void 00117 onRxError(); 00118 00119 // observer TxStartEnd 00120 void 00121 onTxStart(const wns::ldk::CompoundPtr& compound); 00122 void 00123 onTxEnd(const wns::ldk::CompoundPtr& compound); 00124 00125 // observer NAV 00126 void 00127 onNAVBusy(const wns::service::dll::UnicastAddress setter); 00128 void 00129 onNAVIdle(); 00130 00134 void calculateSizes(const wns::ldk::CommandPool* commandPool, Bit& commandPoolSize, Bit& dataSize) const; 00135 00136 private: 00137 virtual 00138 void doWakeup(); 00139 00140 virtual 00141 void 00142 doOnData(const wns::ldk::CompoundPtr& compound); 00143 00144 virtual bool 00145 doIsAccepting(const wns::ldk::CompoundPtr& compound) const; 00146 00147 virtual void 00148 doSendData(const wns::ldk::CompoundPtr& compound); 00149 00150 void onFUNCreated(); 00151 00153 void onTimeout(); 00154 00155 wns::ldk::CompoundPtr 00156 prepareRTS(const wns::ldk::CompoundPtr& mpdu); 00157 00158 wns::ldk::CompoundPtr 00159 prepareCTS(const wns::ldk::CompoundPtr& rts); 00160 00161 const std::string phyUserName; 00162 const std::string managerName; 00163 const std::string arqName; 00164 const std::string navName; 00165 const std::string rxsName; 00166 const std::string txStartEndName; 00167 const std::string protocolCalculatorName; 00168 00170 const wns::simulator::Time sifsDuration; 00171 00172 const wns::simulator::Time maximumACKDuration; 00173 const wns::simulator::Time maximumCTSDuration; 00174 const wns::simulator::Time preambleProcessingDelay; 00175 const wns::simulator::Time ctsTimeout; 00176 00177 const wifimac::convergence::PhyMode rtsctsPhyMode; 00178 00179 const Bit rtsBits; 00180 const Bit ctsBits; 00181 const Bit rtsctsThreshold; 00182 const bool rtsctsOnTxopData; 00183 00184 bool nav; 00185 wns::service::dll::UnicastAddress navSetter; 00186 00187 wns::logger::Logger logger; 00188 00189 wns::ldk::CompoundPtr pendingRTS; 00190 wns::ldk::CompoundPtr pendingCTS; 00191 wns::ldk::CompoundPtr pendingMPDU; 00192 00193 wifimac::management::ProtocolCalculator *protocolCalculator; 00194 struct Friends 00195 { 00196 wifimac::convergence::PhyUser* phyUser; 00197 wifimac::lowerMAC::Manager* manager; 00198 wifimac::lowerMAC::ITransmissionCounter* arq; 00199 } friends; 00200 00201 enum RTSCTSState 00202 { 00203 idle, 00204 transmitRTS, 00205 waitForCTS, 00206 receiveCTS, 00207 receptionFinished 00208 } state; 00209 00210 wns::simulator::Time ctsPrepared; 00211 wns::simulator::Time lastTimeout; 00212 00213 wns::probe::bus::ContextCollectorPtr rtsSuccessProbe; 00214 }; 00215 00216 00217 } // mac 00218 } // wifimac 00219 00220 #endif // WIFIMAC_LOWERMAC_CONSTANTWAIT_HPP
1.5.5