diff --git a/RNS/Interfaces/AX25KISSInterface.py b/RNS/Interfaces/AX25KISSInterface.py index 710a2b8..66f5eca 100644 --- a/RNS/Interfaces/AX25KISSInterface.py +++ b/RNS/Interfaces/AX25KISSInterface.py @@ -58,6 +58,7 @@ class AX25(): class AX25KISSInterface(Interface): MAX_CHUNK = 32768 + BITRATE_GUESS = 1200 owner = None port = None @@ -94,6 +95,7 @@ class AX25KISSInterface(Interface): self.stopbits = stopbits self.timeout = 100 self.online = False + self.bitrate = KISSInterface.BITRATE_GUESS self.packet_queue = [] self.flow_control = flow_control diff --git a/RNS/Interfaces/I2PInterface.py b/RNS/Interfaces/I2PInterface.py index 384e876..7739a95 100644 --- a/RNS/Interfaces/I2PInterface.py +++ b/RNS/Interfaces/I2PInterface.py @@ -210,6 +210,7 @@ class I2PInterfacePeer(Interface): self.i2p_dest = None self.i2p_tunnel_ready = False self.mode = RNS.Interfaces.Interface.Interface.MODE_FULL + self.bitrate = I2PInterface.BITRATE_GUESS if max_reconnect_tries == None: self.max_reconnect_tries = I2PInterfacePeer.RECONNECT_MAX_TRIES @@ -523,6 +524,7 @@ class I2PInterfacePeer(Interface): class I2PInterface(Interface): + BITRATE_GUESS = 256*1000 def __init__(self, owner, name, rns_storagepath, peers, connectable = True): self.rxb = 0 @@ -546,6 +548,7 @@ class I2PInterface(Interface): self.bind_ip = "127.0.0.1" self.bind_port = self.i2p.get_free_port() self.address = (self.bind_ip, self.bind_port) + self.bitrate = I2PInterface.BITRATE_GUESS i2p_thread = threading.Thread(target=self.i2p.start) i2p_thread.setDaemon(True) diff --git a/RNS/Interfaces/KISSInterface.py b/RNS/Interfaces/KISSInterface.py index 533724a..1ef1a32 100644 --- a/RNS/Interfaces/KISSInterface.py +++ b/RNS/Interfaces/KISSInterface.py @@ -51,6 +51,7 @@ class KISS(): class KISSInterface(Interface): MAX_CHUNK = 32768 + BITRATE_GUESS = 1200 owner = None port = None @@ -89,6 +90,7 @@ class KISSInterface(Interface): self.beacon_i = beacon_interval self.beacon_d = beacon_data.encode("utf-8") self.first_tx = None + self.bitrate = KISSInterface.BITRATE_GUESS self.packet_queue = [] self.flow_control = flow_control diff --git a/RNS/Interfaces/SerialInterface.py b/RNS/Interfaces/SerialInterface.py index c091f4b..e77b20b 100755 --- a/RNS/Interfaces/SerialInterface.py +++ b/RNS/Interfaces/SerialInterface.py @@ -74,6 +74,7 @@ class SerialInterface(Interface): self.stopbits = stopbits self.timeout = 100 self.online = False + self.bitrate = self.speed if parity.lower() == "e" or parity.lower() == "even": self.parity = serial.PARITY_EVEN diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index 19bb3f2..674f53f 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -85,6 +85,8 @@ class Reticulum: the default value. """ + MINIMUM_BITRATE = 500 + # TODO: To reach the 300bps level without unreasonably impacting # performance on faster links, we need a mechanism for setting # this value more intelligently. One option could be inferring it @@ -320,6 +322,11 @@ class Reticulum: elif c["mode"] == "pointtopoint" or c["mode"] == "ptp": interface_mode = Interface.Interface.MODE_POINT_TO_POINT + configured_bitrate = None + if "bitrate" in c: + if c.as_int("bitrate") >= Reticulum.MINIMUM_BITRATE: + configured_bitrate = c.as_int("bitrate") + try: if (("interface_enabled" in c) and c.as_bool("interface_enabled") == True) or (("enabled" in c) and c.as_bool("enabled") == True): if c["type"] == "AutoInterface": @@ -350,6 +357,10 @@ class Reticulum: interface.mode = interface_mode RNS.Transport.interfaces.append(interface) + + if configured_bitrate: + interface.bitrate = configured_bitrate + else: RNS.log("AutoInterface is not currently supported on Windows, disabling interface.", RNS.LOG_ERROR); RNS.log("Please remove this AutoInterface instance from your configuration file.", RNS.LOG_ERROR); @@ -389,6 +400,9 @@ class Reticulum: RNS.Transport.interfaces.append(interface) + if configured_bitrate: + interface.bitrate = configured_bitrate + if c["type"] == "TCPServerInterface": device = c["device"] if "device" in c else None @@ -422,6 +436,9 @@ class Reticulum: RNS.Transport.interfaces.append(interface) + if configured_bitrate: + interface.bitrate = configured_bitrate + if c["type"] == "TCPClientInterface": kiss_framing = False @@ -452,6 +469,9 @@ class Reticulum: RNS.Transport.interfaces.append(interface) + if configured_bitrate: + interface.bitrate = configured_bitrate + if c["type"] == "I2PInterface": i2p_peers = c.as_list("peers") if "peers" in c else None @@ -478,6 +498,9 @@ class Reticulum: RNS.Transport.interfaces.append(interface) + if configured_bitrate: + interface.bitrate = configured_bitrate + if c["type"] == "SerialInterface": port = c["port"] if "port" in c else None @@ -508,6 +531,9 @@ class Reticulum: RNS.Transport.interfaces.append(interface) + if configured_bitrate: + interface.bitrate = configured_bitrate + if c["type"] == "KISSInterface": preamble = int(c["preamble"]) if "preamble" in c else None txtail = int(c["txtail"]) if "txtail" in c else None @@ -551,6 +577,9 @@ class Reticulum: RNS.Transport.interfaces.append(interface) + if configured_bitrate: + interface.bitrate = configured_bitrate + if c["type"] == "AX25KISSInterface": preamble = int(c["preamble"]) if "preamble" in c else None txtail = int(c["txtail"]) if "txtail" in c else None @@ -595,6 +624,9 @@ class Reticulum: RNS.Transport.interfaces.append(interface) + if configured_bitrate: + interface.bitrate = configured_bitrate + if c["type"] == "RNodeInterface": frequency = int(c["frequency"]) if "frequency" in c else None bandwidth = int(c["bandwidth"]) if "bandwidth" in c else None @@ -632,6 +664,10 @@ class Reticulum: interface.mode = interface_mode RNS.Transport.interfaces.append(interface) + + if configured_bitrate: + interface.bitrate = configured_bitrate + else: RNS.log("Skipping disabled interface \""+name+"\"", RNS.LOG_DEBUG)