Seems something very hard to do in software but very easy to do in hardware.
# hping -S -p 1234 somehost.com
HPING somehost.com (ens3 1.2.3.4): S set, 40 headers + 0 data bytes
len=46 ip=1.2.3.4 ttl=64 DF id=0 sport=1234 flags=SA seq=0 win=26883 rtt=0.9 ms
len=46 ip=1.2.3.4 ttl=64 DF id=0 sport=1234 flags=SA seq=1 win=26883 rtt=0.8 ms
len=46 ip=1.2.3.4 ttl=64 DF id=0 sport=1234 flags=SA seq=2 win=26883 rtt=0.7 ms
# tc qdisc add dev ens3 root netem delay 25ms
# hping -S -p 1234 somehost.com
HPING somehost.com (ens3 1.2.3.4): S set, 40 headers + 0 data bytes
len=46 ip=1.2.3.4 ttl=64 DF id=0 sport=1234 flags=SA seq=0 win=26883 rtt=25.9 ms
len=46 ip=1.2.3.4 ttl=64 DF id=0 sport=1234 flags=SA seq=1 win=26883 rtt=25.8 ms
len=46 ip=1.2.3.4 ttl=64 DF id=0 sport=1234 flags=SA seq=2 win=26883 rtt=25.7 msand they did it basically after the network stack, so if a paket took 40ms they added no latency if it took 20ms they added 15ms and so on.
so EACH paket was evaluated and of course this is not an easy feat, because lol is serverside authoritive so the latency must be correct inside the server and the client for each packet.
Simulating this stuff is pretty simple. Model each incoming stream as an MM1 queue and play around with your PID algorithm until it gives you the results you need.
Some problems cannot be solved with clever tricks.