• Create Account

## Peer to Peer Online Game

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

12 replies to this topic

### #1Butabee  Members

274
Like
0Likes
Like

Posted 08 June 2014 - 12:51 AM

I was thinking about making a game that uses peer to peer networking. There would be no PvP or trading to minimize the effects of cheating for players that don't want to cheat. I would have a built in system to cheat if a player wanted to. Each player would be responsible for all data relating to them. Stats, hp, items, etc.

NPC spawning and such would be deterministic and should behave the same on all systems, unless a user fiddled with the NPC system, which I no doubt some people would. Not sure what I'd do in that case. Maybe just check to see if the player is in range of certain npcs to apply damage and things to npcs on other users systems.

Making a central server to handle NPCs kinda defeats the purpose of a peer to peer system.

What do you think? Could it work?

### #2hplus0603  Moderators

10581
Like
0Likes
Like

Posted 08 June 2014 - 09:50 AM

Are you intending for an online RPG play style? Kind of like Phantasy Star Online? Or do you want a single, shared, persistent world instance?

There's been a lot of research in this area. The VAST library/project is one that might be interesting if you're going to try for a large, shared world.

For smaller game instances, you could just have a player "host" and other players "join," and support host migration if the first player stops; that would let NPC spawning be controlled by the host to allow for better gameplay -- being 100% deterministic in spawning (without involving player decisions) is actually really hard; what if some players are fighting a mob when it's supposed to also re-spawn?

The other question in P2P is how the players will find each other on the network. I start the game, and want to play with some friends -- how do I get in contact with them?

enum Bool { True, False, FileNotFound };

### #3Butabee  Members

274
Like
0Likes
Like

Posted 08 June 2014 - 01:05 PM

I was thinking that it might not be that bad if npc simulation is not 100% the same on every system. Some players might get some extra loot or something for killing a mob that's not there on everyone's system.

I have an idea where player systems could spawn mobs but on remote systems a single player could only have a few mobs by them spawned at a time. I was also thinking players could ignore mob spawns from remote systems if they wanted to, or maybe set friend ip's that they want to accept spawns from.

I'm thinking the player count could get pretty big. I might have a website where players could post thier ip's to get connected to other players, but once they have those ip's, everytime the game is run it would check to see if it can connect to them. Players that are connected to each other would share ip's.

### #4hplus0603  Moderators

10581
Like
0Likes
Like

Posted 08 June 2014 - 04:48 PM

Some players might get some extra loot or something for killing a mob that's not there on everyone's system.

So what happens when a player tells another player "can you help me with Fippy Darkpaw" and the other player doesn't see that monster?

What kind of gameplay do you need? Why do you need multiple players to talk to each other?

If your website is always online, you could automate the registration of currently-online player instances. Have the game post a message to the website when it starts, and another call to the website to get the list of IPs. Note that you'd have to either set up NAT traversal/introduction, or every player would have to set up port forwarding for this to work, though.

Edited by hplus0603, 08 June 2014 - 04:50 PM.

enum Bool { True, False, FileNotFound };

### #5Butabee  Members

274
Like
0Likes
Like

Posted 08 June 2014 - 08:58 PM

Well it would be for multiplayer PvE. I guess I might have to have a player or server responsible for spawning monsters, and despawning them/getting killed. I just don't want to have to send position updates for all monsters to a lot of players from one machine, so I'd have to come up with a deterministic movement simulation.

### #6hplus0603  Moderators

10581
Like
1Likes
Like

Posted 08 June 2014 - 09:49 PM

I just don't want to have to send position updates for all monsters to a lot of players from one machine, so I'd have to come up with a deterministic movement simulation.

What problem are you actually trying to solve?

I e, can you provide X here? "Right now, PvE multiplayer games suffer because X."
And can you provide Y here? "My solution solves X by doing Y."
enum Bool { True, False, FileNotFound };

### #7Butabee  Members

274
Like
0Likes
Like

Posted 08 June 2014 - 11:11 PM

The problem is not being able to support large amounts of monsters/players in an area at a time while keeping server bandwidth low. Peer to Peer is a solution for that.

### #8hplus0603  Moderators

10581
Like
0Likes
Like

Posted 09 June 2014 - 09:22 AM

The problem is not being able to support large amounts of monsters/players in an area at a time while keeping server bandwidth low.

Is that a problem anyone actually has?
Why does server bandwidth matter?
Is this a problem *you* have?

Peer to Peer is a solution for that.

That's yet to be shown, and there's some evidence to the contrary. Specifically, peer-to-peer grows as N-squared per client, whereas client/server grows as N per client, and N-squared only on the server.
enum Bool { True, False, FileNotFound };

### #9Butabee  Members

274
Like
0Likes
Like

Posted 09 June 2014 - 02:45 PM

What is your solution for handling large amounts of active entities in an area for client/server? Suppose there are 100+ players and 100+ mobs in an area in an action game, what would you do to keep server bandwidth low as possible? And what would be your projected server bandwidth, for only movement?

Peer to Peer may grow more in total data transfer per new user but it only grows by N for data that has to be handled for a single user. One more user to send/recieve from.

Edited by Butabee, 09 June 2014 - 03:00 PM.

### #10hplus0603  Moderators

10581
Like
0Likes
Like

Posted 09 June 2014 - 07:51 PM

what would you do to keep server bandwidth low as possible? And what would be your projected server bandwidth, for only movement?

First, why are you so worried about low server bandwidth cost? Once your game is of any reasonable size, you'll be paying $2 per megabit per second per month inside some co-location facility if you want cheap bandwidth, or$8 per megabit per second if you want fancier bandwidth. That's something like $0.0008 per gigabyte of data. Second, the actual numbers: If this is a RPG, you'd do interest management, where perhaps 10 players and 10 mobs would be of high interest, and sent perhaps 2 times per second, and 90 mobs and 90 players would be of low interest, and sent perhaps once per 5 seconds. (This is based on WoW-style RPG play mechanics.) Let's say that id + position + velocity + target + facing is about 12 bytes per entity. So, this is 10*12*2+90*12*1/5 == 792 bytes per second per player. 79 kB/s for 100 players. Not something I'd worry about on the server side. Let's consider a MMOFPS, where you'd need your high-interest entities at 20 pps and your low-interest at 5 pps; you'd get 10*12*20+90*12*5 or about 7.8 kB/s. 100 players make that 780 kB/s -- you're at about ten megabits per second at that point. Now, count packet overhead. In P2P, each player sends data to each other player, so each player sends at least 198 packets per second in the P2P case, and receives 198 packets, for RPG, and sends/receives 1998 packets per second in the FPS case. This is a rather high packet rate, that many residential firewalls/routers won't even be able to sustain. Then each packet has overhead -- let's count 32 bytes for framing and IP/UDP headers; that's 64 kB extra in packet overhead per player in P2P. That's almost as much as the entire payload data stream for the server to send data to all players! Even a super-expensive bandwidth provider like Amazon EC2 charges less than$0.10 per GB per month (which translates to about four hours of payload for the hypothetical worst-case FPS gameplay session above.)

Peer-to-peer: Okay for distributed bulk file sharing; usually not the right answer for game networking.
enum Bool { True, False, FileNotFound };

### #11Butabee  Members

274
Like
0Likes
Like

Posted 09 June 2014 - 09:58 PM

I wasn't considering packets per second. I was only looking at the bit rate. I guess peer to peer won't work for any large scale miltiplayer action game.

### #12snacktime  Members

393
Like
0Likes
Like

Posted 09 June 2014 - 11:24 PM

There are all sorts of problems with using peer to peer for this kind of thing.  A server that is aware of all the state can optimize all kinds of stuff that you cannot do with p2p.  For instance what if you only want information on objects within a certain radius?  A server that knows where everyone is at can just send you what you want, p2p wouldn't be able to do that.  And then you get into who do you sync against and how, and all sorts of other problems that are fairly straight forward with a server, but really hard with p2p.

The problem with just comparing a simple theory of which method is more bandwidth efficient completely ignores the fact that one of the methods simply doesn't require sending as much data to solve the same problem.

The wall you always hit with games like this is client bandwidth (and to some extent latency they go hand in hand).  Every other problem is basically solved, but you hit the bandwidth/latency wall so fast that you never even get a chance to see how far you could push everything else.  Using p2p just means you will hit that wall much faster.

I'm not saying it wouldn't be fun to play around with, but I just don't see how you could ever overcome some of the obstacles there, or even if you did how it would be better then server authoritative.  It's one of those things that sounds cool but in practice just doesn't work well.

### #13hplus0603  Moderators

10581
Like
0Likes
Like

Posted 10 June 2014 - 09:55 AM

The wall you always hit with games like this is client bandwidth

Actually, in my experience, the wall you hit with "massive" online games (and even not-so-massive ones) is all the content you have to build. You could have a working engine and networking setup handed to you on a platter, and building a game is still a significant challenge!
enum Bool { True, False, FileNotFound };

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.