![]() |
User Manual, Developers Guide and API Documentation |
![]() |
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/management/PERInformationBase.hpp> 00030 00031 #include <WNS/simulator/Time.hpp> 00032 00033 00034 using namespace wimemac::management; 00035 00036 STATIC_FACTORY_REGISTER_WITH_CREATOR(wimemac::management::PERInformationBase, 00037 wns::ldk::ManagementServiceInterface, 00038 "wimemac.management.PERInformationBase", 00039 wns::ldk::MSRConfigCreator); 00040 00041 PERInformationBase::PERInformationBase( wns::ldk::ManagementServiceRegistry* msr, const wns::pyconfig::View& config): 00042 wns::ldk::ManagementService(msr), 00043 logger(config.get("logger")), 00044 windowSize(config.get<simTimeType>("myConfig.windowSize")), 00045 minSamples(config.get<int>("myConfig.minSamples")) 00046 { 00047 00048 } 00049 00050 void 00051 PERInformationBase::onMSRCreated() 00052 { 00053 MESSAGE_SINGLE(NORMAL, logger, "Created."); 00054 } 00055 00056 void PERInformationBase::reset(const wns::service::dll::UnicastAddress receiver) 00057 { 00058 assure(receiver.isValid(), "address " << receiver << " is not valid"); 00059 00060 if(perHolder.knows(receiver)) 00061 { 00062 perHolder.find(receiver)->reset(); 00063 } 00064 } 00065 00066 void PERInformationBase::onSuccessfullTransmission(const wns::service::dll::UnicastAddress receiver) 00067 { 00068 assure(receiver.isValid(), "address " << receiver << " is not valid"); 00069 00070 if(!perHolder.knows(receiver)) 00071 { 00072 perHolder.insert(receiver, new wns::SlidingWindow(windowSize)); 00073 } 00074 perHolder.find(receiver)->put(0.0); 00075 } 00076 00077 00078 void PERInformationBase::onFailedTransmission(const wns::service::dll::UnicastAddress receiver) 00079 { 00080 assure(receiver.isValid(), "address " << receiver << " is not valid"); 00081 00082 if(!perHolder.knows(receiver)) 00083 { 00084 perHolder.insert(receiver, new wns::SlidingWindow(windowSize)); 00085 } 00086 perHolder.find(receiver)->put(1.0); 00087 } 00088 00089 bool PERInformationBase::knowsPER(const wns::service::dll::UnicastAddress receiver) const 00090 { 00091 assure(receiver.isValid(), "address " << receiver << " is not valid"); 00092 00093 if(perHolder.knows(receiver)) 00094 { 00095 return(perHolder.find(receiver)->getNumSamples() >= minSamples); 00096 } 00097 else 00098 { 00099 return(false); 00100 } 00101 } 00102 00103 double PERInformationBase::getPER(const wns::service::dll::UnicastAddress receiver) const 00104 { 00105 assure(receiver.isValid(), "address " << receiver << " is not valid"); 00106 00107 assure(knowsPER(receiver), "Success rate for destination " << receiver << " not known"); 00108 return(perHolder.find(receiver)->getAbsolute() / perHolder.find(receiver)->getNumSamples()); 00109 } 00110 00111
1.5.5