From 12e87425dc82bee272b44ffce93813df5db58616 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 2 Nov 2023 12:24:42 +0100 Subject: [PATCH] Adjusted timings --- RNS/Interfaces/LocalInterface.py | 1 + RNS/Reticulum.py | 11 ++++++++--- RNS/Transport.py | 8 ++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/RNS/Interfaces/LocalInterface.py b/RNS/Interfaces/LocalInterface.py index fbfffdc..ee5a0f4 100644 --- a/RNS/Interfaces/LocalInterface.py +++ b/RNS/Interfaces/LocalInterface.py @@ -339,6 +339,7 @@ class LocalServerInterface(Interface): spawned_interface.target_port = str(handler.client_address[1]) spawned_interface.parent_interface = self spawned_interface.bitrate = self.bitrate + spawned_interface._force_bitrate = self._force_bitrate # RNS.log("Accepting new connection to shared instance: "+str(spawned_interface), RNS.LOG_EXTREME) RNS.Transport.interfaces.append(spawned_interface) RNS.Transport.local_client_interfaces.append(spawned_interface) diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index 496f5c8..c7a6424 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -321,9 +321,8 @@ class Reticulum: interface.OUT = True if hasattr(Reticulum, "_force_shared_instance_bitrate"): interface.bitrate = Reticulum._force_shared_instance_bitrate - interface._force_bitrate = True - RNS.log(f"Forcing shared instance bitrate of {RNS.prettyspeed(interface.bitrate)}ps", RNS.LOG_WARNING) interface._force_bitrate = Reticulum._force_shared_instance_bitrate + RNS.log(f"Forcing shared instance bitrate of {RNS.prettyspeed(interface.bitrate)}", RNS.LOG_WARNING) RNS.Transport.interfaces.append(interface) self.is_shared_instance = True @@ -341,7 +340,7 @@ class Reticulum: if hasattr(Reticulum, "_force_shared_instance_bitrate"): interface.bitrate = Reticulum._force_shared_instance_bitrate interface._force_bitrate = True - RNS.log(f"Forcing shared instance bitrate of {RNS.prettyspeed(interface.bitrate)}ps", RNS.LOG_WARNING) + RNS.log(f"Forcing shared instance bitrate of {RNS.prettyspeed(interface.bitrate)}", RNS.LOG_WARNING) RNS.Transport.interfaces.append(interface) self.is_shared_instance = False self.is_standalone_instance = False @@ -1329,6 +1328,12 @@ class Reticulum: rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key) rpc_connection.send({"get": "first_hop_timeout", "destination_hash": destination}) response = rpc_connection.recv() + + if self.is_connected_to_shared_instance and self._force_shared_instance_bitrate: + simulated_latency = ((1/self._force_shared_instance_bitrate)*8)*RNS.Reticulum.MTU + RNS.log("Adding simulated latency of "+RNS.prettytime(simulated_latency)+" to first hop timeout", RNS.LOG_DEBUG) + response += simulated_latency + return response except Exception as e: RNS.log("An error occurred while getting first hop timeout from shared instance: "+str(e), RNS.LOG_ERROR) diff --git a/RNS/Transport.py b/RNS/Transport.py index 8f03910..52457eb 100755 --- a/RNS/Transport.py +++ b/RNS/Transport.py @@ -66,7 +66,7 @@ class Transport: PATH_REQUEST_TIMEOUT = 15 # Default timuout for client path requests in seconds PATH_REQUEST_GRACE = 0.35 # Grace time before a path announcement is made, allows directly reachable peers to respond first PATH_REQUEST_RW = 2 # Path request random window - PATH_REQUEST_MI = 5 # Minimum interval in seconds for automated path requests + PATH_REQUEST_MI = 20 # Minimum interval in seconds for automated path requests STATE_UNKNOWN = 0x00 STATE_UNRESPONSIVE = 0x01 @@ -2058,9 +2058,9 @@ class Transport: @staticmethod def next_hop_per_byte_latency(destination_hash): - per_byte_latency = Transport.next_hop_per_bit_latency(destination_hash) - if per_byte_latency != None: - return per_byte_latency*8 + per_bit_latency = Transport.next_hop_per_bit_latency(destination_hash) + if per_bit_latency != None: + return per_bit_latency*8 else: return None