Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (773)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  10 Player(instanced) 3D Game, would TCP Suffice?  (Read 9310 times)
0 Members and 1 Guest are viewing this topic.
Offline CTucker1327
« Posted 2014-07-15 22:31:03 »

I've been doing a lot of research on TCP/UDP/RUDP lately and most of it is because my friend who is a Unity freak is near-completion of this MoBA(Multiplayer online Battle Arena) single-player prototype and has asked me to work on the server-side of the networking while he writes the Client-API. I told him that I was up to the challenge, mostly for a learning experience, but helping him out was definitely on my mind. I'm fairly familiar with standard IO TCP Networking, however the problem with that is the Standard IO is blocking, so I would have to study on some NIO Libraries, (Looking at you, Netty). However, some-people have stated that I would be better off using UDP/RUDP.

The problem I've found during my studies with UDP/RUDP is the way that messages will occur. Considering we're going to be working on an authoritative server approach, it's fairly important that things like movement/item activation arrive. In the order that you activate them. For instance, if a player uses an healing item, then an ability that takes 1.5 seconds to cast. If the ability is casted before the item is consumed for some reason (Typically because of UDP Packets not being ordered) it could cause death, and players screaming "Glitches, Fix them." -- This would lead me to stare at the TCP Connections; However then I would be dealing with Latency problems from my studies. However anything under 200 Latency should be fine for this type of game, and we're not really expecting people from across the world to play without the expectation of a little lag.

So this brings me down to the question... For this particular application:
  • Handles all users connected - Users not in game don't transfer any data besides for chat, if being used.
  • Players in a game (Instanced, each game will have its own game-thread) will be moving around constantly in a 2D Environment (3D world using 2 axis')
  • Ordered arrival of packets is required
  • Losing Data is a Critical problem.

The only reason I'm really asking this question is because of the use of Reliable UDP which crosses out the "Losing data" issue, from my understanding, which makes this a question worth asking.

Sorry, no pictures of the game yet Wink
Offline tkausl

Junior Devvie

Medals: 3
Exp: 5 years

« Reply #1 - Posted 2014-07-16 07:50:35 »

If the packets have to arrive in correct order, you should really use TCP, even if its slower then UDP. If you have some data which sometimes can get lost while the game is still playable, you can use 2 connections (UDP and TCP) to handle both, important and unimportant Data (Unimportant may be position-data if you would send them multiple times a second).

If you try to use UDP and still want to get all the data in correct order you will find you implementing a new stack on top of UDP which WILL BE slower then TCP if youre not an professional programmer with excellent networking experiences.

So long answer short: Go with TCP and if its kinda slow try to think about which data you really need and which is just stuff you could calculate yourself on each client.

My English isnt that great. Correct me, if you want, im still learning this Language Smiley
Offline Oskuro

JGO Ninja

Medals: 77
Exp: 10 years

Coding in Style

« Reply #2 - Posted 2014-07-17 03:26:48 »

10 players? Battlefield 1942 could support 64 players, and I recall games with something between 16 to 32 players not being that rare.

I'm not sure why the average playercount has gone down as sharply as it has in later years, but my guess is that the main bottleneck is in the amount of data.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CTucker1327
« Reply #3 - Posted 2014-07-17 03:34:58 »

10 players? Battlefield 1942 could support 64 players, and I recall games with something between 16 to 32 players not being that rare.

I'm not sure why the average playercount has gone down as sharply as it has in later years, but my guess is that the main bottleneck is in the amount of data.

Well, the thing is the (10 players) is instanced. So there could be 72 people connected, and only 40 of them are "In a game" the other 32 would just be idle connections, possibly using chat if nothing else. I'm fairly familiar with TCP becuase I've done custom frameworks for Runescape emulators in the past that could hold the 2,000 player cap that Runescape has with ease. The thing with the RSEmulator is though, the movement was so basic. All you had to do was send to the server the tile you wanted to go to, and the server would say yes/no or "well, not there, but here" and then tell the client where to walk. It was nearly impossible to desynch from the client because you walked a steady speed going through tiles per tick, meaning it could all be calculated.

I mean yeah, if you altered your client to move around different than the server did, then obviously you wont be updating correctly.

--- All in all, I'm not expecting this project to much over 7-800 players (And that's being ridiculously generous). However; I want it to feel like it's done right.

Is there an easy way to make a UDP Socket belong to a TCP Socket? Or perhaps I'm underthinking it. I could create a session class that would hold the players connection to the game. Then from there I can connect UDP. The only thing is knowing which TCP client the UDP packet came from.. Could't you just spoof packets and make other people do whatever you wanted with this?

""From there I can connect UDP"" --- Sorry, I just woke up. LOL
Offline PandaMoniumHUN

JGO Coder

Medals: 32
Exp: 3 years

White-bearded OGL wizard

« Reply #4 - Posted 2014-07-17 06:59:42 »

I'm not sure why the average playercount has gone down as sharply as it has in later years, but my guess is that the main bottleneck is in the amount of data.
@derail on:
It didn't go down. There's still quite a few games where 12+ players play together and in Battlefield games 64 players is still supported (and quite often those 64 slot servers are full).
In Guild Wars 2 WvW there are lots of ~50v50 player battles, same in WoW a few years ago (not sure about now, haven't played in a while).
There are Minecraft servers out there with 100+ slots and some of them really does have 100+ active online players.
I guess it was rather the style of the games that changed, they require more teamwork and strategy which is really hard to do when you try to command 31 people in your team. Smiley
@derail off

My Blog | Jumpbutton Studio - INOP Programmer
Can't stress enough: Don't start game development until you haven't got the basics of programming down! Pointing
Offline Abuse

JGO Ninja

Medals: 70

falling into the abyss of reality

« Reply #5 - Posted 2014-07-17 09:39:20 »

If you have client side prediction, you'll be able to get away with the latency spikes inherent to TCP's packet retransmission method.

If you're doing lockstep without prediction, you'll need UDP. Instead of retransmission, have redundancy through duplication; every packet sent by the client contains everything that occurred since the last ack.
Pages: [1]
  ignore  |  Print  

EgonOlsen (1855 views)
2018-06-10 19:43:48

EgonOlsen (1882 views)
2018-06-10 19:43:44

EgonOlsen (1250 views)
2018-06-10 19:43:20

DesertCoockie (1682 views)
2018-05-13 18:23:11

nelsongames (1348 views)
2018-04-24 18:15:36

nelsongames (1967 views)
2018-04-24 18:14:32

ivj94 (2737 views)
2018-03-24 14:47:39

ivj94 (1940 views)
2018-03-24 14:46:31

ivj94 (3030 views)
2018-03-24 14:43:53

Solater (1081 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!