Networked Physics

ewjordan wrote:
For competitive games this could be a problem, so you have to try and address cheating in another way - Mercenaries 2 is coop, so it wasn't as big a deal.

Could be worth trying with Box2d - for smaller games, you might not run as high a risk of having cheaters hack your client, so you could get away with trusting the client a bit more.


Do you think this is an unvaoidable problem with this approach?
Maybe the server could reject some (possibly cheated) of the client's prediction and resimulate it it's own way?
I'm not sure. The problem with the server potentially rejecting any client side claims is that it then has to do the roll-back and re-simulate every time it rejects an update, which (as Erin pointed out) can get really expensive if the client is touching something like a small pyramid or stack - it's one thing to get one frame of physics every 1/60 of a second, it's another to have to resimulate 30 frames within 1 frame of real time. At the very least you'd need to figure out a low cost way to decide if the client is cheating or not (short of a full rollback).

BTW, my extremely short summary did not cover everything in Glenn's talk, so if you're interested in this I definitely suggest you take a look, he goes into a lot more detail about how they did it.

I'm still not sure what the ideal approach is, or if there even is one at this point. I think processors are still a bit too slow to expect to be able to validate, predict, and correct everything, and our networks are too slow to live with the lag (which is always an option, too, one that I'm pretty sure Glenn talks about a bit in the slides), so there has to be some tradeoff somewhere.
ewjordan wrote:
I'm not sure. The problem with the server potentially rejecting any client side claims is that it then has to do the roll-back and re-simulate every time it rejects an update, which (as Erin pointed out) can get really expensive if the client is touching something like a small pyramid or stack - it's one thing to get one frame of physics every 1/60 of a second, it's another to have to resimulate 30 frames within 1 frame of real time. At the very least you'd need to figure out a low cost way to decide if the client is cheating or not (short of a full rollback).

But the server will reject an update only if it looks like the client is cheating - it shouldn't happen very often if you can find a good way how to determine it. The way how you do it is probably application specific - for example when the client generates big velocity on some of his objects, it can be seen like cheating in a game when you need to throw objects to the distance to achieve something. But in other games when these objects are more like decoration it won't matter.

ewjordan wrote:
BTW, my extremely short summary did not cover everything in Glenn's talk, so if you're interested in this I definitely suggest you take a look, he goes into a lot more detail about how they did it.

Ah, so it was your summary I posted?:)
You suggest to look at what? I looked at his slides, but there are not very detailed either...maybe if I saw some of the demos.

ewjordan wrote:
I'm still not sure what the ideal approach is, or if there even is one at this point. I think processors are still a bit too slow to expect to be able to validate, predict, and correct everything, and our networks are too slow to live with the lag (which is always an option, too, one that I'm pretty sure Glenn talks about a bit in the slides), so there has to be some tradeoff somewhere.

And what if we sacrificed some of the precision/speed/number of objects?
Quote:
But the server will reject an update only if it looks like the client is cheating - it shouldn't happen very often if you can find a good way how to determine it. The way how you do it is probably application specific - for example when the client generates big velocity on some of his objects, it can be seen like cheating in a game when you need to throw objects to the distance to achieve something. But in other games when these objects are more like decoration it won't matter.

Right, and that pretty close to how I originally thought this should be done. The problem is that even if it doesn't happen often, it can be very expensive to resolve via rollback, so you might get glitchy. More on this below, though.

Quote:
Ah, so it was your summary I posted?:)
You suggest to look at what? I looked at his slides, but there are not very detailed either...maybe if I saw some of the demos.

Nope, not my summary you posted, I was referring to my super brief summary in this thread. Honestly, the demos didn't explain much that's not in the slides, other than showing the authority passing between objects.

Quote:
And what if we sacrificed some of the precision/speed/number of objects?

The main problem here is that if you only roll back a piece of a stack or something like that, the rest of it might fall over. To roll back the whole stack could be too expensive, and to do it at a bigger time step or something like that could be unstable.

I'm starting to think that the best approach might be the following:

1) Trust the client's results, but perform a basic cheating check on them
2) If you encounter cheating (or massive simulation errors), you probably don't want that client on your server anyways, so just ban them - if your game relies on the clients to give you good results, don't even try to keep the faulty ones around!
3) Once you've banned the cheater, you can do a one-time rollback and resimulate, which will cause a small pause, but you can take that opportunity to tell the other players that someone has just been booted for cheating.

I'm pretty sure Glenn said in his talk that he doesn't think client cheat detection will ever really work right, so if you really need security you need to simulate everything on the server (which means either lag or rollback thanks to latency), but I don't think I agree - in practice, people just go for the easy targets. HL2 Deathmatch is not totally secure, and I think it does a lot on the client, but it's not overrun by cheaters. If you get clever enough with your server side reality checking, you can probably catch a high percentage of the cheats people will try.
ewjordan wrote:
1) Trust the client's results, but perform a basic cheating check on them
2) If you encounter cheating (or massive simulation errors), you probably don't want that client on your server anyways, so just ban them - if your game relies on the clients to give you good results, don't even try to keep the faulty ones around!
3) Once you've banned the cheater, you can do a one-time rollback and resimulate, which will cause a small pause, but you can take that opportunity to tell the other players that someone has just been booted for cheating.

I'm pretty sure Glenn said in his talk that he doesn't think client cheat detection will ever really work right, so if you really need security you need to simulate everything on the server (which means either lag or rollback thanks to latency), but I don't think I agree - in practice, people just go for the easy targets. HL2 Deathmatch is not totally secure, and I think it does a lot on the client, but it's not overrun by cheaters. If you get clever enough with your server side reality checking, you can probably catch a high percentage of the cheats people will try.

Yes, banning will work:) But then you need to tune the cheat detection carefully to avoid many unwanted disconnects:)

A little offtopic: do you think it is currently possible to create an MMO supporting physics, 2D only? Are today's servers powerful enough for it? I don't have any info about it. It doesn't need to be "massive", but there should be more (=tens) players connected at one time in a persistent world. I got an idea of such game and because it would be in space(or somewhere without gravity) there wouldn't be a problem with stacking:) Actually as I think about it, perhaps it wouldn't need any sophisticated tricks at all? If I understood Gaffer well, then why he does these things is because he had problems with stacking and jitter, right?
An MMO with physics is definitely possible, even in 3d - Second Life does it (no idea what methods they use for networking, but I know it's Havok under the hood), and I'm sure more will in the future. I don't know how performance is, as even physics-free MMOs get pretty laggy when you're in crowded areas, and I'm sure adding physics to the mix would make things even worse. But those problems usually arise when you're dealing with about a hundred players within view distance, so you could probably scale it back and do okay.
Hi Guys,

I posted some stuff over here (I hope you didn't mind me quoting you hardwire):

http://www.javagaming.org/forums/index. ... #msg143560

It would be interesting for any of you to join in. 🙂

Keith
Hi Guys,

I've been playing around in this area lately - and have used Box (a managed port) to test my error prediction / sync framework. Its very much alpha quality at the moment, but if anyone is interested in developing multiplayer games using .Net and wants to take a peek: http://entanglar.dunnchurchill.com.

Cheers,
Mark
Playing around at the moment with setting up a networked block dropping game.

Image

It's a bit simpler than most scenarios i think.
It has two separate worlds simulating simultaneously, one for each player, each player sees their own world and the other world side by side, occasionally messages are sent between them, but the worlds are completely isolated from each other.
It doesn't really matter if they become unsynchronised, as long as they're accurate and smooth.
eg. doesn't matter if one world is half a second behind,
as long as what player 2 sees player 1 doing is the same as what player 1 sees themself doing.

They first being by synchronising their random number generators, checking they're both running the same version etc.

I've tried sending the control vectors (vectors controlled by the player which tell their avatar which way to move) every step and not updating the remote simulation until we get the vectors for that step, this is what i do for demo playback and it works, but seems it's far too slow for network.

Which suggests I need to do something differently.

I don't want the server to have to be authoritative, each player should be authoritative for their own world since they're the only one interacting with it, it doesn't make sense for the server to jump in there, i'll just have it check inputs to make sure they're not cheating too much and if they are then send a message to the other player that their opponent may be cheating.

I'd rather not have to send position/velocity data for all the objects because there can be quite a lot of them when the world gets full.
Perhaps only when objects collide it could send correction data to the other player.

Anyone else played with a scenario like this and have any advise on where to go from here?
This is a old post but I figured I'll add a little input to people who want to network box2d into their game.
I dont know if this is the greatest way of keeping the game smooth but this is how I run server > client.

I'm making a top down AS3 multiplayer tank game with box2d.
I setup a time step for all of the objects so they stay in sync with the Delta time.
All objects that are "awake" send their data to the server.
I use a combination of exact and deterministic approach.
For every 5 updates, only 1 update sends the exact data.

Exact Data:
Sends (xpos, ypos, rotation, linear velocity and angular velocity)

Deterministic Data:
Sends (xpos, ypos)
On the client, to determine rotation, I use a vector to get direction from old and new coordinates.
I get velocity by determining the length of that vector compared with time.
I get angular velocity by the rotational direction the object was traveling and is now currently traveling after the update.
Then i just use setXfrom, setlinearvelocity, and setangularvelocity.


That's about as smooth and pretty close to duplicating the physics on each computer.
The rotation sometimes is off by 5 or 6 degrees if you collide with something but it updates after the exact Data is sent.

- Josh

Original thread: https://box2d.org/forum/viewtopic.php?t=143