User Manual, Developers Guide and API Documentation

Buffer.hpp

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 #ifndef WNS_LDK_BUFFER_HPP
00029 #define WNS_LDK_BUFFER_HPP
00030 
00031 #include <WNS/ldk/FunctionalUnit.hpp>
00032 #include <WNS/ldk/FUNConfigCreator.hpp>
00033 
00034 #include <WNS/probe/bus/ContextCollector.hpp>
00035 
00036 #include <WNS/pyconfig/View.hpp>
00037 #include <WNS/StaticFactory.hpp>
00038 #include <WNS/SlidingWindow.hpp>
00039 #include <WNS/events/PeriodicTimeout.hpp>
00040 
00041 namespace wns { namespace ldk { namespace buffer {
00042 
00047     struct SizeCalculator :
00048         public virtual CloneableInterface
00049     {
00050         typedef wns::Creator<SizeCalculator> Creator;
00051         typedef wns::StaticFactory<Creator> Factory;
00052 
00053         virtual unsigned long int
00054         operator()(const CompoundPtr& compound) const = 0;
00055 
00056         virtual
00057         ~SizeCalculator()
00058         {}
00059     };
00060 
00065     namespace sizecalculators
00066     {
00067         struct PerPDU :
00068             public SizeCalculator,
00069             public Cloneable<PerPDU>
00070         {
00071             virtual unsigned long int
00072             operator()(const CompoundPtr& compound) const;
00073         };
00074 
00075         struct PerBit :
00076             public SizeCalculator,
00077             public Cloneable<PerBit>
00078         {
00079             virtual unsigned long int
00080             operator()(const CompoundPtr& compound) const;
00081         };
00082     }
00083 
00088     class Buffer :
00089         virtual public FunctionalUnit,
00090         public events::PeriodicTimeout
00091     {
00092         typedef unsigned long int PDUCounter;
00093 
00094     public:
00095         Buffer(fun::FUN* fuNet, const pyconfig::View& config);
00096 
00097         virtual
00098         ~Buffer();
00099 
00100         virtual void
00101         onFunCreated();
00102 
00103         virtual unsigned long int
00104         getSize() = 0;
00105 
00106         virtual unsigned long int
00107         getMaxSize() = 0;
00108 
00109     protected:
00110         void
00111         increaseTotalPDUs();
00112 
00113         // Size may be Bit or number of PDUs (depends on size
00114         // calculation strategy)
00115         void
00116         increaseDroppedPDUs(int size);
00117 
00118         void
00119         probe();
00120 
00121         virtual void
00122         periodically();
00123 
00124     private:
00125         wns::probe::bus::ContextCollectorPtr lossRatioProbeBus;
00126         wns::probe::bus::ContextCollectorPtr sizeProbeBus;
00127 
00128         PDUCounter totalPDUs;
00129         PDUCounter droppedPDUs;
00131         SlidingWindow droppedPDUWindow;
00133         simTimeType probeDroppedPDUInterval;
00134 
00135         wns::logger::Logger logger;
00136         bool probingEnabled;
00137     };
00138 
00139     typedef FUNConfigCreator<Buffer> BufferCreator;
00140     typedef wns::StaticFactory<BufferCreator> BufferFactory;
00141 }}}
00142 
00143 
00144 #endif // NOT defined WNS_LDK_BUFFER_HPP
00145 
00146 

Generated on Sun May 27 03:31:41 2012 for openWNS by  doxygen 1.5.5