4#include <aegis2d/net/rtt.hpp>
5#include <aegis2d/net/traffic.hpp>
54 std::array<double, lag_graph_count>
values{};
60 return values.at(
static_cast<std::size_t
>(graph));
71 const aegis2d::net::TrafficCounters& traffic,
73 std::chrono::steady_clock::time_point now);
101 using Clock = std::chrono::steady_clock;
105 static constexpr std::size_t
length = 100;
114 void update(
const aegis2d::net::RttEstimator& rtt,
const aegis2d::net::TrafficCounters& traffic,
115 const NetworkStats& stats, Clock::time_point now, std::uint64_t corrections = 0);
140 Clock::time_point next_{};
142 std::uint64_t corrections_ = 0;
143 std::optional<Clock::time_point> sampled_;
The last seconds of the network statistics, for the graphs of the lagometer.
Definition lagometer.hpp:98
static constexpr std::chrono::milliseconds sample_interval
Time between two samples.
Definition lagometer.hpp:103
void clear() noexcept
Forgets every sample, for a new session.
LagSample latest() const noexcept
The last sample.
static constexpr std::size_t length
Samples kept: the last 10 seconds.
Definition lagometer.hpp:105
double scale(LagGraph graph) const noexcept
Top of a graph: its largest value kept, but never below a floor (100 ms for the RTT,...
std::chrono::steady_clock Clock
Clock of the samples.
Definition lagometer.hpp:101
void add(const LagSample &sample)
Adds a sample, forgetting the oldest beyond length.
const std::deque< LagSample > & samples() const noexcept
The samples kept.
void update(const aegis2d::net::RttEstimator &rtt, const aegis2d::net::TrafficCounters &traffic, const NetworkStats &stats, Clock::time_point now, std::uint64_t corrections=0)
Takes a sample of the statistics if sample_interval went by since the last one.
Measures the loss and the jitter of the server's datagrams over a sliding window.
Definition network_stats.hpp:35
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
LagSample measure_lag(const aegis2d::net::RttEstimator &rtt, const aegis2d::net::TrafficCounters &traffic, const NetworkStats &stats, std::chrono::steady_clock::time_point now)
Reads the network statistics of the client into a sample.
LagLevel
How a figure compares with a sound link.
Definition lagometer.hpp:42
@ Good
As on a local network.
@ Warning
Players start to notice.
@ Bad
The game is hard to play.
LagGraph
A graph of the lagometer.
Definition lagometer.hpp:21
@ Loss
Share of the server's datagrams lost, in percent.
@ BytesOut
Bytes sent per second.
@ Jitter
Jitter of the snapshots' arrivals, in milliseconds.
@ Corrections
Corrections of the predicted ship per second (ShipPrediction::corrections()).
@ Rtt
Smoothed round trip time, in milliseconds.
@ BytesIn
Bytes received per second.
@ Interval
Mean time between two snapshots, in milliseconds.
std::string lag_label(LagGraph graph, double value)
Label of a value of a graph, for the overlay: "RTT 152 MS", "LOSS 2.5 %".
constexpr std::size_t lag_graph_count
Number of graphs: LagGraph values are 0 to lag_graph_count - 1.
Definition lagometer.hpp:39
std::vector< std::string > lag_lines(const LagSample &sample)
The figures of a sample as lines of the engine's metrics overlay, so that the frame metrics (F12) sho...
LagLevel lag_level(LagGraph graph, double value) noexcept
Level of a value of a graph: the RTT is bad above 200 ms, the loss above 5 %...
Packet loss, snapshot interval and jitter of the datagrams the client receives.
The figures of every graph at one time, in the unit of each graph.
Definition lagometer.hpp:52
std::array< double, lag_graph_count > values
One value per graph, indexed by LagGraph.
Definition lagometer.hpp:54
double value(LagGraph graph) const noexcept
The value of a graph.
Definition lagometer.hpp:59