Repository navigation
Expand file tree
/
Copy pathILagQuery.cs
More file actions
214 lines (187 loc) · 10.5 KB
/
Copy pathILagQuery.cs
File metadata and controls
214 lines (187 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
using System.Collections.Generic;
namespace SS.Core.ComponentInterfaces
{
public struct PingSummary
{
public int Current, Average, Min, Max;
}
/// <summary>
/// Client reported latency stats.
/// </summary>
public struct ClientLagStats
{
/// <summary>
/// The average time (ms) difference between position packet times to the estimated server time, for the current interval.
/// </summary>
public int S2CAverageCurrent;
/// <summary>
/// The count of position packets that were considered to be slow, for the current interval.
/// </summary>
/// <remarks>
/// A position packet is considered to be slow when the difference in the position packet time and the estimated server time is >= Latency:ClientSlowPacketTime (arena.conf setting).
/// </remarks>
public ushort S2CSlowCurrent;
/// <summary>
/// The count of position packets that were not considered to be slow based on Latency:ClientSlowPacketTime, for the current interval.
/// </summary>
/// <remarks><inheritdoc cref="S2CSlowCurrent" path="/remarks"/></remarks>
public ushort S2CFastCurrent;
/// <summary>
/// The count of position packets that were considered slow based on Latency:ClientSlowPacketTime,
/// for all intervals, excluding the <see cref="S2CSlowCurrent">current interval</see>.
/// </summary>
/// <remarks><inheritdoc cref="S2CSlowCurrent" path="/remarks"/></remarks>
public uint S2CSlowTotal;
/// <summary>
/// The count of position packets that were not considered slow based on Latency:ClientSlowPacketTime,
/// for all intervals, excluding the <see cref="S2CFastCurrent">current interval</see>.
/// </summary>
/// <remarks><inheritdoc cref="S2CSlowCurrent" path="/remarks"/></remarks>
public uint S2CFastTotal;
}
public struct PacketlossSummary
{
public double S2C, C2S, S2CWeapon, TimeSync;
}
public struct PacketlossDetails
{
public uint ServerPacketsSent, ClientPacketsReceived;
public uint ClientPacketsSent, ServerPacketsReceived;
public uint WeaponSentCount, WeaponReceiveCount;
}
public record struct TimeSyncRecord
{
public required uint ServerTime;
public required uint ClientTime;
}
public record struct PingHistogramBucket
{
public required int Start;
public required int End;
public required uint Count;
}
/// <summary>
/// Interface for querying player lag data.
/// </summary>
public interface ILagQuery : IComponentInterface
{
/// <summary>
/// Gets a player's 1-way C2S position latency data.
/// </summary>
/// <param name="player">The player to get data about.</param>
/// <param name="ping">The data.</param>
void QueryPositionPing(Player player, out PingSummary ping);
/// <summary>
/// Get a player's ping info (reported by the client).
/// </summary>
/// <param name="player">The player to get data about.</param>
/// <param name="ping">The data.</param>
void QueryClientPing(Player player, out PingSummary ping);
/// <summary>
/// Gets a player's lag stats (reported by the client).
/// </summary>
/// <param name="player">The player to get data about.</param>
/// <param name="stats">The detailed data.</param>
void QueryClientLagStats(Player player, out ClientLagStats stats);
/// <summary>
/// Gets a player's ping info (from reliable packets).
/// </summary>
/// <param name="player">The player to get data about.</param>
/// <param name="ping">The data.</param>
void QueryReliablePing(Player player, out PingSummary ping);
/// <summary>
/// Gets a player's ping info (from time syncs).
/// </summary>
/// <param name="player"></param>
/// <param name="clientPing"></param>
/// <param name="serverPing"></param>
void QueryTimeSyncPing(Player player, out PingSummary clientPing, out PingSummary serverPing);
/// <summary>
/// Gets a <paramref name="player"/>'s packetloss <paramref name="summary"/>.
/// </summary>
/// <param name="player">The player to get data about.</param>
/// <param name="summary">The packetloss summary.</param>
void QueryPacketloss(Player player, out PacketlossSummary summary);
/// <summary>
/// Gets a <paramref name="player"/>'s packetloss <paramref name="summary"/> and <paramref name="details"/>.
/// </summary>
/// <param name="player">The player to get data about.</param>
/// <param name="summary">The packetloss summary.</param>
/// <param name="details">The packetloss details.</param>
void QueryPacketloss(Player player, out PacketlossSummary summary, out PacketlossDetails details);
/// <summary>
/// Gets a player's reliable lag info.
/// </summary>
/// <param name="player">The player to get data about.</param>
/// <param name="reliableLag">The data.</param>
void QueryReliableLag(Player player, out ReliableLagData reliableLag);
/// <summary>
/// Gets the estimated minimum C2S latency (in ticks).
/// </summary>
/// <remarks>
/// This is based on the minimum roundtrip time of data samples from recent time syncs.
/// The minimum is useful for position packets since a player's position time shouldn't come before the current server time - the player's minimum C2S latency.
/// </remarks>
/// <param name="player">The player to get the data for.</param>
/// <param name="estimate">When this method returns, the estimated C2S latency if a time sync response was received.</param>
/// <returns><see langword="true"/> if a estimate was available; otherwise, <see langword="false"/>.</returns>
bool TryGetC2SMinLatencyEstimate(Player player, out uint estimate);
/// <summary>
/// Gets a player's history of time sync requests (0x00 0x05 core packet).
/// </summary>
/// <param name="player">The player to get data about.</param>
/// <param name="records">A collection to be filled with a copy of the data.</param>
void QueryTimeSyncHistory(Player player, ICollection<TimeSyncRecord> records);
/// <summary>
/// Gets a player's time sync drift data, in ticks (centiseconds).
/// </summary>
/// <param name="player">The player to get data about.</param>
/// <param name="clientDrift">The client reported drift. <see langword="null"/> if not available (must have received a C2S security packet, and Continuum only).</param>
/// <param name="serverDriftAvg">The server calculated average drift based on time sync requests. <see langword="null"/> if not available (must have received a C2S security packet).</param>
/// <param name="serverDriftStdDev">The server calculated standard deviation of drift based on time sync requests. <see langword="null"/> if not available (must have received a C2S security packet).</param>
void QueryTimeSyncDriftTicks(Player player, out int? clientDrift, out int? serverDriftAvg, out double? serverDriftStdDev);
/// <summary>
/// Gets a player's time sync drift data, in milliseconds.
/// </summary>
/// <param name="player">The player to get data about.</param>
/// <param name="clientDrift">The client reported drift. <see langword="null"/> if not available (must have received a C2S security packet, and Continuum only).</param>
/// <param name="serverDriftAvg">The server calculated average drift based on time sync requests. <see langword="null"/> if not available (must have received a C2S security packet).</param>
/// <param name="serverDriftStdDev">The server calculated standard deviation of drift based on time sync requests. <see langword="null"/> if not available (must have received a C2S security packet).</param>
void QueryTimeSyncDriftMs(Player player, out int? clientDrift, out int? serverDriftAvg, out double? serverDriftStdDev);
/// <summary>
/// Gets a player's latency histogram data based on the difference between the time field in C2S position packets and the actual server time.
/// </summary>
/// <param name="player">The player to get data for.</param>
/// <param name="data">A collection to populate with data.</param>
/// <returns>The number of data points returned.</returns>
int GetC2SPositionHistogram(Player player, ICollection<PingHistogramBucket> data);
/// <summary>
/// Gets a player's latency histogram data based on the S2C latency field provided by clients in C2S position packets (requires the client to send "extra position data").
/// </summary>
/// <param name="player">The player to get data for.</param>
/// <param name="data">A collection to populate with data.</param>
/// <returns></returns>
int GetS2CPositionHistogram(Player player, ICollection<PingHistogramBucket> data);
/// <summary>
/// Gets a player's ping histogram data based on reliable packets.
/// </summary>
/// <param name="player">The player to get data for.</param>
/// <param name="data">A collection to populate with data.</param>
/// <returns>The number of data points returned.</returns>
int GetReliablePingHistogram(Player player, ICollection<PingHistogramBucket> data);
/// <summary>
/// Gets a player's ping histogram data based timesync packets (client times).
/// </summary>
/// <param name="player">The player to get data for.</param>
/// <param name="data">A collection to populate with data.</param>
/// <returns>The number of data points returned.</returns>
int GetClientTimeSyncHistogram(Player player, ICollection<PingHistogramBucket> data);
/// <summary>
/// Gets a player's ping histogram data based timesync packets (server times).
/// </summary>
/// <param name="player">The player to get data for.</param>
/// <param name="data">A collection to populate with data.</param>
/// <returns>The number of data points returned.</returns>
int GetServerTimeSyncHistogram(Player player, ICollection<PingHistogramBucket> data);
}
}