Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (767)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (854)
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  
  Easy and Fast UDP Gaming Library - is there a need for it?  (Read 9461 times)
0 Members and 1 Guest are viewing this topic.
Offline klaus
« Posted 2015-07-14 20:07:21 »

For our upcoming game www.asteroidfight.com I put a lot of effort into making a well-documented library which has an easy API for fast and reliable UDP communication and can use different serialisers (kryo) and other networking libraries (netty) as well as java-only.

The library is specifically designed for games and I also plan to integrate the logic for lockstepping and client-side-prediction - depending on your type of game you can choose the technology you want to use. Also an out-of-the box general-use lobby server (written in kotlin though) will be included.

I'm in a little bit of a dilemma here. Brief background information: I quit my day job to develop games on my own Wink Hence no money for me right now and living of of my savings. Now the idea came to me to put even more work into this library and try to sell it as a product. But on the one hand, I don't know if there is a market for it and on the other hand I would gladly give something back to the open source community.

It would be perfect to even combine the two: open source the library and make money of of it. (maybe dual-licensing? idk)

Well, any thoughts on that?
Offline KudoDEV

JGO Ninja


Medals: 79
Exp: 6 years


Game Dev Hobbyist


« Reply #1 - Posted 2015-07-14 20:11:37 »

It would be cool to see a lightweight TCP server/client library.

That simply manages the multi-threading of the selector and worker threads. Other libraries are awesome and all but have too much going on the backend for me.

I started working on one but I'm too busy with other things for my game at the moment.

Offline noctarius

JGO Knight


Medals: 61


Manager Developer Relations @Hazelcast


« Reply #2 - Posted 2015-07-15 10:11:51 »

Maybe tengi is of interest for you, still in development but Java server and client are working: https://github.com/noctarius/tengi

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline klaus
« Reply #3 - Posted 2015-07-16 09:34:51 »

It would be cool to see a lightweight TCP server/client library.
What exactly would you like better in a TCP library compared to an UDP library?
Offline KudoDEV

JGO Ninja


Medals: 79
Exp: 6 years


Game Dev Hobbyist


« Reply #4 - Posted 2015-07-16 12:25:56 »

I need the reliability of a tcp connection.

However, I've already started to implement Java NIO into my game dev suite.

Offline klaus
« Reply #5 - Posted 2015-07-16 12:31:39 »

Well, maybe I made this not clear enough, but my library allows you reliable and in-sequence transmission of packets.  Smiley

You can use different strategies to achieve this. The most bandwith-saving would be the sequence numbers, but you can also use acknowledge packets.
Offline KudoDEV

JGO Ninja


Medals: 79
Exp: 6 years


Game Dev Hobbyist


« Reply #6 - Posted 2015-07-16 13:42:57 »

UDP is connectionless and does not guarantee that the data will arrive. And if it does arrive it will most likely be out of order.

So I guess I'm interested in seeing how you accomplish this.

Offline Opiop
« Reply #7 - Posted 2015-07-16 13:45:29 »

There are many ways to build a thin layer on top of the UDP client that actually sorts and keeps requesting packets until they are received just like a TCP based client. As far as I know, Kryonet utilizes one.
Offline Soulfoam
« Reply #8 - Posted 2015-07-16 14:48:46 »

UDP is connectionless and does not guarantee that the data will arrive. And if it does arrive it will most likely be out of order.

So I guess I'm interested in seeing how you accomplish this.

There are a boat load of ways to do this man.

The REAL problem is implenting it as good as TCP does (when making it into a library for other people to use). You can pretty easily make your own little reliablity layer of UDP that suits your needs specifically to what you are working on and make it work well, but to actually make it good enough for other people to implement with their projects is a challenge.

@OP, I would run some benchmark tests on your reliablity layer and see how it matches up with TCP.
Offline KudoDEV

JGO Ninja


Medals: 79
Exp: 6 years


Game Dev Hobbyist


« Reply #9 - Posted 2015-07-16 14:55:19 »

I know it's possible. But is the overhead of transporting extra data and processing worth it?

Ultimately, I feel that the speed increase would be negligible.

Also, how can you tell if you missed a packet, without some crazy work around?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Opiop
« Reply #10 - Posted 2015-07-16 14:57:37 »

For your last question; timestamps or a variable included in the packet to indicate which packet number it is.

For your other questions, many game engines and major games use a UDP system with a TCP layer on top. It's definitely worth it in some cases.
Offline KudoDEV

JGO Ninja


Medals: 79
Exp: 6 years


Game Dev Hobbyist


« Reply #11 - Posted 2015-07-16 15:01:12 »

Alright you guys win.

I just don't need that kind of speed. Tcp tends to do it for me.

But I guess in AstroidFight and SoulFoam's game the shaved milliseconds makes a huge difference.

Offline Soulfoam
« Reply #12 - Posted 2015-07-16 16:27:02 »

Alright you guys win.

I just don't need that kind of speed. Tcp tends to do it for me.

But I guess in AstroidFight and SoulFoam's game the shaved milliseconds makes a huge difference.

The queing of packets is the reason I use UDP. My game is pretty fast paced, so the slight stutters TCP COULD cause would be pretty detrimental to gameplay. Slight stutters to other games that aren't fast paced won't even be noticeable really.

TCP works for 99% of everything, it really comes down to YOUR GAME's needs.
Offline klaus
« Reply #13 - Posted 2015-07-16 16:27:42 »

@KudoDEV: of course it strongly depends on what game you're making. But if you want fast paced action and be packet-loss tolerant then I'd suggest you use UDP with a custom reliability layer.

Glen Fiedler wrote a nice article about this: http://gafferongames.com/networked-physics/deterministic-lockstep/

If you don't want to read the full article scroll down to the fourth animation (counted from the top). In this example he uses deterministic lockstepping (like Asteroid Fight does) and compares the UDP + reliability layer to the TCP version. With increasing latency and packet loss TCP will perform increasingly worse compared to UDP.

Also, how can you tell if you missed a packet, without some crazy work around?
You don't need a crazy workaround. Like Soulfoam said, there are a few ways to accomplish this. Right now in my library you can decide if you want to use a sequence number for ordered, reliable transmission or ACK packets for reliable transmission (without the ordering).

With a sequence number a missing packet is easily detected. So if peer1 sends 1,2,3,4 and peer2 receives 1,2,4 it will buffer message #4 and ask peer1 to re-transmit message #3.

With an acknowledge packet the sender sends the message and wait for the receiver to acknowledge the receipt of the message. If this doesn't happen after X ms it will just retransmit it again, until the message is acknowledged.

And there are more ways to do it. Also a combination of the 2 mentioned here. Usually a sequence number will be all what you need. ACK packets increase the bandwith usage.

@Soulfoam: No, I don't need to be as good as TCP, because the library is designed specifically for something else than TCP. If I'd need TCP then I wouldn't implement it another time, but just use it.

But I agree with you that I should make benchmarks to compare my library against TCP Smiley This will yield some interesting numbers for sure Smiley
Offline gouessej
« Reply #14 - Posted 2015-07-17 14:21:22 »

Have you really looked at tengi (noctarius' suggestion)? It implements SCTP, it would be far better than driving UDP more reliable by yourself.

Both Tengi and Kryonet are interesting for me, I wouldn't create yet another network library.

Julien Gouesse | Personal blog | Website | Jogamp
Offline noctarius

JGO Knight


Medals: 61


Manager Developer Relations @Hazelcast


« Reply #15 - Posted 2015-07-17 14:23:32 »

It doesn't yet implement it but it is on the roadmap. Unfortunately I think there is not yet any experience to use it on WAN systems but it'll also feature RUDP and TCP transports. The main idea is to find the best transport possible between server and client.

@TO: Sorry doesn't wanted to hijack your thread.

Offline klaus
« Reply #16 - Posted 2015-07-17 18:40:18 »

@noctarius: No worries - it's related, so it really is ok.

The features and the API look interesting, but it is designed for a lot broader purpose than what I intend. My library has a very specific use-case to which it can be optimized and for which it works well. That doesn't mean tengi wouldn't perform well in the specific game context, but it would probably need more work to fit better for gaming purposes.  Smiley

I will have a look at tengi.  Pointing
Offline noctarius

JGO Knight


Medals: 61


Manager Developer Relations @Hazelcast


« Reply #17 - Posted 2015-07-17 19:53:37 »

Cool I always look for interested people Smiley Feel free to contribute too ;-)

Pages: [1]
  ignore  |  Print  
 
 

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

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

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

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

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

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

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

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

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

Solater (798 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
java-gaming.org 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‑gaming.org
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!