Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java reliable UDP

Please suggest java library, that implements reliable udp. It will be used for a game server to communicate to clients and to other servers.

PS Maybe you can suggest tech that will be more productive to work with for such task(game server)? But this must work on linux.

Edit: It's an action type game, so it needs to talk to server as fast as possible.

Edit 2: I found Enet which was used for a FPS game, but it's C++, will there be an overhead if I call it many times a second?

like image 868
Viktor Avatar asked Jun 30 '11 08:06

Viktor


3 Answers

These are the libraries/frameworks I know of that implement something like reliable UDP:

  • Mobile Reliable UDP (MR-UDP)

MR-UDP aims at providing reliable communication based on UDP from/to mobile nodes (MNs), with least possible overhead. It extends a Reliable UDP (R-UDP) protocol with mobility-tolerating features, such as the ability to handle intermit-tent connectivity, Firewall/NAT traversal and robustness to switching of IP addresses or network interfaces (e.g. Cellular to WiFi, and vice-versa).

  • UDT-Java
    Java implementation of UDP-based Data Transfer (UDT)

UDT is a reliable UDP based application level data transport protocol for distributed data intensive applications over wide area high-speed networks. UDT uses UDP to transfer bulk data with its own reliability control and congestion control mechanisms. The new protocol can transfer data at a much higher speed than TCP does. UDT is also a highly configurable framework that can accommodate various congestion control algorithms.

  • JNetRobust

Fast, reliable & non-intrusive message-oriented virtual network protocol for the JVM 1.6+.
It resides between the transport and the application layer.
Characteristics:

  • reliability of transmitted data
  • received, unvalidated data is available immediately
  • the package is bigger than UDP's package, but smaller than TCP's package
  • no flow control
  • no congestion control

Disclaimer: I'm the author of JNetRobust, it's new and still in alpha.

like image 181
mucaho Avatar answered Oct 10 '22 05:10

mucaho


There is an java implementation of RUDP (Reliable UDP) protocol (RFC908, RFC1151)

http://sourceforge.net/projects/rudp/?source=dlp

like image 45
Oliver_Vienna Avatar answered Oct 10 '22 03:10

Oliver_Vienna


You may find you don't need reliable messaging for all message types. For example, if you are repeatedly sending the status of things like players, and a few packets are lost it may not even matter.


There are reliable high performance UDP based libraries which support Java. One of these is 29West's LBM. It is not cheaper because it is very hard to get this right. Even with a professional product you may need a dedicated network for UDP to minimize loss.

For the purpose of a game I suggest you use a JMS service like ActiveMQ which runs wherever you can run Java. You should be able send 10K messages per second with a few milli-seconds latency.


When people say something must be as fast as possible, this can mean just about anything. For some people this means 10 ms, 1 ms, 100 us, 10 us, 1 us is acceptable. Some network routers support passing packets with a 600 ns latency. The lower the latency the greater the cost and the greater the impact on the design. Assuming you need more speed than you need can impact the design and cost unnecessarily.

You have to be realistic seeing that you have a human interface. A human cannot respond faster than about 1/20 of a second or about 50 ms. If you keep the messaging to less than 5 ms, a human will not be able to tell the difference.

like image 31
Peter Lawrey Avatar answered Oct 10 '22 04:10

Peter Lawrey