![]() |
User Manual, Developers Guide and API Documentation |
![]() |
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_LOWERMAC_MANAGER_HPP 00030 #define WIMEMAC_LOWERMAC_MANAGER_HPP 00031 00032 #include <WIMEMAC/convergence/PhyUser.hpp> 00033 #include <WIMEMAC/convergence/PhyMode.hpp> 00034 #include <WIMEMAC/FrameType.hpp> 00035 #include <WIMEMAC/drp/DRPScheduler.hpp> 00036 #include <WIMEMAC/convergence/ErrorModelling.hpp> 00037 #include <WIMEMAC/management/ProtocolCalculator.hpp> 00038 #include <WIMEMAC/lowerMAC/IManagerServices.hpp> 00039 00040 #include <WNS/logger/Logger.hpp> 00041 00042 #include <WNS/ldk/Command.hpp> 00043 #include <WNS/ldk/fu/Plain.hpp> 00044 #include <WNS/ldk/Processor.hpp> 00045 00046 #include <WNS/service/dll/Address.hpp> 00047 #include <WNS/probe/bus/ContextCollector.hpp> 00048 00049 #include <DLL/Layer2.hpp> 00050 #include <DLL/UpperConvergence.hpp> 00051 00052 #include <list> 00053 00054 namespace wimemac { 00055 namespace lowerMAC { 00056 00057 class IManagerServices; 00058 } 00059 00060 namespace convergence { 00061 class PhyUser; 00062 class ErrorModelling; 00063 }} 00064 00065 namespace wimemac { namespace drp { 00066 class DRPScheduler; 00067 }} 00068 00069 namespace wimemac { namespace lowerMAC { 00070 00071 typedef std::vector<bool> Vector; 00072 00074 class ManagerCommand : 00075 public wimemac::IKnowsFrameTypeCommand 00076 { 00077 public: 00078 struct { 00079 wns::simulator::Time expirationTime; 00080 } local; 00081 00082 struct { 00083 bool hasPayload; 00084 wimemac::CompoundType CompoundType; 00085 wimemac::convergence::PhyMode phyMode; 00086 00092 wns::simulator::Time frameExchangeDuration; 00093 wns::simulator::Time psduDuration; 00094 00096 bool requiresDirectReply; 00097 } peer; 00098 00099 struct { } magic; 00100 00101 ManagerCommand() 00102 { 00103 peer.CompoundType = DATA; 00104 peer.hasPayload = true; 00105 peer.frameExchangeDuration = 0; 00106 peer.psduDuration = 0; 00107 peer.requiresDirectReply = false; 00108 } 00109 00110 CompoundType getCompoundType() 00111 { 00112 return peer.CompoundType; 00113 } 00114 00115 std::string getPreambleMode() 00116 { 00117 return this->peer.phyMode.getPreambleMode(); 00118 } 00119 00120 bool isPreamble() const 00121 { 00122 return (peer.CompoundType == ACK_PREAMBLE || peer.CompoundType == BEACON_PREAMBLE || peer.CompoundType == DATA_PREAMBLE); 00123 } 00124 00125 wimemac::convergence::PhyMode getPhyMode() const 00126 { 00127 return this->peer.phyMode; 00128 } 00129 }; 00130 00141 class Manager : 00142 public wns::ldk::fu::Plain<Manager, ManagerCommand>, 00143 public wns::ldk::Processor<Manager>, 00144 public wimemac::lowerMAC::IManagerServices 00145 00146 00147 { 00148 public: 00149 00150 Manager(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config); 00151 00152 virtual 00153 ~Manager(); 00154 00156 void processIncoming(const wns::ldk::CompoundPtr& compound); 00157 00160 void processOutgoing(const wns::ldk::CompoundPtr& compound); 00161 00162 bool doIsAccepting(const wns::ldk::CompoundPtr& compound) const; 00163 00165 wimemac::convergence::PhyUser* 00166 getPhyUser(); 00167 00169 dll::Layer2::StationType 00170 getStationType() const; 00171 00175 wns::service::dll::UnicastAddress 00176 getMACAddress() const; 00177 00179 bool getRateAdaptation() {return useRateAdaptation;} 00180 int getReservationBlocks() {return reservationBlocks;} 00181 bool getRandomUse() {return useRandomPattern;} 00182 00183 bool getDRPchannelAccess() {return useDRPchannelAccess;} 00184 bool getPCAchannelAccess() {return usePCAchannelAccess;} 00185 00187 wns::ldk::CommandPool* 00188 createReply(const wns::ldk::CommandPool* original) const; 00189 00191 wns::ldk::CommandPool* 00192 createReply(const wns::ldk::CommandPool* original, wimemac::CompoundType compoundType) const; 00193 00196 wns::ldk::CompoundPtr 00197 createCompound(const wns::service::dll::UnicastAddress transmitterAddress, 00198 const wns::service::dll::UnicastAddress receiverAddress, 00199 const CompoundType compoundType, 00200 const bool hasPayload, 00201 const wns::simulator::Time frameExchangeDuration, 00202 const bool requiresDirectReply = false); 00203 00205 wns::service::dll::UnicastAddress 00206 getTransmitterAddress(const wns::ldk::CommandPool* commandPool) const; 00207 00209 wns::service::dll::UnicastAddress 00210 getReceiverAddress(const wns::ldk::CommandPool* commandPool) const; 00211 00213 bool 00214 isForMe(const wns::ldk::CommandPool* commandPool) const; 00215 00217 bool 00218 hasPayload(const wns::ldk::CommandPool* commandPool) const; 00219 00221 void 00222 setHasPayload(const wns::ldk::CommandPool* commandPool, bool setPayloadTo); 00223 00225 wimemac::CompoundType 00226 getCompoundType(const wns::ldk::CommandPool* commandPool) const; 00227 00229 std::string 00230 getPreambleMode(const wns::ldk::CommandPool* commandPool) const; 00231 00233 void 00234 setCompoundType(const wns::ldk::CommandPool* commandPool, const CompoundType type); 00235 00237 bool 00238 isPreamble(const wns::ldk::CommandPool* commandPool) const; 00239 00241 bool 00242 isBeacon(const wns::ldk::CommandPool* commandPool) const; 00243 00253 wns::simulator::Time 00254 getFrameExchangeDuration(const wns::ldk::CommandPool* commandPool) const; 00255 00257 void 00258 setFrameExchangeDuration(const wns::ldk::CommandPool* commandPool, const wns::simulator::Time duration); 00259 00267 wns::simulator::Time 00268 getpsduDuration(const wns::ldk::CommandPool* commandPool) const; 00269 00270 void 00271 setpsduDuration(const wns::ldk::CommandPool* commandPool, const wns::simulator::Time duration); 00272 00274 wimemac::convergence::PhyMode 00275 getPhyMode(const wns::ldk::CommandPool* commandPool) const; 00276 00278 void 00279 setPhyMode(const wns::ldk::CommandPool* commandPool, const wimemac::convergence::PhyMode phyMode); 00280 00282 wimemac::convergence::PhyMode 00283 getDefaultPhyMode() const; 00284 00286 wns::Power 00287 getRxPower(const wns::ldk::CommandPool* commandPool); 00288 00289 wns::Power 00290 getInterference(const wns::ldk::CommandPool* commandPool); 00291 00293 wimemac::convergence::MCS getMaxPosMCS(wns::Ratio sinr_, Bit maxCompoundSize_, double per_); 00294 00296 double getErrorRateForCommandFrames(wns::Ratio sinr_, Bit maxCompoundSize_); 00297 00299 double getDesiredPER(); 00300 00302 double getPatternPEROffset(); 00303 00313 bool 00314 getRequiresDirectReply(const wns::ldk::CommandPool* commandPool) const; 00315 00317 void 00318 setRequiresDirectReply(const wns::ldk::CommandPool* commandPool, bool requiresDirectReply); 00319 00321 bool 00322 lifetimeExpired(const wns::ldk::CommandPool* commandPool) const; 00323 00325 wns::simulator::Time 00326 getExpirationTime(const wns::ldk::CommandPool* commandPool) const; 00327 00328 void 00329 setBPStartTime(wns::simulator::Time bpStartTime_) {BPStartTime = bpStartTime_;} 00330 00331 wns::simulator::Time 00332 getBPStartTime() { return BPStartTime;} 00333 00334 int 00335 getMASNumber(wns::simulator::Time time_); 00336 00337 wimemac::management::ProtocolCalculator* getProtocolCalculator(); 00338 00339 // For BeaconBuilder Services 00340 void prepareDRPConnection(wns::service::dll::UnicastAddress rx, int CompoundspSF, int BitspSF, int MaxCompoundSize); 00341 00342 void updateDRPConnection(wns::service::dll::UnicastAddress rx, int CompoundspSF, int BitspSF, int MaxCompoundSize); 00343 00344 void BuildDTPmap(); 00345 00346 void SetBPDuration(wns::simulator::Time duration); 00347 00348 // For DRPScheduler Services 00349 bool startPCAtransmission(); 00350 void stopPCAtransmission(); 00351 void txOPCloseIn(wns::simulator::Time duration); 00352 00353 wns::service::dll::UnicastAddress getCurrentTransmissionTarget(); 00354 00356 int getNumOfRetransmissions(const wns::ldk::CompoundPtr& compound); 00357 00359 bool UpdateMapWithPeerAvailabilityMap(wns::service::dll::UnicastAddress rx , Vector& DRPMap); 00360 00362 bool adjustMCSdown(wns::service::dll::UnicastAddress rx); 00363 00365 void UpdateDRPMap(Vector DRPMap); 00366 00367 void onBPStart(wns::simulator::Time BPduration); 00368 00369 void Acknowledgment(wns::service::dll::UnicastAddress tx); 00370 00371 00372 private: 00373 virtual void 00374 onFUNCreated(); 00375 00376 const wns::pyconfig::View config_; 00377 wns::logger::Logger logger_; 00379 const wns::simulator::Time expectedACKDuration; 00380 00384 const wns::simulator::Time sifsDuration; 00385 00387 const wns::service::dll::UnicastAddress myMACAddress_; 00388 00390 const std::string ucName_; 00391 00393 const wns::simulator::Time msduLifetimeLimit; 00394 00396 int reservationBlocks; 00397 00399 bool useRandomPattern; 00400 bool useRateAdaptation; 00401 00403 bool useDRPchannelAccess; 00404 bool usePCAchannelAccess; 00405 00406 wns::simulator::Time BPStartTime; 00407 const std::string protocolCalculatorName; 00408 wns::probe::bus::ContextCollectorPtr mcsProbe; 00409 00410 wimemac::management::ProtocolCalculator* protocolCalculator; 00411 00412 struct Friends 00413 { 00414 dll::UpperConvergence* upperConvergence; 00415 wimemac::convergence::PhyUser* phyUser; 00416 wimemac::drp::DRPScheduler* drpScheduler; 00417 wimemac::convergence::ErrorModelling* errorModelling; 00418 } friends; 00419 }; 00420 } // lowerMAC 00421 } // wimemac 00422 00423 #endif // WIMEMAC_LOWERMAC_MANAGER_HPP
1.5.5