From 6a450a8b3fc4320745e7c1b474987f18e4dbca5e Mon Sep 17 00:00:00 2001 From: Hugo Domingos Date: Wed, 11 Mar 2026 20:16:48 +0000 Subject: [PATCH] Fix max hop limit for GBC packets --- src/flexstack/btp/router.py | 3 ++- src/flexstack/geonet/common_header.py | 3 +-- src/flexstack/geonet/router.py | 2 +- src/flexstack/geonet/service_access_point.py | 3 +++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/flexstack/btp/router.py b/src/flexstack/btp/router.py index 40fb814..8003486 100644 --- a/src/flexstack/btp/router.py +++ b/src/flexstack/btp/router.py @@ -81,7 +81,8 @@ def btp_data_request(self, request: BTPDataRequest) -> None: communication_profile=request.communication_profile, traffic_class=request.traffic_class, data=data, - length=len(data) + length=len(data), + max_hop_limit=request.max_hop_limit, ) self.logging.debug( "Sending BTP Data Request: %s", gn_data_request.data) diff --git a/src/flexstack/geonet/common_header.py b/src/flexstack/geonet/common_header.py index d127040..6deb777 100644 --- a/src/flexstack/geonet/common_header.py +++ b/src/flexstack/geonet/common_header.py @@ -70,8 +70,7 @@ def initialize_with_request(cls, request: GNDataRequest) -> "CommonHeader": if ht == HeaderType.TSB and hst == TopoBroadcastHST.SINGLE_HOP: mhl = 1 else: - # TODO: Set the maximum hop limit on other cases than SHB As specified in: Section 10.3.4 Table 20 - mhl = 1 + mhl = request.max_hop_limit return cls(nh=nh, reserved=0, ht=ht, hst=hst, tc=tc, flags=0, pl=pl, mhl=mhl) # type: ignore def encode_to_int(self) -> int: diff --git a/src/flexstack/geonet/router.py b/src/flexstack/geonet/router.py index a5bafad..5e26d3a 100644 --- a/src/flexstack/geonet/router.py +++ b/src/flexstack/geonet/router.py @@ -678,7 +678,7 @@ def gn_data_indicate(self, packet: bytes) -> None: # Decap the common header common_header = CommonHeader.decode_from_bytes(packet[0:8]) packet = packet[8:] - if basic_header.rhl > self.mib.itsGnDefaultHopLimit: + if basic_header.rhl > common_header.mhl: raise DecapError("Hop limit exceeded") # TODO: Forwarding packet buffer flush if common_header.ht == HeaderType.ANY: diff --git a/src/flexstack/geonet/service_access_point.py b/src/flexstack/geonet/service_access_point.py index 333eace..c19e1ba 100644 --- a/src/flexstack/geonet/service_access_point.py +++ b/src/flexstack/geonet/service_access_point.py @@ -406,6 +406,8 @@ class GNDataRequest: Payload. area : Area Area of the GBC algorithm. Only used when the packet transport type is GBC. + max_hop_limit : int + Maximum hop limit for the packet. Default is 10. THIS CLASS WILL BE EXTENDED WHEN FURTHER PACKET TYPES ARE IMPLEMENTED """ @@ -421,6 +423,7 @@ class GNDataRequest: length: int = 0 data: bytes = b"" area: Area = field(default_factory=Area) + max_hop_limit: int = 10 def to_dict(self) -> dict: """