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_GROWTH_HH_
00023 # define WIFI_FRAME_STATS_GROWTH_HH_
00024
00025 # include <wipal/wifi/frame/stats/epoch_tracker.hh>
00026 # include <wipal/wifi/frame/stats/module.hh>
00027
00028 namespace wifi
00029 {
00030
00031 namespace frame
00032 {
00033
00034 namespace stats
00035 {
00036
00037 template <class T, unsigned EpochLength>
00038 struct growth: public abstract_stats
00039 {
00040 void restart();
00041 void update(const tool::microseconds& timestamp);
00042 void update(const T& elt);
00043 std::ostream& print(std::ostream& o) const;
00044
00045 private:
00046 struct epoch_data
00047 {
00048 epoch_data();
00049
00050 unsigned total_count;
00051 unsigned current_count;
00052 };
00053
00054 std::set<T> elements_;
00055 std::set<T> current_elements_;
00056 epoch_tracker<epoch_data, EpochLength> tracker_;
00057 };
00058
00059 template <unsigned Epoch>
00060 struct addr_growth: public module
00061 {
00062 addr_growth(const void* other_modules = 0);
00063
00064 void account_addr(const addr& a);
00065
00066 template <class Frame>
00067 void
00068 account_frame(const Frame& frame,
00069 const size_t& len80211,
00070 const type::frame_type& type,
00071 const unsigned& subtype,
00072 const bool& retx,
00073 const addr* const& receiver,
00074 const addr* const& transmitter,
00075 const bool& from_ap);
00076
00077 std::ostream& print(std::ostream& os) const;
00078 void restart();
00079
00080 protected:
00081 typedef growth<addr, Epoch> growth_type;
00082
00083 growth_type growth_;
00084 };
00085
00086 template <unsigned Epoch>
00087 struct beacon_items_growth: public module
00088 {
00089 beacon_items_growth(const void* other_modules = 0);
00090
00091 template <class Frame>
00092 void
00093 account_beacon(const Frame& frame,
00094 const addr* const& ap,
00095 const addr* const& bss,
00096 const optional_string& ssid,
00097 const bool& ibss);
00098
00099 template <class Frame>
00100 void
00101 account_frame(const Frame& frame,
00102 const size_t& len80211,
00103 const type::frame_type& type,
00104 const unsigned& subtype,
00105 const bool& retx,
00106 const addr* const& receiver,
00107 const addr* const& transmitter,
00108 const bool& from_ap);
00109
00110 std::ostream& print(std::ostream& os) const;
00111 void restart();
00112
00113 private:
00114 typedef growth<addr, Epoch> bssid_growth;
00115 typedef growth<addr, Epoch> ibssid_growth;
00116 typedef growth<std::string, Epoch> ssid_growth;
00117 typedef growth<addr, Epoch> ap_growth;
00118
00119 ap_growth ap_;
00120 bssid_growth bssid_;
00121 ibssid_growth ibssid_;
00122 ssid_growth ssid_;
00123 };
00124
00125 }
00126
00127 }
00128
00129 }
00130
00131 # include "growth.hxx"
00132
00133 #endif // ! WIFI_FRAME_STATS_GROWTH_HH_