Skip to content

File latency_data.hpp

File List > data_format > latency_data.hpp

Go to the documentation of this file

#pragma once

#include "illixr/switchboard.hpp"

#include 

namespace ILLIXR::data_format {

struct latency_ping : public switchboard::event {
    uint64_t sequence_number;     
    uint64_t client_timestamp_ns; 

    latency_ping()
        : sequence_number{0}
        , client_timestamp_ns{0} { }

    latency_ping(uint64_t seq, uint64_t ts)
        : sequence_number{seq}
        , client_timestamp_ns{ts} { }
};

struct latency_pong : public switchboard::event {
    uint64_t sequence_number;     
    uint64_t client_timestamp_ns; 
    uint64_t server_timestamp_ns; 

    latency_pong()
        : sequence_number{0}
        , client_timestamp_ns{0}
        , server_timestamp_ns{0} { }

    latency_pong(uint64_t seq, uint64_t client_ts, uint64_t server_ts)
        : sequence_number{seq}
        , client_timestamp_ns{client_ts}
        , server_timestamp_ns{server_ts} { }
};

struct network_latency_result : public switchboard::event {
    uint64_t sequence_number;              
    double   round_trip_time_ms;           
    double   estimated_one_way_latency_ms; 
    double   client_to_server_ms;          
    double   server_to_client_ms;          
    double   estimated_clock_offset_ms;    
    double   smoothed_clock_offset_ms;     
    double   smoothed_rtt_ms;              
    uint64_t measurement_timestamp_ns;     

    network_latency_result()
        : sequence_number{0}
        , round_trip_time_ms{0.0}
        , estimated_one_way_latency_ms{0.0}
        , client_to_server_ms{0.0}
        , server_to_client_ms{0.0}
        , estimated_clock_offset_ms{0.0}
        , smoothed_clock_offset_ms{0.0}
        , smoothed_rtt_ms{0.0}
        , measurement_timestamp_ns{0} { }

    network_latency_result(uint64_t seq, double rtt_ms, double c2s_ms, double s2c_ms, double clock_offset_ms,
                           double smoothed_offset, double smoothed_rtt, uint64_t ts)
        : sequence_number{seq}
        , round_trip_time_ms{rtt_ms}
        , estimated_one_way_latency_ms{rtt_ms / 2.0}
        , client_to_server_ms{c2s_ms}
        , server_to_client_ms{s2c_ms}
        , estimated_clock_offset_ms{clock_offset_ms}
        , smoothed_clock_offset_ms{smoothed_offset}
        , smoothed_rtt_ms{smoothed_rtt}
        , measurement_timestamp_ns{ts} { }
};
} // namespace ILLIXR::data_format