00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WIFI_FRAME_STATS_ACTIVITY_HXX_
00023 # define WIFI_FRAME_STATS_ACTIVITY_HXX_
00024
00025 # include <cstring>
00026 # include <cassert>
00027
00028 # include <boost/foreach.hpp>
00029
00030 # include <wipal/wifi/frame/stats/activity.hh>
00031
00032 namespace wifi
00033 {
00034
00035 namespace frame
00036 {
00037
00038 namespace stats
00039 {
00040
00041 inline
00042 activity::activity(const void*)
00043 {
00044 }
00045
00046 template <class Frame>
00047 void
00048 activity::account_frame(const Frame& frame,
00049 const size_t& len80211,
00050 const type::frame_type& type,
00051 const unsigned& subtype,
00052 const bool& ,
00053 const addr* const& ,
00054 const addr* const& ,
00055 const bool& from_ap)
00056 {
00057 tracker_.update(frame.microseconds());
00058
00059 epoch& e = tracker_.current();
00060
00061 ++e.count;
00062 ++e.type_count[type];
00063 ++e.subtype_count[type][subtype];
00064 e.size += len80211;
00065 e.type_size[type] += len80211;
00066 e.subtype_size[type][subtype] += len80211;
00067 if (from_ap)
00068 {
00069 ++e.ap_count;
00070 e.ap_size += len80211;
00071 }
00072 }
00073
00074 inline
00075 std::ostream&
00076 activity::print(std::ostream& o) const
00077 {
00078 o << "begin activity\n";
00079
00080 BOOST_FOREACH(const epoch& e, tracker_.epochs())
00081 o << " "
00082 << e.count << ' '
00083 << e.size << ' '
00084 << e.type_size[type::management] << ' '
00085 << e.type_size[type::data] << ' '
00086 << e.ap_size << '\n';
00087 return o << "end activity" << std::endl;
00088 }
00089
00090 inline
00091 void
00092 activity::restart()
00093 {
00094 tracker_.restart();
00095 }
00096
00097 inline
00098 activity::epoch::epoch(): count (0), ap_count (0), size (0), ap_size (0)
00099 {
00100 memset(type_count, 0, sizeof (type_count));
00101 memset(type_size, 0, sizeof (type_size));
00102 memset(subtype_count, 0, sizeof (subtype_count));
00103 memset(subtype_size, 0, sizeof (subtype_size));
00104 }
00105
00106 }
00107
00108 }
00109
00110 }
00111
00112 #endif // ! WIFI_FRAME_STATS_ACTIVITY_HXX_