Mads
Multi-Agent Distributed System
Loading...
Searching...
No Matches
Mads::HostSkewStats Class Reference

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< HostSkewStatsnapshot (std::chrono::steady_clock::time_point now=std::chrono::steady_clock::now()) const
 
void clear ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ HostSkewStats()

Mads::HostSkewStats::HostSkewStats ( std::chrono::milliseconds  window = std::chrono::seconds(10))
explicit

Member Function Documentation

◆ clear()

void Mads::HostSkewStats::clear ( )

◆ record()

void Mads::HostSkewStats::record ( const std::string &  host,
int64_t  skew_us,
std::chrono::steady_clock::time_point  now = std::chrono::steady_clock::now() 
)

◆ snapshot()

std::vector< HostSkewStat > Mads::HostSkewStats::snapshot ( std::chrono::steady_clock::time_point  now = std::chrono::steady_clock::now()) const

The documentation for this class was generated from the following file: