Repository navigation
fix: use per-destination tx sequence counters - #15
Merged
Merged
Conversation
A device talking to several peers shared one outgoing counter, while receivers validate per source address. Traffic to one peer advanced the counter seen by another, so after more than SeqCounterAcceptWindow messages elsewhere the next request was dropped as Stale and the sender timed out (E_TIMEOUT). Since Stale does not update last_seen, the peer stayed stuck until the counter wrapped back into the window. Keep one counter per destination (bounded by MaxTrackedPeers, with the old shared counter as fallback). Wire format is unchanged and receivers need no update.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A device that talks to several peers used one shared outgoing sequence counter, but receivers validate the counter per source address (§7.2). Traffic to peer A advances the counter peer B sees. Once more than
SeqCounterAcceptWindow(15) messages go elsewhere, B drops the next message asStaleand the sender's request times out (E_TIMEOUT).Staledoesn't updatelast_seen, so B keeps dropping until the counter happens to wrap back into the window, which makes the failure look flaky.Seen on the kart: OTA triggers from the headunit to
zc_lightsandzc_motorfailed withreturnCode=6. Those are the two ECUs the headunit regularly sends commands to.zc_buttonsandzc_batteryworked because the headunit had never messaged them before, so the OTA request counted asFirstSeen.Fix
E2EProtection::next_sequence(dest)keeps one counter per destination, bounded byMaxTrackedPeers. Destinations beyond the table share the old counter as a fallback.Runtimepass their destination: fire-and-forget, notify, response and request. SD messages keep their separate counter.Wire format is unchanged. Only the sender needs the update, so peers still on v0.2.3 accept the new counters.
Tests
RuntimeTest.MultiPeerSender_TrafficToOtherPeer_DoesNotStaleRequest: a consumer sends 20 messages to provider A, then a request to provider B. It fails before the fix (B drops the request as stale) and passes after.zc_motorESP32 firmware and thesero-nodenative binding both build against this branch.