Rust GeoNetworking (GN) Router
The rustflexstack::geonet module implements ETSI TS 103 836-4-1 V2.2.1 (GeoNetworking), with the ITS-G5 media-dependent functions of TS 103 836-4-2 (DCC_NET, optional).
Features
Packet types: Beacon, Single-Hop Broadcast (SHB), Topologically-Scoped Broadcast (TSB), GeoBroadcast (GBC), GeoAnycast (GAC), GeoUnicast (GUC), LS Request and LS Reply.
Location Service: resolution of unknown destinations with LS Request and LS Reply.
Forwarding: greedy forwarding and contention-based forwarding, with packet buffers and store-carry-forward.
Security: optional signing on transmission and verification on reception (ETSI TS 103 097, see Rust Security Subsystem).
Spawning the GeoNetworking Router
The router runs in its own thread. Router::spawn returns its handle, the receiver of the packets for the link layer, and the receiver of the indications for BTP:
use rustflexstack::geonet::gn_address::{GNAddress, M, MID, ST};
use rustflexstack::geonet::mib::{GnIfType, Mib};
use rustflexstack::geonet::position_vector::LongPositionVector;
use rustflexstack::geonet::router::Router as GNRouter;
let mac = [0x02u8, 0x11, 0x22, 0x33, 0x44, 0x55];
let mut mib = Mib::new();
mib.itsGnLocalGnAddr = GNAddress::new(M::GnMulticast, ST::PassengerCar, MID::new(mac));
mib.itsGnIfType = GnIfType::ItsG5;
let (gn_handle, gn_to_ll_rx, gn_to_btp_rx) = GNRouter::spawn(
mib,
None, // SignService (signing)
None, // EcdsaBackend (verification)
None, // CertificateLibrary (verification)
);
Transmitting with GNDataRequest
use rustflexstack::geonet::service_access_point::{
Area, CommonNH, CommunicationProfile, GNDataRequest, HeaderSubType, HeaderType,
PacketTransportType, TopoBroadcastHST, TrafficClass,
};
use rustflexstack::security::sn_sap::SecurityProfile;
let payload = b"upper-layer payload".to_vec();
let request = GNDataRequest {
upper_protocol_entity: CommonNH::BtpB,
packet_transport_type: PacketTransportType {
header_type: HeaderType::Tsb,
header_sub_type: HeaderSubType::TopoBroadcast(TopoBroadcastHST::SingleHop),
},
communication_profile: CommunicationProfile::Unspecified,
traffic_class: TrafficClass { scf: false, channel_offload: false, tc_id: 0 },
security_profile: SecurityProfile::NoSecurity,
its_aid: 36,
security_permissions: vec![],
max_hop_limit: 1,
max_packet_lifetime: None,
destination: None,
length: payload.len() as u16,
data: payload,
area: Area { latitude: 0, longitude: 0, a: 0, b: 0, angle: 0 },
};
gn_handle.send_gn_data_request(request);
Updating the Ego Position
The router’s ego position vector is updated from each GNSS fix:
let (latitude, longitude, speed_mps, heading_deg) = (41.3851, 2.1734, 13.9, 90.0);
let fix_time_ms: Option<u64> = None; // time of the GNSS fix (ms since the Unix epoch), if known
let mut epv = LongPositionVector::decode([0u8; 24]);
epv.update_from_gps_at(latitude, longitude, speed_mps, heading_deg, true, fix_time_ms);
gn_handle.update_position_vector(epv);
rustflexstack::facilities::location_service::LocationService provides GNSS fixes from gpsd or a static position; examples/denm_sender_receiver.rs connects it to the router.