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:
Ashin Walpola
2026-11-23 17:34:56 +01:00
parent 7dd83dba3d
commit ce18a393ea
24 changed files with 3305 additions and 2305 deletions
+89
View File
@@ -5,6 +5,95 @@ Engineering to-do list. The reviewer-facing open items live in
## Waiting on hardware
### Large SPATEM / MAPEM through V2X_RX in fragments (added 2026-11-23)
The 2026-11-23 bench run (CiT node sending a 377 B MAPEM and 58 B SPATEM, then 1198 B and 888 B ones; phone on
BLE) lost every large message: 0 of 1537 MAPEMs and 0 of 3004 SPATEMs against 98.5 % / 96.5 % of the small ones,
because `Station::forward_raw` dropped everything over 494 bytes. Firmware now sends those in link fragments
(`link_fragment.hpp`, `v2x_rx_plan`; NOTES.md). Done on the PC, not flashed yet: `make check` in
`obu-firmware/test/host` (46 unit tests, the pcap replay of 3384 + 1727 large messages through unwrap -> fragments ->
two reassemblers, fuzz), the app's `LinkReassemblyTest` on the firmware's own fragments, asn1tools on the large
payloads, ESP-IDF 6.0.2 image build.
- [x] Flashed to COM10 and run against the Berliner Tor RSU (2026-11-23 17:08-17:20, phone on BLE): MAPEM 1198 B 92.9 %,
SPATEM 888 B 81.7 % of what the node heard, `radio_dropped` 0. The V2X screens stayed empty because the app's
`SpatemUperCodec` refused the RSU's SPATEMs (intersection and movement names, advisory speeds); fixed and checked
against asn1tools on all 718 distinct messages, **needs the app reinstalled on the phone**.
- [ ] (original plan) Flash COM6 (`--no-stub` recipe, read the app descriptor first) and repeat the bench run: the node alternating
small and large MAPEM/SPATEM, the phone on BLE, a pcap recorded at the same time. Compare with
`py -3.11 tools/rx_size_compare.py LOG.db capture.pcap replay.tsv` (the header says how to make replay.tsv).
Accept: small messages stay at ~96-98 % of what the node saw, the large ones arrive at a comparable rate,
CAMs unchanged (92-96 % on 2026-11-23).
- [ ] `radio_dropped` (link_status) stays 0 with the large messages, as it did on 2026-11-23 without them, and no BLE
disconnects. If it moves, the fragments hold the station task too long: look at the fragment cap and BLE notify
failures (the board's LOG line "V2X_RX: ... fragmented (... not taken by any transport)", 1 per 10 s).
- [ ] The same over USB, and once with the app set to Raw frames: RAW_FRAME must still deliver the large ones, V2X_RX must
not send them a second time (`raw_covered_`), and switching back to V2X_RX must work without a reconnect.
- [ ] TX unchanged: a phone-originated CAM (signed and unsigned) is still seen by the node in the same session.
### App refresh: map dashboard, V2X switch, routing (added 2026-11-19)
Map-first dashboard (MapLibre, glass panels, folding bottom bar), "V2X ON/OFF" switch in the MicrOBU
box, V2X sending decoupled from trip recording, "Where to?" search and bicycle routing. Built, 185
unit tests green, and driven on the emulator with a mocked GPS fix (map, search, route preview and
guidance all work). Not checked without the ESP32-C5 or a phone on a bike:
- [ ] Connect the ESP32-C5 with no trip recording: V2X turns on by itself and the second ESP32 (or
`tools/cit_one_rx_watch.py`) hears the phone's CAMs. Switch it off on the Connection screen (tap the
MicrOBU box on the dashboard): they stop, and the dashboard box reads "V2X OFF".
Unplug and reconnect: it is on again, even if it was switched off before.
- [ ] Screen off for 5 minutes with V2X on: CAMs keep coming at 1 Hz (`V2xTransmitService` holds the
process and GNSS; the "V2X on" notification is showing).
- [ ] Connect while the app is in the background on Android 14+: the loop still sends if the foreground
service is refused (the start is allowed to fail), but the notification will be missing.
- [ ] CiT One selected: the V2X switch is disabled and mirrors the link, and nothing is sent by the phone.
- [ ] MicrOBU box shows the real battery percentage over BLE and USB, amber and red at the warn and
shutdown voltages.
- [ ] On a ride: heading-up mode tilts and turns the map with the course; guidance announces the turn
before the corner; going off route reroutes within about 15 s.
- [ ] GLOSA hint (speed box) at a real signalised junction with MAPEM and SPATEM on the air: the
advice matches the lights. The rules are unit-tested only; never tried against a live signal.
- [ ] Motion gate (`MotionDetector`): standing still indoors with GPS wandering, the speed box reads 0;
then ride: it never reads 0 while moving, in each mount (handlebar, bag, pocket). Thresholds
(`ENTER_STD` 0.15, `EXIT_STD` 0.07 m/s², 8 s hold) are from synthetic data only; a smooth-road
ride on a handlebar mount is the case most likely to need tuning. Not applied to the CAM speed
the phone transmits yet, which is still the raw GNSS speed.
- [ ] Settings > Developer > CAM pinger (moved from the V2X screen): starts and stops, shows the
loopback count, only appears with the ESP32-C5 selected.
- [ ] Decide the satellite and terrain tile provider (the layer buttons are in the map settings,
disabled until `MapLayer.styleUrl` has a source), and where routing and search run for real:
the app now sends the rider's position to photon.komoot.io and valhalla1.openstreetmap.de, which
are shared demo instances.
### Why the simulated car drops out of the V2X screen while the phone transmits (added 2026-11-19)
The bench beacon (`obu-cam-transmistter`, station 0x0BADC0DE) vanishes from the V2X screen for a
moment and comes back while the phone is sending. The V2X screen forgets a station after 3 s without
a CAM (`staleRemoteMs`), so these are gaps of 3 s or more. Hypothesis: the ESP32-C5 shares its radio
between BLE and ITS-G5 and a transmission and a reception collide with a BLE event.
Not confirmed. Read from the firmware source only, not measured: the TX hold for BLE
(`Station::hold_for_ble_guard`) is a busy-wait of at most 3.5 ms, too short to overflow the 16-frame
receive queue, so a queue overflow from transmitting is unlikely; the firmware's own notes say a frame
handed to the radio during a BLE connection event is accepted and never transmitted, and nothing says
reception is spared; frames the radio never delivers (or the PHY flags bad) are in no counter.
Tooling is in: the V2X data logger (schema 3) now records `link_status` once a second, and
`tools/rx_gap_analysis.py` accounts for every gap in the beacon's frames (lost before the radio saw
them, dropped in the firmware queue, or lost between board and phone) per condition, and checks
whether the gaps recur at a steady interval (two clocks beating). Self-tested on synthetic data only.
- [ ] Install the current build on the Pixel. Beacon on, 1-2 m from the OBU, nothing else on 5.9 GHz.
- [ ] Settings > Developer > V2X data logger > Start logging, then four stretches of at least 3
minutes each in one log, switching between them without stopping the log:
BLE with V2X off (Connection screen), BLE with V2X on, then the same two over USB
(cable from the phone to the OBU, Settings > Connection > ESP32 link = USB).
- [ ] Stop, pull the `.db` (`adb exec-out run-as com.hawhamburg.micr0bu cat files/v2x_logs/<file>`)
and run `python tools/rx_gap_analysis.py <file>.db`. The table says which condition loses frames,
and where; if the beacon's frames vanish before the radio and only on BLE with V2X on, BLE
coexistence with transmitting is the cause, and the recurrence line says whether it is a beat.
- [ ] If it is coexistence: the lever is in the firmware (the colleague's BLE guard calibrates only
TX), not the app; options are fewer or longer-interval BLE events while transmitting, or USB.
### Sensor fusion phase 1: logging and test rides (added 2026-11-18)
Settings > Ride (phone position, Record motion sensors) and the fusion data in the V2X data logger,
@@ -28,6 +28,10 @@ import com.hawhamburg.micr0bu.domain.spat.SpatEvent
* A `SEQUENCE (SIZE(lo..hi)) OF` writes its count in `ceil(log2(hi-lo+1))` bits holding `n-lo`:
* intersections 1..32 gives 5 bits, movements 1..255 gives 8, events 1..16 gives 4.
*
* Names and advisory speeds are walked, not kept: a road RSU (Hamburg, 2026-11-23: 888-byte SPATEMs naming
* "Berliner Tor / Kolbergstrasse" and each movement, with a greenwave and an ecoDrive advice per event) sends
* both, and until then every one of its SPATEMs was refused.
*
* Two traps worth naming, both of which silently shift every later field:
* - `TimeChangeDetails` is **not** extensible, so it has 5 optional bits and no extension bit,
* unlike almost every other SEQUENCE here, which all carry one.
@@ -41,7 +45,7 @@ import com.hawhamburg.micr0bu.domain.spat.SpatEvent
* exactly, with no message hitting an unsupported branch.
*
* Returns null rather than guessing whenever an extension bit is set or an unsupported optional
* appears: a dropped SPATEM is recoverable (they repeat at ~2 Hz), a misread one shows a driver
* (regional extensions) appears: a dropped SPATEM is recoverable (they repeat at ~2 Hz), a misread one shows a driver
* the wrong light.
*/
object SpatemUperCodec {
@@ -73,9 +77,7 @@ object SpatemUperCodec {
val hasName = br.getBitsInt(1) == 1
val hasRegional = br.getBitsInt(1) == 1
val minuteOfYear = if (hasTimeStamp) br.getBitsInt(20) else null
// DescriptiveName is a variable-length IA5String. Nothing in 79k real messages uses it,
// and guessing its length would desynchronise everything after it.
if (hasName) return null
if (hasName) skipName(br)
val intersectionCount = br.getBitsInt(5) + 1
if (intersectionCount > MAX_INTERSECTIONS) return null
@@ -102,7 +104,7 @@ object SpatemUperCodec {
val hasEnabledLanes = br.getBitsInt(1) == 1
val hasManeuvers = br.getBitsInt(1) == 1
val hasRegional = br.getBitsInt(1) == 1
if (hasName) return null
if (hasName) skipName(br)
// IntersectionReferenceID - not extensible, one optional bit for region.
val region = if (br.getBitsInt(1) == 1) br.getBitsInt(16) else null
@@ -133,7 +135,7 @@ object SpatemUperCodec {
val hasName = br.getBitsInt(1) == 1
val hasManeuvers = br.getBitsInt(1) == 1
val hasRegional = br.getBitsInt(1) == 1
if (hasName) return null
if (hasName) skipName(br)
val signalGroup = br.getBitsInt(8)
val eventCount = br.getBitsInt(4) + 1
@@ -162,7 +164,8 @@ object SpatemUperCodec {
if (hasConfidence) br.getBits(4)
if (hasNext) br.getBits(16)
}
if (hasSpeeds || hasRegionalEvent) return null
if (hasSpeeds && !skipAdvisorySpeedList(br)) return null
if (hasRegionalEvent) return null
events.add(SignalPhaseEvent(phase, minEnd, maxEnd, likely))
}
@@ -171,6 +174,41 @@ object SpatemUperCodec {
return SignalMovement(signalGroup, events)
}
/**
* `DescriptiveName` IA5String (SIZE(1..63)): 6-bit length holding n-1, then 7 bits per character.
* Not surfaced (a real RSU names its intersections and movements, the app does not show them here), but
* it has to be walked: it sits in front of fields that are.
*/
private fun skipName(br: BitReader) {
val length = br.getBitsInt(6) + 1
repeat(length) { br.getBits(7) }
}
/**
* Walks an `AdvisorySpeedList` (SIZE(1..16) OF AdvisorySpeed: the RSU's green wave and eco-drive advice)
* without keeping it; nothing consumes it yet. AdvisorySpeed is extensible with five optional fields
* (speed, confidence, distance, class, regional); `type` is an extensible ENUMERATED of four values.
* Returns false for an extension value or a regional extension, which this decoder cannot size.
*/
private fun skipAdvisorySpeedList(br: BitReader): Boolean {
repeat(br.getBitsInt(4) + 1) {
if (br.getBitsInt(1) != 0) return false // AdvisorySpeed extension
val hasSpeed = br.getBitsInt(1) == 1
val hasConfidence = br.getBitsInt(1) == 1
val hasDistance = br.getBitsInt(1) == 1
val hasClass = br.getBitsInt(1) == 1
val hasRegional = br.getBitsInt(1) == 1
if (br.getBitsInt(1) != 0) return false // AdvisorySpeedType extension value
br.getBits(2) // type: none, greenwave, ecoDrive, transit
if (hasSpeed) br.getBits(9) // SpeedAdvice (0..500)
if (hasConfidence) br.getBits(3) // SpeedConfidenceDSRC, 8 values, not extensible
if (hasDistance) br.getBits(14) // ZoneLength (0..10000)
if (hasClass) br.getBits(8) // RestrictionClassID (0..255)
if (hasRegional) return false
}
return true
}
/**
* Walks a `ManeuverAssistList` without keeping it. Nothing consumes queue lengths yet, but the
* list is variable-length, so it has to be parsed to find where the next field starts.
@@ -3,6 +3,7 @@ package com.hawhamburg.micr0bu
import com.hawhamburg.micr0bu.data.transport.LinkMessage
import com.hawhamburg.micr0bu.data.transport.LinkReassembly
import com.hawhamburg.micr0bu.data.transport.RawFrame
import com.hawhamburg.micr0bu.data.transport.V2xRxFrame
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
@@ -100,6 +101,61 @@ class LinkReassemblyTest {
assertArrayEquals(bytes(9, 9, 8, 8), b.body)
}
// ---- large V2X_RX, fragmented by the firmware ---------------------------------------------
private fun hexBytes(s: String) = ByteArray(s.length / 2) { s.substring(it * 2, it * 2 + 2).toInt(16).toByte() }
/**
* `v2x_rx_fragments.tsv` is written by `test_v2x_fragments --dump` in obu-firmware/test/host: the first 888-byte
* SPATEM and 1198-byte MAPEM of the CiT node's 2026-11-23 recording, as the firmware's own code splits them for
* serial / BLE MTU 517 (512-octet messages) and BLE MTU 247 (244). Each line: port, UPER size, limit, V2X_RX body,
* then the link messages in order. The app must put back exactly that body and read the message out of it.
*/
@Test
fun `the firmware's fragments of a large V2X_RX reassemble to the body and parse`() {
val lines = javaClass.classLoader!!.getResource("v2x_rx_fragments.tsv")!!.readText().lines().filter { it.isNotBlank() }
assertEquals(4, lines.size)
for (line in lines) {
val f = line.split('\t')
val port = f[0].toInt()
val size = f[1].toInt()
val limit = f[2].toInt()
val body = hexBytes(f[3])
val wires = f.drop(4).map { hexBytes(it) }
assertTrue("$port/$size at $limit: needs fragments", wires.size >= 2)
var whole: LinkMessage? = null
wires.forEachIndexed { i, wire ->
assertTrue("$port/$size at $limit: a message of ${wire.size} octets exceeds $limit", wire.size <= limit)
val message = LinkMessage.decode(wire)!!
assertEquals(0x90, message.opcode)
assertEquals(if (i == 0) 1 else if (i == wires.size - 1) 3 else 2, message.flags)
whole = reassembly.feed(message)
if (i < wires.size - 1) assertNull(whole)
}
assertEquals(0x90, whole!!.opcode)
assertEquals(0, whole!!.flags)
assertArrayEquals(body, whole!!.body)
val v2x = V2xRxFrame.parse(whole!!.body)!!
assertEquals(port, v2x.btpPort)
assertEquals(size, v2x.uper.size)
assertEquals(if (port == 2003) 5 else 4, v2x.uper[1].toInt() and 0xFF) // ItsPduHeader.messageId: MAPEM 5, SPATEM 4
}
}
@Test
fun `losing one fragment of a large V2X_RX costs that message only`() {
val lines = javaClass.classLoader!!.getResource("v2x_rx_fragments.tsv")!!.readText().lines().filter { it.isNotBlank() }
val f = lines.first { it.split('\t')[2] == "512" && it.split('\t')[0] == "2003" }.split('\t')
val wires = f.drop(4).map { hexBytes(it) }
// the first message loses its middle fragment; the same message again, in full, still completes afterwards
val lost = wires.mapIndexedNotNull { i, w -> if (i == 1) null else LinkMessage.decode(w)!! }
for (m in lost) assertNull(reassembly.feed(m))
val next = wires.map { w -> LinkMessage.decode(w)!!.let { LinkMessage(it.opcode, it.sequence + 1, it.body, it.flags) } }
var whole: LinkMessage? = null
for (m in next) whole = reassembly.feed(m)
assertArrayEquals(hexBytes(f[3]), whole!!.body)
}
// ---- RAW_FRAME record ------------------------------------------------------------------
private fun rawBody(frame: ByteArray, flags: Int = 0x02, rssi: Int = -61): ByteArray {
@@ -153,6 +153,34 @@ class SpatemUperCodecTest {
assertNull(SignalPhaseEvent(SignalPhase.DARK, null, null, null).secondsUntil(topOfHour))
}
@Test
fun `decodes a road RSU SPATEM with names and advisory speeds`() {
// 888 bytes from the Berliner Tor RSU (2026-11-23): intersection and movement names, and a greenwave
// plus an ecoDrive AdvisorySpeed on every event. Before names and speeds were walked, every one of
// its SPATEMs was refused and the V2X screens stayed empty. Expected values: asn1tools, ETSI modules.
val bytes = javaClass.classLoader!!.getResource("spatem_road_rsu_888.hex")!!.readText().trim().hexToBytes()
assertEquals(888, bytes.size)
val spat = SpatemUperCodec.decode(bytes, receivedAt)
assertNotNull(spat)
spat!!
assertEquals(1_095_348_116L, spat.stationId)
assertEquals(470_408, spat.minuteOfYear)
val i = spat.intersections.single()
assertEquals("-1/23", i.key)
assertEquals(2, i.revision)
assertEquals(470_408, i.moy)
assertEquals(59_719, i.timeStampMs)
assertEquals(listOf(1, 2, 3, 4, 5), i.movements.map { it.signalGroup })
i.movements.forEach { assertEquals(8, it.events.size) }
assertEquals(SignalPhaseEvent(SignalPhase.STOP_AND_REMAIN, 5562, 5562, 5562), i.movements[0].events.first())
assertEquals(SignalPhase.PERMISSIVE_CLEARANCE, i.movements[0].events.last().phase)
assertEquals(6522, i.movements[0].events.last().minEndTimeDs)
assertEquals(SignalPhase.PROTECTED_MOVEMENT_ALLOWED, i.movements[2].events.first().phase)
assertEquals(SignalPhase.PERMISSIVE_MOVEMENT_ALLOWED, i.movements[3].events.first().phase)
assertEquals(SignalPhaseEvent(SignalPhase.STOP_AND_REMAIN, 5802, 5802, 5802), i.movements[4].events.first())
assertEquals(6762, i.movements[4].events.last().minEndTimeDs)
}
@Test
fun `does not decode another message type as SPATEM`() {
// protocolVersion 2, messageId 2 (CAM) - the header guard must reject it outright.
@@ -0,0 +1 @@
02044149af94472d8803872165e5b34eecbc9054dfc902f412f7ecc597967e7d3961e7cf28005c10200396c474a3823310b2f2d9a7765e482a6fe483a68e5bfae7d0af665cdd005d8dc2b742b742b75e2e145c0259c453804b323857385738573bc5c28b804b388a700966670b410b410b4178b851700967114e012ccee16aa16aa16aaf170a2e012ce229c02598dc311431143115e2e145c0259c453804b323862786278627bc5c28b804b388a700966670ca90ca90ca978b851700967114e012ccee197a197a197af170a2e012ce229c02581e000018028191859796cd3bb2f241537f241cb4e7d1d009d8dc2b742b742b75e2e145c0259c453804b323857385738573bc5c28b804b388a700966570b410b410b4178b851700967114e012ccee16aa16aa16aaf170a2e012ce229c02598dc311431143115e2e145c0259c453804b323862786278627bc5c28b804b388a700966570ca90ca90ca978b851700967114e012ccee197a197a197af170a2e012ce229c02581e01001c02819697bf662cbcb3f3e9c9074d1cb7f5cfa15eccb9ba01bb33856485648564bc5c28b804b388a700966770add0add0add78b851700967114e012cc6e179a179a179af170a2e012ce229c025991c2f5c2f5c2f5de2e145c0259c453804b333861886188618bc5c28b804b388a700966770c450c450c4578b851700967114e012cc6e1a6a1a6a1a6af170a2e012ce229c025991c34fc34fc34fde2e145c0259c453804b03c06002805031f2f7ecc597967e7d3920e5a73e8e808ecae159215921592f170a2e012ce229c02599dc2b742b742b75e2e145c0259c453804b31b85e685e685e6bc5c28b804b388a700966470bd70bd70bd778b851700967114e012ccae186218621862f170a2e012ce229c02599dc311431143115e2e145c0259c453804b31b869a869a869abc5c28b804b388a700966470d3f0d3f0d3f78b851700967114e012c0f0100140140cdc8c3d7874cd97ae5e5df0e3d195074d1cb7f5cfa15eccb9ba02bb1b85aa85aa85aabc5c28b804b388a700966470b5f0b5f0b5f78b851700967114e012ccce177217721772f170a2e012ce229c02599dc2f342f342f35e2e145c0259c453804b31b865e865e865ebc5c28b804b388a700966470cc70cc70cc778b851700967114e012ccce1a421a421a42f170a2e012ce229c02599dc34d434d434d5e2e145c0259c453804b0bc0800400503c0a00480500
@@ -0,0 +1,4 @@
2004 888 512 d407c40164cceb1fc851f905900102044149af94472d3103872165e5b34eecbc9054dfc902f412f7ecc597967e7d3961e7cf28005c1020039698b4b0023310b2f2d9a7765e482a6fe483a68e5bfae7d0af665cdd005d99cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025999cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e00001c028191859796cd3bb2f241537f241cb4e7d1d009d95cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025995cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e01001802819697bf662cbcb3f3e9c9074d1cb7f5cfa15eccb9ba01bb1b98bc58bc58bc7c5c28b804b388a700966473182b182b182f8b851700967114e012ccce63b963b963b9f170a2e012ce229c02599dcc7c2c7c2c7c3e2e145c0259c453804b31b9970597059707c5c28b804b388a7009664732eab2eab2eaf8b851700967114e012ccce668966896689f170a2e012ce229c02599dccd62cd62cd63e2e145c0259c453804b03c06002005031f2f7ecc597967e7d3920e5a73e8e808ec6e62f162f162f1f170a2e012ce229c025991cc60ac60ac60be2e145c0259c453804b32b98ee58ee58ee7c5c28b804b388a7009667731f0b1f0b1f0f8b851700967114e012cc6e65c165c165c1f170a2e012ce229c025991ccbaacbaacbabe2e145c0259c453804b32b99a259a259a27c5c28b804b388a700966773358b358b358f8b851700967114e012c0f0100160140cdc8c3d7874cd97ae5e5df0e3d195074d1cb7f5cfa15eccb9ba02bb1b9880588058807c5c28b804b388a70096647310ab10ab10af8b851700967114e012ccce62c962c962c9f170a2e012ce229c02599dcc5e2c5e2c5e3e2e145c0259c453804b31b9934593459347c5c28b804b388a700966473272b272b272f8b851700967114e012ccce659965996599f170a2e012ce229c02599dccb82cb82cb83e2e145c0259c453804b0bc0800480503c0a00400500 90014d0086030000d407c40164cceb1fc851f905900102044149af94472d3103872165e5b34eecbc9054dfc902f412f7ecc597967e7d3961e7cf28005c1020039698b4b0023310b2f2d9a7765e482a6fe483a68e5bfae7d0af665cdd005d99cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025999cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e00001c028191859796cd3bb2f241537f241cb4e7d1d009d95cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025995cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e01001802819697bf662cbcb3f3e9c9074d1cb7f5cfa15eccb9ba01bb1b98bc58bc58bc7c5c28b804b388a700966473182b182b182f8b851700967114e012ccce63b963b963b9f170a2e012ce229c02599dcc7c2c7c2c7c3e2e145c0259c453804b31b9970597059707c5c28b804b388a70096 90034d008603f80164732eab2eab2eaf8b851700967114e012ccce668966896689f170a2e012ce229c02599dccd62cd62cd63e2e145c0259c453804b03c06002005031f2f7ecc597967e7d3920e5a73e8e808ec6e62f162f162f1f170a2e012ce229c025991cc60ac60ac60be2e145c0259c453804b32b98ee58ee58ee7c5c28b804b388a7009667731f0b1f0b1f0f8b851700967114e012cc6e65c165c165c1f170a2e012ce229c025991ccbaacbaacbabe2e145c0259c453804b32b99a259a259a27c5c28b804b388a700966773358b358b358f8b851700967114e012c0f0100160140cdc8c3d7874cd97ae5e5df0e3d195074d1cb7f5cfa15eccb9ba02bb1b9880588058807c5c28b804b388a70096647310ab10ab10af8b851700967114e012ccce62c962c962c9f170a2e012ce229c02599dcc5e2c5e2c5e3e2e145c0259c453804b31b9934593459347c5c28b804b388a700966473272b272b272f8b851700967114e012ccce659965996599f170a2e012ce229c02599dccb82cb82cb83e2e145c0259c453804b0bc0800480503c0a00400500
2004 888 244 d407c40164cceb1fc851f905900102044149af94472d3103872165e5b34eecbc9054dfc902f412f7ecc597967e7d3961e7cf28005c1020039698b4b0023310b2f2d9a7765e482a6fe483a68e5bfae7d0af665cdd005d99cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025999cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e00001c028191859796cd3bb2f241537f241cb4e7d1d009d95cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025995cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e01001802819697bf662cbcb3f3e9c9074d1cb7f5cfa15eccb9ba01bb1b98bc58bc58bc7c5c28b804b388a700966473182b182b182f8b851700967114e012ccce63b963b963b9f170a2e012ce229c02599dcc7c2c7c2c7c3e2e145c0259c453804b31b9970597059707c5c28b804b388a7009664732eab2eab2eaf8b851700967114e012ccce668966896689f170a2e012ce229c02599dccd62cd62cd63e2e145c0259c453804b03c06002005031f2f7ecc597967e7d3920e5a73e8e808ec6e62f162f162f1f170a2e012ce229c025991cc60ac60ac60be2e145c0259c453804b32b98ee58ee58ee7c5c28b804b388a7009667731f0b1f0b1f0f8b851700967114e012cc6e65c165c165c1f170a2e012ce229c025991ccbaacbaacbabe2e145c0259c453804b32b99a259a259a27c5c28b804b388a700966773358b358b358f8b851700967114e012c0f0100160140cdc8c3d7874cd97ae5e5df0e3d195074d1cb7f5cfa15eccb9ba02bb1b9880588058807c5c28b804b388a70096647310ab10ab10af8b851700967114e012ccce62c962c962c9f170a2e012ce229c02599dcc5e2c5e2c5e3e2e145c0259c453804b31b9934593459347c5c28b804b388a700966473272b272b272f8b851700967114e012ccce659965996599f170a2e012ce229c02599dccb82cb82cb83e2e145c0259c453804b0bc0800480503c0a00400500 90014d0086030000d407c40164cceb1fc851f905900102044149af94472d3103872165e5b34eecbc9054dfc902f412f7ecc597967e7d3961e7cf28005c1020039698b4b0023310b2f2d9a7765e482a6fe483a68e5bfae7d0af665cdd005d99cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025999cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e00001c028191859796cd 90024d008603ec003bb2f241537f241cb4e7d1d009d95cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025995cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e01001802819697bf662cbcb3f3e9c9074d1cb7f5cfa15eccb9ba01bb1b98bc58bc58bc7c5c28b804b388a700966473182b182b182f8b851700967114e012ccce63b963b963b9f170a2e012ce229c02599dcc7 90024d008603d801c2c7c2c7c3e2e145c0259c453804b31b9970597059707c5c28b804b388a7009664732eab2eab2eaf8b851700967114e012ccce668966896689f170a2e012ce229c02599dccd62cd62cd63e2e145c0259c453804b03c06002005031f2f7ecc597967e7d3920e5a73e8e808ec6e62f162f162f1f170a2e012ce229c025991cc60ac60ac60be2e145c0259c453804b32b98ee58ee58ee7c5c28b804b388a7009667731f0b1f0b1f0f8b851700967114e012cc6e65c165c165c1f170a2e012ce229c025991ccbaacbaacbabe2e145c0259c453804b32b99a259a259a27c5c28b804b388a700966773358b358b358 90034d008603c402f8b851700967114e012c0f0100160140cdc8c3d7874cd97ae5e5df0e3d195074d1cb7f5cfa15eccb9ba02bb1b9880588058807c5c28b804b388a70096647310ab10ab10af8b851700967114e012ccce62c962c962c9f170a2e012ce229c02599dcc5e2c5e2c5e3e2e145c0259c453804b31b9934593459347c5c28b804b388a700966473272b272b272f8b851700967114e012ccce659965996599f170a2e012ce229c02599dccb82cb82cb83e2e145c0259c453804b0bc0800480503c0a00400500
2003 1198 512 d307c40164cceb1fc851f905900102054149af940801038e42cbcb669dd97920a9bf9205e825efd98b2f2cfcfa72c3cf9e5000b8255642f5d9c50d15ac419009601456c0ad802742cbcb669dd97920a9bf920d3b85080000600370c942ae092d5b0496ad024a56c125ab4092d5b0496ad824a568125ab6092d5a0496ad824a568125ab6092d5b0496ad024b56c1252b4092d5b0496ad824b5681252b6092d5a0496ad824b5681252b6092d5b0496ad024b56c125ab409295b0496ad824b568125ab609295a0496ad824b568125ab609295b0496ad024b56c125ab4092d5b0494ad824b568125ab609295b0494af824a57c124abc09295f0494af824a57c124abe09295f0488b5023c6a4121b3e2b0440001005831000100a8011f0b2f2d9a7765e482a6fe4837f5e824400001b85c18db0494ad824b56c125ab4092d5b0494ad024b56c125ab6092d5a0496ad824a568125ab6092d5a0496ad824a56c125ab4092d5b0496ad024a56c125ab6092d5a0496ad824b5681252b6092d5a0496ad824b56c1252b4092d5b0496ad024b56c1252b6092d5a0496ad824b568125ab609295a0496ad824b56c125ab409295b0496ad024b56c125ab609295a0496ad024a57c1252be09295f0492af024a57c1252be09255f0494af824f54c125328090d9e6c03425efd98b2f2cfcfa72c3cf9e541a771210000140078119d1800ee41c05f21b02db0e818a85c0b83ca054de002d4f2819e72c0c4b820665c90378e181af6e00c1b1a06118d02ecc1016c6b00be36a05edb502f6da01756c40ac36e057db902c0dd01a87640fab8c07a17803cebb81d84a808c32e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb81606e00afb6e2b0220004025834000181a802232f7ecc597967e7d3961e7cf2a0dfd7a1110000078127d5dc0e143005822002dd0e815188809bbb6054de00278ee01756d80c538005e5b90342d581ad6d80c1318060d8d0320cc818a6f40be36a05edb402f6da81826e40b3b78057dba02bedd01176640ec252079d7803cebb81f67140d3bae057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00b036e057db802bedb815f6e00afb6ed80acc2cba5064cbc9048c3d7874cd97ae5e5df0e3d195069dc684000060010072364504510b82a992815148e0a864705452382a192015148e0a8a4705432382a291c150c8e0a8a4705452382a191c1514900a864705452382a4920151c900a924805492402a4920151c900a924805492402a4920151c900a9248054523829691814bc8e0a5e46052f238ac0900014116090000a0aa00cd42cba5064cbc9048c3d7874cd97ae5e5df0e3d19506febd0c880000200edba82086a0f05372202a191c15148e0a8a4705432382a291c150c8e0a8a4705452382a192015148e0a864705452382a291c150c8e0a8a4705492402a39201524900a924805472402a49201524900a924805472402a49201524900a9649053323829791c14bc8e0a5e46 90014d00bc040000d307c40164cceb1fc851f905900102054149af940801038e42cbcb669dd97920a9bf9205e825efd98b2f2cfcfa72c3cf9e5000b8255642f5d9c50d15ac419009601456c0ad802742cbcb669dd97920a9bf920d3b85080000600370c942ae092d5b0496ad024a56c125ab4092d5b0496ad824a568125ab6092d5a0496ad824a568125ab6092d5b0496ad024b56c1252b4092d5b0496ad824b5681252b6092d5a0496ad824b5681252b6092d5b0496ad024b56c125ab409295b0496ad824b568125ab609295a0496ad824b568125ab609295b0496ad024b56c125ab4092d5b0494ad824b568125ab609295b0494af824a57c124abc09295f0494af824a57c124abe09295f0488b5023c6a4121b3e2b0440001005831000100a8011f0b2f2d9a7765e482a6fe4837f5e824400001b85c18db0494ad824b56c125ab4092d5b0494ad024b56c125ab6092d5a0496ad824a568125ab6092d5a0496ad824a56c125ab4092d5b0496ad024a56c125ab6092d5a0496ad824b5681252b6092d5a0496ad824b56c1252b4092d5b0496ad024b56c1252b6092d5a0496ad824b568125ab609295a0496ad824b56c125ab409295b0496ad024b56c125ab609295a0496ad024a57c1252be09295f0492af024a57c1252be09255f0494af824f54c125328090d9e6c03425efd98b2f2cfcfa72c3cf9e541a7712100001400781 90024d00bc04f80119d1800ee41c05f21b02db0e818a85c0b83ca054de002d4f2819e72c0c4b820665c90378e181af6e00c1b1a06118d02ecc1016c6b00be36a05edb502f6da01756c40ac36e057db902c0dd01a87640fab8c07a17803cebb81d84a808c32e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb81606e00afb6e2b0220004025834000181a802232f7ecc597967e7d3961e7cf2a0dfd7a1110000078127d5dc0e143005822002dd0e815188809bbb6054de00278ee01756d80c538005e5b90342d581ad6d80c1318060d8d0320cc818a6f40be36a05edb402f6da81826e40b3b78057dba02bedd01176640ec252079d7803cebb81f67140d3bae057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00b036e057db802bedb815f6e00afb6ed80acc2cba5064cbc9048c3d7874cd97ae5e5df0e3d195069dc684000060010072364504510b82a992815148e0a864705452382a192015148e0a8a4705432382a291c150c8e0a8a4705452382a191c1514900 90034d00bc04f003a864705452382a4920151c900a924805492402a4920151c900a924805492402a4920151c900a9248054523829691814bc8e0a5e46052f238ac0900014116090000a0aa00cd42cba5064cbc9048c3d7874cd97ae5e5df0e3d19506febd0c880000200edba82086a0f05372202a191c15148e0a8a4705432382a291c150c8e0a8a4705452382a192015148e0a864705452382a291c150c8e0a8a4705492402a39201524900a924805472402a49201524900a924805472402a49201524900a9649053323829791c14bc8e0a5e46
2003 1198 244 d307c40164cceb1fc851f905900102054149af940801038e42cbcb669dd97920a9bf9205e825efd98b2f2cfcfa72c3cf9e5000b8255642f5d9c50d15ac419009601456c0ad802742cbcb669dd97920a9bf920d3b85080000600370c942ae092d5b0496ad024a56c125ab4092d5b0496ad824a568125ab6092d5a0496ad824a568125ab6092d5b0496ad024b56c1252b4092d5b0496ad824b5681252b6092d5a0496ad824b5681252b6092d5b0496ad024b56c125ab409295b0496ad824b568125ab609295a0496ad824b568125ab609295b0496ad024b56c125ab4092d5b0494ad824b568125ab609295b0494af824a57c124abc09295f0494af824a57c124abe09295f0488b5023c6a4121b3e2b0440001005831000100a8011f0b2f2d9a7765e482a6fe4837f5e824400001b85c18db0494ad824b56c125ab4092d5b0494ad024b56c125ab6092d5a0496ad824a568125ab6092d5a0496ad824a56c125ab4092d5b0496ad024a56c125ab6092d5a0496ad824b5681252b6092d5a0496ad824b56c1252b4092d5b0496ad024b56c1252b6092d5a0496ad824b568125ab609295a0496ad824b56c125ab409295b0496ad024b56c125ab609295a0496ad024a57c1252be09295f0492af024a57c1252be09255f0494af824f54c125328090d9e6c03425efd98b2f2cfcfa72c3cf9e541a771210000140078119d1800ee41c05f21b02db0e818a85c0b83ca054de002d4f2819e72c0c4b820665c90378e181af6e00c1b1a06118d02ecc1016c6b00be36a05edb502f6da01756c40ac36e057db902c0dd01a87640fab8c07a17803cebb81d84a808c32e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb81606e00afb6e2b0220004025834000181a802232f7ecc597967e7d3961e7cf2a0dfd7a1110000078127d5dc0e143005822002dd0e815188809bbb6054de00278ee01756d80c538005e5b90342d581ad6d80c1318060d8d0320cc818a6f40be36a05edb402f6da81826e40b3b78057dba02bedd01176640ec252079d7803cebb81f67140d3bae057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00b036e057db802bedb815f6e00afb6ed80acc2cba5064cbc9048c3d7874cd97ae5e5df0e3d195069dc684000060010072364504510b82a992815148e0a864705452382a192015148e0a8a4705432382a291c150c8e0a8a4705452382a191c1514900a864705452382a4920151c900a924805492402a4920151c900a924805492402a4920151c900a9248054523829691814bc8e0a5e46052f238ac0900014116090000a0aa00cd42cba5064cbc9048c3d7874cd97ae5e5df0e3d19506febd0c880000200edba82086a0f05372202a191c15148e0a8a4705432382a291c150c8e0a8a4705452382a192015148e0a864705452382a291c150c8e0a8a4705492402a39201524900a924805472402a49201524900a924805472402a49201524900a9649053323829791c14bc8e0a5e46 90014d00bc040000d307c40164cceb1fc851f905900102054149af940801038e42cbcb669dd97920a9bf9205e825efd98b2f2cfcfa72c3cf9e5000b8255642f5d9c50d15ac419009601456c0ad802742cbcb669dd97920a9bf920d3b85080000600370c942ae092d5b0496ad024a56c125ab4092d5b0496ad824a568125ab6092d5a0496ad824a568125ab6092d5b0496ad024b56c1252b4092d5b0496ad824b5681252b6092d5a0496ad824b5681252b6092d5b0496ad024b56c125ab409295b0496ad824b568125ab609295a0496ad824b568125ab609295b0496ad024b56c125ab4092d5b0494ad824b568125ab609295b049 90024d00bc04ec004af824a57c124abc09295f0494af824a57c124abe09295f0488b5023c6a4121b3e2b0440001005831000100a8011f0b2f2d9a7765e482a6fe4837f5e824400001b85c18db0494ad824b56c125ab4092d5b0494ad024b56c125ab6092d5a0496ad824a568125ab6092d5a0496ad824a56c125ab4092d5b0496ad024a56c125ab6092d5a0496ad824b5681252b6092d5a0496ad824b56c1252b4092d5b0496ad024b56c1252b6092d5a0496ad824b568125ab609295a0496ad824b56c125ab409295b0496ad024b56c125ab609295a0496ad024a57c1252be09295f0492af024a57c1252be09255f0494af824f 90024d00bc04d80154c125328090d9e6c03425efd98b2f2cfcfa72c3cf9e541a771210000140078119d1800ee41c05f21b02db0e818a85c0b83ca054de002d4f2819e72c0c4b820665c90378e181af6e00c1b1a06118d02ecc1016c6b00be36a05edb502f6da01756c40ac36e057db902c0dd01a87640fab8c07a17803cebb81d84a808c32e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb81606e00afb6e2b0220004025834000181 90024d00bc04c402a802232f7ecc597967e7d3961e7cf2a0dfd7a1110000078127d5dc0e143005822002dd0e815188809bbb6054de00278ee01756d80c538005e5b90342d581ad6d80c1318060d8d0320cc818a6f40be36a05edb402f6da81826e40b3b78057dba02bedd01176640ec252079d7803cebb81f67140d3bae057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00b036e057db802bedb815f6e00afb6ed80acc2cba5064cbc9048c3d7874cd97ae5e5 90024d00bc04b003df0e3d195069dc684000060010072364504510b82a992815148e0a864705452382a192015148e0a8a4705432382a291c150c8e0a8a4705452382a191c1514900a864705452382a4920151c900a924805492402a4920151c900a924805492402a4920151c900a9248054523829691814bc8e0a5e46052f238ac0900014116090000a0aa00cd42cba5064cbc9048c3d7874cd97ae5e5df0e3d19506febd0c880000200edba82086a0f05372202a191c15148e0a8a4705432382a291c150c8e0a8a4705452382a192015148e0a864705452382a291c150c8e0a8a4705492402a39201524900a924805472402a49 90034d00bc049c04201524900a924805472402a49201524900a9649053323829791c14bc8e0a5e46
1 2004 888 512 d407c40164cceb1fc851f905900102044149af94472d3103872165e5b34eecbc9054dfc902f412f7ecc597967e7d3961e7cf28005c1020039698b4b0023310b2f2d9a7765e482a6fe483a68e5bfae7d0af665cdd005d99cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025999cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e00001c028191859796cd3bb2f241537f241cb4e7d1d009d95cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025995cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e01001802819697bf662cbcb3f3e9c9074d1cb7f5cfa15eccb9ba01bb1b98bc58bc58bc7c5c28b804b388a700966473182b182b182f8b851700967114e012ccce63b963b963b9f170a2e012ce229c02599dcc7c2c7c2c7c3e2e145c0259c453804b31b9970597059707c5c28b804b388a7009664732eab2eab2eaf8b851700967114e012ccce668966896689f170a2e012ce229c02599dccd62cd62cd63e2e145c0259c453804b03c06002005031f2f7ecc597967e7d3920e5a73e8e808ec6e62f162f162f1f170a2e012ce229c025991cc60ac60ac60be2e145c0259c453804b32b98ee58ee58ee7c5c28b804b388a7009667731f0b1f0b1f0f8b851700967114e012cc6e65c165c165c1f170a2e012ce229c025991ccbaacbaacbabe2e145c0259c453804b32b99a259a259a27c5c28b804b388a700966773358b358b358f8b851700967114e012c0f0100160140cdc8c3d7874cd97ae5e5df0e3d195074d1cb7f5cfa15eccb9ba02bb1b9880588058807c5c28b804b388a70096647310ab10ab10af8b851700967114e012ccce62c962c962c9f170a2e012ce229c02599dcc5e2c5e2c5e3e2e145c0259c453804b31b9934593459347c5c28b804b388a700966473272b272b272f8b851700967114e012ccce659965996599f170a2e012ce229c02599dccb82cb82cb83e2e145c0259c453804b0bc0800480503c0a00400500 90014d0086030000d407c40164cceb1fc851f905900102044149af94472d3103872165e5b34eecbc9054dfc902f412f7ecc597967e7d3961e7cf28005c1020039698b4b0023310b2f2d9a7765e482a6fe483a68e5bfae7d0af665cdd005d99cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025999cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e00001c028191859796cd3bb2f241537f241cb4e7d1d009d95cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025995cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e01001802819697bf662cbcb3f3e9c9074d1cb7f5cfa15eccb9ba01bb1b98bc58bc58bc7c5c28b804b388a700966473182b182b182f8b851700967114e012ccce63b963b963b9f170a2e012ce229c02599dcc7c2c7c2c7c3e2e145c0259c453804b31b9970597059707c5c28b804b388a70096 90034d008603f80164732eab2eab2eaf8b851700967114e012ccce668966896689f170a2e012ce229c02599dccd62cd62cd63e2e145c0259c453804b03c06002005031f2f7ecc597967e7d3920e5a73e8e808ec6e62f162f162f1f170a2e012ce229c025991cc60ac60ac60be2e145c0259c453804b32b98ee58ee58ee7c5c28b804b388a7009667731f0b1f0b1f0f8b851700967114e012cc6e65c165c165c1f170a2e012ce229c025991ccbaacbaacbabe2e145c0259c453804b32b99a259a259a27c5c28b804b388a700966773358b358b358f8b851700967114e012c0f0100160140cdc8c3d7874cd97ae5e5df0e3d195074d1cb7f5cfa15eccb9ba02bb1b9880588058807c5c28b804b388a70096647310ab10ab10af8b851700967114e012ccce62c962c962c9f170a2e012ce229c02599dcc5e2c5e2c5e3e2e145c0259c453804b31b9934593459347c5c28b804b388a700966473272b272b272f8b851700967114e012ccce659965996599f170a2e012ce229c02599dccb82cb82cb83e2e145c0259c453804b0bc0800480503c0a00400500
2 2004 888 244 d407c40164cceb1fc851f905900102044149af94472d3103872165e5b34eecbc9054dfc902f412f7ecc597967e7d3961e7cf28005c1020039698b4b0023310b2f2d9a7765e482a6fe483a68e5bfae7d0af665cdd005d99cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025999cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e00001c028191859796cd3bb2f241537f241cb4e7d1d009d95cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025995cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e01001802819697bf662cbcb3f3e9c9074d1cb7f5cfa15eccb9ba01bb1b98bc58bc58bc7c5c28b804b388a700966473182b182b182f8b851700967114e012ccce63b963b963b9f170a2e012ce229c02599dcc7c2c7c2c7c3e2e145c0259c453804b31b9970597059707c5c28b804b388a7009664732eab2eab2eaf8b851700967114e012ccce668966896689f170a2e012ce229c02599dccd62cd62cd63e2e145c0259c453804b03c06002005031f2f7ecc597967e7d3920e5a73e8e808ec6e62f162f162f1f170a2e012ce229c025991cc60ac60ac60be2e145c0259c453804b32b98ee58ee58ee7c5c28b804b388a7009667731f0b1f0b1f0f8b851700967114e012cc6e65c165c165c1f170a2e012ce229c025991ccbaacbaacbabe2e145c0259c453804b32b99a259a259a27c5c28b804b388a700966773358b358b358f8b851700967114e012c0f0100160140cdc8c3d7874cd97ae5e5df0e3d195074d1cb7f5cfa15eccb9ba02bb1b9880588058807c5c28b804b388a70096647310ab10ab10af8b851700967114e012ccce62c962c962c9f170a2e012ce229c02599dcc5e2c5e2c5e3e2e145c0259c453804b31b9934593459347c5c28b804b388a700966473272b272b272f8b851700967114e012ccce659965996599f170a2e012ce229c02599dccb82cb82cb83e2e145c0259c453804b0bc0800480503c0a00400500 90014d0086030000d407c40164cceb1fc851f905900102044149af94472d3103872165e5b34eecbc9054dfc902f412f7ecc597967e7d3961e7cf28005c1020039698b4b0023310b2f2d9a7765e482a6fe483a68e5bfae7d0af665cdd005d99cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025999cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e00001c028191859796cd 90024d008603ec003bb2f241537f241cb4e7d1d009d95cc3b2c3b2c3b3e2e145c0259c453804b33b9880588058807c5c28b804b388a7009663731f0b1f0b1f0f8b851700967114e012cc8e63f563f563f5f170a2e012ce229c025995cc952c952c953e2e145c0259c453804b33b9934593459347c5c28b804b388a700966373358b358b358f8b851700967114e012cc8e66c566c566c5f170a2e012ce229c02581e01001802819697bf662cbcb3f3e9c9074d1cb7f5cfa15eccb9ba01bb1b98bc58bc58bc7c5c28b804b388a700966473182b182b182f8b851700967114e012ccce63b963b963b9f170a2e012ce229c02599dcc7 90024d008603d801c2c7c2c7c3e2e145c0259c453804b31b9970597059707c5c28b804b388a7009664732eab2eab2eaf8b851700967114e012ccce668966896689f170a2e012ce229c02599dccd62cd62cd63e2e145c0259c453804b03c06002005031f2f7ecc597967e7d3920e5a73e8e808ec6e62f162f162f1f170a2e012ce229c025991cc60ac60ac60be2e145c0259c453804b32b98ee58ee58ee7c5c28b804b388a7009667731f0b1f0b1f0f8b851700967114e012cc6e65c165c165c1f170a2e012ce229c025991ccbaacbaacbabe2e145c0259c453804b32b99a259a259a27c5c28b804b388a700966773358b358b358 90034d008603c402f8b851700967114e012c0f0100160140cdc8c3d7874cd97ae5e5df0e3d195074d1cb7f5cfa15eccb9ba02bb1b9880588058807c5c28b804b388a70096647310ab10ab10af8b851700967114e012ccce62c962c962c9f170a2e012ce229c02599dcc5e2c5e2c5e3e2e145c0259c453804b31b9934593459347c5c28b804b388a700966473272b272b272f8b851700967114e012ccce659965996599f170a2e012ce229c02599dccb82cb82cb83e2e145c0259c453804b0bc0800480503c0a00400500
3 2003 1198 512 d307c40164cceb1fc851f905900102054149af940801038e42cbcb669dd97920a9bf9205e825efd98b2f2cfcfa72c3cf9e5000b8255642f5d9c50d15ac419009601456c0ad802742cbcb669dd97920a9bf920d3b85080000600370c942ae092d5b0496ad024a56c125ab4092d5b0496ad824a568125ab6092d5a0496ad824a568125ab6092d5b0496ad024b56c1252b4092d5b0496ad824b5681252b6092d5a0496ad824b5681252b6092d5b0496ad024b56c125ab409295b0496ad824b568125ab609295a0496ad824b568125ab609295b0496ad024b56c125ab4092d5b0494ad824b568125ab609295b0494af824a57c124abc09295f0494af824a57c124abe09295f0488b5023c6a4121b3e2b0440001005831000100a8011f0b2f2d9a7765e482a6fe4837f5e824400001b85c18db0494ad824b56c125ab4092d5b0494ad024b56c125ab6092d5a0496ad824a568125ab6092d5a0496ad824a56c125ab4092d5b0496ad024a56c125ab6092d5a0496ad824b5681252b6092d5a0496ad824b56c1252b4092d5b0496ad024b56c1252b6092d5a0496ad824b568125ab609295a0496ad824b56c125ab409295b0496ad024b56c125ab609295a0496ad024a57c1252be09295f0492af024a57c1252be09255f0494af824f54c125328090d9e6c03425efd98b2f2cfcfa72c3cf9e541a771210000140078119d1800ee41c05f21b02db0e818a85c0b83ca054de002d4f2819e72c0c4b820665c90378e181af6e00c1b1a06118d02ecc1016c6b00be36a05edb502f6da01756c40ac36e057db902c0dd01a87640fab8c07a17803cebb81d84a808c32e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb81606e00afb6e2b0220004025834000181a802232f7ecc597967e7d3961e7cf2a0dfd7a1110000078127d5dc0e143005822002dd0e815188809bbb6054de00278ee01756d80c538005e5b90342d581ad6d80c1318060d8d0320cc818a6f40be36a05edb402f6da81826e40b3b78057dba02bedd01176640ec252079d7803cebb81f67140d3bae057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00b036e057db802bedb815f6e00afb6ed80acc2cba5064cbc9048c3d7874cd97ae5e5df0e3d195069dc684000060010072364504510b82a992815148e0a864705452382a192015148e0a8a4705432382a291c150c8e0a8a4705452382a191c1514900a864705452382a4920151c900a924805492402a4920151c900a924805492402a4920151c900a9248054523829691814bc8e0a5e46052f238ac0900014116090000a0aa00cd42cba5064cbc9048c3d7874cd97ae5e5df0e3d19506febd0c880000200edba82086a0f05372202a191c15148e0a8a4705432382a291c150c8e0a8a4705452382a192015148e0a864705452382a291c150c8e0a8a4705492402a39201524900a924805472402a49201524900a924805472402a49201524900a9649053323829791c14bc8e0a5e46 90014d00bc040000d307c40164cceb1fc851f905900102054149af940801038e42cbcb669dd97920a9bf9205e825efd98b2f2cfcfa72c3cf9e5000b8255642f5d9c50d15ac419009601456c0ad802742cbcb669dd97920a9bf920d3b85080000600370c942ae092d5b0496ad024a56c125ab4092d5b0496ad824a568125ab6092d5a0496ad824a568125ab6092d5b0496ad024b56c1252b4092d5b0496ad824b5681252b6092d5a0496ad824b5681252b6092d5b0496ad024b56c125ab409295b0496ad824b568125ab609295a0496ad824b568125ab609295b0496ad024b56c125ab4092d5b0494ad824b568125ab609295b0494af824a57c124abc09295f0494af824a57c124abe09295f0488b5023c6a4121b3e2b0440001005831000100a8011f0b2f2d9a7765e482a6fe4837f5e824400001b85c18db0494ad824b56c125ab4092d5b0494ad024b56c125ab6092d5a0496ad824a568125ab6092d5a0496ad824a56c125ab4092d5b0496ad024a56c125ab6092d5a0496ad824b5681252b6092d5a0496ad824b56c1252b4092d5b0496ad024b56c1252b6092d5a0496ad824b568125ab609295a0496ad824b56c125ab409295b0496ad024b56c125ab609295a0496ad024a57c1252be09295f0492af024a57c1252be09255f0494af824f54c125328090d9e6c03425efd98b2f2cfcfa72c3cf9e541a7712100001400781 90024d00bc04f80119d1800ee41c05f21b02db0e818a85c0b83ca054de002d4f2819e72c0c4b820665c90378e181af6e00c1b1a06118d02ecc1016c6b00be36a05edb502f6da01756c40ac36e057db902c0dd01a87640fab8c07a17803cebb81d84a808c32e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb81606e00afb6e2b0220004025834000181a802232f7ecc597967e7d3961e7cf2a0dfd7a1110000078127d5dc0e143005822002dd0e815188809bbb6054de00278ee01756d80c538005e5b90342d581ad6d80c1318060d8d0320cc818a6f40be36a05edb402f6da81826e40b3b78057dba02bedd01176640ec252079d7803cebb81f67140d3bae057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00b036e057db802bedb815f6e00afb6ed80acc2cba5064cbc9048c3d7874cd97ae5e5df0e3d195069dc684000060010072364504510b82a992815148e0a864705452382a192015148e0a8a4705432382a291c150c8e0a8a4705452382a191c1514900 90034d00bc04f003a864705452382a4920151c900a924805492402a4920151c900a924805492402a4920151c900a9248054523829691814bc8e0a5e46052f238ac0900014116090000a0aa00cd42cba5064cbc9048c3d7874cd97ae5e5df0e3d19506febd0c880000200edba82086a0f05372202a191c15148e0a8a4705432382a291c150c8e0a8a4705452382a192015148e0a864705452382a291c150c8e0a8a4705492402a39201524900a924805472402a49201524900a924805472402a49201524900a9649053323829791c14bc8e0a5e46
4 2003 1198 244 d307c40164cceb1fc851f905900102054149af940801038e42cbcb669dd97920a9bf9205e825efd98b2f2cfcfa72c3cf9e5000b8255642f5d9c50d15ac419009601456c0ad802742cbcb669dd97920a9bf920d3b85080000600370c942ae092d5b0496ad024a56c125ab4092d5b0496ad824a568125ab6092d5a0496ad824a568125ab6092d5b0496ad024b56c1252b4092d5b0496ad824b5681252b6092d5a0496ad824b5681252b6092d5b0496ad024b56c125ab409295b0496ad824b568125ab609295a0496ad824b568125ab609295b0496ad024b56c125ab4092d5b0494ad824b568125ab609295b0494af824a57c124abc09295f0494af824a57c124abe09295f0488b5023c6a4121b3e2b0440001005831000100a8011f0b2f2d9a7765e482a6fe4837f5e824400001b85c18db0494ad824b56c125ab4092d5b0494ad024b56c125ab6092d5a0496ad824a568125ab6092d5a0496ad824a56c125ab4092d5b0496ad024a56c125ab6092d5a0496ad824b5681252b6092d5a0496ad824b56c1252b4092d5b0496ad024b56c1252b6092d5a0496ad824b568125ab609295a0496ad824b56c125ab409295b0496ad024b56c125ab609295a0496ad024a57c1252be09295f0492af024a57c1252be09255f0494af824f54c125328090d9e6c03425efd98b2f2cfcfa72c3cf9e541a771210000140078119d1800ee41c05f21b02db0e818a85c0b83ca054de002d4f2819e72c0c4b820665c90378e181af6e00c1b1a06118d02ecc1016c6b00be36a05edb502f6da01756c40ac36e057db902c0dd01a87640fab8c07a17803cebb81d84a808c32e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb81606e00afb6e2b0220004025834000181a802232f7ecc597967e7d3961e7cf2a0dfd7a1110000078127d5dc0e143005822002dd0e815188809bbb6054de00278ee01756d80c538005e5b90342d581ad6d80c1318060d8d0320cc818a6f40be36a05edb402f6da81826e40b3b78057dba02bedd01176640ec252079d7803cebb81f67140d3bae057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00b036e057db802bedb815f6e00afb6ed80acc2cba5064cbc9048c3d7874cd97ae5e5df0e3d195069dc684000060010072364504510b82a992815148e0a864705452382a192015148e0a8a4705432382a291c150c8e0a8a4705452382a191c1514900a864705452382a4920151c900a924805492402a4920151c900a924805492402a4920151c900a9248054523829691814bc8e0a5e46052f238ac0900014116090000a0aa00cd42cba5064cbc9048c3d7874cd97ae5e5df0e3d19506febd0c880000200edba82086a0f05372202a191c15148e0a8a4705432382a291c150c8e0a8a4705452382a192015148e0a864705452382a291c150c8e0a8a4705492402a39201524900a924805472402a49201524900a924805472402a49201524900a9649053323829791c14bc8e0a5e46 90014d00bc040000d307c40164cceb1fc851f905900102054149af940801038e42cbcb669dd97920a9bf9205e825efd98b2f2cfcfa72c3cf9e5000b8255642f5d9c50d15ac419009601456c0ad802742cbcb669dd97920a9bf920d3b85080000600370c942ae092d5b0496ad024a56c125ab4092d5b0496ad824a568125ab6092d5a0496ad824a568125ab6092d5b0496ad024b56c1252b4092d5b0496ad824b5681252b6092d5a0496ad824b5681252b6092d5b0496ad024b56c125ab409295b0496ad824b568125ab609295a0496ad824b568125ab609295b0496ad024b56c125ab4092d5b0494ad824b568125ab609295b049 90024d00bc04ec004af824a57c124abc09295f0494af824a57c124abe09295f0488b5023c6a4121b3e2b0440001005831000100a8011f0b2f2d9a7765e482a6fe4837f5e824400001b85c18db0494ad824b56c125ab4092d5b0494ad024b56c125ab6092d5a0496ad824a568125ab6092d5a0496ad824a56c125ab4092d5b0496ad024a56c125ab6092d5a0496ad824b5681252b6092d5a0496ad824b56c1252b4092d5b0496ad024b56c1252b6092d5a0496ad824b568125ab609295a0496ad824b56c125ab409295b0496ad024b56c125ab609295a0496ad024a57c1252be09295f0492af024a57c1252be09255f0494af824f 90024d00bc04d80154c125328090d9e6c03425efd98b2f2cfcfa72c3cf9e541a771210000140078119d1800ee41c05f21b02db0e818a85c0b83ca054de002d4f2819e72c0c4b820665c90378e181af6e00c1b1a06118d02ecc1016c6b00be36a05edb502f6da01756c40ac36e057db902c0dd01a87640fab8c07a17803cebb81d84a808c32e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb81606e00afb6e2b0220004025834000181 90024d00bc04c402a802232f7ecc597967e7d3961e7cf2a0dfd7a1110000078127d5dc0e143005822002dd0e815188809bbb6054de00278ee01756d80c538005e5b90342d581ad6d80c1318060d8d0320cc818a6f40be36a05edb402f6da81826e40b3b78057dba02bedd01176640ec252079d7803cebb81f67140d3bae057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00b036e057db802bedb815f6e00afb6ed80acc2cba5064cbc9048c3d7874cd97ae5e5 90024d00bc04b003df0e3d195069dc684000060010072364504510b82a992815148e0a864705452382a192015148e0a8a4705432382a291c150c8e0a8a4705452382a191c1514900a864705452382a4920151c900a924805492402a4920151c900a924805492402a4920151c900a9248054523829691814bc8e0a5e46052f238ac0900014116090000a0aa00cd42cba5064cbc9048c3d7874cd97ae5e5df0e3d19506febd0c880000200edba82086a0f05372202a191c15148e0a8a4705432382a291c150c8e0a8a4705452382a192015148e0a864705452382a291c150c8e0a8a4705492402a39201524900a924805472402a49 90034d00bc049c04201524900a924805472402a49201524900a9649053323829791c14bc8e0a5e46
+113
View File
@@ -0,0 +1,113 @@
# Large SPATEM / MAPEM reception (2026-11-23)
Why a road RSU's SPATEMs and MAPEMs did not reach the phone's V2X screens, in two independent places, and what was
changed. Interface changes are in `obu-firmware/docs/station-link.tex` (revision 3).
## Symptom
A MAPEM and a SPATEM compiled to sit below 494 bytes arrived on the phone; larger ones did not. Later, with the
firmware fixed, the phone *logger* showed the RSU's large messages but the app's V2X screens stayed empty.
The "larger" test messages were far above the limit: **888 bytes (SPATEM) and 1198 bytes (MAPEM)**, from the
Berliner Tor RSU (station 1095348116, intersection 23, 6 lanes, 5 signal groups). The small pair were 377 B (MAPEM)
and 58 B (SPATEM). The test therefore showed that nothing is fragmented on that path, not where a cutoff sits.
## Problem 1: the firmware dropped everything over 494 bytes
**It did receive them.** The radio captures frames up to 2346 bytes, and the firmware's own `gn_unwrap.c`, replayed
on the PC over the CiT node's pcap (`its5_20261123_150746.pcap`, 27 367 frames), accepts all of them: 1727 MAPEMs
of 1198 B and 3384 SPATEMs of 888 B. They are valid: asn1tools decodes every distinct one and re-encodes it
byte-identically.
**The firmware then threw them away.** `V2X_RX` (opcode 0x90, MicrOBU's own) was designed as one link message. A link
message is at most 512 octets (the largest GATT value), minus 4 header and 14 prefix octets leaves **494 bytes** of
ITS payload. `Station::forward_raw` called `v2x_rx_fits()`, and for a longer message only incremented
`raw_oversize_` and returned. The fragmenting code (`LinkService::send_fragmented`, used for `RAW_FRAME`, PKI and
indications) existed and the app already reassembled any fragmented opcode, but the gate in front of it meant a
`V2X_RX` was never offered to it.
**Why nobody noticed:**
- It was a known, documented limit (`gn_unwrap.h`, `NOTES.md`, TODO.md: "road MAPEMs over 494 bytes are still dropped as
oversize (no fragmentation)"), but every earlier bench run used the bench RSU, whose messages are 58 and 295 bytes.
- The drop was silent where the phone could see it. The counter lived only in the firmware, STATUS has a fixed
131-octet layout with no field for it, and the only trace was one LOG line per 10 s on the USB log, which a phone on
BLE never gets.
- Comparing the phone log with a second receiver (the node's pcap) is what exposed it: 0 of 1537 large MAPEMs and
0 of 3004 large SPATEMs reached the phone, against 98.5 % and 96.5 % of the small ones.
**What the 2026-11-23 COM10 read did and did not show.** An early check of COM10's log concluded the board "never saw
a large message". That was wrong. `tools/station_status_watch.py` prints only the first few V2X_RX lines unless asked,
and opening the port reset the board. It showed nothing about large messages either way.
### Fix (obu-firmware)
- `v2x_rx.hpp`: `v2x_rx_plan()` decides `single` (up to 494 B, byte-identical to before), `fragmented` (up to
`v2x_rx_max_forward` = 2300 B), `covered_by_raw` (large and `RAW_CAPTURE` on) or `drop`.
- `link_fragment.hpp` (new, host-testable): `split_fragments()` is the one fragmenter. `LinkService::send_fragmented`
uses it, with the same bytes on the wire as before.
- Best effort, never blocking: fragments of a large `V2X_RX` go out on serial through the non-blocking
`try_write`, no retry, no wait. The first failed fragment ends that message; the app drops the incomplete stream
(2 s idle, or the next first fragment). A transport that would need more than 8 fragments (ATT MTU 23) skips the
message.
- `serial::try_write` now writes nothing when no USB host is connected.
- Counters `raw_fragmented_`, `raw_fragment_failed_`, `raw_covered_`, `raw_oversize_`, in the throttled LOG line.
STATUS is unchanged.
- The app's V2X_RX / Raw frames switch is untouched. While `RAW_CAPTURE` is on a large message is not sent a second
time as V2X_RX.
- TX path untouched.
### Result on air (COM10, BLE, 17:08-17:20)
`tools/rx_size_compare.py` on the new phone log and node pcap: MAPEM 1198 B 92.9 % of what the node heard, SPATEM
888 B 81.7 %, CAMs 92.5-99.3 %, `radio_dropped` 0, no BLE disconnects.
## Problem 2: the app's SPATEM decoder refused the RSU's messages
**Why the logger had them and the screens did not.** Both read the same `V2X_RX` frames from `Esp32Link`. They differ
in what they do with the bytes:
- `V2xLogger` stores the raw UPER payload and classifies it from the ITS PDU header. Decoding only fills convenience
columns (position, speed, a summary), inside `runCatching`, so a decoder that fails leaves them NULL and the row is
stored anyway.
- `CamUseCaseRepository.handleSpatUper` hands the bytes to `SpatemUperCodec.decode`; on `null` it logs
"decode FAILED" and emits nothing, so no SPAT reached the traffic-light screens.
**Why the decoder returned null.** `SpatemUperCodec` returned null whenever it met an optional it could not size.
The RSU's SPATEM uses two such fields on every intersection:
- `name` / `movementName` (`DescriptiveName`, IA5String SIZE(1..63)): "Berliner Tor / Kolbergstrasse" and one per
movement.
- `speeds` (`AdvisorySpeedList`) on every event: a greenwave and an ecoDrive advice per phase. This, with the names
and the 8 events per movement, is why the message is 888 bytes and not ~58.
The decoder's header comment said it had been validated against 79 042 SPATEMs from the 2026-03-18 drive; those
messages simply carried neither field. The gap was latent: until the firmware forwarded large messages, an 888-byte
SPATEM never reached the app, so the decoder never met one.
The MAPEM decoded correctly all along (it already reads names); the traffic-light screens need the SPATEM as well.
### Fix (app)
`SpatemUperCodec` now walks, without keeping, `DescriptiveName` (6-bit length n-1, then 7 bits per character) and
`AdvisorySpeedList` (4-bit count n-1; per entry: extension bit, five optional bits, type = extension bit plus 2 bits,
speed 9 bits, confidence 3 bits, distance 14 bits, class 8 bits). Regional extensions and extension values still
return null. Widths come from `dsrc_2_2_1.asn`.
## Verification
| Check | Result |
|---|---|
| Firmware host suite (`make check` in `obu-firmware/test/host`): chain, replay with asn1tools, 2 M-iteration fuzz, battery, firmware | pass; the firmware unit tests grew from 40 to 46 |
| `test_v2x_fragments`: the node pcap through unwrap, plan, fragments, two independent reassemblers, at link limits 512 and 244, with a lost fragment | 5111 large messages, 0 failures |
| App `LinkReassemblyTest` on the firmware's own fragments (`v2x_rx_fragments.tsv`) | pass |
| `SpatemUperCodec` against asn1tools on every distinct SPATEM of the new phone log | 718 of 718 equal field for field, 3590 movements |
| App unit suite | 197 tests, 0 failures |
| ESP-IDF 6.0.2 image build | 0x1f7aa0 bytes, 34 % of the app partition free |
## Files changed
Firmware: `v2x_rx.hpp`, `link_fragment.hpp` (new), `link_service.cpp/.hpp`, `station.cpp/.hpp`, `serial_link.cpp`,
`gn_unwrap.h` (comment), `NOTES.md`, `README.md`, `docs/station-link.tex`. Tests: `test_firmware.cpp`,
`test_v2x_fragments.cpp` (new), `Makefile`. App: `SpatemUperCodec.kt`, `SpatemUperCodecTest.kt`,
`LinkReassemblyTest.kt`, resources `v2x_rx_fragments.tsv`, `spatem_road_rsu_888.hex`. Tool: `tools/rx_size_compare.py`.
## Still open
- The V2X screens on the phone with the rebuilt app (this document was written before that check).
- MAPEM / SPATEM loss on BLE rises with size (58-byte SPATEM 96.5 % on 2026-11-23 earlier, 888-byte SPATEM 81.7 % now): a lost fragment loses
the message. If the screens need better, options are a smaller fragment cadence or a loss counter in the app
(`LinkReassembly.dropped`).
- Advisory speeds are walked, not used; a GLOSA display could read them.
+11 -3
View File
@@ -35,8 +35,16 @@ custom PCB; pick it in `menuconfig -> micrOBU firmware -> Board`.
(`Station::forward_raw`) and reaches the phone as `V2X_RX`. Body: `u16 port, i8 rssi, u8 flags
(bit0 GBC area, bit1 signed), i32 lat, i32 lon, u16 distance_a, ITS payload`. `0x85` is the spec's
`RAW_FRAME` debug capture and `0x86` is reserved by Niklas Dathe, hence `0x90`. BTP ports 2001
CAM, 2002 DENM, 2003 MAPEM, 2004 SPATEM, 2018 VAM pass; a message over 494 bytes does not fit a
512-octet link message and is dropped and counted (not fragmented).
CAM, 2002 DENM, 2003 MAPEM, 2004 SPATEM, 2018 VAM pass. A message up to 494 bytes is one link
message, unchanged. Since 2026-11-23 a larger one (a road SPATEM or MAPEM, 555-1243 bytes; up to
`v2x_rx_max_forward` = 2300) goes out in link fragments (`link_fragment.hpp`, flags 1/2/3 as the spec
defines them), best effort: no retry and no waiting, a fragment no transport takes ends that message
(the app drops the incomplete stream) and `raw_fragment_failed_` counts it, and the serial fragments use
the non-blocking `try_write` so a stalled USB host cannot hold the station task that drains the radio queue.
A transport that would need more than 8 fragments (ATT MTU 23) skips the message. While `RAW_CAPTURE` is on
the app reads `RAW_FRAME`, so a large message is not sent a second time as `V2X_RX` (`raw_covered_`).
Before this change a message over 494 bytes was dropped and counted (the 2026-11-23 bench run lost every
888-byte SPATEM and 1198-byte MAPEM that way).
- **Unsigned transmission.** Niklas Dathe's station signs everything. A request with GN security
profile 1 (or 0 while the station is configured `security = 0`) goes out unsigned with
`geonet.c`'s header and the position of the last PoTi (`Station::unsecured_request`), from a
@@ -64,7 +72,7 @@ custom PCB; pick it in `menuconfig -> micrOBU firmware -> Board`.
- **Flash size 8 MB** (XIAO), TX power ceiling 20 dBm (`radio_policy.hpp` admits 20 dBm on channel 180).
- **ATT MTU 517** (`CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU`, Niklas Dathe's 512): the app asks for 517 and a 494-octet
V2X_RX is a 512-octet link message, which needs a value of 512, i.e. an MTU of 515. At 512 such a message was
split into fragments the app does not reassemble.
split into fragments the app did not reassemble then (it does now, `LinkReassembly`).
- **Link-layer address.** A signed station without a named MAC uses the address derived from its ticket; with the
16-octet STATION_CONFIGURE the phone names it (see "Unsigned transmission"). The CAM and VAM station ID still
rotates in the app; the app now rotates the MAC with it on a ride and keeps one fixed for the bench pinger.
+2 -2
View File
@@ -90,7 +90,7 @@ It prints the log, the 131-octet STATUS once a second (uptime, signing and radio
battery) and the first V2X_RX messages. Status exchange: the host sends `STATUS_REQUEST` every
1000 ms; `CONFIRM.detail` contains the snapshot.
Received messages reach the phone on two paths that both stay in the firmware: `V2X_RX` (ours, always on, already unwrapped, up to 494 octets) and `RAW_FRAME` (the spec's debug capture, on after `RAW_CAPTURE`, the whole radio frame, fragmented when large). The Android app has a switch for which one it consumes; the board always sends `V2X_RX`. See [NOTES.md](NOTES.md).
Received messages reach the phone on two paths that both stay in the firmware: `V2X_RX` (ours, always on, already unwrapped, one message up to 494 octets, fragmented above that up to 2300) and `RAW_FRAME` (the spec's debug capture, on after `RAW_CAPTURE`, the whole radio frame, fragmented when large). The Android app has a switch for which one it consumes; the board always sends `V2X_RX`. See [NOTES.md](NOTES.md).
```mermaid
flowchart LR
@@ -99,7 +99,7 @@ flowchart LR
Radio --> Unwrap[gn_unwrap.c: 802.11, LLC, GN, BTP, signature envelope]
Radio -->|only while RAW_CAPTURE is on| Cap[Raw capture tap: ITS5 record]
Stack -->|verified only| Ind[BTP_DATA_INDICATION 0x81]
Unwrap -->|always, signed or not, up to 494 octets| Rx[V2X_RX 0x90, MicrOBU]
Unwrap -->|always, signed or not, fragmented above 494 octets| Rx[V2X_RX 0x90, MicrOBU]
Cap -->|fragmented if large| Raw[RAW_FRAME 0x85, spec]
Ind --> Link[Station link: USB or BLE]
Rx --> Link
File diff suppressed because it is too large Load Diff
+27 -9
View File
@@ -21,15 +21,15 @@
\newcolumntype{F}{@{}|P{12mm}|P{43mm}|P{36mm}|P{25mm}|P{48.15mm}|@{}}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[L]{\footnotesize Document revision 2 (MicrOBU)}
\fancyfoot[L]{\footnotesize Document revision 3 (MicrOBU)}
\fancyfoot[R]{\footnotesize\thepage\ / \pageref{LastPage}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\hypersetup{pdftitle={microbu station link interface reference, revision 2 (MicrOBU)}}
\hypersetup{pdftitle={microbu station link interface reference, revision 3 (MicrOBU)}}
\begin{document}
microbu station link interface reference, revision 2 (MicrOBU)\par
microbu station link interface reference, revision 3 (MicrOBU)\par
\vspace{3mm}
Revision 1 was written by Niklas Dathe (microbu-firmware, commit e4e4bd8); revision 2 is revision 1 plus the additions of the MicrOBU production firmware (obu-firmware). Every addition is marked \textbf{MicrOBU extension}; the revision history is at the end.\par\smallskip
Revision 1 was written by Niklas Dathe (microbu-firmware, commit e4e4bd8); revisions 2 and 3 are revision 1 plus the additions of the MicrOBU production firmware (obu-firmware). Every addition is marked \textbf{MicrOBU extension}; the revision history is at the end.\par\smallskip
The maximum link message is 512 bytes, including the four-byte header.\par\smallskip
USB Serial/JTAG and BLE GATT carry the same messages.
The host sends a status request as a link heartbeat.\par\smallskip
@@ -1147,7 +1147,7 @@ Marks record origin and time basis.
{\ttfamily 12} & {\ttfamily frame\_\allowbreak{}length} & {\ttfamily u16} & bytes & Gives the raw radio-frame size in bytes. \\
{\ttfamily 14} & {\ttfamily frame} & {\ttfamily bytes[\allowbreak{}frame\_\allowbreak{}length]} & \textemdash & Contains the raw radio-frame bytes. \\
\end{longtable}}
\Needspace{7\baselineskip}\section{MicrOBU extensions (revision 2)}\label{sec:microbu-extensions}
\Needspace{7\baselineskip}\section{MicrOBU extensions (revisions 2 and 3)}\label{sec:microbu-extensions}
These additions are not in revision 1. A host written for revision 1 keeps working: it never sees opcode 0x90 unless it listens for it, and it never sends security profile 0x01.
\Needspace{8\baselineskip}\subsection{{\ttfamily V2X\_\allowbreak{}RX}}
{\small\color{ink}\textbf{0x90}\quad STATION TO HOST \quad (MicrOBU extension)}
@@ -1156,8 +1156,8 @@ Delivers every ITS message heard on air, verified or not. The station stack deca
\toprule\textbf{Parameter} & \textbf{Setting} & \textbf{Description} \\\midrule\endfirsthead
\toprule\textbf{Parameter} & \textbf{Setting} & \textbf{Description} \\\midrule\endhead
\bottomrule\endfoot
{\ttfamily reply} & {\ttfamily none} & One-way indication, not fragmented. \\
{\ttfamily maximum\_\allowbreak{}payload} & {\ttfamily 494 bytes} & 512 minus the four-byte header and the 14-byte prefix. A longer message is dropped and counted, never fragmented. \\
{\ttfamily reply} & {\ttfamily none} & One-way indication. Fragmented when the body exceeds one link message (revision 3, Section~\ref{sec:microbu-v2xrx-frag}). \\
{\ttfamily maximum\_\allowbreak{}payload} & {\ttfamily 2300 bytes} & Up to 494 bytes (512 minus the four-byte header and the 14-byte prefix) the message is one link message. Revision 3: a longer one is fragmented, up to 2300 bytes; beyond that it is dropped and counted. Revision 2 dropped everything over 494 bytes. \\
{\ttfamily btp\_\allowbreak{}ports} & {\ttfamily 2001--2004, 2018} & CAM, DENM, MAPEM, SPATEM, VAM. Other ports are not delivered. \\
{\ttfamily availability} & {\ttfamily from configure} & The radio is polled from STATION\_CONFIGURE on, before the first POTI\_UPDATE. \\
\end{longtable}}
@@ -1177,10 +1177,27 @@ Delivers every ITS message heard on air, verified or not. The station stack deca
\Needspace{8\baselineskip}\subsection{\texttt{V\_\allowbreak{}2X\_\allowbreak{}RX} and \texttt{RAW\_\allowbreak{}FRAME}: both stay}\label{sec:microbu-rxpaths}
Revision 2 does not replace the debug capture of revision 1 with \texttt{V\_2X\_RX}: the station keeps both, and the host chooses.
\begin{itemize}
\item \texttt{V\_2X\_RX} is sent for every ITS message heard, always, once the radio runs (it needs no \texttt{RAW\_CAPTURE}). The station has already unwrapped the frame, so a host decodes the payload at once; the message is at most 494 octets and is never fragmented.
\item \texttt{RAW\_FRAME} (revision 1) is sent only while \texttt{RAW\_CAPTURE} is on, as a copy of the whole 802.11 frame, fragmented when it exceeds one link message. A host that uses it unwraps the frame itself, is not limited to 494 octets, and accepts that copies may be dropped when the transport is busy.
\item \texttt{V\_2X\_RX} is sent for every ITS message heard, always, once the radio runs (it needs no \texttt{RAW\_CAPTURE}). The station has already unwrapped the frame, so a host decodes the payload at once; a message of up to 494 octets is one link message, a larger one is fragmented (revision 3, Section~\ref{sec:microbu-v2xrx-frag}).
\item \texttt{RAW\_FRAME} (revision 1) is sent only while \texttt{RAW\_CAPTURE} is on, as a copy of the whole 802.11 frame, fragmented when it exceeds one link message. A host that uses it unwraps the frame itself, is not limited to 494 octets (neither is \texttt{V\_2X\_RX} since revision 3), and accepts that copies may be dropped when the transport is busy.
\end{itemize}
The station does not know which path the host uses and sends \texttt{V\_2X\_RX} regardless. The MicrOBU Android app offers both as a setting (Receive path). In raw mode it sends \texttt{RAW\_CAPTURE} with mode 0x03 (capture on, broadcast frames only), reassembles fragments as described in Section~\ref{sec:fragmentation-host}, unwraps each frame with the same rules as the station does for \texttt{V\_2X\_RX} (single-hop broadcast and GeoBroadcast, BTP-B ports 2001--2004 and 2018, a signature envelope unwrapped without verification) and ignores the \texttt{V\_2X\_RX} messages. In \texttt{V\_2X\_RX} mode it sends mode 0 and ignores \texttt{RAW\_FRAME}.
\Needspace{8\baselineskip}\subsection{Fragmented \texttt{V\_\allowbreak{}2X\_\allowbreak{}RX} (revision 3)}\label{sec:microbu-v2xrx-frag}
Road roadside units send SPATEMs and MAPEMs of 555 to 1243 octets (the Berliner Tor unit: 888 and 1198), more than the 494 octets one link message carries. Revision 2 dropped them in the station, silently as far as the host could tell. From revision 3 the station sends them in fragments, with the framing of the fragmentation section of revision 1 (flags 1, 2 and 3; the same opcode 0x90 and sequence on every fragment; each fragment body starts with total length and offset). The body that is reassembled is the ordinary \texttt{V\_2X\_RX} body of this section, the 14-octet prefix included.
{\small\begin{longtable}{@{}P{45mm}P{55mm}P{72.8mm}@{}}
\toprule\textbf{Parameter} & \textbf{Setting} & \textbf{Description} \\\midrule\endfirsthead
\toprule\textbf{Parameter} & \textbf{Setting} & \textbf{Description} \\\midrule\endhead
\bottomrule\endfoot
{\ttfamily single message} & {\ttfamily up to 494 bytes} & Unchanged from revision 2: flags 0, one link message, byte for byte. \\
{\ttfamily fragmented} & {\ttfamily 495 to 2300 bytes} & Body of 14 + payload octets, split into fragments of at most the transport message size minus eight octets (four of link header, four of fragment header): 504 octets of body on serial and on BLE with ATT MTU 517. An 888-byte SPATEM is two fragments, a 1198-byte MAPEM three. \\
{\ttfamily dropped} & {\ttfamily over 2300 bytes} & Counted by the station, not sent. Truncated and empty messages are never sent. \\
{\ttfamily delivery} & {\ttfamily best effort} & No acknowledgement, retry or wait. A fragment the transport does not take ends that message; the host discards the incomplete stream (2000 ms idle, or the next first fragment of the same opcode and sequence). A lost fragment costs only that message and never slows reception. \\
{\ttfamily serial} & {\ttfamily non-blocking} & Fragments are queued without waiting for the host, as \texttt{RAW\_FRAME} is, so a stalled USB host cannot hold up the station. Nothing is queued while no USB host is connected. A message that fits one link message keeps its blocking write. \\
{\ttfamily fragment cap} & {\ttfamily 8 per message} & A transport that would need more than eight fragments (an ATT MTU that was never raised, 23) skips the message. \\
{\ttfamily raw capture on} & {\ttfamily large not sent} & While \texttt{RAW\_CAPTURE} is on the host reads \texttt{RAW\_FRAME}, so a message above 494 octets is left to that copy instead of being sent a second time. Messages up to 494 octets are still sent as \texttt{V\_2X\_RX}. \\
\end{longtable}}
A host that already reassembles fragmented messages (the revision 1 requirement, Section~\ref{sec:fragmentation-host}) needs no change. A host that handled only unfragmented \texttt{V\_2X\_RX} sees flags 1 to 3 on opcode 0x90 for the first time and must reassemble or ignore them. The wire format of every other message is unchanged.
\Needspace{5\baselineskip}\paragraph{Host decoding of the larger messages}
Roadside units also fill the messages out: a SPATEM names the intersection and each movement (\texttt{DescriptiveName}, IA5String of 1 to 63 characters) and gives each signal event a list of advisory speeds (greenwave, ecoDrive). A host decoder must read past these optional fields, not refuse the message. A decoder written against shorter messages and refusing them showed no signal state for the Berliner Tor unit, although every SPATEM had arrived and was in the host's log. The MicrOBU app reads past both since 2026-11-23.
\Needspace{8\baselineskip}\subsection{Fragmentation on the host side}\label{sec:fragmentation-host}
The MicrOBU host reassembles fragmented station-to-host messages as the fragmentation section of revision 1 states: fragments of one message share opcode and sequence, flags 1, 2 and 3 mark first, middle and last, each fragment body starts with total length and offset, a gap, a duplicate, a wrong order or a changed total drops the stream, an unfinished stream is discarded after 2000 ms, at most 8 streams are held, and a complete body is at most 65535 octets. A message that fits one link message (flags 0) passes through unchanged.
\Needspace{8\baselineskip}\subsection{Unsecured transmission}\label{sec:microbu-unsecured}
@@ -1235,5 +1252,6 @@ MicrOBU extension. While no USB host is connected to the native port (the phone
\bottomrule\endfoot
1 & 2026-11 & Niklas Dathe: the microbu-firmware interface reference, commit e4e4bd8. \\
2 & 2026-11-10 & MicrOBU additions: opcode 0x90 V2X\_RX (all heard ITS messages, unverified); unsecured transmission for security profile 0x01 and for profile 0x00 with \texttt{security} 0, from a random MAC per configuration, or the MAC named by the host in the 16-octet STATION\_CONFIGURE; V\_2X\_RX and RAW\_FRAME both kept, the host choosing (Section~\ref{sec:microbu-rxpaths}); the radio is polled from STATION\_CONFIGURE on; battery protection by deep sleep; no USB writes without a host. Wire format of revision 1 unchanged; the original is kept as microbu-firmware/docs/station-link.pdf. \\
3 & 2026-11-23 & \texttt{V\_2X\_RX} larger than 494 octets is fragmented, up to 2300 octets, best effort and non-blocking (Section~\ref{sec:microbu-v2xrx-frag}); revision 2 dropped it. Serial writes of fragments and of \texttt{RAW\_FRAME} are skipped while no USB host is connected. Found on the 2026-11-23 bench run against the Berliner Tor roadside unit (888-byte SPATEM, 1198-byte MAPEM); the findings are in docs/08-large-message-reception.md. Wire format of messages up to 494 octets unchanged. \\
\end{longtable}}
\end{document}
+7 -7
View File
@@ -52,13 +52,13 @@
// only this path). Other ports are dropped. The link message itself is generic: the port says what
// the payload is.
//
// Size caveat: a link message is at most 512 octets (link::maximum_message, which is also the
// largest GATT attribute value), so Station::forward_raw() drops a message whose UPER exceeds
// 494 bytes and counts it as oversize instead of forwarding it. Nothing is fragmented. The bench
// RSU's messages all fit (2026-10-28 capture: SPATEM 58, MAPEM 295 bytes); real road SPATEMs and
// MAPEMs often do not (SPATEM 555 bytes median, 1243 max on the 2026-03-18 drive). The radio
// itself captures frames of up to 2346 bytes (c5_radio.cpp), so `truncated` does not happen on
// this firmware.
// Size: a link message is at most 512 octets (link::maximum_message, which is also the largest
// GATT attribute value), so a UPER up to 494 bytes goes to the phone as one V2X_RX message. A larger
// one (real road SPATEMs and MAPEMs: SPATEM 555 bytes median, 1243 max on the 2026-03-18 drive;
// the 2026-11-23 bench node sent 888 and 1198) is sent by Station::forward_raw() in link fragments,
// see v2x_rx.hpp (v2x_rx_plan) and link_fragment.hpp. Only a message beyond v2x_rx_max_forward is
// dropped and counted as oversize. The radio itself captures frames of up to 2346 bytes
// (c5_radio.cpp), so `truncated` does not happen on this firmware.
//
// No FCS/CRC check here: the WiFi driver has already validated the frame.
typedef struct {
+53
View File
@@ -0,0 +1,53 @@
#pragma once
// Splits a link message body into fragments (station-link "Fragmented messages": the link header with
// flags 1 first / 2 middle / 3 last and the same opcode and sequence on every fragment, then
// u16 total body size, u16 body offset, data). Header-only and free of ESP-IDF, so the host tests compile it
// unmodified and check it against the app's reassembly. LinkService::send_fragmented is the only caller.
#include "link_protocol.hpp"
namespace microbu::link {
/// One fragment: the flags for the link header and the body (u16 total, u16 offset, data).
struct Fragment {
std::uint8_t flags;
Bytes body;
};
/// Largest body that goes out as one unfragmented message on a transport whose messages are at most `limit` octets.
constexpr std::size_t unfragmented_capacity(std::size_t limit) {
return limit > header_size ? limit - header_size : 0;
}
/// Data octets one fragment carries on a transport whose messages are at most `limit` octets.
constexpr std::size_t fragment_capacity(std::size_t limit) {
return limit > header_size + fragment_header_size ? limit - header_size - fragment_header_size : 0;
}
/// @brief Fragments `body`, which must not fit one message of `limit` octets (the caller sends those as they are).
/// @param body Message body to split.
/// @param limit Largest message the transport carries, header included (512, or the BLE ATT MTU - 3).
/// @param out Receives the fragments in order; empty when false is returned.
/// @param max_fragments Refuse when more fragments would be needed (a V2X_RX on a transport with a tiny MTU).
/// @return false when the body fits one message, exceeds 65535 octets, the limit leaves no room for data, or
/// more than max_fragments are needed.
inline bool split_fragments(const Bytes& body, std::size_t limit, std::vector<Fragment>& out,
std::size_t max_fragments = 65535) {
out.clear();
const std::size_t capacity = fragment_capacity(limit);
if (body.size() <= unfragmented_capacity(limit) || body.size() > 65535 || capacity == 0) return false;
if ((body.size() + capacity - 1) / capacity > max_fragments) return false;
for (std::size_t offset = 0; offset < body.size(); offset += capacity) {
const std::size_t n = body.size() - offset < capacity ? body.size() - offset : capacity;
Fragment fragment;
fragment.flags = offset == 0 ? flag_fragment_first
: offset + n == body.size() ? flag_fragment_last : flag_fragment_middle;
fragment.body = {static_cast<std::uint8_t>(body.size()), static_cast<std::uint8_t>(body.size() >> 8),
static_cast<std::uint8_t>(offset), static_cast<std::uint8_t>(offset >> 8)};
fragment.body.insert(fragment.body.end(), body.begin() + static_cast<std::ptrdiff_t>(offset),
body.begin() + static_cast<std::ptrdiff_t>(offset + n));
out.push_back(std::move(fragment));
}
return true;
}
} // namespace microbu::link
+21 -17
View File
@@ -1,4 +1,5 @@
#include "link_service.hpp"
#include "link_fragment.hpp"
#include "simple_ble.hpp"
#include "serial_link.hpp"
#include <esp_log.h>
@@ -19,7 +20,7 @@ LinkService::LinkService(Station& station) : station_(station) {
});
// MicrOBU: every ITS message heard on air, verified or not (Station::on_raw_its).
station_.on_raw_its([this](const link::Bytes& body) {
broadcast(link::Opcode::V2X_RX, ++own_sequence_, body);
return broadcast(link::Opcode::V2X_RX, ++own_sequence_, body);
});
// T_GenVam is included in the status snapshot returned on request.
station_.on_id_event([this](const link::IdChangeEvent& event) {
@@ -34,7 +35,11 @@ bool LinkService::send(LinkTransport transport, link::Opcode opcode, std::uint16
link::Message message {{opcode, flags, sequence}, body};
if (!link::encode(message, octets)) { ESP_LOGE(TAG, "message 0x%02x too long (%u)", unsigned(opcode), unsigned(body.size())); return false; }
if (transport == LinkTransport::serial) {
if (opcode == link::Opcode::RAW_FRAME) return serial::try_write(serial::FrameType::LINK, octets);
// Never wait for the host: RAW_FRAME and the fragments of a large V2X_RX are best effort, a stalled USB
// host must not hold the station task that also drains the radio queue. A V2X_RX that fits one message
// keeps the blocking write it always had.
if (opcode == link::Opcode::RAW_FRAME || (opcode == link::Opcode::V2X_RX && flags != 0))
return serial::try_write(serial::FrameType::LINK, octets);
return serial::write(serial::FrameType::LINK, octets);
}
return ble::write(octets);
@@ -42,26 +47,25 @@ bool LinkService::send(LinkTransport transport, link::Opcode opcode, std::uint16
bool LinkService::send_fragmented(LinkTransport transport, link::Opcode opcode, std::uint16_t sequence, const link::Bytes& body) {
const std::size_t limit = transport == LinkTransport::ble ? ble::max_message() : link::maximum_message;
const std::size_t chunk = limit - link::header_size;
if (body.size() <= chunk) return send(transport, opcode, sequence, body);
if (body.size() > 65535 || chunk <= link::fragment_header_size) return false;
const std::size_t capacity = chunk - link::fragment_header_size;
for (std::size_t offset = 0; offset < body.size(); offset += capacity) {
const std::size_t n = std::min(capacity, body.size() - offset);
const std::uint8_t flags = offset == 0 ? link::flag_fragment_first :
(offset + n == body.size() ? link::flag_fragment_last : link::flag_fragment_middle);
link::Bytes part {std::uint8_t(body.size()), std::uint8_t(body.size() >> 8),
std::uint8_t(offset), std::uint8_t(offset >> 8)};
part.insert(part.end(), body.begin() + offset, body.begin() + offset + n);
if (!send(transport, opcode, sequence, part, flags)) return false;
if (body.size() <= link::unfragmented_capacity(limit)) return send(transport, opcode, sequence, body);
// A received message is never worth a flood of notifications: with a small ATT MTU (no exchange yet, 23) one
// MAPEM would need dozens, so beyond max_received_fragments that transport skips the message.
const std::size_t max_fragments = opcode == link::Opcode::V2X_RX ? max_received_fragments : 65535;
std::vector<link::Fragment> fragments;
if (!link::split_fragments(body, limit, fragments, max_fragments)) return false;
for (const auto& fragment : fragments) {
// The first failed fragment ends this message (the app drops the incomplete stream by itself); nothing is
// retried, and nothing here waits for the transport.
if (!send(transport, opcode, sequence, fragment.body, fragment.flags)) return false;
}
return true;
}
void LinkService::broadcast(link::Opcode opcode, std::uint16_t sequence, const link::Bytes& body) {
bool LinkService::broadcast(link::Opcode opcode, std::uint16_t sequence, const link::Bytes& body) {
// Fragmented when needed: a MAPEM indication is larger than one message on either transport.
send_fragmented(LinkTransport::serial, opcode, sequence, body);
if (ble::connected()) send_fragmented(LinkTransport::ble, opcode, sequence, body);
const bool serial_taken = send_fragmented(LinkTransport::serial, opcode, sequence, body);
const bool ble_taken = ble::connected() && send_fragmented(LinkTransport::ble, opcode, sequence, body);
return serial_taken || ble_taken;
}
void LinkService::reply(LinkTransport transport, std::uint16_t sequence, link::Code code, const link::Bytes& detail) {
+4 -1
View File
@@ -38,7 +38,10 @@ private:
/// @param opcode Message opcode.
/// @param sequence Sequence number to stamp on the header.
/// @param body Encoded message body.
void broadcast(link::Opcode opcode, std::uint16_t sequence, const link::Bytes& body);
/// @return whether at least one transport took the whole message (the caller only counts a false).
bool broadcast(link::Opcode opcode, std::uint16_t sequence, const link::Bytes& body);
/// Most fragments one received ITS message (V2X_RX) may take on a transport; 8 x 504 octets at the full MTU.
static constexpr std::size_t max_received_fragments = 8;
/// @brief Sends a CONFIRM reply to the message's origin transport.
/// @param origin Transport to reply on.
/// @param sequence Sequence number of the message being replied to.
+3
View File
@@ -162,6 +162,9 @@ bool write(FrameType type, const Bytes& payload) {
bool try_write(FrameType type, const Bytes& payload) {
if (payload.size() > maximum_payload || !writer_lock || stalled) return false;
// Like write(): no host on the native port means nothing to queue, or the 8 kB TX buffer fills with
// fragments nobody reads and the next host starts on stale bytes.
if (!usb_serial_jtag_is_connected()) return false;
const auto frame = encode_frame(type, payload);
if (xSemaphoreTake(writer_lock, 0) != pdTRUE) return false;
const bool queued = usb_serial_jtag_write_bytes(frame.data(), frame.size(), 0) == static_cast<int>(frame.size());
+21 -13
View File
@@ -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) {
+6 -3
View File
@@ -30,8 +30,9 @@ public:
using Received = std::function<void()>;
/// RAW_FRAME body (u32 counter, u8 flags, i8 RSSI, ITS5 record) for the link service.
using RawFrame = std::function<void(const link::Bytes&)>;
/// MicrOBU: body of one link V2X_RX message (see link_protocol.hpp).
using RawIts = std::function<void(const link::Bytes&)>;
/// MicrOBU: body of one link V2X_RX message (see link_protocol.hpp). Returns whether a transport took it;
/// a body above one link message goes out in fragments, best effort (a false return is only counted).
using RawIts = std::function<bool(const link::Bytes&)>;
/// DCC_T_GEN_VAM body for the link service (TS 103 300-3 clause 6.2: T_GenVam from management).
using DccUpdate = std::function<void(const link::Bytes&)>;
@@ -283,7 +284,9 @@ private:
bool have_fix_ = false;
link::PotiUpdate last_poti_; // MicrOBU: the GN Source Position Vector of unsecured_request()
std::uint8_t unsecured_mid_[6] = {2, 0, 0, 0, 0, 1}; // MicrOBU: random per configure(); MAC of unsecured frames
std::uint32_t raw_forwarded_ = 0, raw_oversize_ = 0;
// MicrOBU V2X_RX: forwarded in one message, forwarded in fragments (and how many of those no transport took),
// dropped as unusable or beyond v2x_rx_max_forward, and large ones left to the RAW_FRAME copy.
std::uint32_t raw_forwarded_ = 0, raw_fragmented_ = 0, raw_fragment_failed_ = 0, raw_oversize_ = 0, raw_covered_ = 0;
// declared before everything that refers to its keys (security_, pki_pending_), so it is destroyed last
std::unique_ptr<microbu_v2x::security::SecurityModule> module_;
std::unique_ptr<vanetza::ManualRuntime> runtime_;
+22
View File
@@ -14,11 +14,33 @@ constexpr std::size_t v2x_rx_prefix = 14;
/// Largest ITS payload that fits one link message (512 - 4 - 14).
constexpr std::size_t v2x_rx_max_payload = maximum_message - header_size - v2x_rx_prefix;
/// Largest ITS payload forwarded at all (fragmented when it exceeds v2x_rx_max_payload): what one 802.11 frame
/// of the radio's 2346-octet buffer can hold. Real road SPATEMs and MAPEMs reach about 1.3 kB.
constexpr std::size_t v2x_rx_max_forward = 2300;
/// @brief Whether an unwrapped message fits one link message. A truncated or empty one never does.
inline bool v2x_rx_fits(const gn_rx_t& rx) {
return !rx.truncated && rx.payload_len > 0 && static_cast<std::size_t>(rx.payload_len) <= v2x_rx_max_payload;
}
/// What Station::forward_raw does with an unwrapped message.
enum class V2xRxPlan {
drop, ///< truncated, empty or beyond v2x_rx_max_forward: counted as oversize, not sent
single, ///< one link message, exactly as before the fragmentation was added
fragmented, ///< larger than one link message: sent in fragments, best effort
covered_by_raw, ///< larger than one link message while the raw capture is on: the RAW_FRAME copy carries it
};
/// @brief Decides how an unwrapped message goes to the phone.
/// @param raw_capture_on The phone switched RAW_CAPTURE on, so it reads RAW_FRAME and ignores V2X_RX; a large
/// message is then not sent a second time as fragmented V2X_RX (small ones still are, as before).
inline V2xRxPlan v2x_rx_plan(const gn_rx_t& rx, bool raw_capture_on) {
if (rx.truncated || rx.payload_len <= 0 || static_cast<std::size_t>(rx.payload_len) > v2x_rx_max_forward)
return V2xRxPlan::drop;
if (v2x_rx_fits(rx)) return V2xRxPlan::single;
return raw_capture_on ? V2xRxPlan::covered_by_raw : V2xRxPlan::fragmented;
}
/// @brief Builds the V2X_RX body. The caller checks v2x_rx_fits first.
/// @param rx Message unwrapped by gn_unwrap_its (its payload pointer must still be valid).
/// @param rssi Received signal strength, dBm.
+19 -2
View File
@@ -27,11 +27,11 @@ CFLAGS = -std=c11 -O2 -g -Wall -Wextra -Wpedantic -Werror -I$(FW) -I. \
FW_SRCS = $(FW)/geonet.c dot11p.c $(FW)/gn_unwrap.c
DEPS = test_util.c test_util.h dot11p.h $(FW_SRCS) $(wildcard $(FW)/*.h)
.PHONY: all check chain replay fuzz battery firmware corpus clean
.PHONY: all check chain replay fuzz battery firmware fragments corpus clean
all: check
check: chain replay fuzz battery firmware
check: chain replay fuzz battery firmware fragments
$(BUILD):
mkdir -p $@
@@ -83,6 +83,23 @@ $(BUILD)/test_firmware$(EXE): test_firmware.cpp $(FW_CXX_SRCS) $(wildcard $(FW)/
firmware: $(BUILD)/test_firmware$(EXE)
$(BUILD)/test_firmware$(EXE)
# Recorded traffic through unwrap -> V2X_RX body -> fragments -> reassembly (the large MAPEMs and SPATEMs of a road RSU).
# Needs a capture: the CiT node's 2026-11-23 recording has 1198-byte MAPEMs and 888-byte SPATEMs.
FRAG_PCAPS = $(wildcard ../../../databases/its5_20261123_150746.pcap) $(RECORDINGS)
$(BUILD)/fw_c_test_util.o: test_util.c test_util.h | $(BUILD)
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/test_v2x_fragments$(EXE): test_v2x_fragments.cpp $(BUILD)/fw_c_test_util.o $(BUILD)/fw_c_gn_unwrap.o $(FW)/link_protocol.cpp $(wildcard $(FW)/*.hpp) | $(BUILD)
$(CXX) $(CXXFLAGS) -std=c++20 -I. -fsanitize=undefined -fsanitize-undefined-trap-on-error -o $@ test_v2x_fragments.cpp $(FW)/link_protocol.cpp $(BUILD)/fw_c_test_util.o $(BUILD)/fw_c_gn_unwrap.o
fragments: $(BUILD)/test_v2x_fragments$(EXE)
ifeq ($(FRAG_PCAPS),)
@echo "fragments: no captures, skipped"
else
$(BUILD)/test_v2x_fragments$(EXE) $(FRAG_PCAPS)
endif
# Corpus for the app's GnUnwrapTest (the Kotlin port of gn_unwrap.c): recorded frames, cut and corrupted copies of
# them, with the verdict and fields of the firmware's own code. Writes ../../../app/src/test/resources/gn_unwrap_corpus.tsv
CORPUS_OUT = ../../../app/src/test/resources/gn_unwrap_corpus.tsv
+1 -1
View File
@@ -8,7 +8,7 @@ installed 2026-09-11).
**Firmware unit tests (`make firmware`, `test_firmware.cpp`, 40 tests):** the station-link codec byte-exact against
the app's `StationLinkTest` hex, the 131-octet STATUS offsets, request reassembly, the V2X_RX extension
(`main/v2x_rx.hpp`; the 494-octet limit, the 14-octet prefix, TX code -> air frame -> RX path), radio operating
(`main/v2x_rx.hpp`; the 494-octet limit, the 14-octet prefix, TX code -> air frame -> RX path; the plan for large messages and `link_fragment.hpp`'s fragments, round-tripped through two reassemblers), radio operating
points, the BLE TX guard, the ITS clock, CCA counters, BLE security and the battery policy. It prints PASS or FAIL
per test and a `RESULT:` line, and exits non-zero on a failure. It cannot test the radio, BLE, NVS or USB: those are
on the bench list in `TODO.md`.
+120
View File
@@ -9,6 +9,7 @@
#include "battery_policy.hpp"
#include "cca_window.hpp"
#include "its_clock.hpp"
#include "link_fragment.hpp"
#include "link_protocol.hpp"
#include "radio_policy.hpp"
#include "raw_capture_policy.hpp"
@@ -369,6 +370,125 @@ TEST(the_494_octet_limit_is_exact) {
}
}
TEST(v2x_rx_plan_keeps_small_messages_single_and_fragments_large_ones) {
gn_rx_t rx {};
const std::uint8_t byte = 0;
rx.payload = &byte;
const auto plan = [&](int len, bool raw_on, bool truncated = false) {
rx.payload_len = len; rx.truncated = truncated;
return link::v2x_rx_plan(rx, raw_on);
};
using P = link::V2xRxPlan;
CHECK(plan(1, false) == P::single);
CHECK(plan(58, false) == P::single);
CHECK(plan(494, false) == P::single);
CHECK(plan(495, false) == P::fragmented);
CHECK(plan(888, false) == P::fragmented);
CHECK(plan(1198, false) == P::fragmented);
CHECK(plan(2300, false) == P::fragmented);
CHECK(plan(2301, false) == P::drop);
CHECK(plan(0, false) == P::drop);
CHECK(plan(-1, false) == P::drop);
CHECK(plan(600, false, true) == P::drop); // truncated is never forwarded
// raw capture on: the app reads RAW_FRAME, so a large message is not sent twice; small ones are as before
CHECK(plan(494, true) == P::single);
CHECK(plan(495, true) == P::covered_by_raw);
CHECK(plan(1198, true) == P::covered_by_raw);
CHECK(plan(2301, true) == P::drop);
}
// What a phone does with the fragments, written here without link::RequestReassembly.
static bool put_back(const std::vector<link::Fragment>& fragments, Bytes& out) {
out.clear();
std::size_t total = 0;
for (std::size_t i = 0; i < fragments.size(); ++i) {
const auto& b = fragments[i].body;
if (b.size() <= link::fragment_header_size) return false;
const std::size_t t = b[0] | (std::size_t(b[1]) << 8), offset = b[2] | (std::size_t(b[3]) << 8);
if (fragments[i].flags != (i == 0 ? 1 : i + 1 == fragments.size() ? 3 : 2)) return false;
if (i == 0) total = t;
if (t != total || offset != out.size()) return false;
out.insert(out.end(), b.begin() + link::fragment_header_size, b.end());
}
return out.size() == total;
}
TEST(fragments_of_a_large_v2x_rx_reassemble_exactly_on_both_transports) {
for (const int len : {495, 504, 888, 1198, 2300}) {
Bytes mapem(len);
for (std::size_t i = 0; i < mapem.size(); ++i) mapem[i] = static_cast<std::uint8_t>(i * 31 + len);
Bytes frame;
CHECK(air_frame(mapem, 2003, frame));
gn_rx_t rx;
CHECK(gn_unwrap_its(frame.data(), static_cast<int>(frame.size()), &rx));
CHECK_EQ(rx.payload_len, len);
const auto body = link::encode_v2x_rx(rx, -48);
for (const std::size_t limit : {std::size_t(512), std::size_t(244)}) { // serial / MTU 517, MTU 247
std::vector<link::Fragment> fragments;
const bool split = link::split_fragments(body, limit, fragments, 16);
CHECK(split);
if (!split) continue;
CHECK(fragments.size() >= 2);
Bytes rebuilt;
CHECK(put_back(fragments, rebuilt));
CHECK(rebuilt == body);
for (std::size_t i = 0; i < fragments.size(); ++i) {
Bytes wire;
CHECK(link::encode(link::Message {{link::Opcode::V2X_RX, fragments[i].flags, 5}, fragments[i].body}, wire));
CHECK(wire.size() <= limit);
if (i + 1 < fragments.size()) CHECK_EQ(wire.size(), limit); // full except the last
}
}
}
}
TEST(fragment_counts_for_the_bench_messages_at_the_full_mtu) {
// 14 octets of prefix + the UPER payload; a fragment carries 512 - 4 - 4 = 504 octets of it
std::vector<link::Fragment> f;
CHECK(link::split_fragments(Bytes(14 + 888), 512, f)); CHECK_EQ(f.size(), 2u);
CHECK(link::split_fragments(Bytes(14 + 1198), 512, f)); CHECK_EQ(f.size(), 3u);
CHECK(link::split_fragments(Bytes(14 + 495), 512, f)); CHECK_EQ(f.size(), 2u);
CHECK_STR(to_hex(Bytes(f[0].body.begin(), f[0].body.begin() + 4)), std::string("fd010000")); // total 509, offset 0
CHECK_STR(to_hex(Bytes(f[1].body.begin(), f[1].body.begin() + 4)), std::string("fd01f801")); // total 509, offset 504
}
TEST(a_message_that_fits_one_link_message_is_never_fragmented) {
std::vector<link::Fragment> f;
CHECK(!link::split_fragments(Bytes(508), 512, f)); // 508 + 4 = 512: exactly one message
CHECK(f.empty());
CHECK(link::split_fragments(Bytes(509), 512, f));
CHECK(!link::split_fragments(Bytes(240), 244, f)); // MTU 247: 240 + 4 = 244
CHECK(link::split_fragments(Bytes(241), 244, f));
}
TEST(fragmenting_refuses_what_a_transport_cannot_carry_sensibly) {
std::vector<link::Fragment> f;
CHECK(!link::split_fragments(Bytes(1212), 20, f, 8)); // ATT MTU 23: 12 octets a fragment, 101 fragments
CHECK(f.empty());
CHECK(!link::split_fragments(Bytes(1212), 8, f)); // no room for data at all
CHECK(!link::split_fragments(Bytes(65536), 512, f)); // total is a u16
CHECK(link::split_fragments(Bytes(65535), 512, f));
CHECK(link::split_fragments(Bytes(1212), 244, f, 6)); // exactly 6 fragments of 236
CHECK(!link::split_fragments(Bytes(1212), 244, f, 5));
}
TEST(a_lost_fragment_loses_that_message_only) {
std::vector<link::Fragment> a, b;
Bytes first(1212, 0xA1), second(1212, 0xB2);
CHECK(link::split_fragments(first, 512, a));
CHECK(link::split_fragments(second, 512, b));
link::RequestReassembly phone;
std::optional<link::Message> done;
for (std::size_t i = 0; i < a.size(); ++i) {
if (i == 1) continue; // the middle fragment never arrives
done = phone.feed(link::Message {{link::Opcode::V2X_RX, a[i].flags, 1}, a[i].body}, 1, i);
CHECK(!done);
}
for (std::size_t i = 0; i < b.size(); ++i) done = phone.feed(link::Message {{link::Opcode::V2X_RX, b[i].flags, 2}, b[i].body}, 1, 10 + i);
CHECK(done.has_value());
if (done) CHECK(done->body == second);
}
TEST(ports_outside_the_its_set_are_not_forwarded) {
Bytes frame;
CHECK(air_frame(Bytes(20, 1), 1234, frame));
@@ -0,0 +1,171 @@
// Replays recorded air traffic through the whole V2X_RX send path that needs no ESP32: gn_unwrap_its ->
// v2x_rx_plan -> encode_v2x_rx -> split_fragments -> link::encode of every fragment -> reassembly, and checks
// that what a phone would reassemble is byte for byte the body that was sent. Messages that fit one link message
// must stay one message and be byte-identical to the unfragmented encoding.
//
// Usage: test_v2x_fragments capture.pcap [capture.pcap ...]
//
// The reassembly here is written independently of link::RequestReassembly (which is also run, for bodies it
// accepts) and of the app's Kotlin LinkReassembly (checked by LinkReassemblyTest on the same fragments).
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <vector>
extern "C" {
#include "gn_unwrap.h"
#include "test_util.h"
}
#include "link_fragment.hpp"
#include "request_reassembly.hpp"
#include "v2x_rx.hpp"
using namespace microbu;
using link::Bytes;
namespace {
constexpr int rx_frame_max_len = 2346; // c5_radio.cpp's Raw::bytes, as in test_replay.c
struct Stats {
long records = 0, accepted = 0, single = 0, fragmented = 0, dropped = 0, fragments = 0, failures = 0;
std::map<std::pair<unsigned, std::size_t>, long> by_port_size;
};
FILE* dump = nullptr; // --dump out.tsv
std::set<std::pair<unsigned, std::size_t>> dumped;
bool fail(Stats& s, const char* what, int index) {
std::fprintf(stderr, "FAIL record %d: %s\n", index, what);
++s.failures;
return false;
}
// What a phone does with the link messages of one body: independent of every other reassembler.
bool reassemble(const std::vector<link::Message>& messages, Bytes& out) {
out.clear();
std::size_t total = 0;
for (std::size_t i = 0; i < messages.size(); ++i) {
const auto& m = messages[i];
const auto& b = m.body;
if (b.size() <= link::fragment_header_size) return false;
const std::size_t t = b[0] | (std::size_t(b[1]) << 8), offset = b[2] | (std::size_t(b[3]) << 8);
const std::uint8_t want = i == 0 ? 1 : (i + 1 == messages.size() ? 3 : 2);
if (m.header.flags != want || m.header.opcode != link::Opcode::V2X_RX) return false;
if (i == 0) total = t;
if (t != total || offset != out.size()) return false;
out.insert(out.end(), b.begin() + link::fragment_header_size, b.end());
}
return out.size() == total;
}
void check(Stats& s, const gn_rx_t& rx, int index) {
++s.accepted;
const auto plan = link::v2x_rx_plan(rx, false);
if (link::v2x_rx_plan(rx, true) == link::V2xRxPlan::fragmented) { fail(s, "raw capture on still fragments", index); return; }
if (plan == link::V2xRxPlan::drop) { ++s.dropped; return; }
const Bytes body = link::encode_v2x_rx(rx, -60);
if (body.size() != link::v2x_rx_prefix + static_cast<std::size_t>(rx.payload_len)) { fail(s, "body size", index); return; }
++s.by_port_size[{rx.btp_dest_port, static_cast<std::size_t>(rx.payload_len)}];
if (plan == link::V2xRxPlan::single) {
++s.single;
std::vector<link::Fragment> none;
Bytes wire;
if (link::split_fragments(body, link::maximum_message, none)) { fail(s, "a single message was fragmented", index); return; }
if (!link::encode(link::Message {{link::Opcode::V2X_RX, 0, 7}, body}, wire) || wire.size() != body.size() + link::header_size)
fail(s, "single message does not encode", index);
return;
}
++s.fragmented;
if (dump && dumped.insert({rx.btp_dest_port, static_cast<std::size_t>(rx.payload_len)}).second) {
// For the app's LinkReassemblyTest: the first message of each large size, its body and the link messages
// (hex) both transports would carry. `port size limit body wire wire ...`
for (const std::size_t limit : {std::size_t(512), std::size_t(244)}) {
std::vector<link::Fragment> fragments;
if (!link::split_fragments(body, limit, fragments, 8)) continue;
std::fprintf(dump, "%u\t%d\t%zu\t", rx.btp_dest_port, rx.payload_len, limit);
for (const auto b : body) std::fprintf(dump, "%02x", b);
for (const auto& f : fragments) {
Bytes wire;
link::encode(link::Message {{link::Opcode::V2X_RX, f.flags, 77}, f.body}, wire);
std::fputc('\t', dump);
for (const auto b : wire) std::fprintf(dump, "%02x", b);
}
std::fputc('\n', dump);
}
}
// 512: serial and the full BLE MTU 517. 244: ATT MTU 247. Both must carry the message; 20 (MTU 23) must refuse it.
for (const std::size_t limit : {std::size_t(512), std::size_t(244)}) {
std::vector<link::Fragment> fragments;
if (!link::split_fragments(body, limit, fragments, 8)) { fail(s, "split refused", index); return; }
std::vector<link::Message> messages;
link::RequestReassembly oracle;
std::optional<link::Message> done;
for (std::size_t i = 0; i < fragments.size(); ++i) {
link::Message m {{link::Opcode::V2X_RX, fragments[i].flags, 9}, fragments[i].body};
Bytes wire;
if (!link::encode(m, wire) || wire.size() > limit) { fail(s, "fragment exceeds the transport limit", index); return; }
link::Message back;
if (!link::decode(wire, back)) { fail(s, "fragment does not decode", index); return; }
messages.push_back(back);
done = oracle.feed(back, 0, i);
++s.fragments;
}
Bytes rebuilt;
if (!reassemble(messages, rebuilt) || rebuilt != body) { fail(s, "independent reassembly differs", index); return; }
if (body.size() <= link::maximum_request_body && (!done || done->body != body)) { fail(s, "RequestReassembly differs", index); return; }
// One fragment lost anywhere but at the end, then the next message: nothing completes, nothing is poisoned.
if (fragments.size() > 2) {
link::RequestReassembly lossy;
for (std::size_t i = 0; i < fragments.size(); ++i) {
if (i == 1) continue;
const auto got = lossy.feed(link::Message {{link::Opcode::V2X_RX, fragments[i].flags, 9}, fragments[i].body}, 0, i);
if (got) { fail(s, "a message with a lost fragment completed", index); return; }
}
if (body.size() <= link::maximum_request_body) {
std::optional<link::Message> next;
for (std::size_t i = 0; i < fragments.size(); ++i)
next = lossy.feed(link::Message {{link::Opcode::V2X_RX, fragments[i].flags, 10}, fragments[i].body}, 0, 100 + i);
if (!next || next->body != body) { fail(s, "the message after a lost fragment did not complete", index); return; }
}
}
}
std::vector<link::Fragment> too_small;
if (link::split_fragments(body, 20, too_small, 8)) fail(s, "MTU 23 should skip a large message", index);
}
} // namespace
int main(int argc, char** argv) {
int first = 1;
if (argc > 2 && std::strcmp(argv[1], "--dump") == 0) {
dump = std::fopen(argv[2], "w");
if (!dump) { std::fprintf(stderr, "cannot write %s\n", argv[2]); return 2; }
first = 3;
}
if (argc <= first) { std::fprintf(stderr, "usage: test_v2x_fragments [--dump out.tsv] capture.pcap [capture.pcap ...]\n"); return 2; }
tu_install_crash_handler();
tu_guard_init();
Stats stats;
for (int a = first; a < argc; ++a) {
struct Ctx { Stats* s; const char* path; } ctx {&stats, argv[a]};
const int n = tu_pcap_foreach(argv[a], [](const uint8_t* frame, int len, int index, void* c) {
auto* x = static_cast<Ctx*>(c);
++x->s->records;
if (len > rx_frame_max_len) len = rx_frame_max_len;
tu_set_context("fragments %s record %d (%d bytes)", x->path, index, len);
gn_rx_t rx;
if (gn_unwrap_its(tu_guarded(frame, len), len, &rx)) check(*x->s, rx, index);
}, &ctx);
if (n < 0) { std::fprintf(stderr, "cannot read %s as a pcap\n", argv[a]); return 2; }
}
std::printf("test_v2x_fragments: %ld records, %ld accepted: %ld single, %ld fragmented (%ld fragments built for "
"two transports), %ld dropped, %ld failures\n",
stats.records, stats.accepted, stats.single, stats.fragmented, stats.fragments, stats.dropped, stats.failures);
for (const auto& [key, count] : stats.by_port_size)
if (key.second > link::v2x_rx_max_payload) std::printf(" port %u, %zu bytes: %ld\n", key.first, key.second, count);
return stats.failures ? 1 : 0;
}
+81
View File
@@ -0,0 +1,81 @@
"""Which received ITS messages did the phone get, by size? Compares a V2X log (schema 3, ESP32-C5) with a
pcap recorded at the same time by another receiver (the CiT node's its5_*.pcap, linktype 105 or 127).
# 1. unwrap the capture with the firmware's own code (obu-firmware/test/host, MSYS2 gcc on PATH):
# gcc -std=c11 -O2 -I../../main -I. -o test_replay test_replay.c test_util.c \
# ../../main/geonet.c dot11p.c ../../main/gn_unwrap.c
# test_replay replay.tsv capture.pcap
# 2. py -3.11 tools/rx_size_compare.py LOG.db capture.pcap replay.tsv
Written for the 2026-11-23 bench run: the node sent a 377-byte MAPEM and a 58-byte SPATEM, then an 1198-byte
MAPEM and an 888-byte SPATEM, and the phone received only the small ones (the firmware dropped everything over
494 bytes). Run it again after the V2X_RX fragmentation to see the large ones arrive.
The pcap clock is the capture device's own (often seconds since its boot, and it can wrap), so it is aligned to
the phone's wall clock through the CAMs both received byte for byte. A message counts as received when the
phone logged the same message type with identical payload bytes within 1 s of it. The pcap receiver is a
different antenna in a different place, so even small messages sit below 100 %: compare sizes with each other.
"""
import collections
import csv
import sqlite3
import statistics
import struct
import sys
NAMES = {2001: 'CAM', 2002: 'DENM', 2003: 'MAPEM', 2004: 'SPATEM', 2018: 'VAM'}
WINDOW_S = 1.0
def pcap_times(path):
data = open(path, 'rb').read()
little = struct.unpack('<I', data[:4])[0] in (0xA1B2C3D4, 0xA1B23C4D)
e = '<' if little else '>'
nano = struct.unpack(e + 'I', data[:4])[0] in (0xA1B23C4D,)
out, off = [], 24
while off + 16 <= len(data):
s, us, incl, _ = struct.unpack(e + 'IIII', data[off:off + 16])
out.append(s + us / (1e9 if nano else 1e6))
off += 16 + incl
return out
def main(log, pcap, tsv):
times = pcap_times(pcap)
heard = []
for r in csv.DictReader(open(tsv), delimiter='\t'):
if r['accepted'] == '1' and int(r['port']) in NAMES:
heard.append((times[int(r['record'])], int(r['port']), bytes.fromhex(r['payload'])))
con = sqlite3.connect('file:%s?mode=ro' % log.replace('\\', '/'), uri=True)
phone = con.execute('select ts_ms, msg_type, payload from messages order by ts_ms, id').fetchall()
meta = dict(con.execute('select key, value from meta').fetchall())
if not phone:
raise SystemExit('the log holds no messages')
seen = collections.defaultdict(list)
for ts, kind, payload in phone:
seen[(kind, bytes(payload))].append(ts / 1000)
cams = {k[1]: v[0] for k, v in seen.items() if k[0] == 'CAM' and len(v) == 1}
offsets = [cams[p] - t for t, port, p in heard if port == 2001 and p in cams]
if len(offsets) < 20:
raise SystemExit('only %d CAMs in common: cannot align the two clocks' % len(offsets))
off = statistics.median(offsets)
print('log: %s, hardware %s; %d messages; clock offset %.3f s (spread %.0f ms over %d shared CAMs)'
% (log, meta.get('hardware'), len(phone), off, 1000 * statistics.pstdev(offsets), len(offsets)))
first, last = phone[0][0] / 1000, phone[-1][0] / 1000
table = collections.defaultdict(lambda: [0, 0])
for t, port, p in heard:
t += off
if not first - WINDOW_S <= t <= last + WINDOW_S:
continue
key = (NAMES[port], len(p))
table[key][0] += 1
table[key][1] += any(abs(x - t) < WINDOW_S for x in seen.get((NAMES[port], p), ()))
print('%-7s %6s %9s %9s %7s' % ('type', 'bytes', 'on air', 'phone', 'share'))
for (kind, size), (n, got) in sorted(table.items()):
print('%-7s %6d %9d %9d %6.1f%%' % (kind, size, n, got, 100.0 * got / n))
if __name__ == '__main__':
if len(sys.argv) != 4:
raise SystemExit(__doc__)
main(*sys.argv[1:])