![]() |
Mads
Multi-Agent Distributed System
|
Thread-safe sliding-window tracker of per-host clock skew, fed by mads top's passive mode: for every received message, record (local_rx_time - payload's own timestamp field), both as epoch microseconds. No protocol at all – works against any existing MADS deployment, since timestamp/hostname are already stamped on every published message by Agent::publish().
More...
#include <clock_offset.hpp>
Public Member Functions | |
| HostSkewStats (std::chrono::milliseconds window=std::chrono::seconds(10)) | |
| void | record (const std::string &host, int64_t skew_us, std::chrono::steady_clock::time_point now=std::chrono::steady_clock::now()) |
| std::vector< HostSkewStat > | snapshot (std::chrono::steady_clock::time_point now=std::chrono::steady_clock::now()) const |
| void | clear () |
Thread-safe sliding-window tracker of per-host clock skew, fed by mads top's passive mode: for every received message, record (local_rx_time - payload's own timestamp field), both as epoch microseconds. No protocol at all – works against any existing MADS deployment, since timestamp/hostname are already stamped on every published message by Agent::publish().
The minimum skew over the window is what gets reported: it is the sample least polluted by queuing/network delay, and so the tightest available upper bound on the true offset. It can never separate offset from one-way delay the way the four-timestamp exchange can – callers must label it "skew", never "offset".
Same shape and thread-safety as Mads::TopicStats: record() prunes expired events as it appends; snapshot() is read-only.
Definition at line 207 of file clock_offset.hpp.
|
explicit |
| void Mads::HostSkewStats::clear | ( | ) |
| void Mads::HostSkewStats::record | ( | const std::string & | host, |
| int64_t | skew_us, | ||
| std::chrono::steady_clock::time_point | now = std::chrono::steady_clock::now() |
||
| ) |
| std::vector< HostSkewStat > Mads::HostSkewStats::snapshot | ( | std::chrono::steady_clock::time_point | now = std::chrono::steady_clock::now() | ) | const |