User Manual, Developers Guide and API Documentation

TxDurationSetter.cpp

Go to the documentation of this file.
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 #include <WIMEMAC/convergence/TxDurationSetter.hpp>
00030 #include <DLL/Layer2.hpp>
00031 
00032 using namespace wimemac::convergence;
00033 
00034 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00035     wimemac::convergence::TxDurationSetter,
00036     wns::ldk::FunctionalUnit,
00037     "wimemac.convergence.TxDurationSetter",
00038     wns::ldk::FUNConfigCreator);
00039 
00040 TxDurationSetter::TxDurationSetter(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config_) :
00041     wns::ldk::fu::Plain<TxDurationSetter, TxDurationSetterCommand>(fun),
00042     managerName(config_.get<std::string>("managerName")),
00043     logger(config_.get("logger"))
00044 {
00045     MESSAGE_SINGLE(NORMAL, this->logger, "created");
00046     friends.manager = NULL;
00047 }
00048 
00049 
00050 TxDurationSetter::~TxDurationSetter()
00051 {
00052 }
00053 
00054 void TxDurationSetter::onFUNCreated()
00055 {
00056     MESSAGE_SINGLE(NORMAL, this->logger, "onFUNCreated() started");
00057     friends.manager = getFUN()->findFriend<wimemac::lowerMAC::IManagerServices*>(managerName);
00058 }
00059 
00060 void
00061 TxDurationSetter::processIncoming(const wns::ldk::CompoundPtr& /*compound*/)
00062 {
00063 
00064 }
00065 
00066 void
00067 TxDurationSetter::processOutgoing(const wns::ldk::CompoundPtr& compound)
00068 {
00069     TxDurationSetterCommand* command = activateCommand(compound->getCommandPool());
00070     wimemac::convergence::PhyMode phyMode = friends.manager->getPhyMode(compound->getCommandPool());
00071 
00072     // calculate tx duration
00073     wns::simulator::Time preambleTxDuration = friends.manager->getProtocolCalculator()->getDuration()->preamble(phyMode);
00074 
00075     if(friends.manager->isPreamble(compound->getCommandPool()))
00076     {
00077         command->local.txDuration = preambleTxDuration;
00078 
00079         MESSAGE_BEGIN(NORMAL, this->logger, m, "Preamble");
00080         m << ": duration " << command->local.txDuration;
00081         MESSAGE_END();
00082     }
00083     else
00084     {
00085         command->local.txDuration = friends.manager->getProtocolCalculator()->getDuration()->PSDU_PPDU(compound->getLengthInBits(), phyMode) - preambleTxDuration;
00086         //MESSAGE_BEGIN(VERBOSE, this->logger, m, "Outgoing Compound with size ");
00087         MESSAGE_BEGIN(NORMAL, this->logger, m, "Outgoing Compound with size ");
00088         m << compound->getLengthInBits();
00089         m << " with nIBP6S " << phyMode.getInfoBitsPer6Symbols();
00090         m << " --> duration " << friends.manager->getProtocolCalculator()->getDuration()->PSDU_PPDU(compound->getLengthInBits(), phyMode);
00091         m << " - " << preambleTxDuration;
00092         MESSAGE_END();
00093 
00094         MESSAGE_BEGIN(NORMAL, this->logger, m, "Command");
00095         m << " start " << wns::simulator::getEventScheduler()->getTime();
00096         m << " stop " << wns::simulator::getEventScheduler()->getTime() + command->local.txDuration;
00097         MESSAGE_END();
00098 
00099     }
00100 }
00101 
00102 void
00103 TxDurationSetter::calculateSizes(const wns::ldk::CommandPool* commandPool, Bit& commandPoolSize, Bit& dataSize) const
00104 {
00105     getFUN()->getProxy()->calculateSizes(commandPool, commandPoolSize, dataSize, this);
00106 }
00107 

Generated on Sun May 27 03:32:06 2012 for openWNS by  doxygen 1.5.5