Diarkis RUDP

Overview

Reliable User Datagram Protocol (RUDP) is an implementation of UDP communication where data delivery is guaranteed. Diarkis client can use RUDP to transmit data in communication with servers and in P2P communication, ensuring that critical information necessary for game progression is reliably delivered. This page explains the specifications and settings of Diarkis RUDP.

Specifications of Diarkis RUDP

The communication configurations where Diarkis RUDP can be established are server-client and client-client (P2P communication). Some functions are only available in P2P communication.

In Diarkis RUDP, when data is received, an Acknowledgement (ACK) is sent back to inform the sender of successful delivery. If ACK reception is not confirmed within a specified time, the Diarkis client will retransmit the same data. This time period is referred to as RetryInterval on this page. Additionally, if ACK reception is not confirmed even after the specified number of retransmissions, the Diarkis client will disconnect communication due to a timeout. This number of attempts is referred to as RetryMaxCount on this page.

Exclusively for RUDP in P2P communication, there is a sequence ordering toggle feature in addition to guaranteeing data delivery. When the sequence ordering feature is enabled, the order of data received by the application matches the order sent by the counterpart. The Diarkis library will not pass data to the application until packets are received in sequential order. If the sequence ordering feature is disabled, the Diarkis library will deliver data to the application in the order packets are received, which may vary based on network conditions and the presence of retransmitted packets.

In server-client RUDP communication, sequence ordering is always enabled.

Diarkis RUDP Settings

Setting RetryInterval

You can adjust the RetryInterval using the following function:

udp.h
void SetSendRetryInterval(uint32_t minMs, uint32_t maxMs)

RetryInterval starts at the time specified by minMs (milliseconds) and doubles with each retransmission by the client, increasing up to the value specified by maxMs. For instance, if minMs=300ms, maxMs=1000ms, and RetryMaxCount is 5, the RetryInterval will change as follows: 300ms, 600ms, 900ms, 1000ms, 1000ms. If the fifth retransmission times out, the client will disconnect communication.

By exponentially changing the RetryInterval, the network processing load on the client can be reduced. To set a fixed RetryInterval, assign the same value to both minMs and maxMs, ensuring that RetryInterval remains constant regardless of the number of retransmissions.

Setting RetryMaxCount

You can adjust the RetryMaxCount using the following function:

udp.h
void SetSendRetryMaxCount(uint32_t count)

RetryMaxCount will be set to the value specified by count.

Setting Sequence Ordering

a. When using the Diarkis Module, you can control RUDP behavior via the type argument in functions such as SendBroadcast defined in DiarkisP2PBase.h. Specify a value of the enumerated type RudpType for the type argument.

DiarkisP2PBase.h
uint16_t SendBroadcast(const uint8_t* payload, size_t payloadSize, RudpType type)
p2p.h
enum RudpType : uint8_t
{
    UNRELIABLE_UNORDERED = 0, // No delivery guarantee, no sequence guarantee (UDP)
    RELIABLE_UNORDERED = 1,   // Delivery guarantee, no sequence guarantee
    RELIABLE_ORDERED = 2      // Delivery guarantee, sequence guarantee
};

b. When directly using the library, execute the P2P data transmission function below with the bFixedOrder flag set to true.

p2p.h
Diarkis::System::Result RSend(const uint8_t* message, size_t messageSize, bool bFixedOrder)

Considerations for Settings

  • SetSendRetryInterval and SetSendRetryMaxCount configure RUDP communication with the server. For P2P communication settings, use SetSendRetryIntervalP2P and SetSendRetryMaxCountP2P.

  • If RetryInterval is very small or RetryMaxCount is large, the client must send a large number of packets, increasing the network processing load, so please be cautious.

Last updated