FlexStack Logo

1. Overview & Architecture

  • Ecosystem Overview
  • Getting Started
  • Unified Architecture & Design
  • Supported ETSI C-ITS Standards
  • Performance & Validation

2. Python (v2xflexstack)

  • Python Quickstart (v2xflexstack)
  • Python Concurrency & Architecture
  • Python Link Layer Abstraction
  • Python GeoNetworking (GN) Protocol
  • Python Basic Transport Protocol (BTP)
  • Python Security Subsystem
  • Cooperative Awareness (CA) Basic Service
  • Decentralized Environmental Notification (DEN) Service
  • Vulnerable Road User (VRU) Awareness Service
  • Local Dynamic Map
  • Python Location & Time Utilities
  • Python API Reference
    • flexstack.linklayer Module
    • flexstack.geonet Module
    • flexstack.btp Module
    • flexstack.security Module
    • flexstack.facilities Module
    • flexstack.management Module
    • flexstack.utils Module

3. Rust (rustflexstack)

  • Rust Quickstart (rustflexstack)
  • Rust Actor Architecture & Concurrency
  • Rust Link Layer Drivers
  • Rust GeoNetworking (GN) Router
  • Rust Basic Transport Protocol (BTP)
  • Rust Security Subsystem
  • Rust Cooperative Awareness (CAM)
  • Rust Decentralized Environmental (DENM)
  • Rust VRU Awareness (VAM)
  • Rust Local Dynamic Map (LDM)
  • Cross-Compilation for Embedded Linux
  • Embedded Qualcomm C-V2X (Cohda MK6 Deployment)
  • Rust API Reference
    • Rust API: Link Layer
    • Rust API: GeoNetworking
    • Rust API: BTP
    • Rust API: Security
    • Rust API: Facilities
    • Rust API: Management

4. Tutorials & Hardware Deployment

  • Docker Deployment Tutorial
  • V2X Over Ethernet & Virtual Pairs (veth) Tutorial
  • Logging Configuration Tutorial
  • Rust V2X CLI Tool Tutorial (v2x_cli)
  • Certificates: Static Chains and PKI Provisioning
  • Cohda MK6 C-V2X Hardware Deployment Tutorial

5. About & Community

  • Academic Citation & Research Paper
  • Research Projects & Grants
  • License & Attributions
FlexStack
  • Python Link Layer Abstraction
  • View page source

Python Link Layer Abstraction

The link layer in v2xflexstack (package flexstack.linklayer) is the only part of the stack that depends on the radio or network interface. Every implementation derives from LinkLayer: it is created with a receive callback, which it calls with every received GeoNetworking frame, and it offers send(packet) to the GeoNetworking router.

Supported Implementations

Implementation

Underlying Technology

Typical Environment

RawLinkLayer

Linux raw sockets (PF_PACKET, EtherType 0x8947)

IEEE 802.11p (ITS-G5, OCB mode), Ethernet, virtual Ethernet pairs

PythonCV2XLinkLayer

Qualcomm Telematics SDK, through a C++ extension built with pybind11

C-V2X PC5 sidelink (e.g. Cohda MK6)

RawLinkLayer

RawLinkLayer(iface, mac_address, receive_callback) binds a raw socket to the interface, starts a receive thread, and passes every frame with the GeoNetworking EtherType to the callback. Root privileges or the CAP_NET_RAW capability are needed.

from flexstack.linklayer.raw_link_layer import RawLinkLayer

def on_frame_received(packet: bytes) -> None:
    print(f"Received a {len(packet)}-byte GeoNetworking packet")

mac_address = b"\x02\x11\x22\x33\x44\x55"
link_layer = RawLinkLayer("eth0", mac_address, receive_callback=on_frame_received)

# Normally called by the GeoNetworking router: broadcast a GeoNetworking packet
link_layer.send(b"\x11\x00\x1a\x01")

In a station, the receive callback is the GeoNetworking router’s gn_data_indicate and the router is given the link layer, as in the Python Quickstart (v2xflexstack) example:

link_layer = RawLinkLayer("eth0", mac_address, receive_callback=gn_router.gn_data_indicate)
gn_router.link_layer = link_layer

Over ITS-G5 the MID of the station’s GeoNetworking address must be the MAC address of the interface (ETSI TS 103 836-4-2, clause 6.1); gn_router.media_dependent_address_ok() checks it.

PythonCV2XLinkLayer (Qualcomm C-V2X)

PythonCV2XLinkLayer wraps a C++ shared library (cv2xlinklayer.so) that opens the C-V2X transmit and receive flows of the Qualcomm Telematics SDK (telux::cv2x). It only runs on a device with that SDK.

Building the C++ extension

Prerequisites: CMake (3.12 or later), pybind11, the Qualcomm telux_cv2x SDK and a C++ compiler or cross-compilation toolchain for the device.

cd FlexStack/src/flexstack/linklayer/cv2xlinklayer
mkdir build && cd build
cmake ..
make -j$(nproc)

Usage

from flexstack.linklayer.cv2x_link_layer import PythonCV2XLinkLayer

link_layer = PythonCV2XLinkLayer(receive_callback=gn_router.gn_data_indicate)
gn_router.link_layer = link_layer
Previous Next

© Copyright 2025-2026, i2CAT Foundation.

Built with Sphinx using a theme provided by Read the Docs.