From bcfcf4eb86102e68c7df65478b27f00b485a4313 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 31 Dec 2018 20:33:55 +0100 Subject: [PATCH] Link window optimisations --- README.md | 4 ++-- RNS/Interfaces/RNodeInterface.py | 2 +- RNS/Link.py | 14 +++++++++++--- RNS/Resource.py | 4 ++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c9e90fd..231a961 100755 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Reticulum is a complete networking stack, and does not use IP or higher layers, For more info, see [unsigned.io/projects/reticulum](http://unsigned.io/projects/reticulum/) ## Current Status -Reticulum is currently in pre-alpha state. Even the master branch should be considered experimental. At this point the protocol may change without notice, and is made publicly available for development collaboration, previewing and testing features. Do not build anything serious with Reticulum yet. Stable alpha release will be at the end of June 2018. +Reticulum is currently in pre-alpha state. Even the master branch should be considered experimental. At this point the protocol may change without notice, and is made publicly available for development collaboration, previewing and testing features. Do not build anything serious with Reticulum yet. Stable alpha release will be in early 2019. ## What hardware does Reticulum work with? Practically any hardware that can support at least a half-duplex channel with 1.000 bits per second throughput, and an MTU of 500 bytes. Data radios, modems, LoRa radios, serial lines, AX.25 TNCs, HAM radio digital modes, free-space optical systems and similar systems are all examples of the types of interfaces Reticulum was designed for. @@ -18,7 +18,7 @@ An open-source LoRa-based interface called [RNode](https://unsigned.io/projects/ Reticulum can also be tunneled over existing IP networks. ## Can I use Reticulum for amateur radio? -Many countries ban the use of encryption when operating under an amateur radio license. Reticulum offers several encryptionless modes, while still using cryptographic principles for station verification, link establishment, data integrity verification, acknowledgements and routing. It is therefore perfectly possible to include Reticulum in amateur radio use, even if your country bans encryption. +Some countries still ban the use of encryption when operating under an amateur radio license. Reticulum offers several encryptionless modes, while still using cryptographic principles for station verification, link establishment, data integrity verification, acknowledgements and routing. It is therefore perfectly possible to include Reticulum in amateur radio use, even if your country bans encryption. ## How do I get started? Full documentation and video tutorials are coming with the stable alpha release. Until then, you are on your own. If you really want to experiment already, you could take a look in the "Examples" folder, for some well-documented example programs. Be sure to also read the [Reticulum Overview Document](http://unsigned.io/wp-content/uploads/2018/04/Reticulum_Overview_v0.4.pdf) diff --git a/RNS/Interfaces/RNodeInterface.py b/RNS/Interfaces/RNodeInterface.py index 3914df1..98de246 100644 --- a/RNS/Interfaces/RNodeInterface.py +++ b/RNS/Interfaces/RNodeInterface.py @@ -397,7 +397,7 @@ class RNodeInterface(Interface): self.r_stat_tx = ord(command_buffer[0]) << 24 | ord(command_buffer[1]) << 16 | ord(command_buffer[2]) << 8 | ord(command_buffer[3]) elif (command == KISS.CMD_STAT_RSSI): - self.r_stat_rssi = ord(byte)-RSSI_OFFSET + self.r_stat_rssi = ord(byte)-RNodeInterface.RSSI_OFFSET elif (command == KISS.CMD_RANDOM): self.r_random = ord(byte) elif (command == KISS.CMD_ERROR): diff --git a/RNS/Link.py b/RNS/Link.py index 94d4c28..d51e4e2 100644 --- a/RNS/Link.py +++ b/RNS/Link.py @@ -64,10 +64,12 @@ class Link: link.last_inbound = time.time() link.start_watchdog() - if link.owner.callbacks.link_established != None: - link.owner.callbacks.link_established(link) + # TODO: Why was link_established callback here? Seems weird + # to call this before RTT packet has been received + #if self.owner.callbacks.link_established != None: + # self.owner.callbacks.link_established(link) - RNS.log("Incoming link request "+str(link)+" accepted", RNS.LOG_VERBOSE) + RNS.log("Incoming link request "+str(link)+" accepted, waiting for RTT packet", RNS.LOG_VERBOSE) return link except Exception as e: @@ -191,6 +193,7 @@ class Link: RNS.log("Link "+str(self)+" established with "+str(self.destination)+", RTT is "+str(self.rtt), RNS.LOG_VERBOSE) rtt_data = umsgpack.packb(self.rtt) rtt_packet = RNS.Packet(self, rtt_data, context=RNS.Packet.LRRTT) + RNS.log("Sending RTT packet", RNS.LOG_EXTREME); rtt_packet.send() self.status = Link.ACTIVE @@ -215,7 +218,12 @@ class Link: rtt = umsgpack.unpackb(plaintext) self.rtt = max(measured_rtt, rtt) self.status = Link.ACTIVE + # TODO: Link established callback moved here, ok? + if self.owner.callbacks.link_established != None: + self.owner.callbacks.link_established(self) except Exception as e: + RNS.log("Error occurred while processing RTT packet, tearing down link", RNS.LOG_ERROR) + traceback.print_exc() self.teardown() def getSalt(self): diff --git a/RNS/Resource.py b/RNS/Resource.py index 12fcfd6..c3bbec9 100644 --- a/RNS/Resource.py +++ b/RNS/Resource.py @@ -8,8 +8,8 @@ from time import sleep class Resource: WINDOW_MIN = 1 - WINDOW_MAX = 10 - WINDOW = 5 + WINDOW_MAX = 7 + WINDOW = 4 MAPHASH_LEN = 4 SDU = RNS.Reticulum.MTU - RNS.Packet.HEADER_MAXSIZE RANDOM_HASH_SIZE = 4