Lag

From GT New Horizons
Revision as of 17:23, 7 August 2023 by Boubou19 (talk | contribs) (added packet loss issues section)

Lag is something everyone has experienced in minecraft. This page will help you to understand it better and to diagnose it.

Here is a breakdown in possible sources of lag:

  • bad ping
  • packet loss
  • CPU load (TPS)
  • bugs in mods

Ping issues

Ping is a metric giving info about how long it takes for a network packet to go from your computer to the server, or vice versa. It is expressed in miliseconds (ms), and the lower it is, the faster it is to talk with the server. (or you are getting closer if the propagating medium didn't change).

Before digging more into networking stuff, let's talk about how is structured internet as a whole. It's mainly composed of:

  • routers (or nodes)
  • endpoints (servers or clients)
  • connections between all those equipments (or links). The place where you plug a link to a router or an endpoint is called an interface.

A sub network of internet with the same policy for routing is called an Autonomous System (AS).

A ping measure follows these steps:

  1. measuring the time just before sending a "hello" packet
  2. sending a "hello" packet to the server
  3. waiting for a "hello" packet from the server
  4. measuring the time at the arrival of the packet
  5. computing the delta and dividing it by 2 (because of the round trip)

Inside a router, here are the following source of delays

  1. delay of arrival (time of propagation through the medium in the input link)
  2. delay of buffering in the input buffer (fixed by hardware)
  3. delay of processing (influenced by the global load of the router, such as other services or other interfaces being busy too)
  4. delay of buffering in the output buffer (fixed by hardware)
  5. delay of departure (time of propagation through the medium in the output link)

Also, a router is supposed to find the fastest path for routing your packets. For that, some routing algorithms are used, and usually, the route with the least amount of hops is prefered (a hop is a jump to one node to another). The issue is that between 2 AS, there can be what is called an administrative distance. It's simply a faked metric for routing algorithms, and it can impact greatly the routing. It is done by companies or governments for various reasons. Due to that, the fastest route will sometimes appear as the slowest route, causing your traffic to go through a longer route, increasing your ping.

There is also the fact that routers can sometimes become unavailiable (broken link, overloaded router, power failure, etc). When a router did not contacted its neighbors after some times, the neighboors will remove the faulty router from their routing table, which causes your route to be deviated.

To sum thing up, your route is evolving over time, and can be impacted, independantly from you, the server, or your ISP.

Packet loss issues

To convey your network packets over internet, there are two big protocols encapsulating your data: TCP and UDP. TCP is used when an application must transmit data with integrity (packet ordering, reemision of lost packets, etc), and UDP is used when an application must transmit data as fast as possible (streaming for instance). Minecraft uses TCP, because the game requires to process correct information and in the correct order to synchronise the client with the server.


A packet can be lost because of external reasons (router going down, etc), but also on purpose by the routers. In networking, equipments must be as fast as possible, so this translates into doing the least work possible. If the input buffer or the output buffer is full but a packet is incomming, instead of waiting, or asking for a resend of the packet to the previous router, the router will do the least work possible, which is trashing the packet. The integrity checks are delegated to client and server.


Packet loss does not impact your ping per se, but a too high rate of packet loss will cause you to feel a bigger latency than what the ping displays. And this is normal. Let's assume a ping to a server of 50 ms. The client initiate a TCP connection with the server, and start sending data to the server. After each block of data sent, the client will ask if the server got them, if not, the client reemit the packet, and ask again if the server got it. The client will keep emiting the packet until the server tells the client it got it. But each time, the data took 50 ms to be transmitted, so the higher is the amount of reemission, the bigger will be the difference between the latency displayed by the ping and the perceived latency in game.


In short, packet loss can increase your latency, no matter how good your ping is.

CPU load issues

bug in mods