How to use Vanetza on the cube:evk
Accelerate V2X development with Vanetza
Vanetza is an open-source implementation of the ETSI C-ITS protocol suite. Its modular design gives developers and researchers direct access to V2X and its ETSI implementations. Among others, it comprises:
- GeoNetworking (GN)
- Basic Transport Protocol (BTP)
- Decentralized Congestion Control (DCC)
- Security
- Support for ASN.1 messages (Facilities) such as CAM and DENM
The V2X evaluation kit cube:evk comes with native support for Vanetza and its socktap application. Socktap is an example application demonstrating API usage of Vanetza libraries, including support for the cube:evk.
How It Works
The cube:evk provides an RPC (Remote Procedure Call) interface that gives remote access to its V2X radio over IP networks. Built on Cap'n Proto, the cube-radio-rpc service launches automatically when the V2X radio is configured and listens on TCP port 23057. GNSS data is available over the network through gpsd.
- Language flexibility: clients in C++, Python, Go, Rust, and more
- Network transparency: control the radio from anywhere on the network
- Type safety: a schema file defines the contract between server and client
- Zero-copy serialization: low overhead through Cap'n Proto
Step 1: Configure the V2X Radio
Configure the V2X module with the cube-v2xconfig tool. To start C-V2X and enable it on boot:
cube:~$ cube-v2xconfig start cv2x
cube:~$ cube-v2xconfig enable cv2x
For DSRC/ITS-G5:
cube:~$ cube-v2xconfig start dsrc
cube:~$ cube-v2xconfig enable dsrc
Step 2: Verify the RPC Service
Check that cube-radio-rpc is listening on port 23057:
cube:~$ sudo netstat -tlnp | grep 23057
tcp6 0 0 :::23057 :::* LISTEN 567/cube-radio-rpc
Step 3: Connect to the Network
The host reaches the cube:evk over Ethernet or Wi-Fi. To join a Wi-Fi network and look up the IP address:
cube:~$ nmcli dev wifi connect '<ssid>' password '<password>'
cube:~$ ip a
Step 4: Run socktap on the Host
Vanetza's socktap includes a built-in RPC link layer that connects directly to cube-radio-rpc. Socktap runs on the host while the cube:evk handles the V2X radio communication:
# Build Vanetza with socktap
host:~$ git clone https://github.com/riebl/vanetza.git && cd vanetza
host:~$ mkdir build && cd build
host:~$ cmake -DBUILD_SOCKTAP=ON ..
host:~$ make
# Run socktap using the RPC link layer (replace with your cube's IP)
host:~$ ./bin/socktap -l rpc --rpc-host 192.168.8.201 --gpsd-host 192.168.8.201
Example output:
Starting runtime at 2025-Nov-07 10:36:01.881303
Enable application 'ca'...
Connected to RPC server id=0 version=1
RPC server's info: cube-radio=dsrc
Step 5: Write a Python Client
Custom V2X applications can use the RPC interface directly. Set up a Python environment and download the cube_rpc.capnp schema into the working directory:
python3 -m venv .venv
source .venv/bin/activate
pip install pycapnp
Connect to the RPC service and identify the device:
import asyncio
import capnp
capnp.remove_import_hook()
cube_rpc = capnp.load(
'cube_rpc.capnp',
'Cube RPC',
['/usr/include/', '/usr/local/include/']
)
async def main():
host = '192.168.8.201' # Your cube's IP
port = 23057
stream = await capnp.AsyncIoStream.create_connection(host=host, port=port)
client = capnp.TwoPartyClient(stream)
link_layer = client.bootstrap().cast_as(cube_rpc.LinkLayer)
# Identify the connected device
result = await link_layer.identify()
print(f"id: {result.id}, version: {result.version}, info: {result.info}")
if __name__ == '__main__':
asyncio.run(capnp.run(main()))
Transmit a V2X frame:
frame = {
"sourceAddress": bytes.fromhex("001122334455"),
"destinationAddress": bytes.fromhex("FFFFFFFFFFFF"),
"payload": b"Hello from Python RPC!"
}
tx_params = {
"wlan": {
"priority": 3,
"power": int(10 * 8), # 10 dBm
"datarate": 6 * 2 # 6 Mbps
}
}
result = await link_layer.transmitData(frame=frame, txParams=tx_params)
Subscribe to incoming frames:
class DataListenerImpl(cube_rpc.LinkLayer.DataListener.Server):
async def onDataIndication(self, frame, rxParams, **kwargs):
payload = bytes(frame.payload)
print(f"src: {frame.sourceAddress.hex()}")
print(f"dest: {frame.destinationAddress.hex()}")
if rxParams.which() == 'wlan':
power_dbm = rxParams.wlan.power / 8.0
print(f"power: {power_dbm:.1f} dBm")
listener = DataListenerImpl()
await link_layer.subscribeData(listener=listener)
await asyncio.Event().wait() # Keep listening
The cube:evk is designed for research, development, and prototyping. With an RPC interface alongside open-source tools like Vanetza, the radio can be used from any machine on the network.
Visit our Knowledge Base for complete RPC documentation and more examples.
Happy coding!