Low Bandwidth OnLine gaming

 

Low Bandwidth OnLine gaming

Introduction

This is about the problems encountered in designing a Generic API for networking games, and the solutions.

The majority of the current generation of network tools are simple transport layers. They will get your message from A to B but provide little else.

For games with higher data rates and/or a large number of players and interactive objects, this by itself does not offer a sufficiently high-level interface for efficient game design or efficient bandwidth usage.

When developing general retail games, the usual route is to develop the single-user version, then try to add multi-user functionality. Generally doing this is a nightmare unless very tight controls are maintained over both design and coding, and this control requires time that could be better spent adding other functionality.

Even when this control has been achieved, many developers tend only to consider the single-user version. This can lead to problematic logic when it comes to objects interacting on different machines.

Design Goals.

  • Bandwidth reduction.

  • Applicable to multiple applications.

  • Application unaware of network status.


Bandwidth Reduction

There are two basic techniques for reducing the bandwidth requirements of a game. The first is compression. The second is extrapolation. These lead to sending smaller packets and sending fewer packets, respectively.

Compression has little impact on the design of the API. One of the most efficient forms of compression in this situation is 'deltaing'. In order for this to work efficiently, it is usually best to arrange the data so that the most frequently sent data is together at the top of the packet. This allows both truncation and sparse matrix packing to be more efficient.

Every object has several different classes of data.

  • Data that is sent often.

  • Data sent rarely.

  • Local working data.


Database

It seems reasonable to assume that the data that is being sent often will include information on the position and visual state of the object.

The information regarding the position of the object and its orientation is important, as it is used by the extrapolation system (see below). This will require the data to be in a predefined format:

If we wish to add a dynamic object to the database, we will have to make a call to the database. This call adds it and passes information about the size of the various classes of data such as

ID AddDynamicObject(DBHandle, Object *, int sizedynamic, int sizeofstatic, int sizeofworking);

Say the type of dynamic object added contained static information, relating to the allegiance of the object and its status. While allegiance of the object will never change, it will be the same as other objects: as weapons are used and as damage is incurred the status will change. We could just place all this data into the static data portion of the object. This would mean that when the status changed we would have to transmit the entire static portion.

If instead we created two static objects, one of which contained the allegiance data and the other the status, then we could just include the ID’s of these objects in the static portion of the object. Many objects will use the same allegiance object and only the status object is updated. This would save a lot of bandwidth.

ID AddStaticObject(DBHandle, Object *, int sizeofstatic, int sizeofworking);



Once we have the data in the database we have to know when to send it and who to send it to. This depends on knowing the PoP’s (Point of Presence) of the various players. Each player may have multiple PoPs.

A player’s PoP is associated with either a fixed geographical location or a dynamic object; a call to the Database will define this.

ID=AddPoP(ID,z,y,z,speed);

If the ID! =NULL then the X, Y, Zs are offsets from the object. If the object is NULL then they are taken as absolute. If absolute co-ordinates are given then the object will be extrapolated like any other object to reduce bandwidth.



Extrapolation

Once we have all the data in the database, we have to decide what updates require sending immediately and what can be held over for the future. Updates will be held over if they have no significant effect on the world as seen from the various PoPs. This must include being seen by RADAR or any other remote sensor. This is not variation from the last data sent but variation from the extrapolation of the last data sent. We extrapolate at the owner end with the data we have sent up to the present time and compare that with the data that has been updated. If tolerance was broken, we transmit. All the while, the receiver has been extrapolating with the data it has received.

The criteria for the transmission decision can be quite complex depending on the significance of a change in a particular attribute. If a dynamic object is stationary then, normally, it is not transmitted. If, however, the object status changes then it will be transmitted. If the object is monolithic then it will not be transmitted as the criterion for transmission is based purely on positional change. If, however, the object status is held in a separate static object then changing of that object will cause a transmission (since its criterion for transmission is transmit if the data changes).

When a dynamic object is within visual range of the PoP then the allowable error is that which produces a change of one pixel in the player’s view of that object.




This simple calculation is adequate in most cases, but it takes no account of such things as Rayleigh’s Criterion, curvature of the earth or the different resolving powers of Radar. Consideration of these is likely to reduce the transmission of distant objects even further. Rayleigh's criterion provides a cut-off for visual range based upon the largest dimension of the object and the human eye or camera. In reality, this means that any object less than 30 meters in cross-section will be invisible at 10 km unless the sun glints off it.

It would be possible to use these additional criteria to reduce bandwidth usage still further. However, there is a law diminishing returns, and we would be better off looking to increase performance in other areas.

The simplest form of extrapolation is dead reckoning. This involves knowledge of the object's position and velocity, and using s=ut to calculate the distance travelled. Incorporating the acceleration enhances this; although taking into account acceleration does not lead to an extrapolator that can go round corners!

For a more generic application, what we are looking for is a system that can quickly retrain in cases where the object changes its mode of movement. It must also identify and utilise cyclic behaviour in an object’s movement.

Using a three-point Lagrange Interpolation as an extrapolator provides limited cornering with a good retraining characteristic, though it does lack the ability to use cyclic behaviour. There is no reason why an extrapolator cannot have several modes, so long as the modes are switched on the data sent or received. Both owner and watcher would then be in the same mode, which is essential.

Extrapolation has two functions. One is to allow for any gaps in transmission to be filled in. The other is to allow for inherent latency of the system.

Both of these methods require an accurate timebase on both the sender and receiver machines, so that the age of the packets is calculated accurately.

A simulation must have an idea of the current game time to work over a network. It is a simple process to set a time for the database at the start of each game loop.

It should be enough to know the age of the packet when it arrives in order to calculate a correction offset between the sender and receiver. From this we can adjust the current game time to the game time on the sender and extrapolate to find the predicted location.



Getting an object

Once a machine has created a PoP, it will start receiving packets containing data about objects in its view and the context of the database will begin to synchronise. The level of synchronisation will vary from place to place.

The database would provide a form of callback to signal the arrival of a new object or some major change in its state.

Ownership of an object will be held within the database. Unless locked on to a machine by the application, the object would be moved around by the database, with the help of hints from the application (such as “I am dog fighting object 47”). If 47 is an unlocked object on another machine then it will be moved locally and local AI would take over using the workspace moved with the object.

The database would move objects around to minimise bandwidth and latency. This requires the application to process the database rather than to rely on its own copy of the object data.

void *GetObject(ID,Boolean *Owner);

DBError PutObject(ID,void *);

When an application gets an object, it is returned a Boolean indicating if it owns it or not.

If it owns it then at some time it must either run the AI for the object or use the player’s inputs to move it, before putting it back into the database.

If the application is not the owner, then the database will already have extrapolated its location and the application need do nothing else but plot the new location.

Networking.

There is often an underlying network layer. Once the Database has decided what data needs to be sent and to whom. This has the job of getting the data to the other parts of the database.

The game portions of the application need to know nothing about this area of code.

Some items need a more direct route. Sending a text message to another player is not possible via the Database, though it would be possible to do a broadcast.

Summary

We can use an interface like this to reduce the amount of bandwidth required by a game, although we will never have enough bandwidth at our disposal.

In the flight simulations that have been developed, we see a bandwidth usage curve like the following shown below:

The runtime level is related to the number of machines in the game, but it is not a linear relationship. It is limited by the physical proximity of the objects in the world. If you have a 200-player game, objects will not all be in the same place, and as an object's update is dependent on separation, a machine uses its send bandwidth to update machines with objects in close proximity to it. Those machines will also occupy the download bandwidth with their updates.

Each machine will have a focus around itself and will use a large proportion of its bandwidth updating and being updated by a few machines with objects in close proximity. This is only true if we have multicast support.

Multicast will bring with it a whole series of problems if it is to be exploited properly. Some very hard bargaining will need to be done when weighing up processor and memory costs against bandwidth and a compromise will have to be reached. Multicast does offer the possibility of virtually unlimited numbers of players in a game, even on systems with relatively low bandwidths, without the need for game servers.


Cost

The cost of not developing a system like this is that a networking system needs to be developed every time a new game is written. This is obviously expensive and is guaranteed to have more bugs than a matured system. It impacts on game development in that a new API has to be integrated every time. All this adds to development costs.

I personally believe that using a database model and designing a “net-centric” game is the best way to design a single-user game.

The flexibility of the game is increased when it has to deal with actions of wetware rather than its own AI.

Having the database layer between the game and the network allows almost transparent additions of new low level drivers the system with less aggravation than implementing them straight into the application. Correctly implemented, another transport layer is simply another DLL.

Exploiting

A system working using the database model is not tied to scenarios devised at set-up. A scenario may be set up any way. When a game joins the scenario, the data is trickle-fed to it, in order of importance. The alternative is transferring a single monolithic chunk that would saturate the network every time someone joined the game.

This will allow the creation of server-based scenarios as either competitions with prizes or scenarios that are more realistic and the charging of premium rates.

The server side would hold onto the majority of AI-driven objects. The clients would then be free to update only the object the player was controlling or objects requested from the server. Should a machine drop out, less rearranging needs to be done.

More Support from providers.

In order to maximise the potential of these systems we need from providers:

Multicast support: without it we either overload upload or download bandwidth.

Timebase: None of the providers gives an adequate means of determining the age of a network packet with sufficient accuracy. At 1333 ms-1 an SR71 moves 27 meters in a clock tick. Therefore, if the timing is off by 1/50s, the aircraft is positioned wrongly by 27 meters. The view from two machines will be out by 54 meters. Using the provider's system as the reference best solves this problem.



CONCLUSION

I have proposed a number of realistic solutions to the bandwidth problems faced by many larger on-line gaming systems. These solutions are of particular interest in the field of flight or space simulations, and might help avoid the plethora of problems developers have faced in those fields.

John Bradley April 1998.


Comments

Popular posts from this blog

Interrupted

Clone

ACE3NOKB V1