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_DELIMITER_FRAMES_HXX_
00023 # define WIFI_FRAME_STATS_DELIMITER_FRAMES_HXX_
00024
00025 # include <boost/date_time/posix_time/posix_time_duration.hpp>
00026 # include <boost/date_time/posix_time/ptime.hpp>
00027 # include <boost/date_time/posix_time/time_formatters.hpp>
00028
00029 # include <wipal/wifi/frame/stats/delimiter_frames.hh>
00030
00031 namespace wifi
00032 {
00033
00034 namespace frame
00035 {
00036
00037 namespace stats
00038 {
00039
00040 inline
00041 delimiter_frames::delimiter_frames(const void*)
00042 {
00043 }
00044
00045 template <class Frame>
00046 void
00047 delimiter_frames::
00048 account_frame(const Frame& frame,
00049 const size_t& ,
00050 const type::frame_type& ,
00051 const unsigned& ,
00052 const bool& ,
00053 const addr* const& ,
00054 const addr* const& ,
00055 const bool& )
00056 {
00057 const tool::microseconds& phy_stamp = frame.microseconds();
00058 const struct timeval& pcap_stamp = frame.pcap_header()->ts;
00059
00060 if (not earliest_ or earliest_->first > phy_stamp)
00061 earliest_ = stamp_pair (phy_stamp, pcap_stamp);
00062
00063 if (not latest_ or latest_->first < phy_stamp)
00064 latest_ = stamp_pair (phy_stamp, pcap_stamp);
00065 }
00066
00067 inline
00068 std::ostream&
00069 delimiter_frames::print(std::ostream& o) const
00070 {
00071 print(o, "earliest", earliest_);
00072 print(o, "latest", latest_);
00073 return o << std::flush;
00074 }
00075
00076 inline
00077 void
00078 delimiter_frames::restart()
00079 {
00080 earliest_ = latest_ = boost::none_t ();
00081 }
00082
00083 std::ostream&
00084 delimiter_frames::print(std::ostream& o,
00085 const std::string& type,
00086 const optional_stamp_pair& value)
00087 {
00088 o << type << " frame TOA: ";
00089
00090 if (not value)
00091 o << "NA";
00092 else
00093 {
00094 using namespace boost::gregorian;
00095 using namespace boost::posix_time;
00096
00097 const ptime t (date(1970, Jan, 01),
00098 seconds (value->second.tv_sec) +
00099 microseconds (value->second.tv_usec));
00100
00101 o << to_simple_string(t) << " UTC";
00102 }
00103
00104 return o << '\n';
00105 }
00106
00107 }
00108
00109 }
00110
00111 }
00112
00113 #endif // ! WIFI_FRAME_STATS_DELIMITER_FRAMES_HXX_