User Manual, Developers Guide and API Documentation

PERInformationBase.cpp

Go to the documentation of this file.
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/management/PERInformationBase.hpp>
00030 
00031 #include <WNS/simulator/Time.hpp>
00032 
00033 
00034 
00035 
00036 using namespace wifimac::management;
00037 
00038 STATIC_FACTORY_REGISTER_WITH_CREATOR(wifimac::management::PERInformationBase,
00039                                      wns::ldk::ManagementServiceInterface,
00040                                      "wifimac.management.PERInformationBase",
00041                                      wns::ldk::MSRConfigCreator);
00042 
00043 PERInformationBase::PERInformationBase( wns::ldk::ManagementServiceRegistry* msr, const wns::pyconfig::View& config):
00044     wns::ldk::ManagementService(msr),
00045     logger(config.get("logger")),
00046     windowSize(config.get<simTimeType>("myConfig.windowSize")),
00047     minSamples(config.get<int>("myConfig.minSamples"))
00048 {
00049 
00050 }
00051 
00052 void
00053 PERInformationBase::onMSRCreated()
00054 {
00055     MESSAGE_SINGLE(NORMAL, logger, "Created.");
00056 }
00057 
00058 void PERInformationBase::reset(const wns::service::dll::UnicastAddress receiver)
00059 {
00060     assure(receiver.isValid(), "address is not valid");
00061 
00062     if(perHolder.knows(receiver))
00063     {
00064         perHolder.find(receiver)->reset();
00065         successfull.find(receiver) = 0;
00066         failed.find(receiver) = 0;
00067     }
00068 }
00069 
00070 void PERInformationBase::onSuccessfullTransmission(const wns::service::dll::UnicastAddress receiver)
00071 {
00072     assure(receiver.isValid(), "address is not valid");
00073 
00074     if(!perHolder.knows(receiver))
00075     {
00076         perHolder.insert(receiver, new wns::SlidingWindow(windowSize));
00077         successfull.insert(receiver, 0);
00078         failed.insert(receiver, 0);
00079     }
00080     perHolder.find(receiver)->put(0.0);
00081     ++(successfull.find(receiver));
00082 }
00083 
00084 
00085 void PERInformationBase::onFailedTransmission(const wns::service::dll::UnicastAddress receiver)
00086 {
00087     assure(receiver.isValid(), "address is not valid");
00088 
00089     if(!perHolder.knows(receiver))
00090     {
00091         perHolder.insert(receiver, new wns::SlidingWindow(windowSize));
00092         successfull.insert(receiver, 0);
00093         failed.insert(receiver, 0);
00094     }
00095     perHolder.find(receiver)->put(1.0);
00096     ++(failed.find(receiver));
00097 }
00098 
00099 bool PERInformationBase::knowsPER(const wns::service::dll::UnicastAddress receiver) const
00100 {
00101     assure(receiver.isValid(), "address is not valid");
00102 
00103     if(perHolder.knows(receiver))
00104     {
00105         return(perHolder.find(receiver)->getNumSamples() >= minSamples);
00106     }
00107     else
00108     {
00109         return(false);
00110     }
00111 }
00112 
00113 double PERInformationBase::getPER(const wns::service::dll::UnicastAddress receiver) const
00114 {
00115     assure(receiver.isValid(), "address is not valid");
00116 
00117     assure(knowsPER(receiver), "Success rate for destination " << receiver << " not known");
00118     return(perHolder.find(receiver)->getAbsolute() / perHolder.find(receiver)->getNumSamples());
00119 }
00120 
00121 
00122 int PERInformationBase::getSuccessfull(const wns::service::dll::UnicastAddress receiver) const
00123 {
00124     if(not successfull.knows(receiver))
00125     {
00126         return 0;
00127     }
00128     return successfull.find(receiver);
00129 }
00130 
00131 int PERInformationBase::getFailed(const wns::service::dll::UnicastAddress receiver) const
00132 {
00133     if(not failed.knows(receiver))
00134     {
00135         return 0;
00136     }
00137     return failed.find(receiver);
00138 }

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