![]() |
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_MANAGER_HPP 00030 #define WIFIMAC_LOWERMAC_MANAGER_HPP 00031 00032 #include <WIFIMAC/convergence/PhyMode.hpp> 00033 #include <WIFIMAC/convergence/PhyUser.hpp> 00034 #include <WIFIMAC/FrameType.hpp> 00035 00036 #include <WNS/logger/Logger.hpp> 00037 00038 #include <WNS/ldk/Command.hpp> 00039 #include <WNS/ldk/fu/Plain.hpp> 00040 #include <WNS/ldk/Processor.hpp> 00041 00042 #include <WNS/service/dll/Address.hpp> 00043 00044 #include <DLL/Layer2.hpp> 00045 #include <DLL/UpperConvergence.hpp> 00046 00047 namespace wifimac { namespace convergence { 00048 class PhyUser; 00049 }} 00050 00051 namespace wifimac { namespace lowerMAC { 00052 00054 class ManagerCommand : 00055 public wifimac::IKnowsFrameTypeCommand 00056 { 00057 public: 00058 struct { 00060 wns::simulator::Time expirationTime; 00061 00063 wns::simulator::Time replyTimeout; 00064 } local; 00065 00066 struct { 00067 wifimac::FrameType type; 00068 wifimac::convergence::PhyMode phyMode; 00069 00075 wns::simulator::Time frameExchangeDuration; 00076 } peer; 00077 00078 struct { } magic; 00079 00080 ManagerCommand() 00081 { 00082 peer.type = DATA; 00083 peer.frameExchangeDuration = 0.0; 00084 local.replyTimeout = 0.0; 00085 } 00086 00087 FrameType getFrameType() 00088 { 00089 return peer.type; 00090 } 00091 bool isPreamble() const 00092 { 00093 return peer.type == PREAMBLE; 00094 } 00095 00096 wifimac::convergence::PhyMode getPhyMode() const 00097 { 00098 return this->peer.phyMode; 00099 } 00100 }; 00101 00111 class Manager : 00112 public wns::ldk::fu::Plain<Manager, ManagerCommand>, 00113 public wns::ldk::Processor<Manager> 00114 { 00115 public: 00116 Manager(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config); 00117 00118 virtual 00119 ~Manager(); 00120 00122 void processIncoming(const wns::ldk::CompoundPtr& compound); 00123 00126 void processOutgoing(const wns::ldk::CompoundPtr& compound); 00127 00129 wifimac::convergence::PhyUser* 00130 getPhyUser(); 00131 00133 dll::ILayer2::StationType 00134 getStationType() const; 00135 00139 wns::service::dll::UnicastAddress 00140 getMACAddress() const; 00141 00143 void 00144 associateWith(wns::service::dll::UnicastAddress svrAddress); 00145 00147 wns::service::dll::UnicastAddress 00148 getAssociatedTo() const; 00149 00151 wns::ldk::CommandPool* 00152 createReply(const wns::ldk::CommandPool* original) const; 00153 00156 wns::ldk::CompoundPtr 00157 createCompound(const wns::service::dll::UnicastAddress transmitterAddress, 00158 const wns::service::dll::UnicastAddress receiverAddress, 00159 const FrameType type, 00160 const wns::simulator::Time frameExchangeDuration, 00161 const wns::simulator::Time replyTimeout = 0.0); 00162 00164 wns::service::dll::UnicastAddress 00165 getTransmitterAddress(const wns::ldk::CommandPool* commandPool) const; 00166 00168 wns::service::dll::UnicastAddress 00169 getReceiverAddress(const wns::ldk::CommandPool* commandPool) const; 00170 00172 bool 00173 isForMe(const wns::ldk::CommandPool* commandPool) const; 00174 00176 wifimac::FrameType 00177 getFrameType(const wns::ldk::CommandPool* commandPool) const; 00178 00180 void 00181 setFrameType(const wns::ldk::CommandPool* commandPool, const FrameType type); 00182 00194 wns::simulator::Time 00195 getFrameExchangeDuration(const wns::ldk::CommandPool* commandPool) const; 00196 00198 void 00199 setFrameExchangeDuration(const wns::ldk::CommandPool* commandPool, const wns::simulator::Time duration); 00200 00202 wifimac::convergence::PhyMode 00203 getPhyMode(const wns::ldk::CommandPool* commandPool) const; 00204 00206 void 00207 setPhyMode(const wns::ldk::CommandPool* commandPool, const wifimac::convergence::PhyMode phyMode); 00208 00218 wns::simulator::Time 00219 getReplyTimeout(const wns::ldk::CommandPool* commandPool) const; 00220 00222 void 00223 setReplyTimeout(const wns::ldk::CommandPool* commandPool, wns::simulator::Time replyTimeout); 00224 00226 unsigned int 00227 getNumAntennas() const; 00228 00230 bool 00231 lifetimeExpired(const wns::ldk::CommandPool* commandPool) const; 00232 00234 wns::simulator::Time 00235 getExpirationTime(const wns::ldk::CommandPool* commandPool) const; 00236 00237 00238 private: 00239 virtual void 00240 onFUNCreated(); 00241 00242 const wns::pyconfig::View config_; 00243 wns::logger::Logger logger_; 00244 00246 const wns::simulator::Time maximumACKDuration; 00247 00249 const wns::simulator::Time sifsDuration; 00250 00252 const wns::service::dll::UnicastAddress myMACAddress_; 00253 00255 const std::string ucName_; 00256 00258 const unsigned int numAntennas; 00259 00261 const wns::simulator::Time msduLifetimeLimit; 00262 00264 wns::service::dll::UnicastAddress associatedTo; 00265 00266 struct Friends 00267 { 00268 dll::UpperConvergence* upperConvergence; 00269 wifimac::convergence::PhyUser* phyUser; 00270 } friends; 00271 }; 00272 } // lowerMAC 00273 } // wifimac 00274 00275 #endif // WIFIMAC_LOWERMAC_MANAGER_HPP
1.5.5