Skip to content
Extraits de code Groupes Projets
Valider 37de87ae rédigé par Tom Barbette's avatar Tom Barbette
Parcourir les fichiers

TimestampDiff: Enable nanosecond precision

parent 26a2b65a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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
);
}
}
......
......@@ -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();
......
......@@ -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;
}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter