4#include <aegis2d/net/packet.hpp>
38 using Clock = std::chrono::steady_clock;
40 static constexpr std::chrono::seconds
window{2};
48 void record(std::uint16_t sequence, aegis2d::net::PacketType type, Clock::time_point arrival);
57 std::uint16_t sequence = 0;
58 bool snapshot =
false;
59 Clock::time_point time;
63 std::deque<Arrival> arrivals_;
Measures the loss and the jitter of the server's datagrams over a sliding window.
Definition network_stats.hpp:35
NetworkSummary summary(Clock::time_point now) const
Loss, snapshot interval and jitter of the datagrams received in the window.
static constexpr std::chrono::seconds window
How far back summary() looks: 40 snapshots at 20 per second.
Definition network_stats.hpp:40
void record(std::uint16_t sequence, aegis2d::net::PacketType type, Clock::time_point arrival)
Records a datagram received from the server.
std::chrono::steady_clock Clock
Clock of the arrivals.
Definition network_stats.hpp:38
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
What the client received from the server over the last NetworkStats::window.
Definition network_stats.hpp:13
std::chrono::steady_clock::duration snapshot_interval
Mean time between two snapshots, 0 with fewer than two.
Definition network_stats.hpp:23
std::uint32_t snapshots
Snapshot datagrams received.
Definition network_stats.hpp:21
double loss
Share of the datagrams lost, from 0 to 1: lost / (received + lost).
Definition network_stats.hpp:19
std::uint32_t lost
Sequences missing between the oldest and the newest received.
Definition network_stats.hpp:17
std::uint32_t received
Datagrams received, each sequence counted once.
Definition network_stats.hpp:15
std::chrono::steady_clock::duration snapshot_jitter
Mean distance of each interval between two snapshots from their mean: how irregularly the snapshots a...
Definition network_stats.hpp:26