Unified Architecture & Design

V2X FlexStack follows a modular, layer-decoupled architectural pattern implementing the European Telecommunications Standards Institute (ETSI) Cooperative Intelligent Transport Systems (C-ITS) Release 2 protocol suite.

Both the Python (v2xflexstack) and Rust (rustflexstack) implementations share the same fundamental architectural foundations: strictly defined Service Access Points (SAPs), a hardware-agnostic Link Layer abstraction, and comprehensive Facilities management.

ETSI C-ITS Layer Stack

The protocol stack is organized into five vertically decoupled layers according to ETSI EN 302 665:

flowchart LR
    subgraph MGT_COL ["<b>MANAGEMENT ENTITY</b><br/>&nbsp;"]
        direction TB
        MGT_DCC["<b>Decentralized Congestion Control (DCC)</b><br/>• ETSI TS 102 687 & TS 103 175<br/>• Channel Busy Ratio (CBR) evaluation<br/>• DCC Adaptive & Reactive algorithms<br/>• Transmit rate, power & MCS throttling"]
        MGT_SAP["<b>Cross-Layer Management SAPs</b><br/>• <b>MA-SAP</b>: Application layer profile<br/>• <b>MF-SAP</b>: Facilities LDM & CAM/DENM<br/>• <b>MS-SAP</b>: Transport flow control<br/>• <b>MN-SAP</b>: GeoNet MIB & Router state<br/>• <b>MI-SAP</b>: Link layer & DCC state machine"]
        MGT_DCC --- MGT_SAP
    end

    subgraph STACK_COL ["<b>ETSI C-ITS PROTOCOL STACK</b><br/>&nbsp;"]
        direction TB
        APP["<b>APPLICATIONS LAYER</b><br/>Road Hazard Signaling (RHS), VRU Safety, Tele-operation<br/><i>ETSI TS 101 539-1 / TS 101 539-2 / TS 101 539-3</i>"]
        FAC["<b>FACILITIES LAYER</b><br/>CAM (TS 103 900) • DENM (TS 103 831) • VAM (TS 103 300)<br/>Local Dynamic Map (LDM, EN 302 895 / TS 103 301)"]
        TRP["<b>TRANSPORT LAYER</b><br/>Basic Transport Protocol (BTP-A & BTP-B)<br/><i>ETSI EN 302 636-5-1 / TS 103 836-5-1</i>"]
        NET["<b>NETWORK LAYER</b><br/>GeoNetworking Router (SHB, TSB, GBC) & MIB<br/><i>ETSI EN 302 636-4-1 / TS 103 836-4-1</i>"]
        ACC["<b>ACCESS & LINK LAYER</b><br/>RawLinkLayer (802.11p / Ethernet) • Cv2xLinkLayer (PC5 C-V2X)<br/><i>IEEE 802.11p / 3GPP Rel 14/15 PC5 Mode 4</i>"]

        APP -->|"FA-SAP (TS 102 894)"| FAC
        FAC -->|"BTP-SAP (EN 302 636-5)"| TRP
        TRP -->|"GN-SAP (EN 302 636-4)"| NET
        NET -->|"IN-SAP (TS 102 723)"| ACC
    end

    subgraph SEC_COL ["<b>SECURITY ENTITY</b><br/>&nbsp;"]
        direction TB
        SEC_CRYPTO["<b>ETSI TS 103 097 Security Services</b><br/>• Secured Headers & Generic Format<br/>• ECDSA P-256, P-384, brainpool (software back end)<br/>• Real-time packet signing & verification<br/>• Certificate verification & Local Cache"]
        SEC_PKI["<b>Trust & Privacy PKI (TS 102 941)</b><br/>• Enrolment Authority (EA) requests<br/>• Authorization Authority (AA) tickets<br/>• CTL / CRL retrieval (TS 103 601)<br/><br/><b>Security SAPs</b><br/>• <b>SF-SAP</b>: Certificate permissions & AT<br/>• <b>SN-SAP</b>: GeoNet fast sign/verify"]
        SEC_CRYPTO --- SEC_PKI
    end

    MGT_COL <== "Cross-Layer Management<br/>(MA / MF / MS / MN / MI SAP)" ==> STACK_COL
    STACK_COL <== "Trust & Security Verification<br/>(SF-SAP / SN-SAP)" ==> SEC_COL

    style MGT_COL fill:#f5f3ff,stroke:#7c3aed,stroke-width:2px,color:#4c1d95
    style MGT_DCC fill:#ede9fe,stroke:#8b5cf6,stroke-width:1.5px,color:#2e1065
    style MGT_SAP fill:#ede9fe,stroke:#8b5cf6,stroke-width:1.5px,color:#2e1065

    style STACK_COL fill:#f8fafc,stroke:#334155,stroke-width:2px,color:#0f172a
    style APP fill:#f1f5f9,stroke:#64748b,stroke-width:1.5px,color:#0f172a
    style FAC fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
    style TRP fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#1e3a8a
    style NET fill:#fee2e2,stroke:#dc2626,stroke-width:1.5px,color:#7f1d1d
    style ACC fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f

    style SEC_COL fill:#faf5ff,stroke:#9333ea,stroke-width:2px,color:#581c87
    style SEC_CRYPTO fill:#f3e8ff,stroke:#a855f7,stroke-width:1.5px,color:#3b0764
    style SEC_PKI fill:#f3e8ff,stroke:#a855f7,stroke-width:1.5px,color:#3b0764

The Service Access Point (SAP) Paradigm

To ensure strict vertical isolation between protocol layers, interactions occur exclusively across standardized Service Access Points (SAPs). Communication uses formal primitives:

  1. Request Primitives (Downstream data flow): An upper layer requests a service from a lower layer (e.g., GNDataRequest, BTPDataRequest).

  2. Indication Primitives (Upstream data flow): A lower layer notifies an upper layer of an incoming packet or event (e.g., GNDataIndication, BTPDataIndication).

  3. Confirm Primitives (Feedback): Reports transmission status, channel feedback, or security validation back to the issuing service.

Language Concurrency Models: Callbacks vs. Actor Channels

While both implementations offer identical protocol semantics and wire compatibility, their concurrency architectures are optimized for their respective language paradigms:

Python (v2xflexstack): Callback-Driven Event Model

The Python implementation leverages a reactive callback-driven architecture:

  • Non-blocking Dispatch: Lower layers (Link Layer and GeoNetworking) maintain listener threads that dispatch incoming packets upstream by executing registered callback functions.

  • Dynamic Registration: Upper layers dynamically register interest in specific packet types, BTP destination ports, or LDM spatial-temporal updates.

  • Strategy Pattern on LinkLayer: Physical network access is abstracted via an abstract base class (LinkLayer), allowing runtime substitution between RawLinkLayer (Linux socket PF_PACKET) and CV2XLinkLayer (Qualcomm Telematics SDK).

  • Ideal For: Rapid experimentation, dynamic standard modification, academic simulation, and algorithm prototyping.

Rust (rustflexstack): Multi-Threaded Actor Model

The Rust implementation is engineered as a concurrent actor system:

  • OS Thread per Layer: Each major protocol component (LinkLayer, GeoNetworking Router, BTP Router, LDM) executes in its own dedicated operating system thread.

  • Channel-Based Messaging: Intra-stack communication takes place through Rust standard library std::sync::mpsc (Multiple Producer, Single Consumer) channels. Layers never share mutable state.

  • Lightweight Handles: Applications and upper layers interact with running actors through lightweight, cloneable handle structs (e.g., RouterHandle, BTPRouterHandle) that encapsulate channel senders.

  • Move Semantics & Memory Safety: Packet buffers and parsed structures are moved across threads rather than copied, and there is no garbage collector.

  • Ideal For: In-vehicle On-Board Units (Cohda MK6), Roadside Units (RSUs) and embedded Arm platforms.

Cross-Layer Management & Security

Security Subsystem (SN-SAP)

The Security entity complies with ETSI TS 103 097. GeoNetworking packets can be signed downstream before transmission and verified upstream upon reception. The security service maintains a local certificate cache (CertificateLibrary) and interfaces with European C-ITS PKIs (ETSI TS 102 941) for enrolment and authorization.

Decentralized Congestion Control (DCC)

Both implementations incorporate DCC algorithms (ETSI TS 102 687). Channel load measurements (Channel Busy Ratio, CBR) feed into the management entity to dynamically throttle packet generation rates, adjust transmit power, or switch modulation coding schemes, ensuring the radio channel is never saturated.