Fix rtt, including bug in time compute

This commit is contained in:
Andreas Wrede
2026-04-01 19:41:53 -04:00
parent 090d341244
commit 460d2be9e9
13 changed files with 1366 additions and 372 deletions
+8 -7
View File
@@ -115,13 +115,14 @@ class AsyncConnection:
self.logger.debug(f"Sent {msg_id} message ({len(data)} bytes)")
def handle_ack(self, msg: dict, now: float):
"""Handle ACK message from server."""
try:
self.lastack = msg.get("time", now)
rtt = (self.lastack - self.lastsend) * 2000.0 # Convert to ms
except Exception:
self.lastack = now
rtt = (self.lastack - self.lastsend) * 1000.0
"""Handle ACK message from server.
RTT is calculated as: (time ACK received) - (time HTB sent)
"""
self.lastack = now
# Calculate RTT: time ACK received minus time HTB sent
rtt = (now - self.lastsend) * 1000.0 # Convert to ms
self.rtts.append(rtt)
if len(self.rtts) > 10: