|
R-Type
Networked shoot'em up built on Aegis2D
|
Measures the loss and the jitter of the server's datagrams over a sliding window. More...
#include </__w/project-rtype/project-rtype/client/network/include/rtype/network_stats.hpp>
Public Types | |
| using | Clock = std::chrono::steady_clock |
| Clock of the arrivals. | |
Public Member Functions | |
| void | record (std::uint16_t sequence, aegis2d::net::PacketType type, Clock::time_point arrival) |
| Records a datagram received from the server. | |
| NetworkSummary | summary (Clock::time_point now) const |
| Loss, snapshot interval and jitter of the datagrams received in the window. | |
Static Public Attributes | |
| static constexpr std::chrono::seconds | window {2} |
| How far back summary() looks: 40 snapshots at 20 per second. | |
Measures the loss and the jitter of the server's datagrams over a sliding window.
The server numbers every datagram it sends to this client, whatever its type (RFC section 2.2): a sequence missing between two received ones is a lost datagram. The snapshots, sent at a fixed rate, show the jitter: the spread of the times between their arrivals. Next to ClientSession::traffic() and ClientSession::rtt(), the source of the network statistics shown to the player.
| using rtype::NetworkStats::Clock = std::chrono::steady_clock |
Clock of the arrivals.
| void rtype::NetworkStats::record | ( | std::uint16_t | sequence, |
| aegis2d::net::PacketType | type, | ||
| Clock::time_point | arrival | ||
| ) |
Records a datagram received from the server.
Call it for every datagram with a valid header and the session's token. A duplicate counts once; a datagram older than the window is forgotten.
| sequence | The datagram's sequence field. |
| type | Its type: the Snapshot ones give the interval and the jitter. |
| arrival | Time it was received. |
| NetworkSummary rtype::NetworkStats::summary | ( | Clock::time_point | now | ) | const |
Loss, snapshot interval and jitter of the datagrams received in the window.
| now | Current time: the window is (now - window, now]. |
|
staticconstexpr |
How far back summary() looks: 40 snapshots at 20 per second.