Lag (video games)
In computers, lag is delay between the action of the user and the reaction of the server supporting the task, which has to be sent back to the client.
The player's ability to tolerate lag depends on the type of game being played. For instance, a strategy game or a turn-based game with a slow pace may have a high threshold or even be mostly unaffected by high lag. A game with twitch gameplay such as a first-person shooter or a fighting game with a considerably faster pace may require a significantly lower lag to provide satisfying gameplay.
Lag is mostly measured in milliseconds and may be displayed in-game. The most common causes of lag are expressed as [|ping time] and the [|frame rate]. Generally a lag below 100 ms is considered to be necessary for playability. The lowest ping physically possible for a connection between opposite points on Earth crossing half of the planet is 133 ms. Other causes of lag result commonly in a lag below a playable 20 ms, or in the loss, corruption or jitter of the game.
Causes
While a single-player game maintains the main game state on the local machine, an online game requires it to be maintained on a central server in order to avoid inconsistencies between individual clients. As such, the client has no direct control over the central game state and may only send change requests to the server, and can only update the local game state by receiving updates from the server. This need to communicate causes a delay between the clients and the server, and is the fundamental cause behind lag. While there may be numerous underlying reasons for why a player experiences lag, most common reasons are poor connection between the client and server, or insufficient processing in either the client or the server.Connection
Perhaps the most common type of lag is caused by network performance problems. Losses, corruption or jitter may all cause problems, but these problems are relatively rare in a network with sufficient bandwidth and no or little congestion. Instead, the latency involved in transmitting data between clients and server plays a significant role. Latency varies depending on a number of factors, such as the physical distance between the end-systems, as a longer distance means additional transmission length and routing required and therefore higher latency. Routing over the Internet may be extremely indirect, resulting in far more transmission length than a direct route, although the cloud gaming service OnLive has developed a solution to this issue by establishing peering relationships with multiple Tier 1 network Internet Service Providers and choosing an optimal route between server and user.Ping time
Ping time, or simply ping, is the main measure of connection lag. Ping time is the network delay for a round trip between a player's client and the game server as measured with the ping utility or equivalent. Ping time is an average time measured in milliseconds. The lower one's ping is, the lower the latency is and the less lag the player will experience. High ping and low ping are commonly used terms in online gaming, where high ping refers to a ping that causes a severe amount of lag; while any level of ping may cause lag, severe lag is usually indicated by a ping of over 100 ms. This usage is a gaming cultural colloquialism and is not commonly found or used in professional computer networking circles.Some factors that might particularly affect ping include: communication protocol used, Internet throughput, the quality of a user's Internet service provider and the configuration of firewalls. Ping is also affected by geographical location. For instance, if someone is in India, playing on a server located in the United States, the distance between the two is greater than it would be for players located within the US, and therefore it takes longer for data to be transmitted, resulting at 20,000 km in a ping of 133 ms. However, the amount of packet-switching and network hardware in between the two computers is often more significant. For instance, wireless network interface cards must modulate digital signals into radio signals, which is often more costly than the time it takes an electrical signal to traverse a typical span of cable. As such, lower ping can result in faster Internet download and upload rates.
Interface
Input-lag
Input-lag or input latency is the lag produced by the input device, such as a mouse, keyboard or other controller, and its connection. Wireless devices are particularly affected by this kind of lag. Some people claim to notice extra lag when using a wireless controller, while other people claim that the 4–8 milliseconds of lag is negligible. The refresh rate is a type or part of input-lag that is the rate of a display to produce distinct picture, measured in Hz.Display lag
This is the lag caused by the television or monitor. In addition to the latency imposed by the screen's pixel response time, any image processing takes time and therefore adds more input lag. An input lag below 30 ms is generally considered unnoticeable in a television. Once the frame has been processed, the final step is the updating the pixels to display the correct color for the new frame. The time this takes is called the pixel response time.Effects
The noticeable effects of lag vary not only depending on the exact cause, but also on all techniques for lag compensation that the game may implement. As all clients experience some delay, implementing these methods to minimize the effect on players is important for smooth gameplay. Lag causes numerous problems for issues such as accurate rendering of the game state and hit detection. In many games, lag is often frowned upon because it disrupts normal gameplay. The severity of lag depends on the type of game and its inherent tolerance for lag. Some games with a slower pace can tolerate significant delays without any need to compensate at all, whereas others with a faster pace are considerably more sensitive and require extensive use of compensation to be playable. Due to the various problems lag can cause, players that have an insufficiently fast Internet connection are sometimes not permitted, or discouraged from playing with other players or servers that have a distant server host or have high latency to one another. Extreme cases of lag may result in extensive desynchronization of the game state.Lag due to an insufficient update rate between client and server can cause some problems, but these are generally limited to the client itself. Other players may notice jerky movement and similar problems with the player associated with the affected client, but the real problem lies with the client itself. If the client cannot update the game state at a quick enough pace, the player may be shown outdated renditions of the game, which in turn cause various problems with hit- and collision detection.
Testing has found that overall input lag times of approximately are distracting to the user. It also appears that is an average response time and the most sensitive games achieve response times of .
Solutions and lag compensation
There are various methods for reducing or disguising delays, though many of these have their drawbacks and may not be applicable in all cases. If synchronization is not possible by the game itself, the clients may be able to choose to play on servers in geographical proximity to themselves in order to reduce latencies, or the servers may simply opt to drop clients with high latencies in order to avoid having to deal with the resulting problems. However, these are hardly optimal solutions. Instead, games will often be designed with lag compensation in mind.Many problems can be solved simply by allowing the clients to keep track of their own state and send absolute states to the server or directly to other clients. For example, the client can state exactly at what position a player's character is or who the character shot. This solution works and will all but eliminate most problems related to lag. Unfortunately, it also relies on the assumption that the client is honest. There is nothing that prevents a player from modifying the data they send, directly at the client or indirectly via a proxy, in order to ensure they will always hit their targets. In online games, the risk of cheating may make this solution unfeasible, and clients will be limited to sending relative states.
Client-side
As clients are normally not allowed to define the main game state, but rather receive it from the server, the main task of the client-side compensation is to render the virtual world as accurately as possible. As updates come with a delay and may even be dropped, it is sometimes necessary for the client to predict the flow of the game. Since the state is updated in discrete steps, the client must be able to estimate a movement based on available samples. Two basic methods can be used to accomplish this; extrapolation and interpolation.Extrapolation is an attempt to estimate a future game state. As soon as a packet from the server is received, the position of an object is updated to the new position. Awaiting the next update, the next position is extrapolated based on the current position and the movement at the time of the update. Essentially, the client will assume that a moving object will continue in the same direction. When a new packet is received, the position may be corrected slightly.
Interpolation works by essentially buffering a game state and rendering the game state to the player with a slight, constant delay. When a packet from the server arrives, instead of updating the position of an object immediately, the client will start to interpolate the position, starting from the last known position. Over an interpolation interval, the object will be rendered moving smoothly between the two positions. Ideally, this interval should exactly match the delay between packets, but due to loss and variable delay, this is rarely the case.
Both methods have advantages and drawbacks.
- Interpolation ensures that objects will move between valid positions only and will produce good results with constant delay and no loss. Should dropped or out-of-order packets overflow the interpolation buffer the client will have to either freeze the object in position until a new packet arrives, or fall back on extrapolation instead. The downside of interpolation is that it causes the world to be rendered with additional latency, increasing the need for some form of lag compensation to be implemented.
- The problem with extrapolating positions is fairly obvious: it is impossible to accurately predict the future. It will render movement correctly only if the movement is constant, but this will not always be the case. Players may change both speed and direction at random. This may result in a small amount of "warping" as new updates arrive and the estimated positions are corrected, and also cause problems for hit detection as players may be rendered in positions that they are not actually in.