From 2de8d27e54feb4653843bf0a22f7ee8ff52daa58 Mon Sep 17 00:00:00 2001 From: liuming24 Date: Fri, 15 Nov 2024 15:59:27 +0800 Subject: [PATCH 1/6] add resend feature for reliable stream Signed-off-by: liuming24 --- CMakeLists.txt | 1 + include/uxr/client/config.h.in | 1 + src/c/core/session/stream/output_reliable_stream.c | 12 ++++++++++++ 3 files changed, 14 insertions(+) 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; } From 54b87f8919c161ef6dedf6609cee9638f7140149 Mon Sep 17 00:00:00 2001 From: liuming24 Date: Fri, 15 Nov 2024 16:21:28 +0800 Subject: [PATCH 2/6] add head time.h file include Signed-off-by: liuming24 --- src/c/core/session/stream/output_reliable_stream.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/c/core/session/stream/output_reliable_stream.c b/src/c/core/session/stream/output_reliable_stream.c index 421b15dd..65ff2610 100644 --- a/src/c/core/session/stream/output_reliable_stream.c +++ b/src/c/core/session/stream/output_reliable_stream.c @@ -9,6 +9,7 @@ #include "./common_reliable_stream_internal.h" #include "../submessage_internal.h" #include +#include #define MIN_HEARTBEAT_TIME_INTERVAL ((int64_t) UXR_CONFIG_MIN_HEARTBEAT_TIME_INTERVAL) // ms From 391bab85439913ec711fc7ab0fc7e9a290680e18 Mon Sep 17 00:00:00 2001 From: liuming24 Date: Fri, 15 Nov 2024 16:21:28 +0800 Subject: [PATCH 3/6] add head time.h file include Signed-off-by: liuming24 --- src/c/core/session/stream/output_reliable_stream.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/c/core/session/stream/output_reliable_stream.c b/src/c/core/session/stream/output_reliable_stream.c index 421b15dd..a4923596 100644 --- a/src/c/core/session/stream/output_reliable_stream.c +++ b/src/c/core/session/stream/output_reliable_stream.c @@ -9,6 +9,7 @@ #include "./common_reliable_stream_internal.h" #include "../submessage_internal.h" #include +#include #define MIN_HEARTBEAT_TIME_INTERVAL ((int64_t) UXR_CONFIG_MIN_HEARTBEAT_TIME_INTERVAL) // ms From 5be7d888a2a2ca75ea0c9947285cb0777be6a997 Mon Sep 17 00:00:00 2001 From: liuming24 Date: Fri, 15 Nov 2024 18:58:58 +0800 Subject: [PATCH 4/6] fix test compile issue Signed-off-by: liuming24 --- test/shared_memory/SharedMemory.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/shared_memory/SharedMemory.cpp b/test/shared_memory/SharedMemory.cpp index f1f86d3f..69158bb5 100644 --- a/test/shared_memory/SharedMemory.cpp +++ b/test/shared_memory/SharedMemory.cpp @@ -1,3 +1,8 @@ +extern "C" +{ +#include +} + #include #include From 90f6665bceabe018365d652403c96cb21bd1b7ac Mon Sep 17 00:00:00 2001 From: liuming24 Date: Fri, 15 Nov 2024 19:11:02 +0800 Subject: [PATCH 5/6] fix Ut issue Signed-off-by: liuming24 --- test/unitary/session/streams/OutputBestEffortStream.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unitary/session/streams/OutputBestEffortStream.cpp b/test/unitary/session/streams/OutputBestEffortStream.cpp index f09c9664..403364da 100644 --- a/test/unitary/session/streams/OutputBestEffortStream.cpp +++ b/test/unitary/session/streams/OutputBestEffortStream.cpp @@ -7,6 +7,7 @@ extern "C" #include #include #include +#include } #define BUFFER_SIZE size_t(32) From bb9f3be5e50fc1ad326ddc8200fff456e787e22a Mon Sep 17 00:00:00 2001 From: liuming24 Date: Fri, 15 Nov 2024 19:28:59 +0800 Subject: [PATCH 6/6] fix ut compile Signed-off-by: liuming24 --- test/unitary/session/streams/OutputBestEffortStream.cpp | 1 - test/unitary/session/streams/OutputReliableStream.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unitary/session/streams/OutputBestEffortStream.cpp b/test/unitary/session/streams/OutputBestEffortStream.cpp index 403364da..f09c9664 100644 --- a/test/unitary/session/streams/OutputBestEffortStream.cpp +++ b/test/unitary/session/streams/OutputBestEffortStream.cpp @@ -7,7 +7,6 @@ extern "C" #include #include #include -#include } #define BUFFER_SIZE size_t(32) diff --git a/test/unitary/session/streams/OutputReliableStream.cpp b/test/unitary/session/streams/OutputReliableStream.cpp index da05eab4..f087de03 100644 --- a/test/unitary/session/streams/OutputReliableStream.cpp +++ b/test/unitary/session/streams/OutputReliableStream.cpp @@ -8,6 +8,7 @@ extern "C" #include #include #include +#include } #define BUFFER_SIZE size_t(128)