flexstack.geonet Module

The flexstack.geonet package implements ETSI EN 302 636-4-1 GeoNetworking router and tables.

Router

class flexstack.geonet.router.RouteKind(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

How a buffered GN-PDU is forwarded when its buffer is flushed.

BROADCAST = 1
AREA = 2
UNICAST = 3
class flexstack.geonet.router.BufferedPacket(basic_header, body, traffic_class, kind, so_pv=None, sn=None, area_type=None, area=None, destination=None, sender_ll_address=None, area_mode=False, origin=False)[source]

Bases: object

A GN-PDU together with the information needed to (re-)execute its forwarding algorithm (ETSI TS 103 836-4-1 V2.2.1, clauses 8.5, 8.6 and 10.3.5 NOTE 1).

body holds the octets that follow the Basic Header: the Common Header, Extended Header and payload or, for a secured packet, the Secured Packet, which forwarders relay unmodified.

Parameters:
basic_header: BasicHeader
body: bytes
traffic_class: TrafficClass
kind: RouteKind
so_pv: LongPositionVector | None = None
sn: int | None = None
area_type: GeoBroadcastHST | GeoAnycastHST | None = None
area: Area | None = None
destination: ShortPositionVector | None = None
sender_ll_address: bytes | None = None
area_mode: bool = False
origin: bool = False
encode()[source]

The GN-PDU: Basic Header followed by the body.

Return type:

bytes

property key: Tuple[GNAddress, int]

Packet identifier (source GN_ADDR, sequence number).

class flexstack.geonet.router.GNForwardingAlgorithmResponse(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

GN Forwarding Algorithm Selection Response. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex D.

Variables:
  • AREA-FORWARDING (1) – Area Forwarding.

  • NON-AREA-FORWARDING (2) – Non-Area Forwarding.

  • DISCARTED (3) – Discarted.

AREA_FORWARDING = 1
NON_AREA_FORWARDING = 2
DISCARTED = 3
class flexstack.geonet.router.Router(mib, sign_service=None, verify_service=None, clock=None, dcc_net=None)[source]

Bases: object

Geonetworking Router

Handles the routing of Geonetworking packets. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04).

Parameters:
  • mib (MIB) –

  • sign_service (SignService | None) –

  • verify_service (VerifyService | None) –

  • clock (Callable[[], int] | None) –

  • dcc_net (DccNet | None) –

__init__(mib, sign_service=None, verify_service=None, clock=None, dcc_net=None)[source]

Initialize the router.

Parameters:
  • mib (MIB) – MIB to use.

  • sign_service (SignService | None) – Sign service used to sign outgoing secured packets. Defaults to None (no signing).

  • verify_service (VerifyService | None) – Verify service used to verify incoming secured packets. Defaults to None (secured packets are discarded with a warning).

  • clock (Callable[[], int] | None) – Monotonic clock in milliseconds driving the packet-buffer and Location Service timers. When given, no timer thread is started and the caller drives the timers with tick().

  • dcc_net (DccNet | None) – DCC_NET entity for GN over ITS-G5 (ETSI TS 103 836-4-2 clauses 5 to 7): SHBs carry the DCC-MCO field and received SHBs update the LocTEX-G5. Without it the DCC-MCO field is zero-filled.

Return type:

None

gn_data_request_beacon()[source]

Handle a Beacon GNDataRequest.

Parameters:

None –

Return type:

None

get_sequence_number()[source]

Sequence number of the next multi-hop packet (clause 8.4): the local SEQN, initialized to 0, then incremented modulo 2^16.

Returns:

Sequence number to include in the packet.

Return type:

int

next_deadline()[source]

Earliest pending LS, CBF or DCC_NET (CBR_G) timer expiry (ms on the router clock).

Return type:

int | None

tick(now_ms=None)[source]

Process the expired timers: Beacon (clause 10.3.6.2), LS Request retransmission (clause 10.3.7.1.3) and CBF timer expiry (clauses E.3.5, F.3.5).

Parameters:

now_ms (int | None) –

Return type:

None

register_indication_callback(callback)[source]

Registers a callback for GNDataIndication.

Parameters:

callback (Callable[[GNDataIndication], None]) – Callback to register.

Return type:

None

setup_gn_address()[source]

Set the GN address of the router.

Raises:

NotImplementedError : – If the local GN address configuration method is not implemented.

Return type:

None

gn_data_request_shb(request)[source]

Handle a Single Hop Broadcast GNDataRequest.

Parameters:

request (GNDataRequest) – GNDataRequest to handle.

Return type:

GNDataConfirm

static calculate_distance(coord1, coord2)[source]

Returns the distance between two coordinates in meters. As specified in ETSI EN 302 931 - V1.0.0 Latitude -> x Longitude -> -y

Returns:

Tuple of x distance, y distance

Return type:

Tuple[float, float]

Parameters:
  • coord1 (tuple[float, float]) –

  • coord2 (tuple[float, float]) –

static transform_distance_angle(distance, angle)[source]

Adapts the X,Y pointed at north to the right angle

Returns:

X and Y distances adapted to the angle

Return type:

tuple[float, float]

Parameters:
  • distance (tuple[float, float]) –

  • angle (int) –

gn_geometric_function_f(area_type, area, lat, lon)[source]

Geometric function F(x, y) of a point P relative to a geographical area (ETSI EN 302 931, clause 5; ETSI TS 103 899, clause 5): F = 1 at the centre, F > 0 inside, F = 0 at the border and F < 0 outside.

The point is expressed in Cartesian coordinates centred on the area centre with the x axis along the long side a, which is rotated by area.angle degrees clockwise from North (azimuth).

Parameters:
  • area_type (GeoBroadcastHST | GeoAnycastHST) – Shape of the area.

  • area (Area) – Area (centre in 1/10 microdegree, a and b in metres, angle in degrees).

  • lat (int) – Latitude of the point P. In 1/10 microdegrees.

  • lon (int) – Longitude of the point P. In 1/10 microdegrees.

Return type:

float

gn_greedy_forwarding(dest_lat, dest_lon, traffic_class)[source]

§E.2 Greedy Forwarding algorithm (ETSI TS 103 836-4-1 V2.2.1 clause E.2).

Selects the neighbour with the smallest distance to the destination (Most Forward within Radius policy). Returns True if the packet should be transmitted (greedy next hop or BCAST fallback at local optimum), False if it should be buffered (local optimum and SCF is enabled).

Parameters:
  • dest_lat (int) –

  • dest_lon (int) –

  • traffic_class (TrafficClass) –

Return type:

bool

greedy_next_hop(dest_lat, dest_lon)[source]

§E.2 Most Forward within Radius: the neighbour closest to the destination, provided it is closer than the ego position; None at a local optimum.

Parameters:
  • dest_lat (int) –

  • dest_lon (int) –

Return type:

LocationTableEntry | None

gn_forwarding_algorithm_selection(request, sender_gn_addr=None)[source]

Annex D of ETSI TS 103 836-4-1 V2.2.1 (2026-04).

Parameters:
  • request (GNDataRequest) – GNDataRequest to handle.

  • sender_gn_addr (GNAddress | None) – GN address of the sender of the packet being forwarded. Used to look up the sender’s LocTE for the §D SE_POS_VALID / F_SE check. None for source operations (ego is the originator).

Return type:

GNForwardingAlgorithmResponse

gn_data_forward_gbc(basic_header, common_header, gbc_extended_header, packet, secured_body=None, sender_ll_address=None)[source]

Forwarder steps 9 to 14 of clause 10.3.11.3 (GBC) / 10.3.12.3 (GAC): decrement the RHL, buffer when no neighbour exists and SCF is set, then execute the forwarding algorithm (Annex D, E, F).

Parameters:
  • basic_header (BasicHeader) – Basic header of the received packet.

  • common_header (CommonHeader) – Common header of the packet.

  • gbc_extended_header (GBCExtendedHeader) – Extended header of the packet.

  • packet (bytes) – Payload (without headers).

  • secured_body (bytes | None) – Secured Packet as received; relayed unmodified when given.

  • sender_ll_address (bytes | None) – Link-layer address of the previous sender, when known.

Return type:

GNDataConfirm

gn_data_request_gac(request)[source]

Handle a GeoAnycast (GAC) GNDataRequest.

Implements §10.3.12.2 source operations of ETSI TS 103 836-4-1 V2.2.1 (2026-04). The source operations for GAC are identical to those for GBC (§10.3.11.2).

Parameters:

request (GNDataRequest) – GNDataRequest to handle.

Return type:

GNDataConfirm

gn_data_request_gbc(request)[source]

Handle a Geo Broadcast GNDataRequest.

Parameters:

request (GNDataRequest) – GNDataRequest to handle.

Return type:

GNDataConfirm

gn_data_request_tsb(request)[source]

Handle a multi-hop Topologically-Scoped Broadcast GNDataRequest (ETSI TS 103 836-4-1 V2.2.1, clause 10.3.9.2).

Parameters:

request (GNDataRequest) – GNDataRequest to handle.

Return type:

GNDataConfirm

gn_data_request(request)[source]

Handle a GNDataRequest.

Parameters:

request (GNDataRequest) – GNDataRequest to handle.

Return type:

GNDataConfirm

:raises NotImplementedError : PacketTransportType not implemented:

Returns:

Confirmation of the process of the packet.

Return type:

GNDataConfirm

Parameters:

request (GNDataRequest) –

gn_data_indicate_shb(packet, common_header, basic_header)[source]

Handle a Single Hop Broadcast GeoNetworking packet.

Implements §10.3.10.3 receiver operations.

Parameters:
  • packet (bytes) – GeoNetworking packet to handle (without Basic and Common headers).

  • common_header (CommonHeader) – CommonHeader of the packet.

  • basic_header (BasicHeader) – BasicHeader of the packet; used for remaining LT and RHL (Table 35).

Return type:

GNDataIndication | None

gn_data_request_guc(request)[source]

Handle a GeoUnicast (GUC) GNDataRequest.

Implements §10.3.8.2 source operations of ETSI TS 103 836-4-1 V2.2.1 (2026-04).

Parameters:

request (GNDataRequest) – GNDataRequest to handle. Must have destination set to the target GNAddress.

Return type:

GNDataConfirm

gn_data_indicate_guc(packet, common_header, basic_header, secured_body=None, sender_ll_address=None)[source]

Handle a GeoUnicast (GUC) GeoNetworking packet.

Implements the forwarder (clause 10.3.8.3) and destination (clause 10.3.8.4) operations of ETSI TS 103 836-4-1 V2.2.1 (2026-04).

Parameters:
  • packet (bytes) – GeoNetworking packet to handle (without Basic and Common headers).

  • common_header (CommonHeader) – CommonHeader of the packet.

  • basic_header (BasicHeader) – BasicHeader of the packet.

  • secured_body (bytes | None) – Secured Packet as received (relayed unmodified when forwarding).

  • sender_ll_address (bytes | None) – Link-layer address of the previous sender, when known.

Return type:

GNDataIndication | None

gn_data_indicate_gac(packet, common_header, basic_header, secured_body=None, sender_ll_address=None)[source]

Handle a GeoAnycast (GAC) GeoNetworking packet.

Implements the forwarder and receiver operations of ETSI TS 103 836-4-1 V2.2.1 (2026-04), clause 10.3.12.3.

GAC and GBC share the same extended header format (§9.8.5). Key distinction from GBC:

  • Inside/at border of area (F ≥ 0): deliver to upper entity and STOP – do NOT forward.

  • Outside area (F < 0): forward only – do NOT deliver to upper layer.

Parameters:
  • packet (bytes) – GeoNetworking packet to handle (without Basic and Common headers).

  • common_header (CommonHeader) – CommonHeader of the packet.

  • basic_header (BasicHeader) – BasicHeader of the packet.

  • secured_body (bytes | None) – Secured Packet as received (relayed unmodified when forwarding).

  • sender_ll_address (bytes | None) – Link-layer address of the previous sender, when known.

Return type:

GNDataIndication | None

gn_ls_request(sought_gn_addr, buffered_request=None)[source]

Initiate a Location Service request for sought_gn_addr, or queue buffered_request while one is in progress (ETSI TS 103 836-4-1 V2.2.1, clauses 10.2.4 and 10.3.7.1.2).

Parameters:
  • sought_gn_addr (GNAddress) – GN address of the sought GeoAdhoc router.

  • buffered_request (GNDataRequest | None) – GNDataRequest queued in the LS packet buffer (clause 8.5) and sent when the LS completes.

Return type:

None

gn_data_indicate_ls_request(packet, common_header, basic_header, secured_body=None, sender_ll_address=None)[source]

Handle an incoming LS Request packet: forwarder (clause 10.3.7.2, handled as TSB without delivery) or destination (clause 10.3.7.3, answered with an LS Reply).

Parameters:
  • packet (bytes) – GeoNetworking packet body after Basic and Common headers.

  • common_header (CommonHeader) – Common header of the received packet.

  • basic_header (BasicHeader) – Basic header of the received packet.

  • secured_body (bytes | None) – Secured Packet as received (relayed unmodified when forwarding).

  • sender_ll_address (bytes | None) – Link-layer address of the previous sender, when known.

Return type:

None

gn_data_indicate_ls_reply(packet, common_header, basic_header, secured_body=None, sender_ll_address=None)[source]

Handle an incoming LS Reply packet: source of the LS (clause 10.3.7.1.4) or forwarder (clause 10.3.7.2, handled as GUC).

Parameters:
  • packet (bytes) – GeoNetworking packet body after Basic and Common headers.

  • common_header (CommonHeader) – Common header of the received packet.

  • basic_header (BasicHeader) – Basic header of the received packet.

  • secured_body (bytes | None) – Secured Packet as received (relayed unmodified when forwarding).

  • sender_ll_address (bytes | None) – Link-layer address of the previous sender, when known.

Return type:

None

gn_data_indicate_ls(packet, common_header, basic_header, secured_body=None, sender_ll_address=None)[source]

Dispatch an incoming Location Service (LS) packet on its HST.

Parameters:
  • packet (bytes) – GeoNetworking packet body after Basic and Common headers.

  • common_header (CommonHeader) – Common header of the received packet.

  • basic_header (BasicHeader) – Basic header of the received packet.

  • secured_body (bytes | None) – Secured Packet as received (relayed unmodified when forwarding).

  • sender_ll_address (bytes | None) – Link-layer address of the previous sender, when known.

Return type:

None

gn_data_indicate_gbc(packet, common_header, basic_header, secured_body=None, sender_ll_address=None)[source]

Handle a GeoBroadcast GeoNetworking packet.

Implements the forwarder and receiver operations of ETSI TS 103 836-4-1 V2.2.1 (2026-04), clause 10.3.11.3.

Parameters:
  • packet (bytes) – GeoNetworking packet to handle (without Basic and Common headers).

  • common_header (CommonHeader) – CommonHeader of the packet.

  • basic_header (BasicHeader) – BasicHeader of the packet; used for remaining LT and RHL (Table 38).

  • secured_body (bytes | None) – Secured Packet as received (relayed unmodified when forwarding).

  • sender_ll_address (bytes | None) – Link-layer address of the previous sender, when known.

Return type:

GNDataIndication | None

gn_data_indicate_tsb(packet, common_header, basic_header, secured_body=None, sender_ll_address=None)[source]

Handle a multi-hop Topologically-Scoped Broadcast GeoNetworking packet.

Implements the forwarder and receiver operations of ETSI TS 103 836-4-1 V2.2.1 (2026-04), clause 10.3.9.3.

Parameters:
  • packet (bytes) – GeoNetworking packet to handle (without Basic and Common headers).

  • common_header (CommonHeader) – CommonHeader of the packet.

  • basic_header (BasicHeader) – BasicHeader of the packet; used for remaining LT and RHL (Table 32).

  • secured_body (bytes | None) – Secured Packet as received (relayed unmodified when forwarding).

  • sender_ll_address (bytes | None) – Link-layer address of the previous sender, when known.

Return type:

GNDataIndication | None

gn_data_indicate_beacon(packet)[source]

Method to indicate a Beacon GeoNetworking packet.

Lower level layers should call this method to indicate a Beacon GeoNetworking packet.

Parameters:
  • packet (bytes) – GeoNetworking packet to indicate.

  • common_header (CommonHeader) – CommonHeader of the packet.

Return type:

None

process_basic_header(packet, sender_ll_address=None)[source]

Basic Header processing (clause 10.3.3) and dispatch.

Parameters:
  • packet (bytes) –

  • sender_ll_address (bytes | None) –

Return type:

None

process_common_header(packet, basic_header, secured_body=None, sender_ll_address=None, security=None)[source]

Common Header processing (clause 10.3.5) and dispatch on the HT field.

secured_body is the Secured Packet the plain packet was verified from; forwarders relay it unmodified.

Parameters:
  • packet (bytes) –

  • basic_header (BasicHeader) –

  • secured_body (bytes | None) –

  • sender_ll_address (bytes | None) –

  • security (SNVERIFYConfirm | None) –

Return type:

None

set_verify_observer(observer)[source]

Call observer with the outcome of every verification of a received secured packet (SN-VERIFY.confirm, ETSI TS 102 723-8), whatever the report: the secured message (Ieee1609Dot2Data after the Basic Header) and the confirm. For logging and test instrumentation; it does not change the processing of the packet. Mirrors Router::set_verify_observer in RustFlexstack.

Parameters:

observer (Callable[[bytes, SNVERIFYConfirm], None]) –

Return type:

None

process_security_header(packet, basic_header, sender_ll_address=None)[source]

Secured packet processing (clause 10.3.3): verify, then process the plain packet.

Parameters:
  • packet (bytes) –

  • basic_header (BasicHeader) –

  • sender_ll_address (bytes | None) –

Return type:

None

gn_data_indicate(packet, sender_ll_address=None)[source]

Indicate a GeoNetworking packet received from the ALI.

Parameters:
  • packet (bytes) – GeoNetworking packet to indicate.

  • sender_ll_address (bytes | None) – Link-layer source address of the frame (the previous sender), when the ALI provides it; used by the CBF algorithms (PV_SE).

Return type:

None

:raises NotImplementedError : Version not implemented:

resolve_address_conflict()[source]

Duplicate address detected (clause 10.2.1.5 steps 2-3): with auto-address configuration, take a new random MID (unicast, locally administered) for the GN address, update itsGnLocalGnAddr and the ego position vector, and notify address_change_callback.

Return type:

None

media_dependent_address_ok(link_layer_mid=None)[source]

MIB.media_dependent_address_ok() with link_layer_mid defaulting to the MID reported by the attached link layer (ETSI TS 103 836-4-2 clause 6.1, TS 103 836-4-3 clause 5.2).

Parameters:

link_layer_mid (MID | None) –

Return type:

bool

duplicate_address_detection(gn_addr)[source]

Perform Duplicate Address Detection (DAD) on the given GNAddress. Specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 10.2.1.5

Parameters:

gn_addr (GNAddress) – GNAddress to perform Duplicate Address Detection on.

Return type:

None

refresh_ego_position_vector(tpv)[source]

Refresh the ego position vector.

Parameters:

tpv (dict) –

Return type:

None

MIB (Management Information Base)

class flexstack.geonet.mib.LocalGnAddrConfMethod(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

LocalGnAddrConfMethod. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex H.

Variables:
  • (0) (AUTO) – Local GN_ADDR is configured from MIB

  • (1) (MANAGED) – Local GN_ADDR is configured via the GN management using the service primitive GN-MGMT (annex K)

  • (2) (ANONYMOUS) –

AUTO = 0
MANAGED = 1
ANONYMOUS = 2
class flexstack.geonet.mib.GnIsMobile(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

GnIsMobile. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex H.

Variables:
  • (0) (STATIONARY) – The GeoAdhoc router is stationary

  • (1) (MOBILE) – The GeoAdhoc router is mobile

STATIONARY = 0
MOBILE = 1
class flexstack.geonet.mib.GnIfType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

GnIfType. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex H.

Variables:
  • (0) (UNSPECIFIED) – The interface type is unspecified

  • (1) (ITS-G5) – The interface is an ITS-G5 interface

  • (2) (LTE-V2X) – The interface is an LTE-V2X interface

UNSPECIFIED = 0
ITS_G5 = 1
LTE_V2X = 2
class flexstack.geonet.mib.GnSecurity(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

GnSecurity. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex H.

Variables:
  • (0) (DISABLED) – Security is disabled

  • (1) (ENABLED) – Security is enabled

DISABLED = 0
ENABLED = 1
class flexstack.geonet.mib.SnDecapResultHandling(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

SnDecapResultHandling. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex H.

Variables:
  • (0) (STRICT) – The packet is dropped

  • (1) (NON-STRICT) – The packet is forwarded

STRICT = 0
NON_STRICT = 1
class flexstack.geonet.mib.NonAreaForwardingAlgorithm(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

NonAreaForwardingAlgorithm. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex H.

Variables:
  • (0) (UNSPECIFIED) – The forwarding algorithm is unspecified

  • (1) (GREEDY) – Default forwarding algorithm outside target area

  • (2) (CBF) – Non-area contention-based forwarding (ETSI TS 103 836-4-1 V2.2.1, clause E.3)

UNSPECIFIED = 0
GREEDY = 1
CBF = 2
class flexstack.geonet.mib.AreaForwardingAlgorithm(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

AreaForwardingAlgorithm. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex H.

Variables:
  • (0) (UNSPECIFIED) – The forwarding algorithm is unspecified

  • (1) (CBF) – The simple forwarding algorithm inside target area

  • (1) – Default forwarding algorithm inside target area

UNSPECIFIED = 0
SIMPLE = 1
CBF = 2
class flexstack.geonet.mib.MIB(itsGnLocalGnAddr=<factory>, itsGnLocalGnAddrConfMethod=LocalGnAddrConfMethod.AUTO, itsGnProtocolVersion=1, itsGnIsMobile=GnIsMobile.MOBILE, itsGnIfType=GnIfType.UNSPECIFIED, itsGnMinUpdateFrequencyEPV=1000, itsGnPaiInterval=80, itsGnMaxSduSize=1398, itsGnMaxGeoNetworkingHeaderSize=88, itsGnLifetimeLocTE=20, itsGnSecurity=GnSecurity.DISABLED, itsGnSnDecapResultHandling=SnDecapResultHandling.STRICT, itsGnLocationServiceMaxRetrans=10, itsGnLocationServiceRetransmitTimer=1000, itsGnLocationServicePacketBufferSize=1024, itsGnBeaconServiceRetransmitTimer=3000, itsGnBeaconServiceMaxJitter=None, itsGnDefaultHopLimit=10, itsGnDPLLength=8, itsGnMaxPacketLifetime=600, itsGnDefaultPacketLifetime=60, itsGnMaxPacketDataRate=100, itsGnMaxPacketDataRateEmaBeta=90, itsGnMaxGeoAreaSize=10, itsGnMinPacketRepetitionInterval=100, itsGnNonAreaForwardingAlgorithm=NonAreaForwardingAlgorithm.GREEDY, itsGnAreaForwardingAlgorithm=AreaForwardingAlgorithm.CBF, itsGnCbfMinTime=1, itsGnCbfMaxTime=100, itsGnDefaultMaxCommunicationRange=1000, itsGnBroadcastCBFDefSectorAngle=30, itsGnUcForwardingPacketBufferSize=256, itsGnBcForwardingPacketBufferSize=1024, itsGnCbfPacketBufferSize=256, itsGnDefaultTrafficClass=0)[source]

Bases: object

Management Information Base (MIB) for GeoNetworking. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex H.

Variables:
  • itsGnLocalGnAddr (GNAddress) – GeoNetworking address of the GeoAdhoc router

  • itsGnLocalGnAddrConfMethod (LocalGnAddrConfMethod) – Configuration method for the GeoNetworking address of the GeoAdhoc router

  • itsGnProtocolVersion (int) – GeoNetworking protocol version

  • itsGnIsMobile (GnIsMobile) – Mobility status of the GeoAdhoc router

  • itsGnIfType (GnIfType) – Interface type

  • itsGnMinUpdateFrequencyEPV (int) – Minimum update frequency of EPV in [1/ms]

  • itsGnPaiInterval (int) – Distance related to the confidence interval for latitude and longitude [m].

  • itsGnMaxSduSize (int) – Maximum size of an SDU in [byte].

  • itsGnMaxGeoNetworkingHeaderSize (int) – Maximum size of a GeoNetworking header in [byte].

  • itsGnLifetimeLocTE (int) – Lifetime of location table entry [s]

  • itsGnSecurity (GnSecurity) – Security status

  • itsGnSnDecapResultHandling (SnDecapResultHandling) – Handling of the result of the security decapsulation

  • itsGnLocationServiceMaxRetrans (int) – Maximum number of retransmissions for location service requests

  • itsGnLocationServiceRetransmitTimer (int) – Duration of Location service retransmit timer [ms]

  • itsGnLocationServicePacketBufferSize (int) – Size of Location service packet buffer [Octets]

  • itsGnBeaconServiceRetransmitTimer (int) – Duration of Beacon service retransmit timer [ms]

  • itsGnBeaconServiceMaxJitter (int) – Maximum jitter for Beacon service retransmission [ms]

  • itsGnDefaultHopLimit (int) – Default hop limit

  • itsGnDPLLength (int) – Length of Duplicate Packet List (DPL) per source

  • itsGnMaxPacketLifetime (int) – Maximum packet lifetime [s]

  • itsGnDefaultPacketLifetime (int) – Default packet lifetime [s]

  • itsGnMaxPacketDataRate (int) – Maximum packet data rate [ko/s]

  • itsGnMaxPacketDataRateEmaBeta (int) – Weight factor for the Exponential Moving Average of the packet data rate PDR in percent

  • itsGnMaxGeoAreaSize (int) – Maximum size of the geographical area for a GBC and GAC packet [km2]

  • itsGnMinPacketRepetitionInterval (int) – Lower limit of the packet repetition interval [ms]

  • itsGnNonAreaForwardingAlgorithm (NonAreaForwardingAlgorithm) – Forwarding algorithm outside target area

  • itsGnAreaForwardingAlgorithm (AreaForwardingAlgorithm) – Forwarding algorithm inside target area

  • itsGnCbfMinTime (int) – Minimum duration a GN packet shall be buffered in the CBF packet buffer [ms]

  • itsGnCbfMaxTime (int) – Maximum duration a GN packet shall be buffered in the CBF packet buffer [ms]

  • itsGnDefaultMaxCommunicationRange (int) – Default maximum communication range [m]

  • itsGnBroadcastCBFDefSectorAngle (int) – Default threshold angle for advanced GeoBroadcast algorithm in clause F.4 [degrees]

  • itsGnUcForwardingPacketBufferSize (int) – Size of UC forwarding packet buffer [Ko]

  • itsGnBcForwardingPacketBufferSize (int) – Size of BC forwarding packet buffer [Ko]

  • itsGnCbfPacketBufferSize (int) – Size of CBF packet buffer [Ko]

  • itsGnDefaultTrafficClass (int) – Default traffic class

Parameters:
  • itsGnLocalGnAddr (GNAddress) –

  • itsGnLocalGnAddrConfMethod (LocalGnAddrConfMethod) –

  • itsGnProtocolVersion (int) –

  • itsGnIsMobile (GnIsMobile) –

  • itsGnIfType (GnIfType) –

  • itsGnMinUpdateFrequencyEPV (int) –

  • itsGnPaiInterval (int) –

  • itsGnMaxSduSize (int) –

  • itsGnMaxGeoNetworkingHeaderSize (int) –

  • itsGnLifetimeLocTE (int) –

  • itsGnSecurity (GnSecurity) –

  • itsGnSnDecapResultHandling (SnDecapResultHandling) –

  • itsGnLocationServiceMaxRetrans (int) –

  • itsGnLocationServiceRetransmitTimer (int) –

  • itsGnLocationServicePacketBufferSize (int) –

  • itsGnBeaconServiceRetransmitTimer (int) –

  • itsGnBeaconServiceMaxJitter (float | None) –

  • itsGnDefaultHopLimit (int) –

  • itsGnDPLLength (int) –

  • itsGnMaxPacketLifetime (int) –

  • itsGnDefaultPacketLifetime (int) –

  • itsGnMaxPacketDataRate (int) –

  • itsGnMaxPacketDataRateEmaBeta (int) –

  • itsGnMaxGeoAreaSize (int) –

  • itsGnMinPacketRepetitionInterval (int) –

  • itsGnNonAreaForwardingAlgorithm (NonAreaForwardingAlgorithm) –

  • itsGnAreaForwardingAlgorithm (AreaForwardingAlgorithm) –

  • itsGnCbfMinTime (int) –

  • itsGnCbfMaxTime (int) –

  • itsGnDefaultMaxCommunicationRange (int) –

  • itsGnBroadcastCBFDefSectorAngle (int) –

  • itsGnUcForwardingPacketBufferSize (int) –

  • itsGnBcForwardingPacketBufferSize (int) –

  • itsGnCbfPacketBufferSize (int) –

  • itsGnDefaultTrafficClass (int) –

itsGnLocalGnAddr: GNAddress
itsGnLocalGnAddrConfMethod: LocalGnAddrConfMethod = 0
itsGnProtocolVersion: int = 1
itsGnIsMobile: GnIsMobile = 1
itsGnIfType: GnIfType = 0
itsGnMinUpdateFrequencyEPV: int = 1000
itsGnPaiInterval: int = 80
itsGnMaxSduSize: int = 1398
itsGnMaxGeoNetworkingHeaderSize: int = 88
itsGnLifetimeLocTE: int = 20
itsGnSecurity: GnSecurity = 0
itsGnSnDecapResultHandling: SnDecapResultHandling = 0
itsGnLocationServiceMaxRetrans: int = 10
itsGnLocationServiceRetransmitTimer: int = 1000
itsGnLocationServicePacketBufferSize: int = 1024
itsGnBeaconServiceRetransmitTimer: int = 3000
itsGnBeaconServiceMaxJitter: float | None = None
itsGnDefaultHopLimit: int = 10
itsGnDPLLength: int = 8
itsGnMaxPacketLifetime: int = 600
itsGnDefaultPacketLifetime: int = 60
itsGnMaxPacketDataRate: int = 100
itsGnMaxPacketDataRateEmaBeta: int = 90
itsGnMaxGeoAreaSize: int = 10
itsGnMinPacketRepetitionInterval: int = 100
itsGnNonAreaForwardingAlgorithm: NonAreaForwardingAlgorithm = 1
itsGnAreaForwardingAlgorithm: AreaForwardingAlgorithm = 2
itsGnCbfMinTime: int = 1
itsGnCbfMaxTime: int = 100
itsGnDefaultMaxCommunicationRange: int = 1000
itsGnBroadcastCBFDefSectorAngle: int = 30
itsGnUcForwardingPacketBufferSize: int = 256
itsGnBcForwardingPacketBufferSize: int = 1024
itsGnCbfPacketBufferSize: int = 256
itsGnDefaultTrafficClass: int = 0
media_dependent_address_ok(link_layer_mid=None)[source]

Whether itsGnLocalGnAddr follows the media-dependent rule of itsGnIfType: ITS-G5, MID = MAC address of the interface (ETSI TS 103 836-4-2 V2.1.1 clause 6.1); LTE-V2X, MID = 24-bit Source Layer 2 ID followed by three zero octets (ETSI TS 103 836-4-3 V2.1.1 clause 5.2). link_layer_mid is the MID reported by the link layer; when it is unknown only the LTE-V2X zero octets are checked. Always True for an unspecified interface type.

Parameters:

link_layer_mid (MID | None) –

Return type:

bool

GNAddress

class flexstack.geonet.gn_address.M(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

M field of GNAddress as described in ETSI TS 103 836-4-1 V2.2.1 (2026-04)

…

Variables:
  • GN_UNICAST – GN Unicast Address

  • GN_MULTICAST – GN Multicast Address

GN_UNICAST = 0
GN_MULTICAST = 1
encode_to_address()[source]

Encodes M to int for GN address

Returns:

Encoded M

Return type:

int

class flexstack.geonet.gn_address.ST(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

ST field of GNAddress as described in ETSI TS 103 836-4-1 V2.2.1 (2026-04)

…

Variables:
  • UNKNOWN – Unknown

  • PEDESTRIAN – Pedestrianremaining

  • CYCLIST – Cyclist

  • MOPED – Moped

  • MOTORCYCLE – Motorcycle

  • PASSENGER_CAR – Passenger Car

  • BUS – Bus

  • LIGHT_TRUCK – Light Truck

  • HEAVY_TRUCK – Heavy Truck

  • TRAILER – Trailer

  • SPECIAL_VEHICLE – Special Vehicle

  • TRAM – Tram

  • ROAD_SIDE_UNIT – Road Side Unit

UNKNOWN = 0
PEDESTRIAN = 1
CYCLIST = 2
MOPED = 3
MOTORCYCLE = 4
PASSENGER_CAR = 5
BUS = 6
LIGHT_TRUCK = 7
HEAVY_TRUCK = 8
TRAILER = 9
SPECIAL_VEHICLE = 10
TRAM = 11
ROAD_SIDE_UNIT = 12
encode_to_address()[source]

Encodes ST to int for GN address

Returns int bytes

Encoded ST

Return type:

int

exception flexstack.geonet.gn_address.InvalidMIDLength[source]

Bases: Exception

Exception for invalid MID length

class flexstack.geonet.gn_address.MID(mid)[source]

Bases: object

MID field of GNAddress as described in ETSI TS 103 836-4-1 V2.2.1 (2026-04).

Variables:

mid (bytes) – MID field of GNAddress: LL_ADDR (6 bytes)

Parameters:

mid (bytes) –

mid: bytes
classmethod from_its_g5_mac(mac_address)[source]

MID for GN over ITS-G5: the 48-bit MAC address of the ITS-G5 interface (ETSI TS 103 836-4-2 V2.1.1, clause 6.1).

Parameters:

mac_address (bytes) –

Return type:

MID

classmethod from_lte_v2x_l2_id(l2_id)[source]

MID for GN over LTE-V2X: the 24-bit Source Layer 2 ID in octets 2-4 of the GN address, octets 5-7 set to zero (ETSI TS 103 836-4-3 V2.1.1, clause 5.2).

Parameters:

l2_id (int) –

Return type:

MID

encode_to_address()[source]

Encodes MID to int for GN address

Returns:

Encoded MID

Return type:

int

class flexstack.geonet.gn_address.GNAddress(m=M.GN_UNICAST, st=ST.UNKNOWN, mid=<factory>)[source]

Bases: object

GeoNetworking Address.

Variables:
  • m (M) –

  • st (ST) –

  • mid (MID) –

Parameters:
  • m (M) –

  • st (ST) –

  • mid (MID) –

m: M = 0
st: ST = 0
mid: MID
set_m(m)[source]

Return a new GNAddress with updated m.

Parameters:

m (M) – M to set

Return type:

GNAddress

set_st(st)[source]

Return a new GNAddress with updated st.

Parameters:

st (ST) – ST to set

Return type:

GNAddress

set_mid(mid)[source]

Return a new GNAddress with updated mid.

Parameters:

mid (MID) – MID to set

Returns:

New GNAddress with updated mid

Return type:

GNAddress

encode()[source]

Encodes GNAddress to bytes.

Returns:

Encoded GNAddress as bytes

Return type:

bytes

encode_to_int()[source]

Encodes GNAddress to int

Returns:

Encoded GNAddress as int

Return type:

int

classmethod decode(data)[source]

Decode a GNAddress from bytes and return a new instance.

Parameters:

data (bytes) – Bytes to decode

Returns:

Decoded GNAddress instance

Return type:

GNAddress

ServiceAccessPoint

class flexstack.geonet.service_access_point.CommonNH(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Common Next Header class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 9.7

Variables:
  • ANY – Any Next Header.

  • BTP-A – BTP-A Next Header.

  • BTP-B – BTP-B Next Header.

  • IPV6 – IPv6 Next Header.

ANY = 0
BTP_A = 1
BTP_B = 2
IPV6 = 3
class flexstack.geonet.service_access_point.HeaderType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Header Type class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 9.7.4

Variables:
  • ANY – Any Header Type.

  • BEACON – Beacon Header Type.

  • GEOUNICAST – GeoUnicast Header Type.

  • GEOANYCAST – Geographically-Scoped Anycast (GAC) Header Type.

  • GEOBROADCAST – Geographically-Scoped broadcast (GBC) Header Type.

  • TSB – Topologically-scoped broadcast (TSB) Header Type.

  • LS – Location Service Header Type.

ANY = 0
BEACON = 1
GEOUNICAST = 2
GEOANYCAST = 3
GEOBROADCAST = 4
TSB = 5
LS = 6
class flexstack.geonet.service_access_point.HeaderSubType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Common Header Subtype class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 9.7.5

UNSPECIFIED = 0
class flexstack.geonet.service_access_point.GeoAnycastHST(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Geographically-Scoped Anycast (GAC) Header Subtype class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 9.7.4

Variables:
  • GEOANYCAST_CIRCLE – Geographically-Scoped Anycast (GAC) Circle Header Subtype.

  • GEOANYCAST_RECT – Geographically-Scoped Anycast (GAC) Rectangle Header Subtype.

  • GEOANYCAST_ELIP – Geographically-Scoped Anycast (GAC) Ellipse Header Subtype.

GEOANYCAST_CIRCLE = 0
GEOANYCAST_RECT = 1
GEOANYCAST_ELIP = 2
class flexstack.geonet.service_access_point.GeoBroadcastHST(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Geographically-Scoped broadcast (GBC) Header Subtype class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 9.7.4

Variables:
  • GEOBROADCAST_CIRCLE – Geographically-Scoped broadcast (GBC) Circle Header Subtype.

  • GEOBROADCAST_RECT – Geographically-Scoped broadcast (GBC) Rectangle Header Subtype.

  • GEOBROADCAST_ELIP – Geographically-Scoped broadcast (GBC) Ellipse Header Subtype.

GEOBROADCAST_CIRCLE = 0
GEOBROADCAST_RECT = 1
GEOBROADCAST_ELIP = 2
class flexstack.geonet.service_access_point.TopoBroadcastHST(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Topologically-scoped broadcast (TSB) Header Subtype class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 9.7.4

Variables:
  • SINGLE_HOP – Single Hop Header Subtype.

  • MULTI_HOP – Multi Hop Header Subtype.

SINGLE_HOP = 0
MULTI_HOP = 1
class flexstack.geonet.service_access_point.LocationServiceHST(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Location Service Header Subtype class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 9.7.4

Variables:
  • LS_REQUEST – Location Service Request Header Subtype.

  • LS_REPLY – Location Service Reply Header Subtype.

LS_REQUEST = 0
LS_REPLY = 1
class flexstack.geonet.service_access_point.TrafficClass(scf=False, channel_offload=False, tc_id=0)[source]

Bases: object

Common Traffic class class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 9.7.5

Variables:
  • scf (bool) – (1 bit) Store Carry Forward (SCF) flag. Indicates whether the packet shall be buffered when no suitable neighbour exists

  • channel_offload (bool) – (1 bit) Channel Offload flag. Indicates whether the packet may be offloaded to another channel than specified in the TC ID

  • tc_id (int) – (6 bit unsigned integer) Traffic class identifier. TC ID as specified in the media-dependent part of GeoNetworking corresponding to the interface over which the packet will be transmitted

Parameters:
  • scf (bool) –

  • channel_offload (bool) –

  • tc_id (int) –

scf: bool = False
channel_offload: bool = False
tc_id: int = 0
set_scf(scf)[source]

Set the SCF flag.

Parameters:

scf (bool) – SCF flag.

Return type:

TrafficClass

set_tc_id(tc_id)[source]

Set the traffic class identifier.

Parameters:

tc_id (int) – Traffic class identifier.

Return type:

TrafficClass

set_channel_offload(channel_offload)[source]

Set the channel offload flag.

Parameters:

channel_offload (bool) – Channel offload flag.

Return type:

TrafficClass

encode_to_int()[source]

Encodes the traffic class to an integer.

Returns:

Encoded traffic class. 1 byte.

Return type:

int

encode_to_bytes()[source]

Encodes the traffic class to bytes.

Returns:

Encoded traffic class. 1 byte.

Return type:

bytes

classmethod decode_from_int(tc)[source]

Decodes the traffic class from an integer.

Parameters:

tc (int) – Encoded traffic class. 1 byte.

Return type:

TrafficClass

classmethod decode_from_bytes(tc)[source]

Decodes the traffic class from a byte array.

Parameters:

tc (bytes) – Byte array containing the traffic class.

Return type:

TrafficClass

class flexstack.geonet.service_access_point.PacketTransportType(header_type=HeaderType.TSB, header_subtype=TopoBroadcastHST.SINGLE_HOP)[source]

Bases: object

Packet Transport Type class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex J2 Uses the Header Type and Header Subtype fields from the Common Header. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 9.7.4

Variables:
  • header_type (HeaderType) – Header Type.

  • header_subtype (Enum) – Header Subtype.

Parameters:
  • header_type (HeaderType) –

  • header_subtype (Any) –

header_type: HeaderType = 5
header_subtype: Any = 0
to_dict()[source]

Returns a dictionary representation of the Packet Transport Type.

Returns:

Dictionary representation of the Packet Transport Type.

Return type:

dict

classmethod from_dict(packet_transport_type)[source]

Initialize the Packet Transport Type from a dictionary.

Parameters:

packet_transport_type (dict) – Dictionary containing the Packet Transport Type.

Return type:

PacketTransportType

class flexstack.geonet.service_access_point.CommunicationProfile(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Communication Profile class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex J2

Variables:

(0) (UNSPECIFIED) – Unspecified

UNSPECIFIED = 0
class flexstack.geonet.service_access_point.Area(latitude=0, longitude=0, a=0, b=0, angle=0)[source]

Bases: object

Area class. Not specified in the standard

Variables:
  • latitude (int) – Latitude of the center of the area. In 1/10 micro degree.

  • longitude (int) – Longitude of the center of the area. In 1/10 micro degree.

  • a (int) – Length of the semi-major axis. In meters.

  • b (int) – Length of the semi-minor axis. In meters.

  • angle (int) – In degrees from North

Parameters:
  • latitude (int) –

  • longitude (int) –

  • a (int) –

  • b (int) –

  • angle (int) –

latitude: int = 0
longitude: int = 0
a: int = 0
b: int = 0
angle: int = 0
to_dict()[source]

Returns a dictionary representation of the Area.

Returns:

Dictionary representation of the Area.

Return type:

dict

classmethod from_dict(area)[source]
Parameters:

area (dict) –

Return type:

Area

class flexstack.geonet.service_access_point.GNDataRequest(upper_protocol_entity=CommonNH.ANY, packet_transport_type=<factory>, communication_profile=CommunicationProfile.UNSPECIFIED, security_profile=SecurityProfile.NO_SECURITY, its_aid=0, security_permissions=b'\x00', traffic_class=<factory>, length=0, data=b'', area=<factory>, max_hop_limit=1, max_packet_lifetime=None, destination=None)[source]

Bases: object

GN Data Request class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex J2.2

Variables:
  • upper_protocol_entity (CommonNH) – Upper Protocol Entity.

  • packet_transport_type (PacketTransportType) – Packet Transport Type.

  • communication_profile (CommunicationProfile) – Communication Profile.

  • security_profile (SecurityProfile) – Security Profile.

  • its_aid (int) – ITS AID.

  • security_permissions (bytes) – Security Permissions.

  • traffic_class (TrafficClass) – Traffic Class.

  • length (int) – Length of the payload.

  • data (bytes) – 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.

  • IMPLEMENTED (THIS CLASS WILL BE EXTENDED WHEN FURTHER PACKET TYPES ARE) –

Parameters:
  • upper_protocol_entity (CommonNH) –

  • packet_transport_type (PacketTransportType) –

  • communication_profile (CommunicationProfile) –

  • security_profile (SecurityProfile) –

  • its_aid (int) –

  • security_permissions (bytes) –

  • traffic_class (TrafficClass) –

  • length (int) –

  • data (bytes) –

  • area (Area) –

  • max_hop_limit (int) –

  • max_packet_lifetime (float | None) –

  • destination (GNAddress | None) –

upper_protocol_entity: CommonNH = 0
packet_transport_type: PacketTransportType
communication_profile: CommunicationProfile = 0
security_profile: SecurityProfile = 0
its_aid: int = 0
security_permissions: bytes = b'\x00'
traffic_class: TrafficClass
length: int = 0
data: bytes = b''
area: Area
max_hop_limit: int = 1
max_packet_lifetime: float | None = None
destination: GNAddress | None = None
to_dict()[source]

Returns a dictionary representation of the GN Data Request.

Returns:

Dictionary representation of the GN Data Request.

Return type:

dict

classmethod from_dict(gn_data_request)[source]

Initialize the GN Data Request from a dictionary.

Parameters:

gn_data_request (dict) – Dictionary containing the GN Data Request.

Return type:

GNDataRequest

class flexstack.geonet.service_access_point.ResultCode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Result Code class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex J3

Variables:
  • (1) (ACCEPTED) – Accepted

  • (2) (MAXIMUM_LENGTH_EXCEEDED) – The size of the T/GN6-PDU exceeds the GN protocol constant itsGnMaxSduSize;

  • (3) (MAXIMUM_LIFETIME_EXCEEDED) – The lifetime exceeds the maximum value of the GN protocol constant itsGnMaxPacketLifetime;

  • (4) (REPETITION_INTERVAL_TOO_SMALL) – The repetition interval is too small;

  • (5) (UNSUPPORTED_TRAFFIC_CLASS) – The traffic class is not supported;

  • (6) (GEOGRAPHICAL_SCOPE_TOO_LARGE) – The geographical scope is too large;

  • (7) (UNSPECIFIED) – Unspecified

ACCEPTED = 1
MAXIMUM_LENGTH_EXCEEDED = 2
MAXIMUM_LIFETIME_EXCEEDED = 3
REPETITION_INTERVAL_TOO_SMALL = 4
UNSUPPORTED_TRAFFIC_CLASS = 5
GEOGRAPHICAL_SCOPE_TOO_LARGE = 6
UNSPECIFIED = 7
class flexstack.geonet.service_access_point.GNDataConfirm(result_code=ResultCode.UNSPECIFIED)[source]

Bases: object

GN Data Confirm class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex J3

Variables:

result_code (ResultCode) – Result Code.

Parameters:

result_code (ResultCode) –

result_code: ResultCode = 7
class flexstack.geonet.service_access_point.GNDataIndication(upper_protocol_entity=CommonNH.ANY, packet_transport_type=<factory>, destination_area=None, destination=None, source_position_vector=<factory>, traffic_class=<factory>, remaining_packet_lifetime=None, remaining_hop_limit=None, security_report=None, certificate_id=None, its_aid=None, security_permissions=None, length=0, data=b'')[source]

Bases: object

GN Data Indication class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Annex J4

Variables:
  • upper_protocol_entity (CommonNH) – Upper Protocol Entity.

  • packet_transport_type (PacketTransportType) – Packet Transport Type.

  • destination_area (Area or None) – Destination geographical area (GBC/GAC only). Optional per Annex J4.

  • destination (GNAddress or None) – Destination address of a GeoUnicast, as generated by the source (Annex J4).

  • source_position_vector (LongPositionVector) – Source Position Vector.

  • traffic_class (TrafficClass) – Traffic Class.

  • remaining_packet_lifetime (float or None) – Remaining lifetime of the packet in seconds. Optional per Annex J4.

  • remaining_hop_limit (int or None) – Remaining hop limit of the packet. Optional per Annex J4.

  • security_report (int or None) – Report of the security verification (ReportVerify value) of a secured packet; None for an unsecured packet (Table 38).

  • certificate_id (bytes or None) – HashedId8 of the signer’s authorization ticket (Table 38).

  • its_aid (int or None) – ITS-AID (PSID) of the secured packet (Table 38).

  • security_permissions (bytes or None) – SSP of the signer’s authorization ticket for that ITS-AID (Table 38).

  • length (int) – Length of the payload.

  • data (bytes) – Payload.

Parameters:
  • upper_protocol_entity (CommonNH) –

  • packet_transport_type (PacketTransportType) –

  • destination_area (Any | None) –

  • destination (GNAddress | None) –

  • source_position_vector (LongPositionVector) –

  • traffic_class (TrafficClass) –

  • remaining_packet_lifetime (float | None) –

  • remaining_hop_limit (int | None) –

  • security_report (int | None) –

  • certificate_id (bytes | None) –

  • its_aid (int | None) –

  • security_permissions (bytes | None) –

  • length (int) –

  • data (bytes) –

upper_protocol_entity: CommonNH = 0
packet_transport_type: PacketTransportType
destination_area: Any | None = None
destination: GNAddress | None = None
source_position_vector: LongPositionVector
traffic_class: TrafficClass
remaining_packet_lifetime: float | None = None
remaining_hop_limit: int | None = None
security_report: int | None = None
certificate_id: bytes | None = None
its_aid: int | None = None
security_permissions: bytes | None = None
length: int = 0
data: bytes = b''
to_dict()[source]

Returns a dictionary representation of the GN Data Indication.

Returns:

Dictionary representation of the GN Data Indication.

Return type:

dict

classmethod from_dict(gn_data_indication)[source]

Initialize the GN Data Indication from a dictionary.

Parameters:

gn_data_indication (dict) – Dictionary containing the GN Data Indication.

Return type:

GNDataIndication

LocationTable

class flexstack.geonet.location_table.LocationTableEntry(mib)[source]

Bases: object

Location table entry class. As specified in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 8.2.2

Variables:
  • mib (MIB) – MIB to use.

  • position_vector (LongPositionVector) – Position vector of the ITS-S.

  • ls_pending (bool) – Flag indicating that a Location Service (LS) (clause 10.2.4) is in progress.

  • is_neighbour (bool) – Flag indicating that the GeoAdhoc router is in direct communication range, i.e. is a neighbour.

  • dpl (deque[int]) – Duplicate packet list for source GN_ADDR. Stores the itsGnDPLLength most recently seen sequence numbers (annex A.2).

  • tst (TST) – Timestamp TST(GN_ADDR): The timestamp of the last packet from the source GN_ADDR that was identified as ‘not duplicated’

  • pdr (int) – Packet data rate PDR(GN_ADDR) as Exponential Moving Average (EMA) (clause B.2).

Parameters:

mib (MIB) –

get_gn_address()[source]

Get the GN address.

Returns:

GN address.

Return type:

GNAddress

update_position_vector(position_vector)[source]

Updates the position vector. Annex C.2 of ETSI TS 103 836-4-1 V2.2.1 (2026-04): PV is updated only when the received TST is strictly newer than the stored TST (wrap-around handled by TST.__gt__). If not newer, the call returns silently and packet processing continues normally (no exception raised).

Parameters:

position_vector (LongPositionVector) – Position vector to update.

Return type:

None

update_pdr(position_vector, packet_size)[source]

Updates the Packet Data Rate (PDR). Annex B2 of ETSI TS 103 836-4-1 V2.2.1 (2026-04)

Parameters:
  • position_vector (LongPositionVector) – Position vector of the packet.

  • packet_size (int) – Size of the packet.

Return type:

None

update_with_shb_packet(position_vector, packet)[source]

Updates the entry with a SHB packet.

Follows the steps 4, 5 and 6 of the algorithm in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 10.3.10.3

Parameters:
  • position_vector (LongPositionVector) – Position vector of the packet.

  • packet (bytes) – SHB packet (without the basic header, the common header and the position vector).

Raises:
  • IncongruentTimestampException – If there has been another packet with posterior timestamp received before.

  • DuplicatedPacketException – If the packet is duplicated.

Return type:

None

update_with_tsb_packet(packet, tsb_extended_header, is_new_entry)[source]

Updates the entry with a TSB packet.

Follows steps 3-6 of §10.3.9.3 of ETSI TS 103 836-4-1 V2.2.1 (2026-04).

Parameters:
  • packet (bytes) – TSB payload (without headers).

  • tsb_extended_header (TSBExtendedHeader) – TSB extended header.

  • is_new_entry (bool) – True when this LocTE was just created; used to decide whether to set IS_NEIGHBOUR to FALSE (§10.3.9.3 step 5b) or leave it unchanged (NOTE 1).

Raises:
  • IncongruentTimestampException – If a packet with a later timestamp was received before.

  • DuplicatedPacketException – If the packet is duplicated.

Return type:

None

update_with_gbc_packet(packet, gbc_extended_header)[source]

Updates the entry with a SHB packet.

Follows the steps 3, 4, 5 and 6 of the algorithm in ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 10.3.11.3

Parameters:
  • packet (bytes) – GBC packet (without the basic header, the common header and the extended header).

  • gbc_extended_header (GBCExtendedHeader) – GBC extended header.

Raises:
  • IncongruentTimestampException – If there has been another packet with posterior timestamp received before.

  • DuplicatedPacketException – If the packet is duplicated.

Return type:

None

check_duplicate_sn(sn)[source]

Checks if a packet with the given sequence number is a duplicate.

Implements the SN-based DPD algorithm of annex A.2 of ETSI TS 103 836-4-1 V2.2.1 (2026-04).

The DPL is a ring buffer of length itsGnDPLLength that stores the sequence numbers of the most recently received (non-duplicate) packets from this source. When SN is already present in the DPL the packet is a duplicate; otherwise SN is added at the head (overwriting the oldest entry when the buffer is full).

Only applicable to multi-hop packets (GUC, TSB, GBC, GAC, LS Request, LS Reply). BEACON and SHB do not carry an SN field and must NOT call this method.

Parameters:

sn (int) – Sequence number field from the received GeoNetworking packet.

Raises:

DuplicatedPacketException – If sn is already present in the DPL.

Return type:

None

class flexstack.geonet.location_table.LocationTable(mib, clock=None)[source]

Bases: object

Location table class. ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 8.2.1

Variables:
Parameters:
  • mib (MIB) –

  • clock (Callable[[], float] | None) –

__init__(mib, clock=None)[source]

Constructor.

Parameters:
  • mib (MIB) – MIB to use.

  • clock (Callable[[], float] | None) – Local clock in ms (the router clock) for the LocTE lifetime.

get_entry(gn_address)[source]

Gets the entry of the location table.

Parameters:

gn_address (GNAddress) – GN address.

Returns:

Location table entry.

Return type:

LocationTableEntry | None

update_with_de_pv(de_pv)[source]

Forwarder step 7 of clauses 10.3.8.3 / 10.3.7.2: when the DE LocTE does not exist or is not a neighbour, update PV(DE) with the DE PV of the packet (clause C.2, only when newer). The DE PV is a Short Position Vector: PAI, speed and heading are set to 0 (NOTE 3).

Parameters:

de_pv (ShortPositionVector) –

Return type:

None

ensure_entry(gn_address)[source]

Gets or creates a LocTE for gn_address without modifying its fields.

Used by the Location Service to create a placeholder entry before setting ls_pending.

Parameters:

gn_address (GNAddress) – GN address.

Returns:

Existing or newly created location table entry.

Return type:

LocationTableEntry

get_entry_by_mid(mid)[source]

LocTE whose GN_ADDR carries the link-layer address mid in its MID field, used to identify the previous sender of a received packet.

Parameters:

mid (bytes) –

Return type:

LocationTableEntry | None

remove_entry(gn_address)[source]

Removes the LocTE of gn_address (e.g. when a LS does not complete).

Parameters:

gn_address (GNAddress) –

Return type:

None

refresh_table()[source]

Removes the entries whose soft-state lifetime itsGnLifetimeLocTE, restarted at each update on the local clock, has expired (ETSI TS 103 836-4-1 V2.2.1 clause 8.2.3).

Return type:

None

new_shb_packet(position_vector, packet)[source]

Updates the location table with a new packet.

Parameters:
  • position_vector (LongPositionVector) – Position vector of the packet.

  • packet (bytes) – SHB packet (without the basic header, the common header and the position vector).

Raises:
  • IncongruentTimestampException – If there has been another packet with posterior timestamp received before.

  • DuplicatedPacketException – If the packet is duplicated.

Return type:

None

new_guc_packet(guc_extended_header, packet)[source]

Updates the location table with a new GUC packet (SO LocTE).

Follows steps 5-6 of §10.3.8.3 / §10.3.8.4 of ETSI TS 103 836-4-1 V2.2.1 (2026-04). IS_NEIGHBOUR is set to FALSE for new entries only; unchanged for existing ones (NOTE 2).

Parameters:
  • guc_extended_header (GUCExtendedHeader) – GUC extended header.

  • packet (bytes) – GUC payload (without headers).

Raises:
  • IncongruentTimestampException – If a packet with a later timestamp was received before.

  • DuplicatedPacketException – If the packet is duplicated.

Return type:

None

new_tsb_packet(tsb_extended_header, packet)[source]

Updates the location table with a new TSB packet.

Parameters:
  • tsb_extended_header (TSBExtendedHeader) – TSB extended header.

  • packet (bytes) – TSB payload (without headers).

Raises:
  • IncongruentTimestampException – If a packet with a later timestamp was received before.

  • DuplicatedPacketException – If the packet is duplicated.

Return type:

None

new_gac_packet(gbc_extended_header, packet)[source]

Updates the location table with a new GAC packet (SO LocTE).

Follows steps 5-6 of §10.3.12.3 of ETSI TS 103 836-4-1 V2.2.1 (2026-04). GAC and GBC share the same extended header format (§9.8.5), so GBCExtendedHeader is reused for GAC. IS_NEIGHBOUR is set to FALSE for new entries only; unchanged for existing ones (NOTE 1).

Parameters:
  • gbc_extended_header (GBCExtendedHeader) – GAC extended header (same wire format as GBC).

  • packet (bytes) – GAC payload (without headers).

Raises:
  • IncongruentTimestampException – If a packet with a later timestamp was received before.

  • DuplicatedPacketException – If the packet is duplicated.

Return type:

None

new_ls_request_packet(ls_request_header, packet)[source]

Updates the location table with a new LS Request packet (SO LocTE).

Follows steps 5-6 of §10.3.7.3 of ETSI TS 103 836-4-1 V2.2.1 (2026-04). IS_NEIGHBOUR is set to FALSE for new entries only; unchanged for existing ones (NOTE).

Parameters:
  • ls_request_header (LSRequestExtendedHeader) – LS Request extended header.

  • packet (bytes) – LS Request payload/data (used for DPD).

Raises:
  • IncongruentTimestampException – If a packet with a later timestamp was received before.

  • DuplicatedPacketException – If the packet is duplicated.

Return type:

None

new_ls_reply_packet(ls_reply_header, packet)[source]

Updates the location table with a new LS Reply packet (SO LocTE).

Follows steps 4-5 of §10.3.7.1.4 of ETSI TS 103 836-4-1 V2.2.1 (2026-04). The LS Reply SO PV is the replier’s position; IS_NEIGHBOUR is set to FALSE for new entries.

Parameters:
  • ls_reply_header (LSReplyExtendedHeader) – LS Reply extended header.

  • packet (bytes) – LS Reply payload (used for DPD).

Raises:
  • IncongruentTimestampException – If a packet with a later timestamp was received before.

  • DuplicatedPacketException – If the packet is duplicated.

Return type:

None

new_gbc_packet(gbc_extended_header, packet)[source]

Updates the location table with a new packet.

Parameters:
  • gbc_extended_header (GBCExtendedHeader) – GBC extended header.

  • packet (bytes) – GBC packet (without the basic header, the common header and the extended header).

Raises:
  • IncongruentTimestampException – If there has been another packet with posterior timestamp received before.

  • DuplicatedPacketException – If the packet is duplicated.

Return type:

None

get_neighbours()[source]

Gets the neighbours.

Returns:

List of neighbours.

Return type:

List[LocationTableEntry]

PositionVector

class flexstack.geonet.position_vector.TST(msec=0)[source]

Bases: object

Timestamp class. ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 9.5.2

Expresses the time in milliseconds at which the latitude and longitude of the ITS-S were acquired by the GeoAdhoc router. The time is encoded as: TST = TST(TAI)mod 2^32 where TST(TAI) is the number of elapsed TAI milliseconds since 2004-01-01 00:00:00.000 UTC

Variables:

msec (int) – Milliseconds.

Parameters:

msec (int) –

msec: int = 0
classmethod set_in_normal_timestamp_seconds(utc_timestamp_seconds)[source]

Set the timestamp in normal timestamp format.

Parameters:

utc_timestamp_seconds (float) – Timestamp in normal UTC timestamp format.

Return type:

TST

classmethod set_in_normal_timestamp_milliseconds(utc_timestamp_milliseconds)[source]

Set the timestamp in normal timestamp format.

Parameters:

utc_timestamp_milliseconds (int) – Timestamp in normal UTC timestamp format.

Return type:

TST

encode()[source]

Encode the timestamp.

Returns:

Encoded timestamp.

Return type:

int

classmethod decode(data)[source]

Decode the timestamp.

Parameters:

data (int) – Encoded timestamp.

Return type:

TST

class flexstack.geonet.position_vector.LongPositionVector(gn_addr=GNAddress(m=<M.GN_UNICAST: 0>, st=<ST.UNKNOWN: 0>, mid=MID(mid=b'\x00\x00\x00\x00\x00\x00')), tst=TST(msec=0), latitude=0, longitude=0, pai=False, s=0, h=0)[source]

Bases: object

Long Position Vector class. ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 9.5.2

Variables:
  • gn_addr (GNAddress) – GeoNetworking address GN_ADDR.

  • tst (TST) – Timestamp TST indicating when the geographical position POS was generated.

  • Latitude (int) – Latitude of the ITS-S. WGS 84 1/10 micro degree.

  • Longitude (int) – Longitude of the ITS-S. WGS 84 1/10 micro degree.

  • pai (bool) – Accuracy of the geographical position PAI. Set to 1 (i.e. True) if the semiMajorConfidence of the PosConfidenceEllipse as specified in ETSI TS 102 894-2 [11] is smaller than the GN protocol constant itsGnPaiInterval / 2 Set to 0 (i.e. False) otherwise

  • s (int) – Speed S. 0.01 m/s.

  • h (int) – Heading H. 0.1 degree from north.

Parameters:
  • gn_addr (GNAddress) –

  • tst (TST) –

  • latitude (int) –

  • longitude (int) –

  • pai (bool) –

  • s (int) –

  • h (int) –

gn_addr: GNAddress = GNAddress(m=<M.GN_UNICAST: 0>, st=<ST.UNKNOWN: 0>, mid=MID(mid=b'\x00\x00\x00\x00\x00\x00'))
tst: TST = TST(msec=0)
latitude: int = 0
longitude: int = 0
pai: bool = False
s: int = 0
h: int = 0
set_gn_addr(gn_addr)[source]

Set the GN address.

Parameters:

gn_addr (GNAddress) – GN address.

Return type:

LongPositionVector

set_tst_in_normal_timestamp_seconds(timestamp)[source]

Set the timestamp in normal timestamp format.

Parameters:

timestamp (float) – Timestamp in normal timestamp format.

Return type:

LongPositionVector

set_tst_in_normal_timestamp_milliseconds(timestamp)[source]

Set the timestamp in normal timestamp format.

Parameters:

timestamp (int) – Timestamp in normal timestamp format.

Return type:

LongPositionVector

set_latitude(latitude)[source]

Set the latitude.

Parameters:

latitude (float) – Latitude in WGS 84 1/10 micro degree.

Return type:

LongPositionVector

set_longitude(longitude)[source]

Set the longitude.

Parameters:

longitude (float) – Longitude in WGS 84 1/10 micro degree.

Return type:

LongPositionVector

set_pai(pai)[source]

Set the PAI.

Parameters:

pai (bool) – PAI.

Return type:

LongPositionVector

set_speed(speed)[source]

Set the speed.

Parameters:

speed (float) – Speed in m/s.

Return type:

LongPositionVector

set_heading(heading)[source]

Set the heading.

Parameters:

heading (float) – Heading in degree from north.

Return type:

LongPositionVector

refresh_with_tpv_data(tpv_data)[source]

Refresh the LongPositionVector with a dict containing the data from a GPSD TPV message.

Parameters:

tpv_data (dict) – Dict containing the data from a GPSD TPV message.

Return type:

LongPositionVector

encode()[source]

Encode the LongPositionVector.

Returns:

Encoded LongPositionVector.

Return type:

bytes

encode_to_int()[source]

Encode the LongPositionVector.

Returns:

Encoded LongPositionVector.

Return type:

int

classmethod decode(data)[source]

Decode the LongPositionVector.

Parameters:

data (bytes) – Encoded LongPositionVector.

Return type:

LongPositionVector

class flexstack.geonet.position_vector.ShortPositionVector(gn_addr=GNAddress(m=<M.GN_UNICAST: 0>, st=<ST.UNKNOWN: 0>, mid=MID(mid=b'\x00\x00\x00\x00\x00\x00')), tst=TST(msec=0), latitude=0, longitude=0)[source]

Bases: object

Short Position Vector class. ETSI TS 103 836-4-1 V2.2.1 (2026-04). Section 9.5.2

Variables:
  • gn_addr (GNAddress) – GeoNetworking address GN_ADDR.

  • tst (TST) – Timestamp TST indicating when the geographical position POS was generated.

  • latitude (int) – Latitude of the ITS-S. WGS 84 1/10 micro degree.

  • longitude (int) – Longitude of the ITS-S. WGS 84 1/10 micro degree.

Parameters:
  • gn_addr (GNAddress) –

  • tst (TST) –

  • latitude (int) –

  • longitude (int) –

gn_addr: GNAddress = GNAddress(m=<M.GN_UNICAST: 0>, st=<ST.UNKNOWN: 0>, mid=MID(mid=b'\x00\x00\x00\x00\x00\x00'))
tst: TST = TST(msec=0)
latitude: int = 0
longitude: int = 0
set_gn_addr(gn_addr)[source]

Set the GN address.

Parameters:

gn_addr (GNAddress) – GN address.

Return type:

ShortPositionVector

set_tst_in_normal_timestamp_seconds(timestamp)[source]

Set the timestamp in normal timestamp format.

Parameters:

timestamp (int) – Timestamp in normal timestamp format.

Return type:

ShortPositionVector

set_tst_in_normal_timestamp_milliseconds(timestamp)[source]

Set the timestamp in normal timestamp format.

Parameters:

timestamp (int) – Timestamp in normal timestamp format.

Return type:

ShortPositionVector

set_latitude(latitude)[source]

Set the latitude.

Parameters:

latitude (float) – Latitude in WGS 84 1/10 micro degree.

Return type:

ShortPositionVector

get_latitude()[source]

Get the latitude.

Returns:

Latitude in WGS 84 1/10 micro degree.

Return type:

float

set_longitude(longitude)[source]

Set the longitude.

Parameters:

longitude (float) – Longitude in WGS 84 1/10 micro degree.

Return type:

ShortPositionVector

get_longitude()[source]

Get the longitude.

Returns:

Longitude in WGS 84 1/10 micro degree.

Return type:

float

encode()[source]

Encode the ShortPositionVector.

Returns:

Encoded ShortPositionVector.

Return type:

bytes

encode_to_int()[source]

Encode the ShortPositionVector.

Returns:

Encoded ShortPositionVector.

Return type:

int

classmethod decode(data)[source]

Decode the ShortPositionVector.

Parameters:

data (bytes) – Encoded ShortPositionVector.

Return type:

ShortPositionVector