P2P network programming

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

P2P network programming

Post by B@z »

Hey
Im making a 3 players cooperative game (only a demo tho), and im at the part where i have to integrate the networking.
So before starting the basic server-client networking, i was wondering if i could use p2p networking, like in borderlands.

In borderlands, one person "hosts" the game, but e.g. that host leaves, the game still working, and one other person will become the game master.
So i believe its P2P connection, and it just selects one person to control the game (mobs, the world). And if that person disconnects, other computer takes the control role.

As for network, every user should connect to every user (thats why p2p), sending player specific informations to every connection, also the control role computer sends the basic control informations (mobs, map).

But there comes the problems. Routers doesnt let connections come in, unless they are port forwarded. But i know games (s4 league, and also borderlands), what connects to my pc even if not port forwarded the router. How they do it?

So please point me in the right direction ^^
Image
Image
mager
Posts: 24
Joined: Thu Jul 22, 2010 11:55 pm

Post by mager »

I'm not really sure how you'd go about this, one way would be write a program that will run as a server. Distribute it with the game, and who ever is the host allow people to connect to that server. But the portforwarding im not to sure about it. Find a port that is usually already open i guess?
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

I'm pretty sure things like borderlands etc. have an inbetween server, that acts like a messenger. Your computer sends the information to it, and then it sends that information out to others. If you've ever hosted a game that uses gamespy, that's exactly how they do it.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

hmm i see.
so there is no way to avoid the server-client connection?
Image
Image
mager
Posts: 24
Joined: Thu Jul 22, 2010 11:55 pm

Post by mager »

In WoW Emulation, the only person who needs to forward ports is the server host. Thats how all the big companies avoid port forwarding, the create a server and have everyone connect to it (or multiple servers), your biggest factor is the hosting your server ordeal.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

yeah but wow is an mmo. this is a 3 player coop game. i dont want to make a server what runs always, pay for hosting free, because someone might play it once xD

If no other method, i have to make the server and the client differently...
Image
Image
mager
Posts: 24
Joined: Thu Jul 22, 2010 11:55 pm

Post by mager »

You can get free hosting, or even host it off your computer. In WoW Emulation we would usually host it off of our computer til we could get a dedicated host. But thats just my input, good luck with what you decide.

------------

And I'm pretty sure gamespy would be a good way to do this.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

thats why i said its not wow, not even mmo. it only serves 3 ppl, i wont make a host for it.
Image
Image
mager
Posts: 24
Joined: Thu Jul 22, 2010 11:55 pm

Post by mager »

But i can garuntee that borderlands does the same thing - only it has a room system or something like it where there is a maximum amount of people allowed.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

yeah probably.. thats a bit disappointed me.. so i'm gonna keep the server-client architecture D:
thanks for answers!
Image
Image
loki1985
Posts: 214
Joined: Thu Mar 31, 2005 2:36 pm

Post by loki1985 »

i will write down a few of my recent thoughts about this topic:

i think the most modern approach would be a system combining most of the basic principles which exist today and using different channels for different data depending on the datas priority.

these are 4 different systems used today:

- option 1: the basic system is 1 server for a limited amount of players (like in FPS game servers).

- option 2: a bit more advanced, have a big game world with lots of players, divided in adjacent maps and/or channels, and when moving from one to the other, players can be potentially handed over to another server. this would massively increase possible count of players per game world.

- option 3: this is basically option 2, but with servers which are in the same location and have high speed networking for internal communication (fibre optics), this would make handovers smoother, or even unnecessary sometimes.

option 4: use option 2 (or 3 if possible) and add real P2P networking for data which does not require very low latency or does not need to be known by the game server (e.g. voice, text, file transfers, individual textures and similar). this would require a stable UDP hole punching implementation.


while these ideas are most effective in MMO games and similar, having a simple multiplayer (lets say up to 8 users) CoOp game would also benefit from using P2P connections provided by UDP hole punching in a way which would require the central game server to only mediate connections, thus no heavy server load is created.
Post Reply