diff --git a/elements/analysis/timestampdiff.cc b/elements/analysis/timestampdiff.cc index 99dd36fa7a911983de58812e39d6366665badea8..dc1130552186f36694fb0acf25e933cbefb1e200 100644 --- a/elements/analysis/timestampdiff.cc +++ b/elements/analysis/timestampdiff.cc @@ -56,6 +56,7 @@ int TimestampDiff::configure(Vector<String> &conf, ErrorHandler *errh) .read("OFFSET",_offset) .read("N", _limit) .read("MAXDELAY", _max_delay_ms) + .read("NANO", _nano) .read_or_set("SAMPLE", _sample, 1) .read_or_set("VERBOSE", _verbose, false) .read_or_set("TC_OFFSET", _tc_offset, -1) @@ -256,12 +257,12 @@ inline int TimestampDiff::smaction(Packet *p) } TimestampT diff = now - old; - uint32_t usec = diff.usecval(); - if ((usec > _max_delay_ms * 1000)) { + uint32_t usec = _nano? diff.nsecval() : diff.usecval(); + if ((usec > _max_delay_ms * (_nano?1000000:1000))) { if (_verbose) { click_chatter( "Packet %" PRIu64 " experienced delay %u ms > %u ms", - i, (usec)/1000, _max_delay_ms + i, (usec)/ (_nano?1000000:1000), _max_delay_ms ); } } diff --git a/elements/analysis/timestampdiff.hh b/elements/analysis/timestampdiff.hh index 649ee88a2d3434ef4cecd6475f16b61fc6007eef..12c379b509a49f8fa43c75ce754a6d463d3c17ea 100644 --- a/elements/analysis/timestampdiff.hh +++ b/elements/analysis/timestampdiff.hh @@ -89,7 +89,7 @@ private: bool _verbose; int _tc_offset; unsigned char _tc_mask; - + bool _nano; inline int smaction(Packet *p); RecordTimestamp *get_recordtimestamp_instance(); diff --git a/include/click/tsctimestamp.hh b/include/click/tsctimestamp.hh index 906f696e4bc87e2543b9a8613906f570476d94c9..f1c0560055440f0c47172e2c6d0bc7b1ce6711e0 100644 --- a/include/click/tsctimestamp.hh +++ b/include/click/tsctimestamp.hh @@ -76,6 +76,13 @@ class TSCTimestamp { return val / (cycles_hz_warp() / 1000000); } + /** + * @brief returns the total number of nsecs represented by this timestamp + */ + inline double nsecval() { + return (double)val / ((double)cycles_hz_warp() / 1000000000.0d); + } + inline int64_t tsc_val() { return val; }