From b6c39ef042b16691d2769571e4824e3fcd4e7641 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 10 Jun 2023 11:02:48 -0400 Subject: [PATCH] fix firewalling/fragmentation issue --- veilid-core/src/network_manager/mod.rs | 11 ++++++++++- veilid-core/src/rpc_processor/mod.rs | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/veilid-core/src/network_manager/mod.rs b/veilid-core/src/network_manager/mod.rs index 9456c625..d11f9b73 100644 --- a/veilid-core/src/network_manager/mod.rs +++ b/veilid-core/src/network_manager/mod.rs @@ -1077,8 +1077,17 @@ impl NetworkManager { // Dial info filter comes from the target node ref let dial_info_filter = target_node_ref.dial_info_filter(); - let sequencing = target_node_ref.sequencing(); + let mut sequencing = target_node_ref.sequencing(); + + // If the node has had lost questions or failures to send, prefer sequencing + // to improve reliability. The node may be experiencing UDP fragmentation drops + // or other firewalling issues and may perform better with TCP. + let unreliable = target_node_ref.peer_stats().rpc_stats.failed_to_send > 0 || target_node_ref.peer_stats().rpc_stats.recent_lost_answers > 0; + if unreliable && sequencing < Sequencing::PreferOrdered { + sequencing = Sequencing::PreferOrdered; + } + // Get the best contact method with these parameters from the routing domain let cm = routing_table.get_contact_method( routing_domain, &peer_a, diff --git a/veilid-core/src/rpc_processor/mod.rs b/veilid-core/src/rpc_processor/mod.rs index ba24517e..daf8ff80 100644 --- a/veilid-core/src/rpc_processor/mod.rs +++ b/veilid-core/src/rpc_processor/mod.rs @@ -844,6 +844,10 @@ impl RPCProcessor { // Record for node if this was not sent via a route if safety_route.is_none() && remote_private_route.is_none() { node_ref.stats_failed_to_send(send_ts, wants_answer); + + // Also clear the last_connections for the entry so we make a new connection next time + node_ref.clear_last_connections(); + return; } @@ -872,6 +876,10 @@ impl RPCProcessor { // Record for node if this was not sent via a route if safety_route.is_none() && remote_private_route.is_none() { node_ref.stats_question_lost(); + + // Also clear the last_connections for the entry so we make a new connection next time + node_ref.clear_last_connections(); + return; } // Get route spec store