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_BSS_STATS_HXX_
00023 # define WIFI_FRAME_STATS_BSS_STATS_HXX_
00024
00025 # include <set>
00026
00027 # include <boost/foreach.hpp>
00028
00029 # include <wipal/wifi/frame/stats/bss_stats.hh>
00030 # include <wipal/tool/less.hh>
00031
00032 namespace wifi
00033 {
00034
00035 namespace frame
00036 {
00037
00038 namespace stats
00039 {
00040
00041 inline
00042 bss_stats::bss_stats(): beacon_count_ (0)
00043 {
00044 }
00045
00046 inline
00047 void
00048 bss_stats::account_beacon(const addr& bss, const addr& ap)
00049 {
00050 single_bss_stats& s = bss_stats_[bss];
00051
00052 ++beacon_count_;
00053 ++s.total_;
00054 ++s.ap_stats_[ap];
00055 }
00056
00057 inline
00058 std::ostream&
00059 bss_stats::print(std::ostream& o) const
00060 {
00061 typedef std::set<internal_stats::const_iterator,
00062 tool::less_using_second> sorted_type;
00063
00064 sorted_type sorted;
00065
00066 for (internal_stats::const_iterator i = bss_stats_.begin();
00067 i != bss_stats_.end();
00068 ++i)
00069 sorted.insert(i);
00070
00071 o << " total beacon count: " << beacon_count_ << '\n'
00072 << " distinct BSSIDs: " << bss_stats_.size() << '\n';
00073
00074 BOOST_FOREACH(const internal_stats::const_iterator& i, sorted)
00075 {
00076 typedef single_bss_stats::ap_stats::value_type single_ap_stats;
00077
00078 const single_bss_stats::ap_stats& s = i->second.ap_stats_;
00079
00080 o << '\n'
00081 << " begin BSS: " << i->first << '\n'
00082 << " beacon count: " << i->second.total_ << '\n'
00083 << " beacon ratio: "
00084 << (double (i->second.total_) / beacon_count_) << '\n'
00085 << " distinct beacon senders: " << s.size() << '\n';
00086
00087 assert(not s.empty());
00088 if (s.size() > 1 or s.begin()->first != i->first)
00089 {
00090 BOOST_FOREACH(const single_ap_stats& p, i->second.ap_stats_)
00091 o << '\n'
00092 << " begin beacon sender: (" << i->first << ") "
00093 << p.first << '\n'
00094 << " beacon count: " << p.second << '\n'
00095 << " beacon count ratio (total): "
00096 << (double (p.second) / beacon_count_) << '\n'
00097 << " beacon count ratio (this BSS): "
00098 << (double (p.second) / i->second.total_) << '\n'
00099 << " end beacon sender: (" << i->first << ") "
00100 << p.first << '\n';
00101 }
00102 o << " end BSS: " << i->first << '\n';
00103 }
00104 return o << std::flush;
00105 }
00106
00107 inline
00108 bss_stats::single_bss_stats::single_bss_stats(): total_ (0)
00109 {
00110 }
00111
00112 inline
00113 bool
00114 bss_stats::
00115 single_bss_stats::operator < (const single_bss_stats& rhs) const
00116 {
00117 return total_ < rhs.total_;
00118 }
00119
00120 }
00121
00122 }
00123
00124 }
00125
00126 #endif // ! WIFI_FRAME_STATS_BSS_STATS_HXX_