Author Topic: Lag/Delay - A guide.  (Read 16628 times)

0 Members and 1 Guest are viewing this topic.

Hanney

  • Guest
Lag/Delay - A guide.
« on: March 11, 2016, 05:07:53 PM »
I've seen countless players in game crying about lag and telling others to "buy better internet" and also some others asking how to get a lower ping. Therefore, I thought I would take a little bit of time to make this guide. Please note that the example/explanation below is not 100% accurate and may have some errors and is only used for theory purposes.

Lag / Ping / Latency - What is it?

Ping is a measurement of the total time it takes for your computer to send information to the server and receive a reply from the server back to your computer. Ping is measured in milliseconds (ms) for example, 1000 ms = 1 second, 500ms = 0.5 seconds, 200 ms = 0.2 seconds. A large variety of factors can effect your ping.

Some of the most common problems would be:

Bandwidth - Bandwidth is the amount of data being transferred at one given time. By default most players should have enough bandwidth on a normal basis to be able to play vc-mp. However, if you or someone else in your house sharing the same connection begins downloading a file then this can cause sudden instability in ping with large spikes called jitter.

Infrastructure - i.e wireless network card positioning. Another common factor that can sometimes cause a very bad connection is due to poor signal to your router. If you play using a laptop then it's most likely you are using a wireless card to connect to your router. If you are having difficulty with the signal between your laptop and router then the rest of the connection will be effected which may also lead to instability in ping (jitter).

Geographical distance - If you live a long distance away from the server then your ping will be higher as the data being transferred to the server has to travel a much further distance. Littlewhitey's is located in France, this is why players in Europe get a lower ping where as other players in Pakistan will receive a much higher ping.

Ingame example

Here is an example I have created in an attempt to explain latency in an in game situation. This example is based on the point of view of a Pakistan player with an optimal connection from end-to-end. The event happening is the firing of a weapon at another player. 

1. The player clicks the left mouse button to fire his gun.



2. Vice City Multiplayer sends a network "packet".

A packet is a piece of data which gets sent from your computer to the server to describe what actions you are doing. e.g in this case we are firing a gun.

As soon as the fire button is clicked the packet is sent from your game > to your network card > to your home router.



3. Your home router sends the packet out to the Internet towards the server. This usually goes towards your ISP network then passes through a series of routers (called hops) on the way to it's destination (littlewhiteys).

The image below shows an example of this journey (please note that the route location is not accurate):



The total time for traveling to the server in this case is 120ms.

4. Afterwards, Littlewhitey server will receive this packet, process it then re-transmit a packet with the similar information and send this packet to all players in the nearby vicinity of the player that sent the original packet. (Not 100% sure if only nearby players or all players on the server)

Lets take the example of a second player in Pakistan that the first player is shooting at to see how their transmission may look:



As a theory example, in this case it's the exact same route but in reverse with a total time of 120ms again meaning that the current total time to and from the server is 120ms + 120ms = 240ms.

The packet goes through their home router, to their network card and is then processed by their computer to Vice City.

But wait... theirs more...

The player has received the packet telling his Vice City game that another player is shooting at him but for him to take damage he must first see the fire animation of the gun being fired play on his game. This is obviously dependent on the weapon being used, some weapons take longer to fire than others. In this example we will use the stubby shotgun.

Let's say that the stubby shotgun takes 0.6 (600ms) seconds for the animation to play (at 30 fps) and the shells to come out of the gun and hit the player being aimed at. Now

Total time = (120ms from PC to Littlewhiteys) + (120ms from Littlewhiteys to other player) + (600ms for fire animation of stubby) = 840ms to damage a player.


When it comes to the fire animation, a players game lagging can have an effect as well. If the players game is running at say 20 fps as opposed to 30 fps then this may also add another 200ms for the fire animation to play meaning that the animation total time would be 800ms.

Now the shot has been received:



This is why you should lead aim. lead aim is when you try to 'predict' where that player will be in the total time and try to fire at that spot. Basically, in this example, try to shoot 840ms ahead of where the player is currently is. This can be easy if the player is running in one direction but difficult if the player is moving in multiple directions. Stubbys also have a wide spread meaning that you can cover a much wider range when you fire meaning more chance of hit being a success.

But admin how do I reduce my latency!?!?!?

In most cases if you are living far away from the server there isn't much you can do. If you live close to the server e.g as in Europe and you have a high ping then the problem may be on your end. Make sure your cabling is good within your house, make sure no downloads are running in the background, make sure you have a good wi-fi signal if wireless.

Other problems may occur aswell that are out of your hand. e.g if one of the 'datacentres' also known as one of the routers on the map diagram above are experiencing difficulty then this will slow your whole connection down. As a rule of thumb, your connection is only as fast as the slowest link between you and the littlewhitey server.

But admin I will upgrade internet speed to get faster speeds!!


In most cases if you are just increasing bandwidth this won't help. For example, if you increase bandwidth it just increases the amount of data which you can transfer at one time, this will not speed up your connection time to the server. Take this example below,

There is a wooden barrel that you need to fill with water. What is faster? pouring water into a cup and filling the barrel or using a glass jug of water to fill the barrel? Obviously, it's the jug that will be faster but only faster because you can carry more water at one given time.

In terms of your connection you may be able to carry more data at one given time, but it won't be travelling any faster meaning that the overall time it takes is still the same amount.

Hopefully this guide is a helpful lesson and wasn't too confusing. It would probably be more best suited for video material but as for now it can be here. I will try to clean it up. If any questions or confusions please post them below and I'll try my best to clarify.
« Last Edit: March 11, 2016, 10:21:20 PM by Hanney »

Offline DamnYouBerkley!

  • VC-MP Donator
  • *
  • Posts: 648
    • Awards
Re: Lag/Delay - A guide.
« Reply #1 on: March 11, 2016, 06:09:53 PM »
Nice one Hanney, this is great.
Quote from: NewK
First of all, amazing work Berkley, we need more people like you in this community, people who are willing to go the extra mile to catch these cunts.

Offline WannaCry

  • VC-MP Donator
  • *
  • Posts: 113
  • Heart touching virus
    • https://en.wikipedia.org/wiki/WannaCry_ransomware_attack
    • Awards
  • SA-MP: WanaCrypt
Re: Lag/Delay - A guide.
« Reply #2 on: March 12, 2016, 04:19:11 AM »
THNx

Offline Rest

  • VC-MP Donator
  • *
  • Posts: 90
    • Awards
Re: Lag/Delay - A guide.
« Reply #3 on: March 12, 2016, 06:29:15 AM »
 :-\ :-\

Offline Noori

  • VC-MP Retirees
  • *
  • Posts: 885
  • Give Respect Get Respect
  • Awards VC-MP Admin of the Year (2016)
    • Awards
Re: Lag/Delay - A guide.
« Reply #4 on: March 12, 2016, 09:26:39 AM »
Nice work