Skip to content

Lag Accounting

DarksideCode edited this page Jan 19, 2019 · 8 revisions

Problem

We will start with a brave claim that ping or TPS accounting cannot be called lag accounting. This may sound strange at first, but what if I tell you that ping of a player and TPS of your server are only updated once in a few seconds? And while it is still possible to write a more frequent and sensitive TPS monitor, it will still not handle all the lag properly. Moreover, we shouldn't forget that the most common form of lag is a short client-side lag spike/timeout. All this means that you should never rely on ping accounting — that's nearly useless. Oh, and did I say that ping can be easily spoofed by client?

Solution

In Reflex, we have decided to dedicate some time for creation of a better approach of detecting lag. Now, we're proud to say that we have gone pretty far in this, and now use a completely different, packet-based lag accounting technology. We monitor packet-level behavior of a player for a short period of time (usually less than a second) and compare it to a precomputed "normal" behavior, calculating so-called offsets from norms. Then we sum all those offsets in a special way so that highest offsets have higher importance and therefore have a higher impact on the result, and lower offsets' importance reduces gradually. The "weighted" sum is then divided by the overall balance of behavior of the player, which greatly helps in detecting very short lag-spikes and client FPS (!) drops sometimes. We call the final result the number of Lag Points for this player at this moment (or just LP). Knowing players' LP and having an awesome pre-made table (which was created experimentally, hello debugging) [see below], we can get their Lag Status at this moment. Lag Status of players is then used by Reflex to modify the number of violations they get (more lag — fewer violations) and internally by many checks to give lagging players a variety of additional leniences.

Table of Lag Statuses in Reflex

Name Lower LP Bound Higher LP Bound General Violations Multiplier Description
Hasty 1 8 1.25 Player's behavior is suspiciously smooth. Likely because of some hacks/mods/other software that affects client tick rate (e.g. Timer).
OK 9 26 1.00 The client is ticking as it is meant to. Completely no lag-related false positives or bugs appear.
Minor Lag 27 39 0.80 Some packets might be a little bit not in time. Might be a very minor, barely noticeable lag, without serious gameplay or checking bugs.
Noticeable Lag 40 57 0.69 Easily noticeable lag which interrupts the gameplay a bit, and which is the reason of some common false positives.
Vivid Lag 58 78 0.37 The gameplay is observably interrupted, it is often difficult to fight against non-lagging players. Heavy checks affects start appearing.
Extreme Lag 79 +∞ 0.20 A player seems to be really desperate if they are trying to play with such lag. 9999 FPs/s, the gameplay is entirely ducked, and so are the checks.