![]() |
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 #include <WIFIMAC/convergence/TxDurationSetter.hpp> 00030 #include <DLL/Layer2.hpp> 00031 00032 #include <iomanip> 00033 00034 using namespace wifimac::convergence; 00035 00036 STATIC_FACTORY_REGISTER_WITH_CREATOR( 00037 wifimac::convergence::TxDurationSetter, 00038 wns::ldk::FunctionalUnit, 00039 "wifimac.convergence.TxDurationSetter", 00040 wns::ldk::FUNConfigCreator); 00041 00042 TxDurationSetter::TxDurationSetter(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config_) : 00043 wns::ldk::fu::Plain<TxDurationSetter, TxDurationSetterCommand>(fun), 00044 00045 protocolCalculatorName(config_.get<std::string>("protocolCalculatorName")), 00046 managerName(config_.get<std::string>("managerName")), 00047 00048 logger(config_.get("logger")) 00049 { 00050 MESSAGE_SINGLE(NORMAL, this->logger, "created"); 00051 00052 protocolCalculator = NULL; 00053 friends.manager = NULL; 00054 } 00055 00056 00057 TxDurationSetter::~TxDurationSetter() 00058 { 00059 } 00060 00061 void TxDurationSetter::onFUNCreated() 00062 { 00063 MESSAGE_SINGLE(NORMAL, this->logger, "onFUNCreated() started"); 00064 00065 protocolCalculator = getFUN()->getLayer<dll::ILayer2*>()->getManagementService<wifimac::management::ProtocolCalculator>(protocolCalculatorName); 00066 friends.manager = getFUN()->findFriend<wifimac::lowerMAC::Manager*>(managerName); 00067 } 00068 00069 void 00070 TxDurationSetter::processIncoming(const wns::ldk::CompoundPtr& /*compound*/) 00071 { 00072 00073 } 00074 00075 void 00076 TxDurationSetter::processOutgoing(const wns::ldk::CompoundPtr& compound) 00077 { 00078 TxDurationSetterCommand* command = activateCommand(compound->getCommandPool()); 00079 wifimac::convergence::PhyMode phyMode = friends.manager->getPhyMode(compound->getCommandPool()); 00080 00081 // calculate tx duration 00082 wns::simulator::Time preambleDuration = protocolCalculator->getDuration()->preamble(phyMode); 00083 00084 if(friends.manager->getFrameType(compound->getCommandPool()) == PREAMBLE) 00085 { 00086 command->local.txDuration = preambleDuration; 00087 00088 MESSAGE_BEGIN(NORMAL, this->logger, m, "Preamble"); 00089 m << ": duration " << command->local.txDuration; 00090 MESSAGE_END(); 00091 } 00092 else 00093 { 00094 command->local.txDuration = protocolCalculator->getDuration()->MPDU_PPDU(compound->getLengthInBits(), phyMode) - preambleDuration; 00095 MESSAGE_BEGIN(NORMAL, this->logger, m, "Outgoing Compound with size "); 00096 m << compound->getLengthInBits(); 00097 m << " at " << phyMode; 00098 m << " --> dur " << protocolCalculator->getDuration()->MPDU_PPDU(compound->getLengthInBits(), phyMode); 00099 m << " - " << preambleDuration; 00100 m << " ( " << protocolCalculator->getDuration()->ofdmSymbols(compound->getLengthInBits(), phyMode) << " symb"; 00101 m << " with " << protocolCalculator->getDuration()->symbol(phyMode) << " per symbol)"; 00102 MESSAGE_END(); 00103 00104 MESSAGE_BEGIN(NORMAL, this->logger, m, "Command"); 00105 m << " start " << std::fixed << std::setprecision(8) << wns::simulator::getEventScheduler()->getTime(); 00106 m << " stop " << std::fixed << std::setprecision(8) << wns::simulator::getEventScheduler()->getTime() + command->local.txDuration; 00107 MESSAGE_END(); 00108 00109 } 00110 } 00111
1.5.5