![]() |
User Manual, Developers Guide and API Documentation |
![]() |
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/Window.hpp> 00029 #include <WNS/ldk/Layer.hpp> 00030 00031 using namespace wns::ldk; 00032 using namespace wns::ldk::probe; 00033 00034 STATIC_FACTORY_REGISTER_WITH_CREATOR( 00035 Window, 00036 Probe, 00037 "wns.probe.Window", 00038 FUNConfigCreator); 00039 00040 STATIC_FACTORY_REGISTER_WITH_CREATOR( 00041 Window, 00042 FunctionalUnit, 00043 "wns.probe.Window", 00044 FUNConfigCreator); 00045 00046 Window::Window(fun::FUN* fuNet, const wns::pyconfig::View& config) : 00047 Probe(), 00048 fu::Plain<Window, WindowCommand>(fuNet), 00049 Forwarding<Window>(), 00050 events::PeriodicTimeout(), 00051 00052 sampleInterval(config.get<wns::simulator::Time>("sampleInterval")), 00053 00054 cumulatedBitsIncoming(config.get<wns::simulator::Time>("windowSize")), 00055 cumulatedPDUsIncoming(config.get<wns::simulator::Time>("windowSize")), 00056 cumulatedBitsOutgoing(config.get<wns::simulator::Time>("windowSize")), 00057 cumulatedPDUsOutgoing(config.get<wns::simulator::Time>("windowSize")), 00058 aggregatedThroughputInBit(config.get<wns::simulator::Time>("windowSize")), 00059 aggregatedThroughputInPDUs(config.get<wns::simulator::Time>("windowSize")), 00060 00061 //logger("WNS", config.get<std::string>("name")) 00062 logger(config.get("logger")) 00063 { 00064 assure( 00065 sampleInterval <= config.get<wns::simulator::Time>("windowSize"), 00066 "sampleInterval length must be shorter or equal to windowSize"); 00067 00068 // this is for the new probe bus 00069 wns::probe::bus::ContextProviderCollection* cpcParent = &fuNet->getLayer()->getContextProviderCollection(); 00070 00071 wns::probe::bus::ContextProviderCollection cpc(cpcParent); 00072 00073 for (int ii = 0; ii<config.len("localIDs.keys()"); ++ii) 00074 { 00075 std::string key = config.get<std::string>("localIDs.keys()",ii); 00076 int value = config.get<int>("localIDs.values()",ii); 00077 cpc.addProvider(wns::probe::bus::contextprovider::Constant(key, value)); 00078 MESSAGE_SINGLE(VERBOSE, logger, "Using Local IDName '"<<key<<"' with value: "<<value); 00079 } 00080 00081 bitsIncomingBus = wns::probe::bus::ContextCollectorPtr(new wns::probe::bus::ContextCollector(cpc, config.get<std::string>("incomingBitThroughputProbeName"))); 00082 compoundsIncomingBus = wns::probe::bus::ContextCollectorPtr(new wns::probe::bus::ContextCollector(cpc, config.get<std::string>("incomingCompoundThroughputProbeName"))); 00083 bitsOutgoingBus = wns::probe::bus::ContextCollectorPtr(new wns::probe::bus::ContextCollector(cpc, config.get<std::string>("outgoingBitThroughputProbeName"))); 00084 compoundsOutgoingBus = wns::probe::bus::ContextCollectorPtr(new wns::probe::bus::ContextCollector(cpc, config.get<std::string>("outgoingCompoundThroughputProbeName"))); 00085 bitsAggregatedBus = wns::probe::bus::ContextCollectorPtr(new wns::probe::bus::ContextCollector(cpc, config.get<std::string>("aggregatedBitThroughputProbeName"))); 00086 compoundsAggregatedBus = wns::probe::bus::ContextCollectorPtr(new wns::probe::bus::ContextCollector(cpc, config.get<std::string>("aggregatedCompoundThroughputProbeName"))); 00087 00088 00089 // start after first window is full, then sample every sampleInterval seconds 00090 this->startPeriodicTimeout(sampleInterval, config.get<wns::simulator::Time>("windowSize")); 00091 } // Window 00092 00093 Window::~Window() 00094 {} 00095 00096 void 00097 Window::processOutgoing(const CompoundPtr& compound) 00098 { 00099 WindowCommand* command = this->activateCommand(compound->getCommandPool()); 00100 command->magic.probingFU = this; 00101 00102 Bit commandPoolSize; 00103 Bit dataSize; 00104 this->getFUN()->calculateSizes(compound->getCommandPool(), commandPoolSize, dataSize, this); 00105 const long int compoundLength = commandPoolSize + dataSize; 00106 00107 MESSAGE_BEGIN(NORMAL, logger, m, this->getFUN()->getName()); 00108 m << " outgoing" 00109 << " length " << compoundLength; 00110 MESSAGE_END(); 00111 00112 this->cumulatedBitsOutgoing.put(compoundLength); 00113 this->cumulatedPDUsOutgoing.put(1); 00114 00115 Forwarding<Window>::processOutgoing(compound); 00116 } // processOutgoing 00117 00118 00119 void 00120 Window::processIncoming(const CompoundPtr& compound) 00121 { 00122 Bit commandPoolSize; 00123 Bit dataSize; 00124 this->getFUN()->calculateSizes(compound->getCommandPool(), commandPoolSize, dataSize, this); 00125 const long int compoundLength = commandPoolSize + dataSize; 00126 00127 MESSAGE_BEGIN(NORMAL, logger, m, this->getFUN()->getName()); 00128 m << " incoming" 00129 << " length " << compoundLength; 00130 MESSAGE_END(); 00131 00132 this->cumulatedBitsIncoming.put(compoundLength); 00133 this->cumulatedPDUsIncoming.put(1); 00134 00135 WindowCommand* command = this->getCommand(compound->getCommandPool()); 00136 command->magic.probingFU->aggregatedThroughputInBit.put(compoundLength); 00137 command->magic.probingFU->aggregatedThroughputInPDUs.put(1); 00138 00139 Forwarding<Window>::processIncoming(compound); 00140 } // processIncoming 00141 00142 00143 void 00144 Window::periodically() 00145 { 00146 this->bitsOutgoingBus->put(this->cumulatedBitsOutgoing.getPerSecond()); 00147 this->compoundsOutgoingBus->put(this->cumulatedPDUsOutgoing.getPerSecond()); 00148 this->bitsIncomingBus->put(this->cumulatedBitsIncoming.getPerSecond()); 00149 this->compoundsIncomingBus->put(this->cumulatedPDUsIncoming.getPerSecond()); 00150 this->bitsAggregatedBus->put(this->aggregatedThroughputInBit.getPerSecond()); 00151 this->compoundsAggregatedBus->put(this->aggregatedThroughputInPDUs.getPerSecond()); 00152 } // periodically 00153 00154 00155
1.5.5