4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief RateAnalyzer public header */
31 #ifndef HH_SENF_PPI_RateAnalyzer_
32 #define HH_SENF_PPI_RateAnalyzer_ 1
35 #include <boost/function.hpp>
36 #include <boost/signal.hpp>
37 #include "MonitorModule.hh"
38 #include "IntervalTimer.hh"
40 //#include "RateAnalyzer.mpp"
41 //-/////////////////////////////////////////////////////////////////////////////////////////////////
47 /** \brief Generate periodic packet statistics
49 This module will periodically generate statistics concerning the traversing packets. The
50 statistics are emitted as Boost.Signals signals:
52 \li \c signals.packetsPerSecond: number of packets in the last interval scaled to 1 second
53 \li \c signals.bytesPerSecond; number of bytes in the last interval scaled to 1 second
54 \li \c signals.bytesPerPacket: minimal, average and maximal packet size in the last interval
56 These signals are normally connected as needed to senf::Statistics instances.
59 senf::RateAnalyzer analyzer;
60 senf::Statistics packets;
61 senf::Statistics packetSize;
63 analyzer.signals.packetsPerSecond.connect(packets);
64 analyzer.signals.bytesPerPacket.connect(packetSize);
66 analyzer.startStatistics(senf::ClockService::milliseconds(100u));
69 Statistics output is only generated after a call to startStatistics()
71 \ingroup routing_modules
74 : public MonitorModule<>
76 SENF_PPI_MODULE(RateAnalyzer);
78 //-////////////////////////////////////////////////////////////////////////
79 ///\name Structors and default members
85 //-////////////////////////////////////////////////////////////////////////
89 boost::signal<void (float)> packetsPerSecond;
90 boost::signal<void (float)> bytesPerSecond;
91 boost::signal<void (unsigned,float,unsigned)> bytesPerPacket;
94 void startStatistics(senf::ClockService::clock_type interval);
95 ///< Start generating statistics at given interval
98 void v_handlePacket(Packet const & p);
101 senf::ppi::IntervalTimer timer_;
111 //-/////////////////////////////////////////////////////////////////////////////////////////////////
112 //#include "RateAnalyzer.cci"
113 //#include "RateAnalyzer.ct"
114 //#include "RateAnalyzer.cti"
121 // comment-column: 40
122 // c-file-style: "senf"
123 // indent-tabs-mode: nil
124 // ispell-local-dictionary: "american"
125 // compile-command: "scons -u test"