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 void
00043 activity::account_frame(const tool::microseconds& timestamp,
00044 unsigned len,
00045 unsigned type,
00046 unsigned subtype,
00047 bool from_ap)
00048 {
00049 tracker_.update(timestamp);
00050
00051 epoch& e = tracker_.current();
00052
00053 ++e.count;
00054 ++e.type_count[type];
00055 ++e.subtype_count[type][subtype];
00056 e.size += len;
00057 e.type_size[type] += len;
00058 e.subtype_size[type][subtype] += len;
00059 if (from_ap)
00060 {
00061 ++e.ap_count;
00062 e.ap_size += len;
00063 }
00064 }
00065
00066 inline
00067 void
00068 activity::restart()
00069 {
00070 tracker_.restart();
00071 }
00072
00073 inline
00074 std::ostream&
00075 activity::print(std::ostream& o) const
00076 {
00077 BOOST_FOREACH(const epoch& e, tracker_.epochs())
00078 o << " "
00079 << e.count << ' '
00080 << e.size << ' '
00081 << e.type_size[type::management] << ' '
00082 << e.type_size[type::data] << ' '
00083 << e.ap_size << '\n';
00084 return o << std::flush;
00085 }
00086
00087 inline
00088 activity::epoch::epoch(): count (0), ap_count (0), size (0), ap_size (0)
00089 {
00090 memset(type_count, 0, sizeof (type_count));
00091 memset(type_size, 0, sizeof (type_size));
00092 memset(subtype_count, 0, sizeof (subtype_count));
00093 memset(subtype_size, 0, sizeof (subtype_size));
00094 }
00095
00096 }
00097
00098 }
00099
00100 }
00101
00102 #endif // ! WIFI_FRAME_STATS_ACTIVITY_HXX_