diff --git a/CMakeLists.txt b/CMakeLists.txt index d3c2e46f..9ac38fe6 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,7 @@ set(UCLIENT_MAX_INPUT_RELIABLE_STREAMS 1 CACHE STRING "Set the maximum number of set(UCLIENT_MAX_SESSION_CONNECTION_ATTEMPTS 10 CACHE STRING "Set the number of connection attemps.") set(UCLIENT_MIN_SESSION_CONNECTION_INTERVAL 1000 CACHE STRING "Set the connection interval in milliseconds.") set(UCLIENT_MIN_HEARTBEAT_TIME_INTERVAL 100 CACHE STRING "Set the time interval between heartbeats in milliseconds.") +set(UCLIENT_RELIABLE_RESENT_TIME 100 CACHE STRING "Set the time for reliable stream resend in milliseconds.") set(UCLIENT_UDP_TRANSPORT_MTU 512 CACHE STRING "Set the UDP transport MTU.") set(UCLIENT_TCP_TRANSPORT_MTU 512 CACHE STRING "Set the TCP transport MTU.") set(UCLIENT_SERIAL_TRANSPORT_MTU 512 CACHE STRING "Set the Serial transport MTU.") diff --git a/include/uxr/client/config.h.in b/include/uxr/client/config.h.in index 7b00cd2c..416fcdae 100644 --- a/include/uxr/client/config.h.in +++ b/include/uxr/client/config.h.in @@ -46,6 +46,7 @@ #define UXR_CONFIG_MAX_SESSION_CONNECTION_ATTEMPTS @UCLIENT_MAX_SESSION_CONNECTION_ATTEMPTS@ #define UXR_CONFIG_MIN_SESSION_CONNECTION_INTERVAL @UCLIENT_MIN_SESSION_CONNECTION_INTERVAL@ #define UXR_CONFIG_MIN_HEARTBEAT_TIME_INTERVAL @UCLIENT_MIN_HEARTBEAT_TIME_INTERVAL@ +#define UXR_CONFIG_RELIABLE_RESENT_TIME @UCLIENT_RELIABLE_RESENT_TIME@ #ifdef UCLIENT_PROFILE_UDP #define UXR_CONFIG_UDP_TRANSPORT_MTU @UCLIENT_UDP_TRANSPORT_MTU@ diff --git a/src/c/core/session/stream/output_reliable_stream.c b/src/c/core/session/stream/output_reliable_stream.c index 93ca6e25..421b15dd 100644 --- a/src/c/core/session/stream/output_reliable_stream.c +++ b/src/c/core/session/stream/output_reliable_stream.c @@ -64,6 +64,7 @@ bool uxr_prepare_reliable_buffer_to_write( uint16_t available_block_size = (uint16_t)(buffer_capacity - (uint16_t)(stream->offset + SUBHEADER_SIZE)); size_t remaining_blocks = get_available_free_slots(stream); + static int64_t reliable_ackend_ts = 0x0; // Aligment required for inserting an XRCE subheader buffer_size += ucdr_alignment(buffer_size, 4); @@ -164,6 +165,17 @@ bool uxr_prepare_reliable_buffer_to_write( } } + if (available_to_write == false) { + if (reliable_ackend_ts == 0x0) { + reliable_ackend_ts = uxr_millis() + UXR_CONFIG_RELIABLE_RESENT_TIME; + } else if (reliable_ackend_ts <= uxr_millis()) { + stream->last_sent = uxr_seq_num_sub(stream->last_sent, 1); + reliable_ackend_ts = uxr_millis() + UXR_CONFIG_RELIABLE_RESENT_TIME; + } + } else { + reliable_ackend_ts = 0x0; + } + return available_to_write; }