Lag (online gaming)
Encyclopedia
In online gaming
Online game
An online game is a game played over some form of computer network. This almost always means the Internet or equivalent technology, but games have always used whatever technology was current: modems before the Internet, and hard wired terminals before modems...

, Lag is a term used to describe delays between the action of players and the reaction of the server (and vice versa). Although it is commonly used to refer to delays caused by high latency
Latency (engineering)
Latency is a measure of time delay experienced in a system, the precise definition of which depends on the system and the time being measured. Latencies may have different meaning in different contexts.-Packet-switched networks:...

, it is occasionally used to describe delays caused by insufficient processing power in the client and/or server. While all communication between a client and server, or even between hardware components in the same machine, will experience a certain amount of lag, the term is usually reserved for delays noticeable to the user.

The tolerance for lag depends heavily on the type of game. For instance, a strategy game
Strategy game
A strategy game or strategic game is a game in which the players' uncoerced, and often autonomous decision-making skills have a high significance in determining the outcome...

 or a turn-based game with a low pace may have a high threshold or even be mostly unaffected by high delays, whereas a twitch gameplay game such as a first-person shooter
First-person shooter
First-person shooter is a video game genre that centers the gameplay on gun and projectile weapon-based combat through first-person perspective; i.e., the player experiences the action through the eyes of a protagonist. Generally speaking, the first-person shooter shares common traits with other...

 with a considerably higher pace may require significantly lower delay to be able to provide satisfying gameplay. But, the specific characteristic of the game matter. For example, fast chess is a turn-based game that is fast action and may not tolerate high lag. And, some twitch games can be designed such that only events that impact the outcome of the game introduce lag, allowing for fast local response most of the time.

Causes

While a single-player game maintains the main game state on the local machine, an online game
Online game
An online game is a game played over some form of computer network. This almost always means the Internet or equivalent technology, but games have always used whatever technology was current: modems before the Internet, and hard wired terminals before modems...

 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 while a player experiences lag, they can be summarized as insufficient hardware in either the client or the server, or a poor connection between the client and server.

Hardware related issues causes lag due to the fundamental structure of the game architecture. Generally, games consists of a looped sequence of states, or "frames". During each frame, the game accepts user input, performs necessary calculations (AI, graphics etc.). When all processing is finished, the game will update the game state and produce an output, for example in the form of a new image on the screen and/or a packet to be sent to the server. The frequency at which frames are generated is often referred to as the frame rate
Frame rate
Frame rate is the frequency at which an imaging device produces unique consecutive images called frames. The term applies equally well to computer graphics, video cameras, film cameras, and motion capture systems...

. As the central game state is located on the server, the updated information must be sent from the client to the server in order to take effect. In addition, the client must receive the necessary information from the server in order to fully update the state. Generating packets to send to the server and processing the received packets can only be done as often as the client is able to update its local state. Although packets could theoretically be generated and sent faster than this, it would only result in sending redundant data if the game state cannot be updated between each packet. A low frame rate would therefore make the game less responsive to updates and may force it to skip outdated data.

Conversely, the same hold true for the server. The frame rate (or tick rate) of the server determines how often it can process data from clients and send updates.
This type of problem is difficult to predict and compensate for. Apart from enforcing minimum hardware requirements and attempting to optimizing the game for better performance, there are no feasible ways to deal with it.

Perhaps the most common type of lag is caused by network performance
Network performance
Network performance refers to the service quality of a telecommunications product as seen by the customer. It should not be seen merely as an attempt to get "more through" the network....

 problems. Losses
Packet loss
Packet loss occurs when one or more packets of data travelling across a computer network fail to reach their destination. Packet loss is distinguished as one of the three main error types encountered in digital communications; the other two being bit error and spurious packets caused due to noise.-...

, corruption
Data corruption
Data corruption refers to errors in computer data that occur during writing, reading, storage, transmission, or processing, which introduce unintended changes to the original data...

 or jitter
Packet delay variation
In computer networking, packet delay variation is the difference in end-to-end delay between selected packets in a flow with any lost packets being ignored...

 (an outdated packet is in effect a loss) may all cause problems, but these problems are relatively rare in network with sufficient bandwidth
Bandwidth (computing)
In computer networking and computer science, bandwidth, network bandwidth, data bandwidth, or digital bandwidth is a measure of available or consumed data communication resources expressed in bits/second or multiples of it .Note that in textbooks on wireless communications, modem data transmission,...

 and no or little congestion
Network congestion
In data networking and queueing theory, network congestion occurs when a link or node is carrying so much data that its quality of service deteriorates. Typical effects include queueing delay, packet loss or the blocking of new connections...

. Instead, the latency involved in transmitting data between clients and server play 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
Routing
Routing is the process of selecting paths in a network along which to send network traffic. Routing is performed for many kinds of networks, including the telephone network , electronic data networks , and transportation networks...

 required and therefore higher latency. Routing over the Internet
Internet
The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite to serve billions of users worldwide...

 may be extremely indirect, resulting in far more transmission length (and consequential latency) than a direct route, although the cloud gaming service OnLive
OnLive
OnLive is a cloud gaming platform: the games are synchronized, rendered, and stored on remote servers and delivered via the Internet.The service is available using the OnLive Game System, PCs running Microsoft Windows and Intel-based Macs with OS X 10.5.8 or later...

 has developed a solution to this issue by establishing peering
Peering
In computer networking, peering is a voluntary interconnection of administratively separate Internet networks for the purpose of exchanging traffic between the customers of each network. The pure definition of peering is settlement-free or "sender keeps all," meaning that neither party pays the...

 relationships with multiple Tier 1 network
Tier 1 network
A tier 1 network is an Internet Protocol network that participates in the Internet solely via settlement-free interconnection, also known as settlement-free peering.-Definition:...

 Internet Service Providers and choosing an optimal route between server and user. In addition, insufficient bandwidth and congestion, even if not severe enough to cause losses, may cause additional delays regardless of distance. As with the hardware issues, packets that arrive slowly or not at all will make both the client and server unable to update the game state in a timely manner.

Online game systems utilizing a wireless network
Wireless network
Wireless network refers to any type of computer network that is not connected by cables of any kind. It is a method by which homes, telecommunications networks and enterprise installations avoid the costly process of introducing cables into a building, or as a connection between various equipment...

 may be subject to significant lag, depending on the architecture of the wireless network and local electromagnetic interference
Electromagnetic interference
Electromagnetic interference is disturbance that affects an electrical circuit due to either electromagnetic induction or electromagnetic radiation emitted from an external source. The disturbance may interrupt, obstruct, or otherwise degrade or limit the effective performance of the circuit...

 impacting that network. Although radio propagation
Radio propagation
Radio propagation is the behavior of radio waves when they are transmitted, or propagated from one point on the Earth to another, or into various parts of the atmosphere...

 through air is faster than light through optical fiber, wireless systems are often shared among many users and may suffer from latency incurred due to network congestion
Network congestion
In data networking and queueing theory, network congestion occurs when a link or node is carrying so much data that its quality of service deteriorates. Typical effects include queueing delay, packet loss or the blocking of new connections...

, or due to network protocols that introduce latency. And, in the event of electromagnetic interference
Electromagnetic interference
Electromagnetic interference is disturbance that affects an electrical circuit due to either electromagnetic induction or electromagnetic radiation emitted from an external source. The disturbance may interrupt, obstruct, or otherwise degrade or limit the effective performance of the circuit...

, transmitted packets may be lost, requiring a retransmission which also incurs latency.

Effects

The noticeable effects of lag vary depending on the exact cause, but also on any and all techniques for lag compensation that the game may implement (described below). As all clients experience some amount of 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 requires extensive use of compensation to be playable (most prevalent is probably the first-person shooter genre). Due to the various problems lag can cause, many players that have a lower speed Internet connection are often 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 caused by 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 for 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 causes various problems with hit- and collision detection. If the low update rate is caused by a low frame rate (as opposed to a setting on the client, as some games allow), these problems are usually overshadowed by numerous problems related to the client-side processing itself. Both the display and controls will be sluggish and unresponsive. While this may increase the perceived lag, it is important to note that it is of a different kind than network-related delays.
In comparison, the same problem on the server may cause significant problems for all clients involved. If the server is unable or unwilling to accept packets from clients fast enough and process these in a timely manner, client actions may never be registered. When the server then sends out updates to the clients, they may experience freezing (unresponsive game) and/or rollbacks
Rollback (data management)
In database technologies, a rollback is an operation which returns the database to some previous state. Rollbacks are important for database integrity, because they mean that the database can be restored to a clean copy even after erroneous operations are performed...

, depending on what types of lag compensation, if any, the game uses.

Lag due to network delay is in contrast often less of a problem. Though more common, the actual effects are generally smaller, and it is possible to compensate for these types of delays. Without any form of lag compensation, the clients will notice that the game responds only a short time after an action is performed. This is especially problematic in first-person shooters, where enemies are likely to move as a player attempts to shoot them and the margin for errors is often small.

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 themselves 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 it is or who they 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 infeasible, and clients will be limited to sending relative states (i.e. which vector it moved or shot in).

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
Extrapolation
In mathematics, extrapolation is the process of constructing new data points. It is similar to the process of interpolation, which constructs new points between known points, but the results of extrapolations are often less meaningful, and are subject to greater uncertainty. It may also mean...

 and interpolation
Interpolation
In the mathematical field of numerical analysis, interpolation is a method of constructing new data points within the range of a discrete set of known data points....

.

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 they are not actually in.


Often, in order to allow smooth gameplay, the client is allowed to do soft changes to the game state. While the server may ultimately keep track of ammunition, health, position etc., the client may be allowed to predict the new server-side game state based on the player's actions, such as allowing a player to start moving before the server has responded to the command. These changes will generally be accepted under normal conditions and make delay mostly transparent. Problems will arise only in the case of high delays or losses, when the clients predictions are very noticeably undone by the server. Sometimes, in the case of minor differences, they server may even allow "incorrect" changes to the state based on updates from the client.

Server-side

Unlike clients the server knows the exact current game state, and as such prediction is unnecessary. The main purpose of server-side lag compensation is instead to provide accurate effects of client actions. This is important because by the time a player's command has arrived time will have moved on, and the world will no longer be in the state that the player saw when issuing their command. A very explicit example of this is hit detection for weapons fired in first-person shooters, where margins are small and can potentially cause significant problems if not properly handled.

Do nothing

One potential "solution" is to simply ignore the problem. A game may simply make players do their own predictions. For hit detection in first-person shooters, this means a player will have to lead their target, aiming at the position where the target will be by the time the shot reaches the server. With variable latency, this may be frustrating even under ideal conditions. With higher latency and random player movement it can make playing virtually impossible. For example if a remote player passes by a window in a period shorter than the client's latency, it will be impossible for the local player to hit them even if they fire immediately.

Rewind time

Another way to address the issue is to store past game states for a certain length of time, then rewind player locations when processing a command. The server uses the latency of the player (including any inherent delay due to interpolation; see above) to rewind time by an appropriate amount in order to determine what the shooting client saw at the time the shot was fired. This will usually result in the server seeing the client firing at the target's old position and thus hitting. In the worst case a player will be so far behind that the server runs out of historic data and they have to start leading their targets.

This is a WYSIWYG
WYSIWYG
WYSIWYG is an acronym for What You See Is What You Get. The term is used in computing to describe a system in which content displayed onscreen during editing appears in a form closely corresponding to its appearance when printed or displayed as a finished product...

 solution that allows players to aim directly at what they are seeing. But the price is an aggravation of the effects of latency when a player is under fire: not only does their own latency play a part, but their attacker's too. In many situations this is not noticeable, but players who have just taken cover will notice that they carry on receiving damage/death messages from the server for longer than their own latency can justify. This can lead more often to the (false) impression that they were shot through cover and the (not entirely inaccurate) impression of "laggy hitbox
Hitbox
Hitbox was a popular web counter and web analytics product created by WebSideStory, until taken over by Omniture subsequently taken over by Adobe), originally for adult entertainment websites. It was now widely used by commercial & other organizations across a variety of industrial sectors as a...

es".

The effects of rewinding can be seen from the perspective of both parties in this video.

One design issue that arises from rewinding is whether to stop rewinding a dead player's lagged commands as soon as they die on the server, or to continue running them until they "catch up" to the time of death. Cutting compensation off immediately prevents victims from posthumously attacking their killers, which meets expectations, but preserves the advantage of moving players who round a corner, acquire a target and kill them in less time than a round trip to the stationary victim's client.

Rewinding can be criticised for allowing the high latency of one player to negatively affect the experience of low-latency players. Servers with lag compensation will sometimes reduce the length of player history stored, or enforce ping limits, to reduce this problem.

Make clients extrapolate

A third lag solution is to do nothing on the server and to have each client extrapolate (see above) to cover its latency. This produces incorrect results unless remote players maintain a constant velocity, granting an advantage to those who dodge back and forth or simply start/stop moving.

Extended extrapolation also results in remote players becoming visible (though not vulnerable) when they should not be: for example if a remote player sprints up to a corner then stops abruptly at the edge, other clients will render them sprinting onward, into the open, for the duration of their own latency. On the other side of this problem, clients have to give remote players who just started moving an extra burst of speed in order to push them into a theoretically-accurate predicted location.

Cloud gaming

Cloud gaming
Cloud gaming
Cloud gaming, also called gaming on demand, is a type of online gaming that allows direct and on-demand streaming of games onto a computer, similar to video on demand, through the use of a thin client, in which the actual game is stored on the operator's or game company's server and is streamed...

 is a type of online gaming where the entire game is hosted on a game server in a data center, and the user is only running a thin client
Thin client
A thin client is a computer or a computer program which depends heavily on some other computer to fulfill its traditional computational roles. This stands in contrast to the traditional fat client, a computer designed to take on these roles by itself...

 locally that forwards game controller
Game controller
A game controller is a device used with games or entertainment systems used to control a playable character or object, or otherwise provide input in a computer game. A controller is typically connected to a game console or computer by means of a wire, cord or nowadays, by means of wireless connection...

 actions upstream to the game server. The game server then renders the next frame of the game video which is compressed using low-lag video compression and is sent downstream and decompressed by the thin client. For the cloud gaming experience to be acceptable, the round-trip lag of all elements of the cloud gaming system (the thin client, the Internet and/or LAN connection the game server, the game execution on the game server, the video and audio compression and decompression, and the display of the video on a display device
Display device
A display device is an output device for presentation of information in visual or tactile form...

) must be low enough that the user perception is that the game is running locally. Because of such tight lag requirements, distance considerations of the speed of light
Speed of light
The speed of light in vacuum, usually denoted by c, is a physical constant important in many areas of physics. Its value is 299,792,458 metres per second, a figure that is exact since the length of the metre is defined from this constant and the international standard for time...

 through optical fiber
Optical fiber
An optical fiber is a flexible, transparent fiber made of a pure glass not much wider than a human hair. It functions as a waveguide, or "light pipe", to transmit light between the two ends of the fiber. The field of applied science and engineering concerned with the design and application of...

 come into play, currently limiting the distance between a user and a cloud gaming game server to approximately 1000 miles, according to OnLive
OnLive
OnLive is a cloud gaming platform: the games are synchronized, rendered, and stored on remote servers and delivered via the Internet.The service is available using the OnLive Game System, PCs running Microsoft Windows and Intel-based Macs with OS X 10.5.8 or later...

, the only company thus far operating a cloud gaming service.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK