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 try
00058 {
00059 tracker_.update(frame.microseconds());
00060 }
00061 catch (const non_increasing_timestamp&)
00062 {
00063 std::cerr << frame << ": [activity] Decreasing timestamp, "
00064 << "ignoring." << std::endl;
00065 return;
00066 }
00067
00068 epoch& e = tracker_.current();
00069
00070 ++e.count;
00071 ++e.type_count[type];
00072 ++e.subtype_count[type][subtype];
00073 e.size += len80211;
00074 e.type_size[type] += len80211;
00075 e.subtype_size[type][subtype] += len80211;
00076 if (from_ap)
00077 {
00078 ++e.ap_count;
00079 e.ap_size += len80211;
00080 }
00081 }
00082
00083 inline
00084 std::ostream&
00085 activity::print(std::ostream& o) const
00086 {
00087 o << "begin activity\n";
00088
00089 BOOST_FOREACH(const epoch& e, tracker_.epochs())
00090 o << " "
00091 << e.count << ' '
00092 << e.size << ' '
00093 << e.type_size[type::management] << ' '
00094 << e.type_size[type::data] << ' '
00095 << e.ap_size << '\n';
00096 return o << "end activity" << std::endl;
00097 }
00098
00099 inline
00100 void
00101 activity::restart()
00102 {
00103 tracker_.restart();
00104 }
00105
00106 inline
00107 activity::epoch::epoch(): count (0), ap_count (0), size (0), ap_size (0)
00108 {
00109 memset(type_count, 0, sizeof (type_count));
00110 memset(type_size, 0, sizeof (type_size));
00111 memset(subtype_count, 0, sizeof (subtype_count));
00112 memset(subtype_size, 0, sizeof (subtype_size));
00113 }
00114
00115 }
00116
00117 }
00118
00119 }
00120
00121 #endif // ! WIFI_FRAME_STATS_ACTIVITY_HXX_