00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WIFI_STATS_SSID_STATS_HXX_
00023 # define WIFI_STATS_SSID_STATS_HXX_
00024
00025 # include <boost/format.hpp>
00026
00027 # include <wipal/wifi/stats/ssid_stats.hh>
00028 # include <wipal/wifi/essid.hh>
00029 # include <wipal/tool/less.hh>
00030
00031 namespace wpl
00032 {
00033
00034 namespace wifi
00035 {
00036
00037 namespace stats
00038 {
00039
00040 inline
00041 ssid_stats::ssid_stats(const void*): total_ (0)
00042 {
00043 }
00044
00045 template <class Frame>
00046 void
00047 ssid_stats::account_beacon(const Frame& ,
00048 const addr* const& ,
00049 const addr* const& ,
00050 const optional_string& ssid,
00051 const bool& )
00052 {
00053 if (ssid)
00054 {
00055 ++total_;
00056 ++freqs_[*ssid];
00057 }
00058 }
00059
00060 inline
00061 std::ostream&
00062 ssid_stats::print(std::ostream& os) const
00063 {
00064 typedef std::set<freq_type::const_iterator,
00065 tool::less_using_second> sorted_ssids;
00066
00067 boost::format f (" %40d %f %d\n");
00068 sorted_ssids s;
00069
00070 for (freq_type::const_iterator i = freqs_.begin();
00071 i != freqs_.end();
00072 ++i)
00073 s.insert(i);
00074
00075 os << "begin SSID figures\n"
00076 << " distinct SSID's: " << freqs_.size() << '\n'
00077 << '\n'
00078 << " begin SSID list (ordered by frequency)\n";
00079 for (sorted_ssids::const_iterator i = s.begin(); i != s.end(); ++i)
00080 os << (f % essid ((*i)->first)
00081 % (double ((*i)->second) / double (total_))
00082 % (*i)-> second);
00083 os << " end SSID list (ordered by frequency)\n"
00084 << '\n'
00085 << " begin SSID list (ordered by SSID)\n";
00086 for (freq_type::const_iterator i = freqs_.begin();
00087 i != freqs_.end();
00088 ++i)
00089 os << (f % essid (i->first)
00090 % (double (i->second) / double (total_))
00091 % i-> second);
00092 os << " end SSID list (ordered by SSID)\n";
00093
00094 return os << "end SSID figures" << std::endl;
00095 }
00096
00097 }
00098
00099 }
00100
00101 }
00102
00103 #endif // ! WIFI_STATS_SSID_STATS_HXX_