Grand Prix
Garage - GPL
The workings of
GPL Online - Part 1
(Below is a general discussion
of the topic. See the part
2 for all details, especially when you
host races.)
The limitations of
the Internet
When the Internet is used as a medium to race online against
each other, there are limitations in terms of bandwidth and
latency. The available bandwidth, the amount of data that can be
transmitted between participating computers, is limited. Latency,
the time it takes to transmit data from one computer to another
and back, can be high and irregular at times.
GPL copes with these limitations in the following ways:
- In order to reduce bandwidth
requirements, not all cars are shown to all clients.
Only the server can see all other cars. Using the default
core.ini settings, clients will see 4 cars in front and 1
car behind. This can lead to cars seemingly disappearing
and appearing on the track as positions change.
- In order to account for latency,
GPL predicts where a car has travelled in the time
it took the data describing that car to reach the client.
This can lead to slightly different positions being shown
for the same car on its own client, on the server, and on
the other clients where it is shown.
The consequences
for racing
In normal, moderate conditions, good racing is possible
despite the limitations of the Internet. There are a number of
situations however, where these limitations play an important
role in the events:
- Start of the race. At the
start of the race, when all cars are close together, the
limitation of seeing 4 cars in front and 1 behind makes
that you can't see cars that are close by. Especially
when there is a crash in front of you and you pass the
crashed cars, suddenly other cars may appear in front of
you (and they may not be moving as fast as you...). Also,
a car may suddenly appear close behind you when it passes
the car that was behind you until that point.
My online grids can help
avoid big crashes at the start.
- Being lapped. When you get
lapped, or when you leave the pits to qualify, and two or
more cars are lapping you, you won't see or hear the
second car until the first one has passed you. The second
car can suddenly appear very closeby.
Braking.
When a car brakes, the computer signals this to the
server and from there to the other clients. Due to
latency, the other computers won't know of this for some
time (typically 100 to 500 ms, maybe more). So on the
other systems, the braking takes place later, and the car
is further ahead than on its own system. This goes the
other way around as well: other cars seem to be further
ahead on the local system than on their own when they
brake. The result is that when one car chases another,
under braking the car behind sees a greater distance to
the car in front than the car in front sees to the car
behind. So when the car behind brakes as late as one
would normally do when racing against the ai cars, he
will hit the car in front. Maybe not on his own system,
but on the front cars system, where the distance is less,
he will! When the car in front crashes, it may take out
the car behind as well. So the lesson is to keep a bit
more distance when racing online, or take an alternative
line.
The view of the car in front is in black, the
view of the car behind is in red. To the car in front, there
is less distance between the two than to the car behind. The
effect of the prediction mechanism is shown exaggerated by
the broken straight lines.
- Together through a corner.
When going side by side through a corner, an effect
similar to what happens under braking may occur. Because
prediction assumes a straight line, each car will be more
to the outside on a remote system than on its own system.
This too works both ways, with the result that the car on
the inside will see more space between him and the other
car than the car on the outside will see. It is therefore
possible that the car on the outside experiences a hit by
the car on the inside, while the car on the inside sees
no hit at all. He will be able to see the outside car act
according to the hit, but as far as he can tell, it was
not him that caused it. The lesson is be careful when
you're on the outside of a corner.
The view of the car with the inside line is in
black, the view of the car with the outside line is in red.
To the car with the inside line there is a greater distance
between the two than to the car with the outside line. Again
the effect of the prediction mechanism is shown exaggerated
by the broken straight lines.
- Bad connection. The
predictions GPL makes about other cars are corrected all
the time when more recent data arrives. Normally the
corrections are so numerous and small that they go mostly
unnoticed and the motion seems to be smooth and
continuous. When prediction has to cover a greater gap,
due to a bad spell in the connection, the corrections
will be greater. The cars will behave jerky, jump across
the track (warping) or even disappear completely an
reappear later (winking out). When you see only one car
behave like this, it's probably his connection to the
server that has gone bad. When you see all cars jerking,
warping or winking out, including the car of the server,
it's probably your own connction that has gone bad, or
the server has a problem, either on its machine or its
connection to the Internet.
- Watching an accident. During an accident, a car's velocity and
direction change fast and abruptly. This is a problem for
the prediction mechanism. As a result, the car will
appear to move about wildly and it will often be shown in
a place where it is not, appear to be stuck half in the
ground or an object, and so on. So be prepared for the
car to warp at any moment, hopefully not in your way.
- Overlapping cars. When a
predicted position of a car is corrected, it may be
placed in a position where it overlaps with the local
car. When this happens, a very violent accident may
occur, that has no relation to the speed of the cars at
that time. For an artificial example, see my expoding grid. The better the
connections of all clients to the server, the less likely
these violent collision are to occur.
More details on bandwidth, latency and the related core.ini
parameters can be found in part 2.