29 : tsftMapInitialized_(false),
36 dir.
add(
"duration", fty::Variable(duration_)
37 .doc(
"set the TSFT histogram collection duration. Default 60s."));
38 dir.
add(
"start", fty::Command(
40 .doc(
"enables/resets the TSFT Histogram accepting any SRC address."));
41 dir.
add(
"start", fty::Command(
43 .doc(
"enables/resets the TSFT Histogram accepting only the specified SRC address."));
44 dir.
add(
"enabled", fty::Command(
46 .doc(
"returns the TSFT Histogram state"));
47 dir.
add(
"dump", fty::Command(
49 .doc(
"dumps the current TSFT Histogram"));
55 if ((senf::scheduler::now() - startTime_) > duration_) {
61 if (!tsftMapInitialized_) {
62 tsftMapInitialized_ =
true;
68 if (src_ && (src != src_)) {
73 if (tsft >= lastTSFT_) {
74 diff = boost::uint32_t(tsft - lastTSFT_);
77 diff = boost::uint32_t(boost::uint64_t(-1) - lastTSFT_ + tsft);
80 TSFTMap::iterator it( tsftMap_.find(diff));
81 if (it != tsftMap_.end()) {
85 tsftMap_.insert( std::make_pair( diff, 1u));
100 startTime_ = senf::scheduler::now();
101 tsftMapInitialized_ =
false;
110 os <<
"=== TSFT Histogram (times in us) of " << src_ <<
", age " <<
senf::ClockService::in_seconds(senf::scheduler::now() - startTime_) <<
"s ===" << std::endl;
112 if (tsftMap_.size() == 0) {
113 os <<
"no values collected." << std::endl;
118 boost::uint64_t avg = 0;
120 TSFTMap::const_iterator it;
121 for( it = tsftMap_.begin(); it != tsftMap_.end(); it++){
122 avg += it->second*it->second;
124 avg /= tsftMap_.size();
126 for( it = tsftMap_.begin(); it != tsftMap_.end(); it++){
127 if ((it->second * it->second) > avg) {
128 os << it->first <<
"," << it->second << std::endl;
static MACAddress const None
#define SENF_MEMBINDFNP(ret, cls, fn, args)
senf::console::ScopedDirectory dir
void update(senf::MACAddress const &src, boost::uint64_t const &tsft)
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_seconds(clock_type const &v)
void dump(std::ostream &os) const
NodeType & add(std::string const &name, boost::shared_ptr< NodeType > node)