Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate latency, receive uplink RSSI, calculate bandwidth congestion and packet rate #492

Merged
merged 20 commits into from
Dec 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f6e6186
Echo timestamps to calculate latency
gemenerik Sep 25, 2024
ed096ac
Merge branch 'master' into rik/latency
gemenerik Sep 25, 2024
fda63c1
Refactor latency measurement into dedicated Latency class
gemenerik Sep 26, 2024
bb2e55c
Undo redundant radiodriver changes
gemenerik Sep 26, 2024
1b1f1b1
🐍 Python Formatting Fiasco: The Quest for Perfect Quotation!
gemenerik Sep 26, 2024
a6a9215
Enhance Latency class to allow restarting the ping thread
gemenerik Sep 26, 2024
a80e670
Add Caller to indicate updated latency + example how to use
gemenerik Sep 26, 2024
4136a69
" -> '
gemenerik Sep 30, 2024
da4fcbb
Receive uplink RSSI
gemenerik Oct 3, 2024
4435c7c
add congestion statistics
knmcguire Oct 3, 2024
73963e0
Move bandwidth congestion and packet rate into signal health class
gemenerik Oct 3, 2024
c0186ba
Only try to callback signal health when set
gemenerik Oct 4, 2024
f91dcf4
Merge branch 'master' into rik/uplink_rssi
gemenerik Oct 11, 2024
716071f
Merge branch 'master' into rik/latency
gemenerik Oct 22, 2024
8264b02
Merge branch 'master' into rik/uplink_rssi
gemenerik Oct 22, 2024
45c537d
Merge branch 'rik/uplink_rssi' into rik/link_quality
gemenerik Oct 22, 2024
81bfd4a
Refactor SignalHealth to RadioLinkStatistics for clarity
gemenerik Oct 22, 2024
31ff8e4
Rename latency update callback, reduce ping interval to 0.1 seconds
gemenerik Nov 12, 2024
fba6170
Move radio link statistics into (universal) link statistics object
gemenerik Dec 5, 2024
965f3d2
Enable deprecation warnings lib-wide
gemenerik Dec 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add congestion statistics
knmcguire authored and gemenerik committed Oct 3, 2024
commit 4435c7c19f125cd2d9ea807d9e2a922201ba814f
32 changes: 32 additions & 0 deletions cflib/crtp/radiodriver.py
Original file line number Diff line number Diff line change
@@ -584,6 +584,12 @@ def run(self):
break
self._link.needs_resending = not self._has_safelink

previous_time_stamp = time.time()
amount_null_packets_up = 0
amount_packets_up = 0
amount_null_packets_down = 0
amount_packets_down = 0

while (True):
if (self._sp):
break
@@ -620,10 +626,18 @@ def run(self):
continue
self._retry_before_disconnect = _nr_of_retries

## Find null packets in the downlink and count them
data = ackStatus.data
mask = 0b11110011
empty_ack_packet = int(data[0]) & mask

if empty_ack_packet == 0xF3:
amount_null_packets_down += 1
amount_packets_down += 1

# If there is a copter in range, the packet is analysed and the
# next packet to send is prepared
# TODO: THis seems not to work since there is always a byte filled in the data even with null packets
if (len(data) > 0):
inPacket = CRTPPacket(data[0], list(data[1:]))
self._in_queue.put(inPacket)
@@ -660,7 +674,25 @@ def run(self):
else:
dataOut.append(ord(X))
else:
# If no packet to send, send a null packet
dataOut.append(0xFF)
amount_null_packets_up += 1
amount_packets_up += 1

# Low level stats every second
if time.time() - previous_time_stamp > 1:
rate_up = amount_packets_up / (time.time() - previous_time_stamp)
rate_down = amount_packets_down / (time.time() - previous_time_stamp)
congestion_up = 1.0 - amount_null_packets_up / amount_packets_up
congestion_down = 1.0 - amount_null_packets_down / amount_packets_down

amount_packets_up = 0
amount_null_packets_up = 0
amount_packets_down = 0
amount_null_packets_down = 0
previous_time_stamp = time.time()

self._link_quality_low_level_callback(rate_up, rate_down, congestion_up, congestion_down)


def set_retries_before_disconnect(nr_of_retries):