Added transport hop limiter

This commit is contained in:
Mark Qvist 2026-10-28 13:28:43 +01:00
parent 4867e889e2
commit 134db17c81
No known key found for this signature in database
2 changed files with 7 additions and 0 deletions

View file

@ -159,6 +159,7 @@ class Interface:
self.protocol_violations = 0
self.ifac_violations = 0
self.packet_filter_hits = 0
self.hop_limiter_hits = 0
self.dp_ingress_tcount = 0
self.dp_ingress_bytes = 0
self.dp_ingress_packets = 0
@ -338,6 +339,10 @@ class Interface:
self.packet_filter_hits += 1
return None
def hop_limiter_hit(self):
self.hop_limiter_hits += 1
return None
@property
def ic_burst_count(self): return None

View file

@ -202,6 +202,7 @@ class Transport:
PR_VALUE = 19 # Default target stamp value for emitted path requests
LR_COST = 11 # Default required link request cost if not explicitly announced or configured
LINK_STAMP_TIMEOUT = 15 # TODO: Provisional, set sensible default and wire to config
HOP_LIMITER = PATHFINDER_M # TODO: Locally configurable hop limiter, wire to config
STAMPER_PR_QUEUE_LENGTH = 32 # TODO: Provisional, wire to config handling
STAMPER_AN_QUEUE_LENGTH = 32 # TODO: Provisional, wire to config handling
@ -1996,6 +1997,7 @@ class Transport:
packet = RNS.Packet(None, raw)
if not packet.unpack(): return interface.protocol_violation(f"Malformed packet ({len(raw)} bytes)") if interface else None
if not packet.hops < Transport.HOP_LIMITER: return interface.hop_limiter_hit()
if not Transport.packet_filter(packet): return interface.packet_filter_hit()
traffic_class = tc or Transport.TC_DATA