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 inline
00040 void
00041 delimiter_frames::restart()
00042 {
00043 earliest_ = latest_ = boost::none_t ();
00044 }
00045
00046 inline
00047 void
00048 delimiter_frames::account_frame(const tool::microseconds& phy_stamp,
00049 const struct timeval& pcap_stamp)
00050 {
00051 if (not earliest_ or earliest_->first > phy_stamp)
00052 earliest_ = stamp_pair (phy_stamp, pcap_stamp);
00053
00054 if (not latest_ or latest_->first < phy_stamp)
00055 latest_ = stamp_pair (phy_stamp, pcap_stamp);
00056 }
00057
00058 inline
00059 std::ostream&
00060 delimiter_frames::print(std::ostream& o) const
00061 {
00062 print(o, "earliest", earliest_);
00063 print(o, "latest", latest_);
00064 return o << std::flush;
00065 }
00066
00067 std::ostream&
00068 delimiter_frames::print(std::ostream& o,
00069 const std::string& type,
00070 const optional_stamp_pair& value)
00071 {
00072 o << type << " frame TOA: ";
00073
00074 if (not value)
00075 o << "NA";
00076 else
00077 {
00078 using namespace boost::gregorian;
00079 using namespace boost::posix_time;
00080
00081 const ptime t (date(1970, Jan, 01),
00082 seconds (value->second.tv_sec) +
00083 microseconds (value->second.tv_usec));
00084
00085 o << to_simple_string(t) << " UTC";
00086 }
00087
00088 return o << '\n';
00089 }
00090
00091
00092 }
00093
00094 }
00095
00096 }
00097
00098 #endif // ! WIFI_FRAME_STATS_DELIMITER_FRAMES_HXX_