简体   繁体   中英

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?

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 (eg 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.

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

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

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.

Libjitsi has SCTP over UDP, which breaks everything up into packets like UDP but guarantees reliable delivery, like TCP. See https://github.com/jitsi/libjitsi/blob/master/src/org/jitsi/sctp4j/Sctp.java

UDP is by definition not a reliable service. It does not guarantee a high quality of service. You can, however, use TCP .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM