4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief RateAnalyzer public header */
26 #ifndef HH_SENF_PPI_RateAnalyzer_
27 #define HH_SENF_PPI_RateAnalyzer_ 1
30 #include <boost/function.hpp>
31 #include <boost/signal.hpp>
32 #include "MonitorModule.hh"
33 #include "IntervalTimer.hh"
35 //#include "RateAnalyzer.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
42 /** \brief Generate periodic packet statistics
44 This module will periodically generate statistics concerning the traversing packets. The
45 statistics are emitted as Boost.Signals signals:
47 \li \c signals.packetsPerSecond: number of packets in the last interval scaled to 1 second
48 \li \c signals.bytesPerSecond; number of bytes in the last interval scaled to 1 second
49 \li \c signals.bytesPerPacket: minimal, average and maximal packet size in the last interval
51 These signals are normally connected as needed to senf::Statistics instances.
54 senf::RateAnalyzer analyzer;
55 senf::Statistics packets;
56 senf::Statistics packetSize;
58 analyzer.signals.packetsPerSecond.connect(packets);
59 analyzer.signals.bytesPerPacket.connect(packetSize);
61 analyzer.startStatistics(senf::ClockService::milliseconds(100u));
64 Statistics output is only generated after a call to startStatistics()
66 \ingroup routing_modules
69 : public MonitorModule<>
71 SENF_PPI_MODULE(RateAnalyzer);
73 ///////////////////////////////////////////////////////////////////////////
74 ///\name Structors and default members
80 ///////////////////////////////////////////////////////////////////////////
84 boost::signal<void (float)> packetsPerSecond;
85 boost::signal<void (float)> bytesPerSecond;
86 boost::signal<void (unsigned,float,unsigned)> bytesPerPacket;
89 void startStatistics(senf::ClockService::clock_type interval);
90 ///< Start generating statistics at given interval
93 void v_handlePacket(Packet const & p);
96 senf::ppi::IntervalTimer timer_;
106 ///////////////////////////////hh.e////////////////////////////////////////
107 //#include "RateAnalyzer.cci"
108 //#include "RateAnalyzer.ct"
109 //#include "RateAnalyzer.cti"
116 // comment-column: 40
117 // c-file-style: "senf"
118 // indent-tabs-mode: nil
119 // ispell-local-dictionary: "american"
120 // compile-command: "scons -u test"