Fragment large V2X_RX messages and decode road-RSU SPATEMs
The firmware dropped every received ITS message over 494 bytes (one link message), so a road RSU's 888-byte SPATEM and 1198-byte MAPEM never reached the phone. V2X_RX now goes out in link fragments up to 2300 bytes, best effort and non-blocking; messages up to 494 bytes are unchanged. The app's SPATEM decoder then refused those messages because they carry intersection and movement names and advisory speed lists. It now reads past both, checked against asn1tools on 718 distinct messages. Adds the pure fragmenter with host tests and a pcap replay, a Kotlin cross-check on the firmware's own fragments, tools/rx_size_compare.py, docs/08-large-message-reception.md and station-link revision 3.
This commit is contained in:
@@ -644,20 +644,28 @@ void Station::forward_raw(const ByteBuffer& frame, int rssi) {
|
||||
// Most captured frames are not ITS traffic this handles; false is the common case, not an error.
|
||||
gn_rx_t rx;
|
||||
if (!gn_unwrap_its(frame.data(), static_cast<int>(frame.size()), &rx)) return;
|
||||
const bool fits = link::v2x_rx_fits(rx);
|
||||
if (!fits) {
|
||||
++raw_oversize_;
|
||||
static std::int64_t last_report = 0; // one line per 10 s at most, the counter has the rest
|
||||
const auto now = esp_timer_get_time();
|
||||
if (now - last_report > 10000000) {
|
||||
last_report = now;
|
||||
ESP_LOGW(TAG, "V2X_RX: port %u message of %d bytes does not fit a link message (%lu dropped so far)",
|
||||
unsigned(rx.btp_dest_port), rx.payload_len, (unsigned long)raw_oversize_);
|
||||
}
|
||||
return;
|
||||
const auto plan = link::v2x_rx_plan(rx, (raw_mode_ & C5Radio::capture_on) != 0);
|
||||
// A message above one link message goes out in fragments (LinkService), best effort: no retry, no waiting, so
|
||||
// a lost fragment costs that message only and never the receive path.
|
||||
switch (plan) {
|
||||
case link::V2xRxPlan::drop: ++raw_oversize_; break;
|
||||
case link::V2xRxPlan::covered_by_raw: ++raw_covered_; break;
|
||||
case link::V2xRxPlan::single: ++raw_forwarded_; break;
|
||||
case link::V2xRxPlan::fragmented: ++raw_fragmented_; break;
|
||||
}
|
||||
if (plan == link::V2xRxPlan::single || plan == link::V2xRxPlan::fragmented) {
|
||||
if (!raw_its_(link::encode_v2x_rx(rx, rssi)) && plan == link::V2xRxPlan::fragmented) ++raw_fragment_failed_;
|
||||
}
|
||||
if (plan == link::V2xRxPlan::single || plan == link::V2xRxPlan::covered_by_raw) return;
|
||||
static std::int64_t last_report = 0; // one line per 10 s at most, the counters have the rest
|
||||
const auto now = esp_timer_get_time();
|
||||
if (now - last_report > 10000000) {
|
||||
last_report = now;
|
||||
ESP_LOGW(TAG, "V2X_RX: port %u message of %d bytes: %lu fragmented (%lu not taken by any transport), "
|
||||
"%lu dropped as unusable or over %u bytes",
|
||||
unsigned(rx.btp_dest_port), rx.payload_len, (unsigned long)raw_fragmented_,
|
||||
(unsigned long)raw_fragment_failed_, (unsigned long)raw_oversize_, unsigned(link::v2x_rx_max_forward));
|
||||
}
|
||||
++raw_forwarded_;
|
||||
raw_its_(link::encode_v2x_rx(rx, rssi));
|
||||
}
|
||||
|
||||
link::Code Station::unsecured_request(const link::BtpDataRequest& q) {
|
||||
|
||||
Reference in New Issue
Block a user