Repository navigation
Drop echoes of own datagrams to a peer that shares our hash - #3867
Open
marcelverdult wants to merge 1 commit into
Open
marcelverdult wants to merge 1 commit into
marcelverdult wants to merge 1 commit into
Conversation
Peer datagrams (TXT_MSG, REQ, RESPONSE, PATH) carry a 1-byte dest_hash and src_hash. If a contact's public key starts with the same byte as ours, a repeater echo of our own datagram to that contact matches self_id as destination, searchPeersByHash(src_hash) finds the contact, and the shared secret is symmetric, so the MAC checks out. onPeerDataRecv() then reports our own message as received from the contact and sends an ACK and a path return. The only guard today is the seen table, which is a ring of MAX_PACKET_HASHES entries shared with all received traffic. On a busy mesh the entry for our packet can be evicted before a late echo arrives. Keep a small separate ring of hashes of sent datagrams whose dest_hash equals our own hash. Normal traffic does not write to it, so these entries are not evicted by it. An incoming datagram with dest_hash == src_hash == our hash whose hash is in that ring is handled like a seen packet: not processed and not forwarded. Genuine datagrams from that contact differ in content and hash and are delivered as before. No wire format change.
Collaborator
|
I prefer to let @ripplebiz manage the PRs about the core functions of the protocol and do the burden on the peripherals ... |
This branch has not been deployed
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.
Peer datagrams (TXT_MSG, REQ, RESPONSE, PATH) carry a 1-byte dest_hash and
src_hash. When a contact's public key starts with the same byte as ours, a
repeater echo of our own DM to that contact looks like a DM from that
contact: dest_hash matches self_id, searchPeersByHash(src_hash) finds the
contact, and the ECDH secret is the same in both directions, so the MAC is
valid. onPeerDataRecv() then shows our own text as a message from the
contact and sends an ACK plus a path return.
The seen table normally catches the echo, since sendFlood()/sendDirect()
mark the packet as seen. That table is a ring of MAX_PACKET_HASHES (160)
entries that every received packet also writes to, so on a busy mesh a late
echo can arrive after our entry was evicted. A user reported exactly this
symptom: a DM to a contact out of range came back as a "reply" from that
contact, and both keys start with the same byte.
This change adds a second ring of 8 packet hashes to Mesh. send*() writes
to it only for peer datagrams whose dest_hash equals our own hash, which
only happens when we share a prefix with the destination. On receive, a
datagram with dest_hash == src_hash == our hash whose hash is in that ring
is dropped like a seen packet: no decrypt, no ACK, no forward. A real DM
from that contact has different content and a different hash, so it is
delivered as before. The wire format is unchanged. RAM cost is 65 bytes,
and MAX_SELF_ADDRESSED_SENT can be overridden at build time.
Tested: builds for RAK_4631_companion_radio_ble and
Heltec_v3_companion_radio_ble. A local host test (not part of this PR) with
two BaseChatMesh nodes sharing a key prefix fails without the change (own
DM delivered as from the contact, one TX) and passes with it; a genuine DM
from the same-prefix contact is still delivered once.
Open PRs #3523, #3839, #3521 and #3473 also edit the datagram branch of
Mesh::onRecvPacket(), so a rebase may be needed depending on merge order.
@fdlamotte