![]() |
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_DRAFTN_BLOCKACK_HPP 00030 #define WIFIMAC_DRAFTN_BLOCKACK_HPP 00031 00032 #include <WIFIMAC/lowerMAC/Manager.hpp> 00033 #include <WIFIMAC/management/PERInformationBase.hpp> 00034 #include <WIFIMAC/lowerMAC/ITransmissionCounter.hpp> 00035 #include <WIFIMAC/draftn/BlockACKCommand.hpp> 00036 #include <WIFIMAC/draftn/TransmissionQueue.hpp> 00037 #include <WIFIMAC/draftn/ReceptionQueue.hpp> 00038 #include <WIFIMAC/convergence/IRxStartEnd.hpp> 00039 #include <WIFIMAC/convergence/ITxStartEnd.hpp> 00040 00041 #include <WNS/ldk/fu/Plain.hpp> 00042 #include <WNS/ldk/Delayed.hpp> 00043 #include <WNS/ldk/arq/ARQ.hpp> 00044 #include <WNS/ldk/probe/Probe.hpp> 00045 #include <WNS/ldk/buffer/Buffer.hpp> 00046 00047 #include <WNS/probe/bus/ContextCollector.hpp> 00048 #include <WNS/events/CanTimeout.hpp> 00049 #include <WNS/Observer.hpp> 00050 #include <WNS/RoundRobin.hpp> 00051 00052 #include <WIFIMAC/draftn/IBlockACKObserver.hpp> 00053 00054 namespace wifimac { 00055 namespace draftn { 00056 00113 class BlockACK: 00114 public wns::ldk::arq::ARQ, 00115 public wns::ldk::fu::Plain<BlockACK, BlockACKCommand>, 00116 public wns::ldk::Delayed<BlockACK>, 00117 public wns::events::CanTimeout, 00118 public wns::Observer<wifimac::convergence::IRxStartEnd>, 00119 public wns::Observer<wifimac::convergence::ITxStartEnd>, 00120 public wifimac::lowerMAC::ITransmissionCounter, 00121 public wns::ldk::probe::Probe 00122 { 00123 friend class TransmissionQueue; 00124 friend class ReceptionQueue; 00125 00126 typedef wns::container::Registry<wns::service::dll::UnicastAddress, BlockACKCommand::SequenceNumber> AddrSNMap; 00127 00128 public: 00129 00131 BlockACK(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config); 00132 00134 BlockACK(const BlockACK& other); 00135 00137 virtual ~BlockACK(); 00138 00140 virtual void 00141 onFUNCreated(); 00142 00144 virtual void 00145 registerObserver(IBlockACKObserver *o) 00146 { 00147 observers.push_back(o); 00148 } 00149 00159 virtual void 00160 processIncoming(const wns::ldk::CompoundPtr& compound); 00161 00175 virtual void 00176 processOutgoing(const wns::ldk::CompoundPtr& compound); 00177 00191 virtual bool 00192 hasCapacity() const; 00193 00198 virtual const wns::ldk::CompoundPtr 00199 hasACK() const; 00200 00204 virtual const wns::ldk::CompoundPtr 00205 hasData() const; 00206 00210 virtual wns::ldk::CompoundPtr 00211 getACK(); 00212 00216 virtual wns::ldk::CompoundPtr 00217 getData(); 00218 00223 virtual void 00224 onTimeout(); 00225 00227 virtual void 00228 onRxStart(wns::simulator::Time expRxTime); 00229 00231 virtual void 00232 onRxEnd(); 00233 00235 virtual void 00236 onRxError(); 00237 00239 virtual void 00240 onTxStart(const wns::ldk::CompoundPtr& compound); 00241 00243 virtual void 00244 onTxEnd(const wns::ldk::CompoundPtr& compound); 00245 00252 virtual void 00253 onTransmissionHasFailed(const wns::ldk::CompoundPtr& compound); 00254 00256 virtual unsigned int 00257 getTransmissionCounter(const wns::ldk::CompoundPtr& compound) const; 00258 00260 virtual void 00261 copyTransmissionCounter(const wns::ldk::CompoundPtr& src, const wns::ldk::CompoundPtr& dst); 00262 00264 virtual void 00265 calculateSizes(const wns::ldk::CommandPool* commandPool, Bit& commandPoolSize, Bit& dataSize) const; 00266 00268 wifimac::lowerMAC::Manager* 00269 getManager() const 00270 { 00271 return friends.manager; 00272 } 00273 00274 virtual bool 00275 doIsAccepting(const wns::ldk::CompoundPtr& compound) const; 00276 00277 const size_t 00278 getMaxOnAir() 00279 { 00280 return maxOnAir; 00281 } 00282 00283 wifimac::management::PERInformationBase* 00284 getPERMIB() 00285 { 00286 return this->perMIB; 00287 } 00288 00289 protected: 00291 wns::logger::Logger logger; 00292 00294 TransmissionQueue *currentTxQueue; 00295 00297 virtual unsigned int 00298 storageSize() const; 00299 00301 const Bit capacity; 00302 00304 std::auto_ptr<wns::ldk::buffer::SizeCalculator> sizeCalculator; 00305 00307 const size_t maxOnAir; 00308 00319 enum BAState { 00320 idle, 00321 waitForACK, 00322 receiving, 00323 receptionFinished 00324 } baState; 00325 00336 virtual void 00337 processIncomingACKSNs(std::set<BlockACKCommand::SequenceNumber> ackSNs); 00338 00339 private: 00340 00341 bool 00342 isAccepting(const wns::ldk::CompoundPtr& compound) const; 00343 00345 void printTxQueueStatus() const; 00346 00347 const std::string managerName; 00348 const std::string rxStartEndName; 00349 const std::string txStartEndName; 00350 const std::string sendBufferName; 00351 const std::string perMIBServiceName; 00352 00353 const wifimac::convergence::PhyMode blockACKPhyMode; 00354 00356 const wns::simulator::Time sifsDuration; 00358 const wns::simulator::Time maximumACKDuration; 00360 const wns::simulator::Time ackTimeout; 00361 00363 const Bit baBits; 00365 const Bit baReqBits; 00366 00368 const size_t maximumTransmissions; 00369 00371 const bool impatientBAreqTransmission; 00372 00374 wns::container::Registry<wns::service::dll::UnicastAddress, ReceptionQueue*> rxQueues; 00375 00377 wns::service::dll::UnicastAddress hasACKfor; 00378 00382 AddrSNMap nextTransmissionSN; 00383 00384 struct Friends 00385 { 00387 wns::ldk::DelayedInterface* sendBuffer; 00388 00389 wifimac::lowerMAC::Manager* manager; 00390 } friends; 00391 00394 wifimac::management::PERInformationBase* perMIB; 00395 00398 wns::probe::bus::ContextCollectorPtr numTxAttemptsProbe; 00399 00400 std::vector<IBlockACKObserver *> observers; 00401 }; 00402 00403 } // mac 00404 } // wifimac 00405 00406 #endif // WIFIMAC_LOWERMAC_BLOCKACK_HPP
1.5.5