User Manual, Developers Guide and API Documentation

Window.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * This file is part of openWNS (open Wireless Network Simulator)
00003  * _____________________________________________________________________________
00004  *
00005  * Copyright (C) 2004-2007
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 5, D-52074 Aachen, Germany
00008  * phone: ++49-241-80-27910,
00009  * fax: ++49-241-80-22242
00010  * email: info@openwns.org
00011  * www: http://www.openwns.org
00012  * _____________________________________________________________________________
00013  *
00014  * openWNS is free software; you can redistribute it and/or modify it under the
00015  * terms of the GNU Lesser General Public License version 2 as published by the
00016  * Free Software Foundation;
00017  *
00018  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00019  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00020  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00021  * details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public License
00024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00025  *
00026  ******************************************************************************/
00027 
00028 #include <WNS/ldk/probe/bus/Window.hpp>
00029 #include <WNS/ldk/Layer.hpp>
00030 #include <WNS/probe/bus/utils.hpp>
00031 
00032 using namespace wns::ldk;
00033 using namespace wns::ldk::probe::bus;
00034 
00035 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00036     wns::ldk::probe::bus::Window,
00037     wns::ldk::probe::Probe,
00038     "wns.probe.WindowProbeBus",
00039     FUNConfigCreator);
00040 
00041 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00042     wns::ldk::probe::bus::Window,
00043     wns::ldk::FunctionalUnit,
00044     "wns.probe.WindowProbeBus",
00045     FUNConfigCreator);
00046 
00047 Window::Window(fun::FUN* fuNet, const wns::pyconfig::View& config) :
00048     Probe(),
00049     fu::Plain<Window, WindowCommand>(fuNet),
00050     Forwarding<Window>(),
00051     events::PeriodicTimeout(),
00052 
00053     sampleInterval(config.get<simTimeType>("sampleInterval")),
00054 
00055     bitsIncoming(),
00056     compoundsIncoming(),
00057     bitsOutgoing(),
00058     compoundsOutgoing(),
00059     bitsAggregated(),
00060     compoundsAggregated(),
00061     relativeBitsGoodput(),
00062     relativeCompoundsGoodput(),
00063 
00064     cumulatedBitsIncoming(config.get<simTimeType>("windowSize")),
00065     cumulatedPDUsIncoming(config.get<simTimeType>("windowSize")),
00066     cumulatedBitsOutgoing(config.get<simTimeType>("windowSize")),
00067     cumulatedPDUsOutgoing(config.get<simTimeType>("windowSize")),
00068     aggregatedThroughputInBit(config.get<simTimeType>("windowSize")),
00069     aggregatedThroughputInPDUs(config.get<simTimeType>("windowSize")),
00070 
00071     //logger("WNS", config.get<std::string>("name"))
00072     logger(config.get("logger"))
00073 {
00074     assure(
00075         sampleInterval <= config.get<simTimeType>("windowSize"),
00076         "sampleInterval length must be shorter or equal to windowSize");
00077 
00078     // read the localContext from the config
00079     wns::probe::bus::ContextProviderCollection localContext(&fuNet->getLayer()->getContextProviderCollection());
00080     for (int ii = 0; ii<config.len("localIDs.keys()"); ++ii)
00081     {
00082         std::string key = config.get<std::string>("localIDs.keys()",ii);
00083         unsigned long int value  = config.get<unsigned long int>("localIDs.values()",ii);
00084         localContext.addProvider(wns::probe::bus::contextprovider::Constant(key, value));
00085         MESSAGE_SINGLE(VERBOSE, logger, "Using Local IDName '"<<key<<"' with value: "<<value);
00086     }
00087 
00088     this->bitsIncoming = wns::probe::bus::collector(localContext, config, "incomingBitThroughputProbeName");
00089     this->compoundsIncoming = wns::probe::bus::collector(localContext, config, "incomingCompoundThroughputProbeName");
00090     this->bitsOutgoing = wns::probe::bus::collector(localContext, config, "outgoingBitThroughputProbeName");
00091     this->compoundsOutgoing = wns::probe::bus::collector(localContext, config, "outgoingCompoundThroughputProbeName");
00092     this->bitsAggregated = wns::probe::bus::collector(localContext, config, "aggregatedBitThroughputProbeName");
00093     this->compoundsAggregated = wns::probe::bus::collector(localContext, config, "aggregatedCompoundThroughputProbeName");
00094     this->relativeBitsGoodput = wns::probe::bus::collector(localContext, config, "relativeBitsGoodputProbeName");
00095     this->relativeCompoundsGoodput = wns::probe::bus::collector(localContext, config, "relativeCompoundsGoodputProbeName");
00096 
00097     // start after first window is full, then sample every sampleInterval seconds
00098     this->startPeriodicTimeout(sampleInterval, config.get<simTimeType>("windowSize"));
00099 } // Window
00100 
00101 Window::~Window()
00102 {}
00103 
00104 void
00105 Window::processOutgoing(const CompoundPtr& compound)
00106 {
00107     WindowCommand* command = this->activateCommand(compound->getCommandPool());
00108     command->magic.probingFU = this;
00109 
00110     Bit commandPoolSize;
00111     Bit dataSize;
00112     this->getFUN()->calculateSizes(compound->getCommandPool(), commandPoolSize, dataSize, this);
00113     const long int compoundLength = commandPoolSize + dataSize;
00114 
00115     MESSAGE_BEGIN(NORMAL, logger, m, this->getFUN()->getName());
00116     m << " outgoing"
00117       << " length " << compoundLength;
00118     MESSAGE_END();
00119 
00120     this->cumulatedBitsOutgoing.put(compoundLength);
00121     this->cumulatedPDUsOutgoing.put(1);
00122 
00123     Forwarding<Window>::processOutgoing(compound);
00124 } // processOutgoing
00125 
00126 
00127 void
00128 Window::processIncoming(const CompoundPtr& compound)
00129 {
00130     Bit commandPoolSize;
00131     Bit dataSize;
00132     this->getFUN()->calculateSizes(compound->getCommandPool(), commandPoolSize, dataSize, this);
00133     const long int compoundLength = commandPoolSize + dataSize;
00134 
00135     MESSAGE_BEGIN(NORMAL, logger, m, this->getFUN()->getName());
00136     m << " incoming"
00137       << " length " << compoundLength;
00138     MESSAGE_END();
00139 
00140     this->cumulatedBitsIncoming.put(compoundLength);
00141     this->cumulatedPDUsIncoming.put(1);
00142 
00143     WindowCommand* command = this->getCommand(compound->getCommandPool());
00144     command->magic.probingFU->aggregatedThroughputInBit.put(compoundLength);
00145     command->magic.probingFU->aggregatedThroughputInPDUs.put(1);
00146 
00147     Forwarding<Window>::processIncoming(compound);
00148 } // processIncoming
00149 
00150 
00151 void
00152 Window::periodically()
00153 {
00154     this->bitsOutgoing->put(this->cumulatedBitsOutgoing.getPerSecond());
00155     this->compoundsOutgoing->put(this->cumulatedPDUsOutgoing.getPerSecond());
00156     this->bitsIncoming->put(this->cumulatedBitsIncoming.getPerSecond());
00157     this->compoundsIncoming->put(this->cumulatedPDUsIncoming.getPerSecond());
00158     this->bitsAggregated->put(this->aggregatedThroughputInBit.getPerSecond());
00159     this->compoundsAggregated->put(this->aggregatedThroughputInPDUs.getPerSecond());
00160 
00161     if(this->cumulatedBitsOutgoing.getPerSecond() > 0)
00162     {
00163         this->relativeBitsGoodput->put(this->aggregatedThroughputInBit.getPerSecond()/this->cumulatedBitsOutgoing.getPerSecond());
00164         this->relativeCompoundsGoodput->put(this->aggregatedThroughputInPDUs.getPerSecond()/this->cumulatedPDUsOutgoing.getPerSecond());
00165     }
00166 
00167 } // periodically
00168 
00169 
00170 

Generated on Sat May 26 03:31:43 2012 for openWNS by  doxygen 1.5.5