00001 // $Id: RateAnalyzer.hh 1742 2010-11-04 14:51:56Z g0dil $ 00002 // 00003 // Copyright (C) 2008 00004 // Fraunhofer (FOKUS) 00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY 00006 // Stefan Bund <g0dil@berlios.de> 00007 // 00008 // This program is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 2 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program; if not, write to the 00020 // Free Software Foundation, Inc., 00021 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 00026 #ifndef HH_SENF_PPI_RateAnalyzer_ 00027 #define HH_SENF_PPI_RateAnalyzer_ 1 00028 00029 // Custom includes 00030 #include <boost/function.hpp> 00031 #include <boost/signal.hpp> 00032 #include "MonitorModule.hh" 00033 #include "IntervalTimer.hh" 00034 00035 //#include "RateAnalyzer.mpp" 00036 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00037 00038 namespace senf { 00039 namespace ppi { 00040 namespace module { 00041 00068 class RateAnalyzer 00069 : public MonitorModule<> 00070 { 00071 SENF_PPI_MODULE(RateAnalyzer); 00072 public: 00073 //-//////////////////////////////////////////////////////////////////////// 00075 //\{ 00076 00077 RateAnalyzer(); 00078 00079 //\} 00080 //-//////////////////////////////////////////////////////////////////////// 00081 // Statistics signals 00082 00083 struct Statistics { 00084 boost::signal<void (float)> packetsPerSecond; 00085 boost::signal<void (float)> bytesPerSecond; 00086 boost::signal<void (unsigned,float,unsigned)> bytesPerPacket; 00087 } signals; 00088 00089 void startStatistics(senf::ClockService::clock_type interval); 00091 00092 private: 00093 void v_handlePacket(Packet const & p); 00094 void tick(); 00095 00096 senf::ppi::IntervalTimer timer_; 00097 unsigned packets_; 00098 unsigned bytes_; 00099 unsigned minSize_; 00100 unsigned maxSize_; 00101 double factor_; 00102 }; 00103 00104 }}} 00105 00106 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00107 //#include "RateAnalyzer.cci" 00108 //#include "RateAnalyzer.ct" 00109 //#include "RateAnalyzer.cti" 00110 #endif 00111 00112 00113 // Local Variables: 00114 // mode: c++ 00115 // fill-column: 100 00116 // comment-column: 40 00117 // c-file-style: "senf" 00118 // indent-tabs-mode: nil 00119 // ispell-local-dictionary: "american" 00120 // compile-command: "scons -u test" 00121 // End: