Java reliable UDP

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

PS Maybe you can offer a technology that will be more productive for working with such a task (game server)? But this should work on Linux.

Edit: This is an action type game, so you need to talk to the server as quickly as possible.

Edit 2: I found Enet that was used to play FPS, but this is C ++, will there be overhead if I call it many times per second?

+6
source share
5 answers

You may find that you do not need reliable messaging for all types of messages. For example, if you repeatedly send the status of things like players, and several packages are lost, it may not even matter.


There are reliable, high-performance, UDP-based libraries that support Java. One of them is 29West LBM. It is not cheaper because it is very difficult. Even with a professional product, you may need a dedicated UDP network to minimize losses.

For the purposes of the game, I suggest you use a JMS service, such as ActiveMQ, which works wherever you can run Java. You should be able to send 10 thousand messages per second with a delay of several milliseconds.


When people say that something should be as fast as possible, it can mean anything. For some, this means 10 ms, 1 ms, 100 ms, 10 ms, 1 m. Some network routers support packet transmission with a delay of 600 ns. The lower the latency, the higher the cost and the greater the impact on the design. Assuming you need more speed than you need, this can affect the design and costs unnecessarily.

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

+2
source

These are the libraries / frameworks I know about this, something like reliable UDP:

  • Reliable Mobile UDP (MR-UDP)

    MR-UDP aims to provide reliable UDP-based communications from / to mobile nodes (MNs) at the lowest possible cost. It extends the Reliable UDP (R-UDP) protocol with mobility-compatible features such as inter-terminal connectivity, firewall / NAT bypass, and reliability for switching IP addresses or network interfaces (e.g. Cellular to WiFi and vice versa) .

  • UDT-Java
    Java implementation UDP data transfer (UDT)

    UDT is a robust UDP-based application layer data transfer protocol for applications with high-bandwidth data distribution in broadband high-speed networks. UDT uses UDP to transmit bulk data using proprietary reliability and congestion control mechanisms. The new protocol can transmit data at a much higher speed than TCP. UDT is also a highly customizable framework that can accommodate various congestion control algorithms.

  • JNetRobust

    Fast, reliable and non-intrusive communication-oriented virtual network protocol for JVM 1.6+.
    It is between the transport and application layer.
    Specifications:

    • reliability of transmitted data
    • unapproved data available immediately.
    • the packet is larger than the UDP packet, but smaller than the TCP packet
    • flow control
    • lack of congestion control

Disclaimer: I am the author of JNetRobust, it is new and still in alpha.

+4
source

There is a Java version of the RUDP protocol (reliable UDP) (RFC908, RFC1151)

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

+3
source

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

+1
source

UDP is by definition not a reliable service. This does not guarantee a high quality service. However, you can use TCP .

-2
source

Source: https://habr.com/ru/post/891706/


All Articles