Python GeoNetworking (GN) Protocol

The GeoNetworking router (flexstack.geonet.router.Router) implements ETSI TS 103 836-4-1 V2.2.1: all packet types (Beacon, SHB, TSB, GBC, GAC, GUC, LS Request and LS Reply), greedy and contention-based forwarding, the location service, the location table, packet buffers with store-carry-forward, and duplicate packet and address detection. The ITS-G5 media-dependent functions of TS 103 836-4-2 (DCC_NET) are optional.

Layer Architecture

flowchart TD
    BTP["Basic Transport Protocol (BTP)"]
    GN["GeoNetworking (GN) Router"]
    SEC["Security<br/>(ETSI TS 103 097)"]
    LL["Link Layer<br/>(802.11p / C-V2X / Ethernet)"]

    BTP -->|"GN-DATA.request"| GN
    GN -->|"GN-DATA.indication"| BTP
    GN <-->|"frames"| LL
    GN -->|"SN-SIGN / SN-VERIFY"| SEC

    style BTP fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a8a
    style GN fill:#fee2e2,stroke:#dc2626,stroke-width:2px,color:#7f1d1d
    style SEC fill:#f3e8ff,stroke:#7c3aed,stroke-width:2px,color:#581c87
    style LL fill:#fef3c7,stroke:#d97706,stroke-width:2px,color:#78350f

Core Components

  • Router: packet encapsulation, forwarding, location service and the location table.

  • MIB (flexstack.geonet.mib): the Management Information Base, a frozen dataclass whose fields are the itsGn* parameters of the standard (local address, interface type, security, beacon timer, packet lifetimes, DCC_NET, …). Set them when it is created.

  • GNAddress: the 64-bit GeoNetworking address (m, st and mid).

Router Instantiation

from flexstack.geonet.gn_address import GNAddress, M, ST, MID
from flexstack.geonet.mib import GnIfType, MIB
from flexstack.geonet.router import Router as GNRouter

mac_address = b"\x02\xbb\xcc\xdd\xee\xff"
mib = MIB(
    itsGnIfType=GnIfType.ITS_G5,
    itsGnLocalGnAddr=GNAddress(m=M.GN_MULTICAST, st=ST.PASSENGER_CAR, mid=MID(mac_address)),
)
gn_router = GNRouter(mib=mib, sign_service=None)

# The router needs the ego position (TPV dictionaries from a location service)
location_service.add_callback(gn_router.refresh_ego_position_vector)

With sign_service=None the station is unsecured. For a secured station, see Python Security Subsystem.

Sending GeoNetworking Packets

Upper layers send data with a GNDataRequest, a frozen dataclass built with keyword arguments. The default packet transport type is a single-hop broadcast (SHB):

from flexstack.geonet.service_access_point import (
    CommonNH,
    GNDataRequest,
    PacketTransportType,
)

payload = b"upper-layer payload"
request = GNDataRequest(
    upper_protocol_entity=CommonNH.BTP_B,
    packet_transport_type=PacketTransportType(),  # SHB
    its_aid=36,
    data=payload,
    length=len(payload),
)
confirm = gn_router.gn_data_request(request)

A GeoBroadcast to a circle of 500 m around a point (latitude and longitude in tenths of a microdegree):

from flexstack.geonet.service_access_point import Area, GeoBroadcastHST, HeaderType

request = GNDataRequest(
    upper_protocol_entity=CommonNH.BTP_B,
    packet_transport_type=PacketTransportType(
        header_type=HeaderType.GEOBROADCAST,
        header_subtype=GeoBroadcastHST.GEOBROADCAST_CIRCLE,
    ),
    area=Area(latitude=413_869_310, longitude=21_121_040, a=500, b=500, angle=0),
    max_hop_limit=10,
    its_aid=37,
    data=payload,
    length=len(payload),
)
gn_router.gn_data_request(request)

Receiving GeoNetworking Packets

The router passes every packet for this station to the callback registered with register_indication_callback (normally the BTP router):

from flexstack.geonet.service_access_point import GNDataIndication

def on_gn_packet(indication: GNDataIndication) -> None:
    print(f"{indication.length} bytes from {indication.source_position_vector.gn_addr}")

gn_router.register_indication_callback(on_gn_packet)

The link layer delivers received frames to gn_router.gn_data_indicate (see Python Link Layer Abstraction). To observe the security verdict of every received secured packet, verified or not, register an observer with gn_router.set_verify_observer(callback).